Class LocoNetSlot
- java.lang.Object
-
- jmri.jmrix.loconet.LocoNetSlot
-
- Direct Known Subclasses:
UhlenbrockSlot
public class LocoNetSlot extends java.lang.Object
Represents the contents of a single slot in the LocoNet command station.A SlotListener can be registered to hear of changes in this slot. All changes in values will result in notification.
Strictly speaking, functions 9 through 28 are not in the actual slot, but it's convenient to imagine there's an "extended slot" and keep track of them here. This is a partial implementation, though, because setting is still done directly in
LocoNetThrottle
. In particular, if this slot has not been read from the command station, the first message directly setting F9 through F28 will not have a place to store information. Instead, it will trigger a slot read, so the following messages will be properly handled.Some of the message formats used in this class are Copyright Digitrax, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Digitrax Inc for separate permission.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
localF10
(package private) boolean
localF11
(package private) boolean
localF12
(package private) boolean
localF13
(package private) boolean
localF14
(package private) boolean
localF15
(package private) boolean
localF16
(package private) boolean
localF17
(package private) boolean
localF18
(package private) boolean
localF19
(package private) boolean
localF20
(package private) boolean
localF21
(package private) boolean
localF22
(package private) boolean
localF23
(package private) boolean
localF24
(package private) boolean
localF25
(package private) boolean
localF26
(package private) boolean
localF27
(package private) boolean
localF28
(package private) boolean
localF9
-
Constructor Summary
Constructors Constructor Description LocoNetSlot(int slotNum)
Create a slot based solely on a slot number.LocoNetSlot(int slotNum, int inLoconetProtocol)
Create a slot based solely on a slot number.LocoNetSlot(int slotNum, int inLoconetProtocol, SlotMapEntry.SlotType inSlotType)
Create a slot , initialize slotnum, protocol and slot typeLocoNetSlot(LocoNetMessage l)
Creates a slot object based on the contents of a LocoNet message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSlotListener(SlotListener l)
Registers a slot listener if it is not already registered.int
consistStatus()
Get consist status.int
cvval()
int
decoderType()
Get decoder mode.int
dirf()
Returns the mobile decoder direction and F0-F4 bits, as used in the DIRF bits of various LocoNet messages.LocoNetMessage
dispatchSlot()
Create LocoNet message which dispatches this slot Note that the invoking method ought to invoke the slot's NotifySlotListeners method to inform any other interested parties that the slot status has changed.void
functionMessage(long pkt)
Sets F9 through F28 (as appropriate) from data extracted from LocoNet "OPC_IMM_PACKET" message.int
getFcDays()
Return the days value from the slot.int
getFcFracMins()
Return the fractional minutes value from the slot.int
getFcHours()
Return the hours value from the slot.int
getFcMinutes()
Return the minutes value from the slot.int
getFcRate()
Get the fast-clock rate.boolean
getIsInitilized()
Get the state of the Acquire Throttle / slot.long
getLastUpdateTime()
Returns the timestamp when this LocoNetSlot was updated by some LocoNet message.int
getLeadSlot()
int
getProtocol()
int
getSlot()
Returns the slot number which was either specified or inferred at object creation time.SlotMapEntry.SlotType
getSlotType()
int
getThrottleIdentity()
Get the throttle ID in the slotint
getTrackStatus()
Get the track status byte (location 7)int
id()
Returns the "Throttle ID" associated with the slot.boolean
isF0()
Returns the slot's F0 stateboolean
isF1()
Returns the slot's F1 stateboolean
isF10()
Returns the slot's F10 stateboolean
isF11()
Returns the slot's F11 stateboolean
isF12()
Returns the slot's F12 stateboolean
isF13()
Returns the slot's F13 stateboolean
isF14()
Returns the slot's F14 stateboolean
isF15()
Returns the slot's F15 stateboolean
isF16()
Returns the slot's F16 stateboolean
isF17()
Returns the slot's F17 stateboolean
isF18()
Returns the slot's F1 stateboolean
isF19()
Returns the slot's F19 stateboolean
isF2()
Returns the slot's F2 stateboolean
isF20()
Returns the slot's F20 stateboolean
isF21()
Returns the slot's F21 stateboolean
isF22()
Returns the slot's F22 stateboolean
isF23()
Returns the slot's F23 stateboolean
isF24()
Returns the slot's F24 stateboolean
isF25()
Returns the slot's F25 stateboolean
isF26()
Returns the slot's F26 stateboolean
isF27()
Returns the slot's F27 stateboolean
isF28()
Returns the slot's F28 stateboolean
isF3()
Returns the slot's F3 stateboolean
isF4()
Returns the slot's F4 stateboolean
isF5()
Returns the slot's F5 stateboolean
isF6()
Returns the slot's F6 stateboolean
isF7()
Returns the slot's F7 stateboolean
isF8()
Returns the slot's F8 stateboolean
isF9()
Returns the slot's F9 stateboolean
isForward()
Returns the direction of loco movement which applies when the slot's speed is set for movement.boolean
isFunction(int Fn)
Return a slot Function state.boolean
isSystemSlot()
int
locoAddr()
Returns the mobile decoder address associated with the slot.void
notifySlotListeners()
Notifies all listeners that this slot has been changed in some way.int
pcmd()
Returns the programmer command associated with the slot.LocoNetMessage
releaseSlot()
Create a LocoNet OPC_SLOT_STAT1 message which releases this slot to the "Common" state The invoking method must send the returned LocoNet message to LocoNet in order to have a useful effect.void
removeSlotListener(SlotListener l)
Un-registers a slot listener.void
setFcCntrlBitOff(int val)
For fast-clock slot, set a "CLK_CNTRL" bit Off.void
setFcCntrlBitOn(int val)
For fast-clock slot, set a "CLK_CNTRL" bit On.void
setFcDays(int val)
For fast-clock slot, set "days" value.void
setFcFracMins(int val)
Set the "frac_mins" value.void
setFcHours(int val)
For fast-clock slot, set "hours" value.void
setFcMinutes(int val)
For fast-clock slot, set "minutes" value.void
setFcRate(int val)
For fast-clock slot, set "rate" value.protected void
setIsInitialized(boolean state)
protected void
setProtocol(int value)
set the protocol to be usedvoid
setSlot(LocoNetMessage l)
Update the slot object to reflect the specific contents of a LocoNet message.void
setSlotType(SlotMapEntry.SlotType value)
Set the Slot Typevoid
setThrottleIdentity(int throttleId)
Set the throttle ID in the slotvoid
setTrackStatus(int status)
Set the track status byte (location 7)int
slotStatus()
Get slot status.int
snd()
Returns the mobile decoder F5-F8 bits, as used in the SND bits of various LocoNet messages.int
speed()
Returns the mobile decoder speed associated with the slotint
ss2()
Get secondary slot status.LocoNetMessage
writeMode(int status)
Update the decoder type bits in STAT1 (D2, D1, D0)LocoNetMessage
writeNullMove()
Create a message to perform a null move on this slot.LocoNetMessage
writeSlot()
Creates a LocoNet "OPC_WR_SL_DATA" message containing the current state of the LocoNetSlot object.LocoNetMessage
writeSpeed(int speed)
Update SpeedLocoNetMessage
writeStatus(int status)
Update the status mode bits in STAT1 (D5, D4)LocoNetMessage
writeThrottleID(int newID)
Sets the object's ID value and returns a LocoNet message to inform the command station that the throttle ID has been changed.
-
-
-
Field Detail
-
localF9
boolean localF9
-
localF10
boolean localF10
-
localF11
boolean localF11
-
localF12
boolean localF12
-
localF13
boolean localF13
-
localF14
boolean localF14
-
localF15
boolean localF15
-
localF16
boolean localF16
-
localF17
boolean localF17
-
localF18
boolean localF18
-
localF19
boolean localF19
-
localF20
boolean localF20
-
localF21
boolean localF21
-
localF22
boolean localF22
-
localF23
boolean localF23
-
localF24
boolean localF24
-
localF25
boolean localF25
-
localF26
boolean localF26
-
localF27
boolean localF27
-
localF28
boolean localF28
-
-
Constructor Detail
-
LocoNetSlot
public LocoNetSlot(int slotNum)
Create a slot based solely on a slot number. The remainder of the slot is left un-initialized.- Parameters:
slotNum
- slot number to be assigned to the new LocoNetSlot object
-
LocoNetSlot
public LocoNetSlot(int slotNum, int inLoconetProtocol)
Create a slot based solely on a slot number. The remainder of the slot is left un-initialized.- Parameters:
slotNum
- - slot number to be assigned to the new LocoNetSlot objectinLoconetProtocol
- - can be 0 = unknown, 1 = version 1.1, 2 = Expandedslot
-
LocoNetSlot
public LocoNetSlot(int slotNum, int inLoconetProtocol, SlotMapEntry.SlotType inSlotType)
Create a slot , initialize slotnum, protocol and slot type- Parameters:
slotNum
- - slot number to be assigned to the new LocoNetSlot objectinLoconetProtocol
- - can be 0 = unknown, 1 = version 1.1, 2 = ExpandedslotinSlotType
- - SLotType enum
-
LocoNetSlot
public LocoNetSlot(LocoNetMessage l) throws LocoNetException
Creates a slot object based on the contents of a LocoNet message. The slot number is assumed to be found in byte 2 of the message if message is 0xE6 or bytes 2 and 3 for 0xE7- Parameters:
l
- a LocoNet message- Throws:
LocoNetException
- if the slot does not have an easily-found slot number
-
-
Method Detail
-
getSlot
public int getSlot()
Returns the slot number which was either specified or inferred at object creation time.- Returns:
- the slot number
-
setSlotType
public void setSlotType(SlotMapEntry.SlotType value)
Set the Slot Type- Parameters:
value
- enum for slottype
-
isSystemSlot
public boolean isSystemSlot()
- Returns:
- true if this is a systems slot else false
-
getSlotType
public SlotMapEntry.SlotType getSlotType()
- Returns:
- true if this is a systems slot else false
-
getProtocol
public int getProtocol()
- Returns:
- the protocol level support by the slot.
-
setProtocol
protected void setProtocol(int value)
set the protocol to be used- Parameters:
value
- one,two or unknown
-
decoderType
public int decoderType()
Get decoder mode. The decoder (operating) mode is taken from those bits in the slot's STAT byte which reflect the "speed steps" and "consisting" mode. Note that the other bits from the STAT byte are not visible via this method. thisFor slot numbers not normally associated with mobile decoders, these bits may have other meanings.
Possible values are
LnConstants.DEC_MODE_128A
,LnConstants.DEC_MODE_28A
,LnConstants.DEC_MODE_128
,LnConstants.DEC_MODE_14
,LnConstants.DEC_MODE_28TRI
,LnConstants.DEC_MODE_28
- Returns:
- the encoded decoder operating mode.
-
slotStatus
public int slotStatus()
Get slot status.These bits are set based on the STAT byte as seen in LocoNet slot write and slot read messages. These bits determine whether the command station is actively "refreshing" the loco's speed and direction information on the DCC track signal, and whether the slot is able to be re-assigned for use by another locomotive.
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
This returns only those bits of the slot's STAT byte which are related to the slot's "status".
Possible values are
LnConstants.LOCO_IN_USE
,LnConstants.LOCO_IDLE
,LnConstants.LOCO_COMMON
,LnConstants.LOCO_FREE
- Returns:
- the slot status bits associated with the slot
-
ss2
public int ss2()
Get secondary slot status.These bits are set based on the STAT2 byte as seen in LocoNet slot write and slot read messages. These bits determine how the command station interprets the "address" field of the slot.
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
This returns only those bits of the slot's STAT2 byte which are related to the slot's "secondary status".
- Returns:
- the slot secondary status bits associated with the slot
-
getIsInitilized
public boolean getIsInitilized()
Get the state of the Acquire Throttle / slot. It is fully initialized if this is true. If it is false then any changes to its state may be lost.- Returns:
- true
-
setIsInitialized
protected void setIsInitialized(boolean state)
-
consistStatus
public int consistStatus()
Get consist status.This returns only those bits of the slot's STAT byte which are related to the slot's "consisting status".
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
Possible values are
LnConstants.CONSIST_NO
,LnConstants.CONSIST_TOP
,LnConstants.CONSIST_MID
,LnConstants.CONSIST_SUB
- Returns:
- the slot "consist status", with unrelated bits zeroed
-
isForward
public boolean isForward()
Returns the direction of loco movement which applies when the slot's speed is set for movement.For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if slot is set for forward movement, else false
-
isFunction
public boolean isFunction(int Fn)
Return a slot Function state.See individual Functions for meanings.
- Parameters:
Fn
- Function number, 0-28- Returns:
- true if Function is "on", else false
-
isF0
public boolean isF0()
Returns the slot's F0 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F0 is "on", else false
-
isF1
public boolean isF1()
Returns the slot's F1 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F1 is "on", else false
-
isF2
public boolean isF2()
Returns the slot's F2 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F2 is "on", else false
-
isF3
public boolean isF3()
Returns the slot's F3 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F3 is "on", else false
-
isF4
public boolean isF4()
Returns the slot's F4 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F4 is "on", else false
-
isF5
public boolean isF5()
Returns the slot's F5 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F5 is "on", else false
-
isF6
public boolean isF6()
Returns the slot's F6 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F6 is "on", else false
-
isF7
public boolean isF7()
Returns the slot's F7 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F7 is "on", else false
-
isF8
public boolean isF8()
Returns the slot's F8 stateFor slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F8 is "on", else false
-
isF9
public boolean isF9()
Returns the slot's F9 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F9 is "on", else false
-
isF10
public boolean isF10()
Returns the slot's F10 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F10 is "on", else false
-
isF11
public boolean isF11()
Returns the slot's F11 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F11 is "on", else false
-
isF12
public boolean isF12()
Returns the slot's F12 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F12 is "on", else false
-
isF13
public boolean isF13()
Returns the slot's F13 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F13 is "on", else false
-
isF14
public boolean isF14()
Returns the slot's F14 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F14 is "on", else false
-
isF15
public boolean isF15()
Returns the slot's F15 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F15 is "on", else false
-
isF16
public boolean isF16()
Returns the slot's F16 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F16 is "on", else false
-
isF17
public boolean isF17()
Returns the slot's F17 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F17 is "on", else false
-
isF18
public boolean isF18()
Returns the slot's F1 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F1 is "on", else false
-
isF19
public boolean isF19()
Returns the slot's F19 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F19 is "on", else false
-
isF20
public boolean isF20()
Returns the slot's F20 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F20 is "on", else false
-
isF21
public boolean isF21()
Returns the slot's F21 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F21 is "on", else false
-
isF22
public boolean isF22()
Returns the slot's F22 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F22 is "on", else false
-
isF23
public boolean isF23()
Returns the slot's F23 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F23 is "on", else false
-
isF24
public boolean isF24()
Returns the slot's F24 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F24 is "on", else false
-
isF25
public boolean isF25()
Returns the slot's F25 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F25 is "on", else false
-
isF26
public boolean isF26()
Returns the slot's F26 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F26 is "on", else false
-
isF27
public boolean isF27()
Returns the slot's F27 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F27 is "on", else false
-
isF28
public boolean isF28()
Returns the slot's F28 stateSome command stations do not actively remember the state of this function. JMRI attempts to track the messages which control this function, but may not reliably do so in some cases.
For slot numbers not normally associated with mobile decoders, this bit may have other meanings.
- Returns:
- true if F28 is "on", else false
-
locoAddr
public int locoAddr()
Returns the mobile decoder address associated with the slot.Note that the returned address can encode a "short" address, a "long" address or an "alias".
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
- Returns:
- the mobile decoder address
-
speed
public int speed()
Returns the mobile decoder speed associated with the slotIf this slot object is consisted to another slot and is not the "top" of the consist, then the return value is the slot number to which this slot is consisted.
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
- Returns:
- the current speed step associated with the slot.
-
dirf
public int dirf()
Returns the mobile decoder direction and F0-F4 bits, as used in the DIRF bits of various LocoNet messages.If this slot object is consisted to another slot and is not the "top" of the consist, then the "direction" bit reflects the relative direction of this loco with respect to the loco it is consisted to, where "Reverse" means it travels in the "reverse" direction with respect to the loco to which it is consisted.
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
- Returns:
- the <DIRF> byte value
-
snd
public int snd()
Returns the mobile decoder F5-F8 bits, as used in the SND bits of various LocoNet messages.For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
- Returns:
- the <SND> byte value
-
id
public int id()
Returns the "Throttle ID" associated with the slot.The returned value is a 14-bit integer comprised of ID1 as the least-significant bits and ID2 as the most-significant bits.
For slot numbers not normally associated with mobile decoders, these bits may have other meanings.
- Returns:
- an integer representing the throttle ID number
-
pcmd
public int pcmd()
Returns the programmer command associated with the slot.The returned value is taken from the <PCMD> byte of programmer slot read and write LocoNet messages.
For slot numbers other than the programmer slot, these bits may have other meanings.
- Returns:
- the <PCMD> byte
-
cvval
public int cvval()
-
setSlot
public void setSlot(LocoNetMessage l) throws LocoNetException
Update the slot object to reflect the specific contents of a LocoNet message.Note that the object's "slot" field is not updated by this method.
- Parameters:
l
- a LocoNet message- Throws:
LocoNetException
- if the message is not one which contains slot-related data
-
functionMessage
public void functionMessage(long pkt)
Sets F9 through F28 (as appropriate) from data extracted from LocoNet "OPC_IMM_PACKET" message.If the pkt parameter does not contain data from an appropriate OPC_IMM_PACKET message, the pkt is ignored and the slot object remains unchanged.
- Parameters:
pkt
- is a "long" consisting of four bytes extracted from a LocoNet "OPC_IMM_PACKET" message.
-
writeMode
public LocoNetMessage writeMode(int status)
Update the decoder type bits in STAT1 (D2, D1, D0)- Parameters:
status
- New values for STAT1 (D2, D1, D0)- Returns:
- Formatted LocoNet message to change value.
-
writeThrottleID
public LocoNetMessage writeThrottleID(int newID)
Sets the object's ID value and returns a LocoNet message to inform the command station that the throttle ID has been changed.- Parameters:
newID
- the new ID number to set into the slot object- Returns:
- a LocoNet message containing a "Slot Write" message to inform the command station that a specific throttle is controlling the slot.
-
setThrottleIdentity
public void setThrottleIdentity(int throttleId)
Set the throttle ID in the slot- Parameters:
throttleId
- full id
-
getThrottleIdentity
public int getThrottleIdentity()
Get the throttle ID in the slot- Returns:
- the Id of the Throttle
-
getLeadSlot
public int getLeadSlot()
-
writeStatus
public LocoNetMessage writeStatus(int status)
Update the status mode bits in STAT1 (D5, D4)- Parameters:
status
- New values for STAT1 (D5, D4)- Returns:
- Formatted LocoNet message to change value.
-
writeSpeed
public LocoNetMessage writeSpeed(int speed)
Update Speed- Parameters:
speed
- new speed- Returns:
- Formatted LocoNet message to change value.
-
dispatchSlot
public LocoNetMessage dispatchSlot()
Create LocoNet message which dispatches this slot Note that the invoking method ought to invoke the slot's NotifySlotListeners method to inform any other interested parties that the slot status has changed.- Returns:
- LocoNet message which "dispatches" the slot
-
writeNullMove
public LocoNetMessage writeNullMove()
Create a message to perform a null move on this slot.- Returns:
- correct LocoNetMessage for protocol being used.
-
releaseSlot
public LocoNetMessage releaseSlot()
Create a LocoNet OPC_SLOT_STAT1 message which releases this slot to the "Common" state The invoking method must send the returned LocoNet message to LocoNet in order to have a useful effect. Upon receipt of the echo of the transmitted OPC_SLOT_STAT1 message, the LocoNetSlot object will notify its listeners.- Returns:
- LocoNet message which "releases" the slot to the "Common" state
-
writeSlot
public LocoNetMessage writeSlot()
Creates a LocoNet "OPC_WR_SL_DATA" message containing the current state of the LocoNetSlot object.- Returns:
- a LocoNet message which can be used to inform the command station of a change in the slot contents.
-
addSlotListener
public void addSlotListener(SlotListener l)
Registers a slot listener if it is not already registered.- Parameters:
l
- a slot listener
-
removeSlotListener
public void removeSlotListener(SlotListener l)
Un-registers a slot listener.- Parameters:
l
- a slot listener
-
getLastUpdateTime
public long getLastUpdateTime()
Returns the timestamp when this LocoNetSlot was updated by some LocoNet message.- Returns:
- last time the slot info was updated
-
notifySlotListeners
public void notifySlotListeners()
Notifies all listeners that this slot has been changed in some way.
-
setFcCntrlBitOn
public void setFcCntrlBitOn(int val)
For fast-clock slot, set a "CLK_CNTRL" bit On. This method logs an error if invoked for a slot other than the fast-clock slot.- Parameters:
val
- is the new "CLK_CNTRL" bit value to turn On
-
setFcCntrlBitOff
public void setFcCntrlBitOff(int val)
For fast-clock slot, set a "CLK_CNTRL" bit Off. This method logs an error if invoked for a slot other than the fast-clock slot.- Parameters:
val
- is the new "CLK_CNTRL" bit value to turn Off
-
getTrackStatus
public int getTrackStatus()
Get the track status byte (location 7)Note that the <TRK> byte is not accurate on some command stations.
- Returns:
- the effective <TRK> byte
-
setTrackStatus
public void setTrackStatus(int status)
Set the track status byte (location 7)Note that setting the LocoNetSlot object's track status may result in a change to the command station's actual track status if the slot's status is communicated to the command station via an OPC_WR_DL_DATA LocoNet message.
- Parameters:
status
- is the new track status value.
-
getFcDays
public int getFcDays()
Return the days value from the slot. Only valid for fast-clock slot.This method logs an error if invoked for a slot other than the fast-clock slot.
- Returns:
- "Days" value currently in fast-clock slot.
-
setFcDays
public void setFcDays(int val)
For fast-clock slot, set "days" value.Note that the new days value is not effective until a LocoNet message is sent which writes the fast-clock slot data.
This method logs an error if invoked for a slot other than the fast-clock slot.
- Parameters:
val
- is the new fast-clock "days" value
-
getFcHours
public int getFcHours()
Return the hours value from the slot. Only valid for fast-clock slot.This method logs an error if invoked for a slot other than the fast-clock slot.
- Returns:
- "Hours" value currently stored in fast clock slot.
-
setFcHours
public void setFcHours(int val)
For fast-clock slot, set "hours" value.Note that the new hours value is not effective until a LocoNet message is sent which writes the fast-clock slot data.
This method logs an error if invoked for a slot other than the fast-clock slot.
- Parameters:
val
- is the new fast-clock "hours" value
-
getFcMinutes
public int getFcMinutes()
Return the minutes value from the slot. Only valid for fast-clock slot.This method logs an error if invoked for a slot other than the fast-clock slot.
- Returns:
- Return minutes value currently stored in the fast clock slot.
-
setFcMinutes
public void setFcMinutes(int val)
For fast-clock slot, set "minutes" value.Note that the new minutes value is not effective until a LocoNet message is sent which writes the fast-clock slot data.
This method logs an error if invoked for a slot other than the fast-clock slot.
- Parameters:
val
- is the new fast-clock "minutes" value
-
getFcFracMins
public int getFcFracMins()
Return the fractional minutes value from the slot. Only valid for fast- clock slot.This method logs an error if invoked for a slot other than the fast-clock slot.
- Returns:
- Return frac_mins field which is the number of 65ms ticks until then next minute rollover. These ticks step at the current fast clock rate
-
setFcFracMins
public void setFcFracMins(int val)
Set the "frac_mins" value. This has to be calculated as required by the Command Station, then bit shifted if required. It is comprised of a base number and the distance from the base to 0x8000 or 0x4000 deoending on command station. It is read and written as is LO,HO and loses the bit 7 of the LO. It was never intended for external use. The base can be found by setting the clock to 0xXX7F, with a rate of 1 and pounding the clock every 250 to 100 msecs until it roles.Note 1: The new fractional minutes value is not effective until a LocoNet slot write happens
Note 2: DT40x & DT500 throttles ignore this value, and set only the whole minutes.
This method logs an error if invoked for a slot other than the fast-clock slot.
- Parameters:
val
- is the new fast-clock "fractional minutes" including the base, and bit shifted if required.
-
getFcRate
public int getFcRate()
Get the fast-clock rate. Only valid for fast-clock slot.This method logs an error if invoked for a slot other than the fast-clock slot.
- Returns:
- Rate stored in fast clock slot.
-
setFcRate
public void setFcRate(int val)
For fast-clock slot, set "rate" value.Note that the new rate is not effective until a LocoNet message is sent which writes the fast-clock slot data.
This method logs an error if invoked for a slot other than the fast-clock slot.
- Parameters:
val
- is the new fast-clock rate
-
-