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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations