Search in sources :

Example 51 with CanMessage

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;
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 52 with CanMessage

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());
    }
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 53 with CanMessage

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);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 54 with CanMessage

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);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 55 with CanMessage

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);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Aggregations

CanMessage (jmri.jmrix.can.CanMessage)63 Test (org.junit.Test)4 CanReply (jmri.jmrix.can.CanReply)3 CanListener (jmri.jmrix.can.CanListener)2 CbusAddress (jmri.jmrix.can.cbus.CbusAddress)2 DccLocoAddress (jmri.DccLocoAddress)1 AbstractMRMessage (jmri.jmrix.AbstractMRMessage)1 CanSystemConnectionMemo (jmri.jmrix.can.CanSystemConnectionMemo)1 TestTrafficController (jmri.jmrix.can.TestTrafficController)1 TrafficControllerScaffold (jmri.jmrix.can.TrafficControllerScaffold)1 GridConnectMessage (jmri.jmrix.can.adapters.gridconnect.GridConnectMessage)1 GridConnectReply (jmri.jmrix.can.adapters.gridconnect.GridConnectReply)1 LoaderClient (org.openlcb.LoaderClient)1 OlcbInterface (org.openlcb.OlcbInterface)1 AliasMap (org.openlcb.can.AliasMap)1 CanInterface (org.openlcb.can.CanInterface)1 MessageBuilder (org.openlcb.can.MessageBuilder)1 Hub (org.openlcb.hub.Hub)1