use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class LocoStatsFunc method sendQuery.
private void sendQuery() {
if (memo == null) {
return;
}
LocoNetMessage l = new LocoNetMessage(new int[] { 0x81, 0x7f });
memo.getLnTrafficController().sendLocoNetMessage(l);
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class PR3Adapter method configure.
/**
* Set up all of the other objects to operate with a PR3 connected to this
* port. This overrides the version in loconet.locobuffer, but it has to
* duplicate much of the functionality there, so the code is basically
* copied.
*/
@Override
public void configure() {
setCommandStationType(getOptionState(option2Name));
setTurnoutHandling(getOptionState(option3Name));
if (commandStationType == LnCommandStationType.COMMAND_STATION_PR3_ALONE) {
// PR3 standalone case
// connect to a packetizing traffic controller
// that does echoing
jmri.jmrix.loconet.pr2.LnPr2Packetizer packets = new jmri.jmrix.loconet.pr2.LnPr2Packetizer();
packets.connectPort(this);
// create memo
/*PR3SystemConnectionMemo memo
= new PR3SystemConnectionMemo(packets, new SlotManager(packets));*/
this.getSystemConnectionMemo().setLnTrafficController(packets);
// do the common manager config
this.getSystemConnectionMemo().configureCommandStation(commandStationType, mTurnoutNoRetry, mTurnoutExtraSpace);
this.getSystemConnectionMemo().configureManagersPR2();
// start operation
packets.startThreads();
// set mode
LocoNetMessage msg = new LocoNetMessage(6);
msg.setOpCode(0xD3);
msg.setElement(1, 0x10);
// set PR2
msg.setElement(2, 1);
msg.setElement(3, 0);
msg.setElement(4, 0);
packets.sendLocoNetMessage(msg);
} else {
// MS100 modes - connecting to a separate command station
// connect to a packetizing traffic controller
LnPacketizer packets = new LnPacketizer();
packets.connectPort(this);
// create memo
/*PR3SystemConnectionMemo memo
= new PR3SystemConnectionMemo(packets, new SlotManager(packets));*/
this.getSystemConnectionMemo().setLnTrafficController(packets);
// do the common manager config
this.getSystemConnectionMemo().configureCommandStation(commandStationType, mTurnoutNoRetry, mTurnoutExtraSpace);
this.getSystemConnectionMemo().configureManagersMS100();
// start operation
packets.startThreads();
// set mode
LocoNetMessage msg = new LocoNetMessage(6);
msg.setOpCode(0xD3);
msg.setElement(1, 0x10);
// set MS100, no power
msg.setElement(2, 0);
if (commandStationType == LnCommandStationType.COMMAND_STATION_STANDALONE) {
// set MS100, with power
msg.setElement(2, 3);
}
msg.setElement(3, 0);
msg.setElement(4, 0);
packets.sendLocoNetMessage(msg);
}
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class PR3SystemConnectionMemo method configureManagersPR2.
/**
* Configure the subset of LocoNet managers valid for the PR3 in PR2 mode.
*/
public void configureManagersPR2() {
mode = PR3MODE;
InstanceManager.store(getPowerManager(), jmri.PowerManager.class);
InstanceManager.setThrottleManager(getThrottleManager());
jmri.InstanceManager.setProgrammerManager(getProgrammerManager());
// Finally, create and register a shutdown task to ensure clean exit
if (restoreToLocoNetInterfaceModeTask == null) {
restoreToLocoNetInterfaceModeTask = new // NOI18N
QuietShutDownTask(// NOI18N
"Restore PR3 to LocoNet Interface Mode") {
@Override
public boolean execute() {
if (mode == PR3MODE) {
// try to change from "standalone programmer" to "LocoNet interface" mode
LnTrafficController tc;
tc = getLnTrafficController();
if (tc != null) {
LocoNetMessage msg = new LocoNetMessage(6);
msg.setOpCode(0xD3);
msg.setElement(1, 0x10);
// set MS100, no power
msg.setElement(2, 0);
msg.setElement(3, 0);
msg.setElement(4, 0);
tc.sendLocoNetMessage(msg);
// NOI18N
log.info("Configuring PR3 for 'LocoNet Interface' mode");
}
}
return true;
}
};
if (InstanceManager.getNullableDefault(jmri.ShutDownManager.class) != null) {
InstanceManager.getDefault(jmri.ShutDownManager.class).register(restoreToLocoNetInterfaceModeTask);
} else {
// NOI18N
log.warn("The PR3 will not be automatically returned to 'LocoNet interface' mode upon quit!");
}
}
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class Pr3SelectPane method initComponents.
@Override
public void initComponents(LocoNetSystemConnectionMemo memo) {
super.initComponents(memo);
// listen for LocoNet messages
if (memo.getLnTrafficController() != null) {
memo.getLnTrafficController().addLocoNetListener(~0, this);
} else {
log.error("No LocoNet connection available, can't function");
}
// request status
LocoNetMessage msg = new LocoNetMessage(2);
msg.setOpCode(LnConstants.OPC_GPBUSY);
memo.getLnTrafficController().sendLocoNetMessage(msg);
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class LoaderEngine method getExitMessage.
/**
* Get a message to exit the download process
*/
LocoNetMessage getExitMessage() {
LocoNetMessage m = new LocoNetMessage(new int[] { 0xD3, 0x00, 0x00, 0x00, 0x00, 0x2C });
m.setParity();
return m;
}
Aggregations