use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.
the class CbusMessage method getReadCV.
/**
* CBUS programmer commands
*/
public static CanMessage getReadCV(int cv, ProgrammingMode mode, int header) {
CanMessage m = new CanMessage(5, header);
m.setElement(0, CbusConstants.CBUS_QCVS);
m.setElement(1, CbusConstants.SERVICE_HANDLE);
m.setElement(2, (cv / 256) & 0xff);
m.setElement(3, cv & 0xff);
if (mode.equals(DefaultProgrammerManager.PAGEMODE)) {
m.setElement(4, CbusConstants.CBUS_PROG_PAGED);
} else if (mode.equals(DefaultProgrammerManager.DIRECTBITMODE)) {
m.setElement(4, CbusConstants.CBUS_PROG_DIRECT_BIT);
} else if (mode.equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
m.setElement(4, CbusConstants.CBUS_PROG_DIRECT_BYTE);
} else {
m.setElement(4, CbusConstants.CBUS_PROG_REGISTER);
}
setPri(m, 0xb);
return m;
}
use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.
the class CbusLight method doNewState.
/**
* Handle a request to change state by sending CBUS events.
*
*/
@Override
protected void doNewState(int oldState, int newState) {
CanMessage m;
if (newState == ON) {
m = addrOn.makeMessage(tc.getCanid());
tc.sendCanMessage(m, this);
} else if (newState == OFF) {
m = addrOff.makeMessage(tc.getCanid());
tc.sendCanMessage(m, this);
} else {
log.warn("illegal state requested for Light: " + getSystemName());
}
}
use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.
the class CbusCommandStation method sendKeepAlive.
/**
* Send keep alive (DKEEP) packet for a throttle
*
*/
public void sendKeepAlive(int handle) {
CanMessage msg = new CanMessage(2, tc.getCanid());
msg.setOpCode(CbusConstants.CBUS_DKEEP);
msg.setElement(1, handle);
log.debug("keep alive handle: " + handle);
tc.sendCanMessage(msg, null);
}
use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.
the class CbusCommandStation method setFunctions.
/**
* Send a CBUS message to set functions
*
* @param group The function group
* @param handle The handle of the session for the loco being controlled
* @param functions Function bits
*/
protected void setFunctions(int group, int handle, int functions) {
log.debug("Set function group " + group + " Fns " + functions + " for session handle" + handle);
CanMessage msg = new CanMessage(4, tc.getCanid());
msg.setOpCode(CbusConstants.CBUS_DFUN);
msg.setElement(1, handle);
msg.setElement(2, group);
msg.setElement(3, functions);
tc.sendCanMessage(msg, this);
}
use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.
the class CbusCommandStation method releaseSession.
/**
* Release a session freeing up the slot for reuse
*
* @param handle the handle for the session to be released
*/
public void releaseSession(int handle) {
// Send KLOC
CanMessage msg = new CanMessage(2, tc.getCanid());
msg.setOpCode(CbusConstants.CBUS_KLOC);
msg.setElement(1, handle);
log.debug("Release session handle " + handle);
tc.sendCanMessage(msg, null);
}
Aggregations