/** * stops a running observer */ public void stopObserver() { log(lvl, "observe: request to stop observer for " + this.toStringShort()); observing = false; observingInBackground = false; }
protected void initialize() { log(3, "resetting observe states for " + observedRegion.toStringShort()); synchronized (eventNames) { for (String name : eventNames.keySet()) { eventStates.put(name, State.FIRST); eventCounts.put(name, 0); eventMatches.put(name, null); } } shouldStopOnFirstEvent = false; if (Observing.getStopOnFirstEvent()) { log(lvl, "requested to stop on first event"); shouldStopOnFirstEvent = true; } }
public String onChangeDo(Integer threshold, Object observer) { String name = Observing.add(this, (ObserverCallBack) observer, ObserveEvent.Type.CHANGE, threshold); log(lvl, "%s: onChange%s: %s minSize: %d", toStringShort(), (observer == null ? "" : " with callback"), name, threshold); return name; }
private <PSIC> String onEvent(PSIC targetThreshhold, Object observer, ObserveEvent.Type obsType) { if (observer != null && (observer.getClass().getName().contains("org.python") || observer.getClass().getName().contains("org.jruby"))) { observer = new ObserverCallBack(observer, obsType); } if (!(targetThreshhold instanceof Integer)) { Image img = Image.getImageFromTarget(targetThreshhold); Boolean response = true; if (!img.isValid() && img.hasIOException()) { response = handleImageMissing(img, false); if (response == null) { runTime.abortScripting("onEvent(" + obsType.name() + "): Abort:", "ImageMissing: " + targetThreshhold.toString()); } } } String name = Observing.add(this, (ObserverCallBack) observer, obsType, targetThreshhold); log(lvl, "%s: observer %s %s: %s with: %s", toStringShort(), obsType, (observer == null ? "" : " with callback"), name, targetThreshhold); return name; }
private boolean observeDo(double secs) { if (regionObserver == null) { Debug.error("Region: observe: Nothing to observe (Region might be invalid): " + this.toStringShort()); return false; log(lvl, "observe: starting in " + this.toStringShort() + " for " + secs + " seconds"); int MaxTimePerScan = (int) (1000.0 / observeScanRate); long begin_t = (new Date()).getTime(); observing = false; log(lvl, "observe: stopped due to timeout in " + this.toStringShort() + " for " + secs + " seconds"); } else { log(lvl, "observe: ended successfully: " + this.toStringShort()); observeSuccess = Observing.hasEvents(this);
eventMatches.put(name, match); log(lvl + 1, "(%s): %s match: %s in:%s", eventTypes.get(name), ptn.toString(), match.toStringShort(), observedRegion.toStringShort()); } else if (eventStates.get(ptn) == State.FIRST) { log(lvl + 1, "(%s): %s match: %s in:%s", eventTypes.get(name), ptn.toString(), match.toStringShort(), observedRegion.toStringShort()); eventStates.put(name, State.UNKNOWN);
/** * show the regions Highlight for the given time in seconds (frame of specified color) if 0 - use the global * Settings.SlowMotionDelay * * @param secs time in seconds * @param color Color of frame (see method highlight(color)) * @return the region itself */ public Region highlight(float secs, String color) { if (getScreen() == null || isOtherScreen() || isScreenUnion) { Debug.error("highlight: not possible for %s", getScreen()); return this; } if (secs < 0.1) { return highlight((int) secs, color); } Debug.action("highlight " + toStringShort() + " for " + secs + " secs" + (color != null ? " color: " + color : "")); ScreenHighlighter _overlay = new ScreenHighlighter(getScreen(), color); _overlay.highlight(this, secs); return this; }
log(lvl, "find: waiting 0 secs for %s to appear in %s", targetStr, this.toStringShort()); lastMatch = doFind(target, img, null); if (lastMatch != null) {
log(lvl, "wait: waiting %.1f secs for %s to appear in %s", timeout, targetStr, this.toStringShort()); if (rf.repeat(timeout)) { lastMatch = rf.getMatch();
log(lvl, "exists: waiting %.1f secs for %s to appear in %s", timeout, targetStr, this.toStringShort()); if (rf.repeat(timeout)) { lastMatch = rf.getMatch();
autoWaitTimeout, targetStr, this.toStringShort()); if (autoWaitTimeout > 0) { rf.repeat(autoWaitTimeout);