/** * Applies the operation. * * @param respSubsys The responding subsystem. * @param a The action to be emitted. * @param instant The current instant. */ public void apply(RespondingSubsystem respSubsys, Action a, int instant) { // TODO Put better values for response's latency, duration and intensity Response rp = new Response(null, a, 1, 5, new Intensity(1.0)); respSubsys.getCurrentResponses().addInactiveResponse(rp); respSubsys.getActionHistory().addAction(instant, a); }
/** * Checks the preconditions for the operation. * * @param respSubsys The responding subsystem. * @param a The action to be emitted. * @param instant The current instant. * @return <code>true</code> if the operation's preconditions are true; <code>false</code> * otherwise. */ public boolean precondition(RespondingSubsystem respSubsys, Action a, int instant) { Response rp = respSubsys.getCurrentResponses().getSpontaneousResponse(a); // If the spontaneous action is not currently associated with a response, the precondition is // met if (rp == null) { return true; } // The spontaneous action already originates a response return false; }