public void Resume(bool stopByTimeout) { // unregister (to not receive intentionAdded again) c.RemoveEventListener(this); // invoke changes in C latter, so to avoid concurrent changes in C ts.RunAtBeginOfNextCycle(new MyRunnable2(c, si, sEvt, dropped, stopByTimeout, te, formula, elapsedTimeTerm, ts, un, startTime)); /*{ * public void run() { * try { * // add SI again in C.I if (1) it was not removed (2) is is not running (by some other reason) -- but this test does not apply to atomic intentions --, and (3) this wait was not dropped * if (c.removePendingIntention(sEvt) == si && (si.isAtomic() || !c.hasRunningIntention(si)) && !dropped) { * if (stopByTimeout && (te != null || formula != null) && elapsedTimeTerm == null) { * // fail the .wait by timeout * if (si.isSuspended()) { // if the intention was suspended by .suspend * PlanBody body = si.peek().getPlan().getBody(); * body.add(1, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail"))); * c.addPendingIntention(suspend.SUSPENDED_INT+si.getId(), si); * } else { * ts.generateGoalDeletion(si, JasonException.createBasicErrorAnnots("wait_timeout", "timeout in .wait")); * } * } else if (! si.isFinished()) { * si.peek().removeCurrentStep(); * * if (elapsedTimeTerm != null) { * long elapsedTime = System.currentTimeMillis() - startTime; * un.unifies(elapsedTimeTerm, new NumberTermImpl(elapsedTime)); * } * if (si.isSuspended()) { // if the intention was suspended by .suspend * c.addPendingIntention(suspend.SUSPENDED_INT+si.getId(), si); * } else { * c.resumeIntention(si); * } * } * } * } catch (Exception e) { * ts.getLogger().log(Level.SEVERE, "Error at .wait thread", e); * } * } * }*/ ts.GetUserAgArch().WakeUpDeliberate(); }