Package jmri.jmrix.rps
Class Engine
java.lang.Object
jmri.jmrix.rps.Engine
- All Implemented Interfaces:
ReadingListener
Engine does basic computations of RPS system.
Holds all the alignment info. Receivers are indexed by their RPS receiver number in all cases.
Gets a reading from the Distributor and passes back a Measurement
Bound properties:
- vSound - velocity of sound, in whatever units are in use
This class maintains a collection of "Transmitter" objects representing the RPS-equipped rolling stock (usually engines) on the layout. This is an extension to the common Roster, and every entry in this class's collection must be present in the Roster.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Engine(package private) String(package private) boolean(package private) Measurement(package private) int(package private) boolean(package private) int(package private) boolean(package private) Thread(package private) PropertyChangeSupport(package private) Receiver[](package private) boolean(package private) ArrayList<Transmitter> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddispose()booleanbooleanintintintintbooleanintgetReceiver(int i) javax.vecmath.Point3dgetReceiverPosition(int i) booleangetTransmitter(int i) getTransmitterByAddress(int addr) doublestatic Engineinstance()voidloadAlignment(File file) (package private) voidvoidloadPollConfig(File file) (package private) voidvoidvoid(package private) voidsaveLastMeasurement(String id, Measurement m) (package private) intThe real core of the polling, this selects the next one to poll. -1 means none selected, try again later.voidsetAlgorithm(String algorithm) voidprotected voidvoidprotected voidvoidsetMaxReceiverNumber(int n) Set the maximum receiver number expected.(package private) voidsetOff(int i) voidsetOffset(int offset) (package private) voidsetOn(int i) voidsetPolling(boolean polling) voidsetPollingInterval(int pollingInterval) voidsetReceiver(int address, Receiver receiver) Set a particular receiver by address (starting at 1).voidsetReceiverPosition(int i, javax.vecmath.Point3d p) voidvoidsetVSound(double v) (package private) void(package private) voidstopPoll()voidstoreAlignment(File file) voidstorePollConfig(File file) (package private) voidwaitBeforeNextPoll(int pollingInterval) Wait before sending next poll.
-
Field Details
-
lastPoint
-
receivers
-
algorithm
-
pollingInterval
int pollingInterval -
polling
boolean polling -
transmitters
-
pollIndex
int pollIndex -
bscPoll
boolean bscPoll -
throttlePoll
boolean throttlePoll -
pollThread
-
pollOutstanding
boolean pollOutstanding -
_instance
-
prop
-
-
Constructor Details
-
Engine
public Engine()
-
-
Method Details
-
loadValues
void loadValues() -
dispose
-
setVSound
-
getVSound
-
setOffset
-
getOffset
-
setMaxReceiverNumber
Set the maximum receiver number expected.If the highest value in the hardware is 5, that's what's needed here.
- Parameters:
n- max receivers.
-
getMaxReceiverNumber
-
setReceiver
Set a particular receiver by address (starting at 1).- Parameters:
address- the receiver address.receiver- the receiver.
-
getReceiver
-
setReceiverPosition
-
getReceiverPosition
-
setAlgorithm
-
getAlgorithm
-
notify
- Specified by:
notifyin interfaceReadingListener
-
saveLastMeasurement
-
storeAlignment
- Throws:
IOException
-
loadAlignment
- Throws:
org.jdom2.JDOMExceptionIOException
-
setInitialAlignment
-
setDefaultAlignment
-
setPollingInterval
-
getPollingInterval
-
setPolling
-
getPolling
-
loadInitialTransmitters
void loadInitialTransmitters() -
storePollConfig
- Throws:
IOException
-
loadPollConfig
- Throws:
org.jdom2.JDOMExceptionIOException
-
getTransmitterByAddress
-
getTransmitter
-
getNumTransmitters
-
getPolledID
-
getPolledAddress
-
selectNextPoll
int selectNextPoll()The real core of the polling, this selects the next one to poll. -1 means none selected, try again later.- Returns:
- index to poll next
-
setBscPollMode
-
setDirectPollMode
-
setThrottlePollMode
-
getBscPollMode
-
getThrottlePollMode
-
getDirectPollMode
-
startPoll
void startPoll() -
waitBeforeNextPoll
Wait before sending next poll.Waits specified time, and then checks to see if response has been returned. If not, it waits again (twice) by 1/2 the interval, then finally polls anyway.
- Parameters:
pollingInterval- in milliseconds- Throws:
InterruptedException- in theory, but not in practice.
-
stopPoll
void stopPoll() -
setOn
-
setOff
-
instance
-
removePropertyChangeListener
-
addPropertyChangeListener
-