Search in sources :

Example 31 with NceMessage

use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.

the class NceMacroEditPanel method writeUsbMemory1.

/**
     * USB Write 1 byte of NCE memory
     *
     * @param value - byte being written
     */
private void writeUsbMemory1(int value) {
    // Expect 1 byte response
    replyLen = NceMessage.REPLY_1;
    waiting++;
    byte[] bl = NceBinaryCommand.usbMemoryWrite1((byte) value);
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, NceMessage.REPLY_1);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 32 with NceMessage

use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.

the class NceMacroEditPanel method setUsbCabMemoryPointer.

// USB set cab memory pointer
private void setUsbCabMemoryPointer(int cab, int offset) {
    // Expect 1 byte response
    replyLen = NceMessage.REPLY_1;
    waiting++;
    byte[] bl = NceBinaryCommand.usbMemoryPointer(cab, offset);
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, NceMessage.REPLY_1);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 33 with NceMessage

use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.

the class NceMacroEditPanel method writeSerialMemory4.

// Write 4 bytes of NCE memory 
private void writeSerialMemory4(int nceMacroAddr, byte[] x) {
    // Expect 1 byte response
    replyLen = NceMessage.REPLY_1;
    waiting++;
    byte[] bl = NceBinaryCommand.accMemoryWrite4(nceMacroAddr);
    for (int i = 0; i < 4; i++) {
        bl[3 + i] = x[i];
    }
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, NceMessage.REPLY_1);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 34 with NceMessage

use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.

the class NceMacroGenPanel method createMacroCmd.

NceMessage createMacroCmd(String s) {
    int macroNum = 0;
    try {
        macroNum = Integer.parseInt(s);
    } catch (NumberFormatException e) {
        return null;
    }
    if (macroNum < 0 || macroNum > 255) {
        return null;
    }
    if (tc.getCommandOptions() >= NceTrafficController.OPTION_2006) {
        // NCE always responds with okay (!) if macro number is in range.
        // We need to send this version of macro command to cause turnout
        // state to change in NCE CS
        NceMessage m = new NceMessage(5);
        // Macro cmd
        m.setElement(0, NceBinaryCommand.ACC_CMD);
        // addr_h
        m.setElement(1, 0x00);
        // addr_l
        m.setElement(2, 0x01);
        // Macro cmd
        m.setElement(3, 0x01);
        // Macro #
        m.setElement(4, macroNum);
        m.setBinary(true);
        m.setReplyLen(REPLY_LEN);
        return m;
    } else {
        // NCE responds with okay (!) if macro exist, (0) if not
        NceMessage m = new NceMessage(2);
        // Macro cmd
        m.setElement(0, NceBinaryCommand.MACRO_CMD);
        // Macro #
        m.setElement(1, macroNum);
        m.setBinary(true);
        m.setReplyLen(REPLY_LEN);
        return m;
    }
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 35 with NceMessage

use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.

the class NceShowCabPanel method readUsbCabMemoryN.

// USB Read N bytes of NCE cab memory 
private void readUsbCabMemoryN(int num) {
    switch(num) {
        case 1:
            // Expect 1 byte response
            replyLen = NceMessage.REPLY_1;
            break;
        case 2:
            // Expect 2 byte response
            replyLen = NceMessage.REPLY_2;
            break;
        case 4:
            // Expect 4 byte response
            replyLen = NceMessage.REPLY_4;
            break;
        default:
            log.error("Invalid usb read byte count");
            return;
    }
    waiting++;
    byte[] bl = NceBinaryCommand.usbMemoryRead((byte) num);
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, replyLen);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Aggregations

NceMessage (jmri.jmrix.nce.NceMessage)46 IOException (java.io.IOException)3 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 JFileChooser (javax.swing.JFileChooser)2 JPanel (javax.swing.JPanel)2 NceReply (jmri.jmrix.nce.NceReply)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1