Search in sources :

Example 6 with LocoNetMessage

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

the class LnIPLImplementation method createIplSpecificSlaveQueryPacket.

/**
     * Creates a LocoNet packet which queries IPL devices by specific host
     * manufacturer, specific host device type, specific slave manufacturer and
     * specific slave device type. The invoking method is responsible for
     * sending the message to LocoNet.
     * <p>
     * Note: Different devices respond differently depending on whether host
     * and/or slave manufacturer and/or device type information are provided.
     * <p>
     * @param hostMfr     defines the host manufacturer number
     * @param hostDevice  defines the host device type number
     * @param slaveMfr    defines the slave manufacturer number
     * @param slaveDevice defines the slave device type number
     * @return a LocoNetMessage containing the packet required to request IPL
     *         identity information from devices of the specified host and slave
     *         manufacturers and host and slave device types.
     */
public static final LocoNetMessage createIplSpecificSlaveQueryPacket(Integer hostMfr, Integer hostDevice, Integer slaveMfr, Integer slaveDevice) {
    LocoNetMessage m = createQueryAllIplDevicesPacket();
    m.setElement(4, hostMfr);
    m.setElement(5, hostDevice);
    m.setElement(7, slaveMfr);
    m.setElement(6, slaveDevice);
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 7 with LocoNetMessage

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

the class LnIPLImplementation method createQueryAllIplDevicesPacket.

/**
     * Creates a LocoNet packet which queries UR92(s) for Duplex group
     * identification information. The invoking method is responsible for
     * sending the message to LocoNet.
     *
     * @return a LocoNetMessage containing the packet required to query UR92
     *         device Duplex Group Identity information
     */
public static final LocoNetMessage createQueryAllIplDevicesPacket() {
    LocoNetMessage m = new LocoNetMessage(LnConstants.RE_IPL_OP_LEN);
    // fill in data for an IPL Query of UR92s message
    m.setElement(0, LnConstants.OPC_PEER_XFER);
    m.setElement(1, LnConstants.RE_IPL_OP_LEN);
    m.setElement(2, LnConstants.RE_IPL_IDENTITY_OPERATION);
    m.setElement(3, LnConstants.RE_IPL_OP_QUERY);
    m.setElement(4, LnConstants.RE_IPL_MFR_ALL);
    m.setElement(5, LnConstants.RE_IPL_DIGITRAX_HOST_ALL);
    m.setElement(6, LnConstants.RE_IPL_DIGITRAX_SLAVE_ALL);
    m.setElement(7, LnConstants.RE_IPL_MFR_ALL);
    m.setElement(8, LnConstants.RE_IPL_OP_HFW_QUERY);
    m.setElement(9, LnConstants.RE_IPL_OP_HSNM_QUERY);
    m.setElement(10, LnConstants.RE_IPL_OP_SFW_QUERY);
    m.setElement(11, LnConstants.RE_IPL_OP_HSN0_QUERY);
    m.setElement(12, LnConstants.RE_IPL_OP_HSN1_QUERY);
    m.setElement(13, LnConstants.RE_IPL_OP_HSN2_QUERY);
    m.setElement(14, LnConstants.RE_IPL_OP_SSNM_QUERY);
    m.setElement(15, LnConstants.RE_IPL__OP_SSN0_QUERY);
    m.setElement(16, LnConstants.RE_IPL_OP_SSN1_QUERY);
    m.setElement(17, LnConstants.RE_IPL_OP_SSN2_QUERY);
    m.setElement(18, LnConstants.RE_IPL_OP_SSN3_QUERY);
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 8 with LocoNetMessage

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

the class LnDplxGrpInfoImpl method createUr92GroupPasswordReportPacket.

// the following code may be used to create a LocoNet message that follows the
// form of the message sent by a UR92 in response to a Duplex Group Password query
// LocoNet message.
// No attempt is made to check the validity of the dupPass argument.
public static final LocoNetMessage createUr92GroupPasswordReportPacket(String dupPass) {
    // format packet
    LocoNetMessage m = new LocoNetMessage(LnConstants.RE_DPLX_OP_LEN);
    int i = 0;
    m.setElement(i++, LnConstants.OPC_PEER_XFER);
    // 20-byte message
    m.setElement(i++, LnConstants.RE_DPLX_OP_LEN);
    // Group Password Operation
    m.setElement(i++, LnConstants.RE_DPLX_GP_PW_TYPE);
    // Report Operation
    m.setElement(i++, LnConstants.RE_DPLX_OP_TYPE_REPORT);
    // NOI18N
    dupPass += "0000";
    m.setElement(i++, ((dupPass.charAt(0) & 0x80) == 0x80 ? 8 : 0) + ((dupPass.charAt(1) & 0x80) == 0x80 ? 3 : 0) + ((dupPass.charAt(2) & 0x80) == 0x80 ? 2 : 0) + ((dupPass.charAt(3) & 0x80) == 0x80 ? 1 : 0));
    m.setElement(i++, dupPass.charAt(0) & 0x7f);
    m.setElement(i++, dupPass.charAt(1) & 0x7f);
    m.setElement(i++, dupPass.charAt(2) & 0x7f);
    m.setElement(i++, dupPass.charAt(3) & 0x7f);
    for (; i < LnConstants.RE_DPLX_OP_LEN; i++) {
        m.setElement(i, 0);
    }
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 9 with LocoNetMessage

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

the class LnSv2MessageContents method createSv2Message.

/**
     * Create a LocoNet message containing an SV Programming Format 2 message
     * @param source - source device address (7 bit, for &lt;SRC&gt;)
     * @param command - SV Programming Format 2 command number (for &lt;SV_CMD&gt;)
     * @param destination = SV format 2 destination address (for &lt;DST_L&gt; and &lt;DST_H&gt;)
     * @param svNum - SV Programming Format 2 16-bit SV number (for &lt;SVN_L&gt; and &lt;SVN_H&gt;)
     * @param d1 - SV Programming Format 2 first data value (for &lt;D1&gt;)
     * @param d2 - SV Programming Format 2 second data value (for &lt;D2&gt;)
     * @param d3 - SV Programming Format 2 third data value (for &lt;D3&gt;)
     * @param d4 - SV Programming Format 2 fourth data value (for &lt;D4&gt;)
     * @return - LocoNet message for the requested message
     * @throws IllegalArgumentException of command is not a valid SV Programming Format 2 &lt;SV_CMD&gt; value
     */
public static LocoNetMessage createSv2Message(int source, int command, int destination, int svNum, int d1, int d2, int d3, int d4) throws java.lang.IllegalArgumentException {
    if (!isSupportedSv2Command(command)) {
        // NOI18N
        throw new java.lang.IllegalArgumentException("Command is not a supported SV2 command");
    }
    LocoNetMessage m = new LocoNetMessage(SV2_LENGTH_ELEMENT_VALUE);
    m.setOpCode(LnConstants.OPC_PEER_XFER);
    m.setElement(SV2_LENGTH_ELEMENT_INDEX, SV2_LENGTH_ELEMENT_VALUE);
    m.setElement(SV2_SRC_ELEMENT_INDEX, (source & SV2_SRC_ELEMENT_MASK));
    m.setElement(SV2_SV_CMD_ELEMENT_INDEX, command);
    m.setElement(SV2_SV_TYPE_ELEMENT_INDEX, SV2_SV_TYPE_ELEMENT_VALIDITY_CHECK_VALUE);
    int svx1 = SV2_SVX1_ELEMENT_VALIDITY_CHECK_VALUE;
    svx1 = svx1 + (((destination & 0x80) == 0x80) ? SV2_SV_DST_L_DSTLX7_CHECK_MASK : 0);
    svx1 = svx1 + (((destination & 0x8000) == 0x8000) ? SV2_SV_DST_H_DSTHX7_CHECK_MASK : 0);
    svx1 = svx1 + (((svNum & 0x80) == 0x80) ? SV2_SV_ADRL_SVADRL7_CHECK_MASK : 0);
    svx1 = svx1 + (((svNum & 0x8000) == 0x8000) ? SV2_SV_ADRH_SVADRH7_CHECK_MASK : 0);
    m.setElement(SV2_SVX1_ELEMENT_INDEX, svx1);
    m.setElement(SV2_SV_DST_L_ELEMENT_INDEX, (destination & 0x7f));
    m.setElement(SV2_SV_DST_H_ELEMENT_INDEX, ((destination >> 8) & 0x7f));
    m.setElement(SV2_SV_ADRL_ELEMENT_INDEX, (svNum & 0x7f));
    m.setElement(SV2_SV_ADRH_ELEMENT_INDEX, ((svNum >> 8) & 0x7f));
    int svx2 = SV2_SVX2_ELEMENT_VALIDITY_CHECK_VALUE;
    svx2 = svx2 + (((d1 & 0x80) == 0x80) ? SV2_SV_D1_D1X7_CHECK_MASK : 0);
    svx2 = svx2 + (((d2 & 0x80) == 0x80) ? SV2_SV_D2_D2X7_CHECK_MASK : 0);
    svx2 = svx2 + (((d3 & 0x80) == 0x80) ? SV2_SV_D3_D3X7_CHECK_MASK : 0);
    svx2 = svx2 + (((d4 & 0x80) == 0x80) ? SV2_SV_D4_D4X7_CHECK_MASK : 0);
    m.setElement(SV2_SVX2_ELEMENT_INDEX, svx2);
    m.setElement(SV2_SVD1_ELEMENT_INDEX, (d1 & 0x7f));
    m.setElement(SV2_SVD2_ELEMENT_INDEX, (d2 & 0x7f));
    m.setElement(SV2_SVD3_ELEMENT_INDEX, (d3 & 0x7f));
    m.setElement(SV2_SVD4_ELEMENT_INDEX, (d4 & 0x7f));
    return m;
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 10 with LocoNetMessage

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

the class LocoIdPanel method createReadPacket.

/**
     * Create a LocoNet packet to Query panels for the LocoNet ID
     *
     * @return The packet, with contents filled-in
     */
LocoNetMessage createReadPacket() {
    LocoNetMessage m = new LocoNetMessage(6);
    m.setElement(0, 0xDF);
    m.setElement(1, 0x00);
    m.setElement(2, 0x00);
    m.setElement(3, 0x00);
    m.setElement(4, 0x00);
    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