JMACS

org.jmacs.pd
Interface IProgram

All Superinterfaces:
Serializable

public interface IProgram
extends Serializable

to be implemented by all programs. Synchronization is not required.

Be sure to override Object.toString(), returning a description of what the program does. This will be called once only, prior to init().

Any non-Serializable fields (e.g. driver) should be declared as transient.

Version:
$Id: IProgram.java 803 2006-07-14 15:21:14Z rob $
Author:
Rob Dickens

Nested Class Summary
static interface IProgram.States
          program states.
 
Method Summary
 void init(IDevice.IDriver driver, IDevice.IStatus status, IDevice.IConstants constants, Timer timer)
          called once, first, when the program is run.
 void terminate(IDevice.IStatus status)
          called last, if the program is terminated externally, to permit any tidying up to be performed.
 boolean wake(IDevice.IStatus status, IAlert alert)
          called after init, whenever timer.sleep() returns (where timer is one of the arguments passed to init).
 

Method Detail

init

void init(IDevice.IDriver driver,
          IDevice.IStatus status,
          IDevice.IConstants constants,
          Timer timer)
called once, first, when the program is run.

Parameters:
driver - Cast appropriately.
status - as of last boundary. Cast appropriately.
constants - Cast appropriately.
timer - wake is called whenever timer.sleep() returns. By default, this will happen midway between consecutive (device status) sampling boundaries. If timer is reconfigured by the program, be sure to have the program implement ISamplingDependent, otherwise timer will be reconfigured again whenever the sampling parameters change.

wake

boolean wake(IDevice.IStatus status,
             IAlert alert)
called after init, whenever timer.sleep() returns (where timer is one of the arguments passed to init). Time-consuming tasks should not be undertaken.

Parameters:
status - as of last boundary. Cast appropriately.
alert - this will be cleared automatically if not IAlert.trigger(String)ed, each time wake is called.
Returns:
false signals program termination

terminate

void terminate(IDevice.IStatus status)
called last, if the program is terminated externally, to permit any tidying up to be performed.

Parameters:
status - as of last boundary. Cast appropriately.

JMACS

jmacs.org