Package jmri.jmrit.automat
Class SampleAutomaton3
java.lang.Object
jmri.jmrit.automat.AbstractAutomaton
jmri.jmrit.automat.SampleAutomaton3
- All Implemented Interfaces:
Runnable
This sample Automaton runs a locomotive back and forth on a piece of track by
watching two sensors.
The sensors and locomotive are hardcoded, as this is an example of just the Automaton function. Adding a GUI to configure these would be straight-forward. The values could be passed via the constructor, or the constructor (which can run in any required thread) could invoke a dialog.
For test purposes, one of these objects can be created and invoked by a SampleAutomaton3Action.
For more information on JMRI support for automation classes, please see the JMRI Layout Automation in Java page.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrit.automat.AbstractAutomaton
AbstractAutomaton.MsgFrame -
Field Summary
FieldsModifier and TypeFieldDescription(package private) SensorReferences the sensor the locomotive will enter when it moves forward to the limit.(package private) StringBy default, monitors sensor "182" for the forward end of the track(package private) int(package private) boolean(package private) intBy default, controls locomotive 77(short).(package private) boolean(package private) SensorReferences the sensor the locomotive will enter when it moves backward to the limit.(package private) StringBy default, monitors sensor "178" for the reverse end of the track(package private) int(package private) DccThrottleReferences the locomotive decoder to be controlledFields inherited from class jmri.jmrit.automat.AbstractAutomaton
debugWaitFrame, message, messageFrame, promptOnWait, waitChangePrecheckBeans, waitChangePrecheckStates, waitChangeQueue -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class jmri.jmrit.automat.AbstractAutomaton
defaultName, done, getCount, getName, getThrottle, getThrottle, getThrottle, getThrottle, isRunning, isWaiting, readServiceModeCV, run, setName, setTurnouts, start, stop, wait, waitChange, waitChange, waitChangePrecheck, waitMsec, waitSensorActive, waitSensorActive, waitSensorChange, waitSensorChange, waitSensorInactive, waitSensorInactive, waitSensorState, waitSensorState, waitSignalHeadState, waitSignalMastState, waitTurnoutConsistent, waitWarrantBlock, waitWarrantBlockChange, waitWarrantRunState, writeOpsModeCV, writeServiceModeCV
-
Field Details
-
throttle
References the locomotive decoder to be controlled -
fwdSensor
References the sensor the locomotive will enter when it moves forward to the limit. -
revSensor
References the sensor the locomotive will enter when it moves backward to the limit. -
fwdSensorName
By default, monitors sensor "182" for the forward end of the track -
revSensorName
By default, monitors sensor "178" for the reverse end of the track -
locoNumber
int locoNumberBy default, controls locomotive 77(short). -
locoLong
boolean locoLong -
moveFwd
boolean moveFwd -
fwdState
int fwdState -
revState
int revState
-
-
Constructor Details
-
SampleAutomaton3
public SampleAutomaton3()
-
-
Method Details
-
init
Description copied from class:AbstractAutomatonUser-provided initialization routine.This is called exactly once each time the object's start() method is called. This is where you put all the code that needs to be run when your object starts up: Finding sensors and turnouts, getting a throttle, etc.
- Overrides:
initin classAbstractAutomaton
-
handle
Watch the sensors, and change direction to match.- Overrides:
handlein classAbstractAutomaton- Returns:
- Always returns true to continue operation
-