Search in sources :

Example 41 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusSensorTest method testIncomingChange.

public void testIncomingChange() {
    // load dummy TrafficController
    TestTrafficController t = new TestTrafficController();
    Assert.assertNotNull("exists", t);
    CbusSensor s = new CbusSensor("MS", "+1;-1", t);
    // message for Active and Inactive
    CanMessage mActive = new CanMessage(new int[] { CbusConstants.CBUS_ASON, 0x00, 0x00, 0x00, 0x01 }, t.getCanid());
    CanMessage mInactive = new CanMessage(new int[] { CbusConstants.CBUS_ASOF, 0x00, 0x00, 0x00, 0x01 }, t.getCanid());
    // check states
    Assert.assertTrue(s.getKnownState() == Sensor.UNKNOWN);
    s.message(mActive);
    Assert.assertTrue(s.getKnownState() == Sensor.ACTIVE);
    s.message(mInactive);
    Assert.assertTrue(s.getKnownState() == Sensor.INACTIVE);
}
Also used : TestTrafficController(jmri.jmrix.can.TestTrafficController) CanMessage(jmri.jmrix.can.CanMessage)

Example 42 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class OlcbSensorTest method testIncomingChange.

public void testIncomingChange() {
    Assert.assertNotNull("exists", t);
    OlcbSensor s = new OlcbSensor("MS", "1.2.3.4.5.6.7.8;1.2.3.4.5.6.7.9", t.iface);
    // message for Active and Inactive
    CanMessage mActive = new CanMessage(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }, 0x195B4123);
    mActive.setExtended(true);
    CanMessage mInactive = new CanMessage(new int[] { 1, 2, 3, 4, 5, 6, 7, 9 }, 0x195B4123);
    mInactive.setExtended(true);
    // check states
    Assert.assertTrue(s.getKnownState() == Sensor.UNKNOWN);
    t.sendMessage(mActive);
    Assert.assertTrue(s.getKnownState() == Sensor.ACTIVE);
    t.sendMessage(mInactive);
    Assert.assertTrue(s.getKnownState() == Sensor.INACTIVE);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 43 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class OlcbTurnoutTest method testNameFormatXlower.

public void testNameFormatXlower() {
    // load dummy TrafficController
    OlcbTurnout s = new OlcbTurnout("MT", "x0501010114FF2000;x0501010114FF2001", t.iface);
    s.finishLoad();
    Assert.assertNotNull("to exists", s);
    // message for Active and Inactive
    CanMessage mActive = new CanMessage(new int[] { 0x05, 0x01, 0x01, 0x01, 0x14, 0xFF, 0x20, 0x00 }, 0x195B4000);
    mActive.setExtended(true);
    CanMessage mInactive = new CanMessage(new int[] { 0x05, 0x01, 0x01, 0x01, 0x14, 0xFF, 0x20, 0x01 }, 0x195B4000);
    mInactive.setExtended(true);
    // check states
    Assert.assertTrue(s.getCommandedState() == Turnout.UNKNOWN);
    t.sendMessage(mActive);
    Assert.assertTrue(s.getCommandedState() == Turnout.THROWN);
    t.sendMessage(mInactive);
    Assert.assertTrue(s.getCommandedState() == Turnout.CLOSED);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 44 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class LawicellTrafficController method encodeForHardware.

/**
     * Encode a CanMessage for the hardware
     */
@Override
public AbstractMRMessage encodeForHardware(CanMessage m) {
    log.debug("Encoding for hardware");
    Message ret = new Message(m);
    if (log.isDebugEnabled()) {
        log.debug("encoded as " + ret);
    }
    return ret;
}
Also used : AbstractMRMessage(jmri.jmrix.AbstractMRMessage) CanMessage(jmri.jmrix.can.CanMessage)

Example 45 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusThrottleManager method requestThrottleSetup.

/**
     * Request a new throttle object be created for the address
     *
     */
@Override
public synchronized void requestThrottleSetup(LocoAddress address, boolean control) {
    _dccAddr = (DccLocoAddress) address;
    _intAddr = _dccAddr.getNumber();
    // The CBUS protocol requires that we request a session from the command
    // station. Throttle object will be notified by Command Station
    log.debug("Requesting session for throttle");
    CanMessage msg = new CanMessage(3, tc.getCanid());
    // Request a session for this throttle
    msg.setOpCode(CbusConstants.CBUS_RLOC);
    if (((DccLocoAddress) address).isLongAddress()) {
        _intAddr = _intAddr | 0xC000;
    }
    msg.setElement(1, (_intAddr / 256));
    msg.setElement(2, _intAddr & 0xff);
    tc.sendCanMessage(msg, this);
    _handleExpected = true;
    startThrottleRequestTimer();
}
Also used : CanMessage(jmri.jmrix.can.CanMessage) DccLocoAddress(jmri.DccLocoAddress)

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