Search in sources :

Example 16 with LocoNetMessage

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

Example 17 with LocoNetMessage

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);
    }
}
Also used : LnPacketizer(jmri.jmrix.loconet.LnPacketizer) LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 18 with LocoNetMessage

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!");
        }
    }
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage) LnTrafficController(jmri.jmrix.loconet.LnTrafficController)

Example 19 with LocoNetMessage

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

Example 20 with LocoNetMessage

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

Aggregations

LocoNetMessage (jmri.jmrix.loconet.LocoNetMessage)103 Test (org.junit.Test)8 JFrame (javax.swing.JFrame)3 LocoNetInterfaceScaffold (jmri.jmrix.loconet.LocoNetInterfaceScaffold)3 LocoNetSystemConnectionMemo (jmri.jmrix.loconet.LocoNetSystemConnectionMemo)3 LocoStatsPanel (jmri.jmrix.loconet.locostats.swing.LocoStatsPanel)3 JmriJFrame (jmri.util.JmriJFrame)3 LocoNetSlot (jmri.jmrix.loconet.LocoNetSlot)2 SpjFile (jmri.jmrix.loconet.spjfile.SpjFile)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 StringTokenizer (java.util.StringTokenizer)1 LnPacketizer (jmri.jmrix.loconet.LnPacketizer)1 LnReporter (jmri.jmrix.loconet.LnReporter)1 LnTrafficController (jmri.jmrix.loconet.LnTrafficController)1 LnTurnout (jmri.jmrix.loconet.LnTurnout)1