Search in sources :

Example 51 with LocoNetMessage

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

the class LlnmonTest method testPR3ModeMessages.

public void testPR3ModeMessages() {
    LocoNetMessage l;
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x02, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 1", "Set PR3 to decoder programming track mode (i.e. no command station present).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x00, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 2", "Set PR3 to MS100 mode without PR3 termination of LocoNet (i.e. use PR3 with command station present).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x03, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 3", "Set PR3 to MS100 mode with PR3 termination of LocoNet (i.e. use PR3 without command station present).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x09, 0x03, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 4", "Unable to parse LocoNet message.\ncontents: D3 09 03 00 00 3D\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x07, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 5", "Unable to parse LocoNet message.\ncontents: D3 10 07 00 00 3D\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x03, 0x01, 0x00, 0x3D });
    assertEquals("PR3 mode test 6", "Unable to parse LocoNet message.\ncontents: D3 10 03 01 00 3D\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x03, 0x00, 0x10, 0x3D });
    assertEquals("PR3 mode test 7", "Unable to parse LocoNet message.\ncontents: D3 10 03 00 10 3D\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD3, 0x10, 0x01, 0x00, 0x00, 0x3D });
    assertEquals("PR3 mode test 8", "Unable to parse LocoNet message.\ncontents: D3 10 01 00 00 3D\n", f.displayMessage(l));
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 52 with LocoNetMessage

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

the class Ds64TabbedPanel method initComponents.

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 53 with LocoNetMessage

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

the class DuplexGroupScanPanel method createGetGroupChannelPacketInt.

/**
     * Create a LocoNet packet to get the current Duplex group channel number.
     * <p>
     * @return The packet which writes the Group Channel Number to the UR92
     *         device(s)
     */
private LocoNetMessage createGetGroupChannelPacketInt() {
    int i;
    // format packet
    LocoNetMessage m = new LocoNetMessage(LnConstants.RE_DPLX_OP_LEN);
    i = 0;
    m.setElement(i++, LnConstants.OPC_PEER_XFER);
    // 20-byte message
    m.setElement(i++, LnConstants.RE_DPLX_OP_LEN);
    // Group Channel Operation
    m.setElement(i++, LnConstants.RE_DPLX_GP_CHAN_TYPE);
    // Write Operation
    m.setElement(i++, LnConstants.RE_DPLX_OP_TYPE_QUERY);
    for (; i < (LnConstants.RE_DPLX_OP_LEN - 1); i++) {
        // always 0 for duplex group channel query
        m.setElement(i, 0);
    }
    // LocoNet send process will compute and add checksum byte in correct location
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 54 with LocoNetMessage

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

the class LnDplxGrpInfoImpl method createSetUr92GroupChannelPacket.

/**
     * Create a LocoNet packet to set the Duplex group channel number.
     * <p>
     * If s provides a 0-length group name, a bogus LocoNet message is returned.
     * If s does not define an integer is too short, it is padded with spaces at
     * the end of the string.
     * <p>
     * @param iChannelNumber The desired group channel number value as an
     *                       integer
     * @return The packet which writes the Group Channel Number to the UR92
     *         device(s)
     * @throws jmri.jmrix.loconet.LocoNetException if sGroupName is not a valid
     *                                             Duplex Group Name
     */
public static final LocoNetMessage createSetUr92GroupChannelPacket(Integer iChannelNumber) throws jmri.jmrix.loconet.LocoNetException {
    int i;
    if (validateGroupChannel(iChannelNumber) == false) {
        // NOI18N
        throw new jmri.jmrix.loconet.LocoNetException("Invalid Duplex Group Channel - must be between 11 and 26, inclusive");
    }
    // format packet
    LocoNetMessage m = new LocoNetMessage(LnConstants.RE_DPLX_OP_LEN);
    i = 0;
    m.setElement(i++, LnConstants.OPC_PEER_XFER);
    // 20-byte message
    m.setElement(i++, LnConstants.RE_DPLX_OP_LEN);
    // Group Channel Operation
    m.setElement(i++, LnConstants.RE_DPLX_GP_CHAN_TYPE);
    // Write Operation
    m.setElement(i++, LnConstants.RE_DPLX_OP_TYPE_WRITE);
    // always 0 for duplex group channel write
    m.setElement(i++, 0);
    // Group Channel Number
    m.setElement(i++, iChannelNumber);
    for (; i < (LnConstants.RE_DPLX_OP_LEN - 1); i++) {
        // always 0 for duplex group channel write
        m.setElement(i, 0);
    }
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 55 with LocoNetMessage

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

the class LnDplxGrpInfoImpl method createSetUr92GroupNamePacket.

/**
     * Create a LocoNet packet to set the Duplex group name.
     * <p>
     * Throws an exception if s provides a 0-length group name string. If s is
     * too short, it is padded with spaces at the end of the string.
     * <p>
     * @param sGroupName is the desired group name value as a string
     * @return The LocoNet packet which writes the Group Name to the UR92
     *         device(s)
     * @throws jmri.jmrix.loconet.LocoNetException if sGroupName is not a valid
     *                                             Duplex Group Name
     */
public static final LocoNetMessage createSetUr92GroupNamePacket(String sGroupName) throws jmri.jmrix.loconet.LocoNetException {
    int gr_msb1 = 0;
    int gr_msb2 = 0;
    int i;
    if (validateGroupName(sGroupName) == false) {
        // NOI18N
        throw new jmri.jmrix.loconet.LocoNetException("Invalid Duplex Group Name - must be exactly 8 characters");
    }
    // format packet
    LocoNetMessage m = new LocoNetMessage(LnConstants.RE_DPLX_OP_LEN);
    // update extended data storage for most-significant bits of each character
    gr_msb1 += (Character.valueOf(sGroupName.charAt(0)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB1_BIT : 0;
    gr_msb1 += (Character.valueOf(sGroupName.charAt(1)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB2_BIT : 0;
    gr_msb1 += (Character.valueOf(sGroupName.charAt(2)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB3_BIT : 0;
    gr_msb1 += (Character.valueOf(sGroupName.charAt(3)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB4_BIT : 0;
    gr_msb2 += (Character.valueOf(sGroupName.charAt(4)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB1_BIT : 0;
    gr_msb2 += (Character.valueOf(sGroupName.charAt(5)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB2_BIT : 0;
    gr_msb2 += (Character.valueOf(sGroupName.charAt(6)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB3_BIT : 0;
    gr_msb2 += (Character.valueOf(sGroupName.charAt(7)) > LnConstants.RE_DPLX_7BITS_MAX) ? LnConstants.RE_DPLX_MSB4_BIT : 0;
    i = 0;
    m.setElement(i++, LnConstants.OPC_PEER_XFER);
    // 20-byte message
    m.setElement(i++, LnConstants.RE_DPLX_OP_LEN);
    // Group Name Operation
    m.setElement(i++, LnConstants.RE_DPLX_GP_NAME_TYPE);
    // Write Operation
    m.setElement(i++, LnConstants.RE_DPLX_OP_TYPE_WRITE);
    // MSB1
    m.setElement(i++, gr_msb1);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(0)) & // 7 LSBs of leftmost character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(1)) & // 7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(2)) & // 7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(3)) & //  7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    // MSB2
    m.setElement(i++, gr_msb2);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(4)) & //  7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(5)) & //  7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(6)) & //  7 LSBs of next character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    m.setElement(i++, Character.valueOf(sGroupName.charAt(7)) & // 7 LSBs of rightmost character
    LnConstants.RE_DPLX_MAX_NOT_OPC);
    for (; i < (LnConstants.RE_DPLX_OP_LEN - 1); i++) {
        // always 0 for duplex group name write
        m.setElement(i, 0);
    }
    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