Package jmri.jmrix.can.cbus
Class CbusCommandStation
- java.lang.Object
-
- jmri.jmrix.can.cbus.CbusCommandStation
-
- All Implemented Interfaces:
CommandStation
public class CbusCommandStation extends java.lang.Object implements CommandStation
CommandStation for CBUS communications. Unlike some other systems, we will hold minimal command station state in the software model. The actual command station state should always be referred to.
-
-
Constructor Summary
Constructors Constructor Description CbusCommandStation(CanSystemConnectionMemo memo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CbusNode
getMasterCommandStation()
Get the master command station from the CBUS Node Tablejava.lang.String
getSystemPrefix()
java.lang.String
getUserName()
protected boolean
isShareAvailable()
Get if Share is available on the Command Station.protected boolean
isStealAvailable()
Get if Steal is available on the Command Stationprotected void
releaseSession(int handle)
Release a session freeing up the slot for reuse.protected void
sendKeepAlive(int handle)
Send keep alive (DKEEP) packet for a throttle.boolean
sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.protected void
setFunctions(int group, int handle, int functions)
Send a CBUS message to set functions.protected void
setSpeedDir(int handle, int speed_dir)
Set loco speed and direction.protected void
setSpeedSteps(int handle, int mode)
Send a CBUS message to change the session speed step mode.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.CommandStation
sendAccSignalDecoderPkt, sendAltAccSignalDecoderPkt
-
-
-
-
Constructor Detail
-
CbusCommandStation
public CbusCommandStation(CanSystemConnectionMemo memo)
-
-
Method Detail
-
sendPacket
public boolean sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.- Specified by:
sendPacket
in interfaceCommandStation
- Parameters:
packet
- Byte array representing the packet, including the error-correction byte. Must not be null.repeats
- Number of times to repeat the transmission, but is ignored in the current implementation- Returns:
true
if the operation succeeds,false
otherwise.
-
releaseSession
protected void releaseSession(int handle)
Release a session freeing up the slot for reuse.- Parameters:
handle
- the handle for the session to be released
-
sendKeepAlive
protected void sendKeepAlive(int handle)
Send keep alive (DKEEP) packet for a throttle.- Parameters:
handle
- The handle of the session to which it applies
-
setSpeedDir
protected void setSpeedDir(int handle, int speed_dir)
Set loco speed and direction.- Parameters:
handle
- The handle of the session to which it appliesspeed_dir
- Bit 7 is direction (1 = forward) 6:0 are speed
-
setFunctions
protected void setFunctions(int group, int handle, int functions)
Send a CBUS message to set functions.- Parameters:
group
- The function grouphandle
- The handle of the session for the loco being controlledfunctions
- Function bits
-
setSpeedSteps
protected void setSpeedSteps(int handle, int mode)
Send a CBUS message to change the session speed step mode.- Parameters:
handle
- The handle of the session to which it appliesmode
- the speed step mode
-
getMasterCommandStation
@CheckForNull protected CbusNode getMasterCommandStation()
Get the master command station from the CBUS Node TableFull CBUS spec is defined as to comply with CBUS Developers Guide Version 6b
eg. CANCMD FW v3 supports the main loco OPCs but not full spec, will return null. eg. CANCMD FW v4 supports the full steal / share spec, will return the CbusNode.
- Returns:
- the Master Command Station, else null if not found
-
isStealAvailable
protected boolean isStealAvailable()
Get if Steal is available on the Command StationSteal availability can change, so CbusThrottleManager checks this value when it struggles on initial attempt to obtain a throttle
- Returns:
- false if not available, defaults to true
-
isShareAvailable
protected boolean isShareAvailable()
Get if Share is available on the Command Station.Share availability can change, so CbusThrottleManager checks this value when it struggles on initial attempt to obtain a throttle.
- Returns:
- false if not available, defaults to true
-
getUserName
public java.lang.String getUserName()
- Specified by:
getUserName
in interfaceCommandStation
-
getSystemPrefix
public java.lang.String getSystemPrefix()
- Specified by:
getSystemPrefix
in interfaceCommandStation
-
-