Search in sources :

Example 66 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class BDL16Panel method initComponents.

/**
     * Initialize LocoNet connection for use by the tool
     * 
     * @param memo - LocoNet Connection
     */
@Override
public void initComponents(LocoNetSystemConnectionMemo memo) {
    super.initComponents(memo);
    LocoNetMessage m = new LocoNetMessage(6);
    m.setElement(0, LnConstants.OPC_MULTI_SENSE);
    m.setElement(1, 0x62);
    m.setElement(2, 0);
    m.setElement(3, 0x70);
    m.setElement(4, 0);
    memo.getLnTrafficController().sendLocoNetMessage(m);
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 67 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoGenPanel method createPacket.

/**
     * Create a well-formed LocoNet packet from a String
     *
     * @return The packet, with contents filled-in
     */
LocoNetMessage createPacket(String s) {
    // gather bytes in result
    byte[] b = StringUtil.bytesFromHexString(s);
    if (b.length == 0) {
        // no such thing as a zero-length message
        return null;
    }
    LocoNetMessage m = new LocoNetMessage(b.length);
    for (int i = 0; i < b.length; i++) {
        m.setElement(i, b[i]);
    }
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 68 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoGenPanel method sendNextItem.

/**
     * Send next item; may be used for the first item or when a delay has
     * elapsed.
     */
void sendNextItem() {
    // NOI18N
    log.debug("sendNextItem");
    // check if still running
    if (!mRunButton.isSelected()) {
        return;
    }
    // have we run off the end?
    if (mNextSequenceElement >= MAXSEQUENCE) {
        // past the end, go back
        mNextSequenceElement = 0;
    }
    // is this one enabled?
    if (mUseField[mNextSequenceElement].isSelected()) {
        // make the packet
        LocoNetMessage m = createPacket(mPacketField[mNextSequenceElement].getText());
        // send it
        mNextEcho = m;
        memo.getLnTrafficController().sendLocoNetMessage(m);
    } else {
        // ask for the next one
        mNextSequenceElement++;
        sendNextItem();
    }
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 69 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LnSv2MessageContents method createSvReadReply.

/**
     * 
     * @param m - the preceeding LocoNet message
     * @param svValues - array containing the SV values; only one value is used 
     *          when m contains a SV_QUERY_ONE, else contains 4 values.
     * @return  LocoNet message containing the reply, or null if preceeding 
     *          message isn't a query.
     */
public static LocoNetMessage createSvReadReply(LocoNetMessage m, int[] svValues) {
    if (!isSupportedSv2Message(m)) {
        return null;
    }
    if ((m.getElement(3) != Sv2Command.SV2_QUERY_ONE.cmd) && (m.getElement(3) != Sv2Command.SV2_QUERY_FOUR.cmd)) {
        return null;
    }
    LocoNetMessage n = m;
    n.setElement(3, n.getElement(3) + 0x40);
    n.setElement(11, svValues[0] & 0x7F);
    if (n.getElement(3) == Sv2Command.SV2_QUERY_ONE.cmd) {
        n.setElement(12, 0);
        n.setElement(13, 0);
        n.setElement(14, 0);
        int a = n.getElement(10);
        a &= 0x70;
        if ((svValues[0] & 0xFF) > 0x7f) {
            a |= 1;
        }
        n.setElement(10, a);
        return n;
    }
    n.setElement(12, svValues[1] & 0x7F);
    n.setElement(13, svValues[2] & 0x7F);
    n.setElement(14, svValues[3] & 0x7F);
    int a = n.getElement(10);
    a &= 0x70;
    a |= ((svValues[1] & 0x80) >> 6);
    a |= ((svValues[2] & 0x80) >> 5);
    a |= ((svValues[3] & 0x80) >> 5);
    n.setElement(10, a);
    return n;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 70 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoIO method probeLocoIOs.

public static void probeLocoIOs(LnTrafficController ln) {
    LocoNetMessage msg;
    msg = LocoIO.readCV(0x0100, 0, 2);
    ln.sendLocoNetMessage(msg);
}
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