Search in sources :

Example 21 with NceMessage

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

the class NceConsistEditPanel method sendNceMessage.

private void sendNceMessage(byte[] b, int replyLength) {
    NceMessage m = NceMessage.createBinaryMessage(tc, b, replyLength);
    waiting++;
    // Expect n byte response
    replyLen = replyLength;
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 22 with NceMessage

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

the class NceMacroEditPanel method readSerialMemory16.

// Reads 16 bytes of NCE memory 
private void readSerialMemory16(int nceCabAddr) {
    // Expect 16 byte response
    replyLen = NceMessage.REPLY_16;
    waiting++;
    byte[] bl = NceBinaryCommand.accMemoryRead(nceCabAddr);
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, NceMessage.REPLY_16);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 23 with NceMessage

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

the class UsbInterfacePanel method writeUsbCabId.

// USB set Cab Id in USB 
private void writeUsbCabId(int value) {
    // Expect 1 byte response
    replyLen = REPLY_1;
    waiting++;
    byte[] bl = NceBinaryCommand.usbSetCabId(value);
    NceMessage m = NceMessage.createBinaryMessage(tc, bl, REPLY_1);
    tc.sendNceMessage(m, this);
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 24 with NceMessage

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

the class SimulatorAdapter method loadChars.

/**
     * Get characters from the input source.
     *
     * @returns filled message
     * @throws IOException when presented by the input source.
     */
private NceMessage loadChars() throws java.io.IOException {
    int nchars;
    byte[] rcvBuffer = new byte[32];
    nchars = inpipe.read(rcvBuffer, 0, 32);
    //log.debug("new message received");
    NceMessage msg = new NceMessage(nchars);
    for (int i = 0; i < nchars; i++) {
        msg.setElement(i, rcvBuffer[i] & 0xFF);
    }
    return msg;
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage)

Example 25 with NceMessage

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

the class SimulatorAdapter method run.

@Override
public void run() {
    // report status?
    if (log.isInfoEnabled()) {
        log.info("NCE Simulator Started");
    }
    while (true) {
        try {
            wait(100);
        } catch (Exception e) {
        }
        NceMessage m = readMessage();
        if (log.isDebugEnabled()) {
            StringBuffer buf = new StringBuffer();
            buf.append("Nce Simulator Thread received message: ");
            for (int i = 0; i < m.getNumDataElements(); i++) {
                buf.append(Integer.toHexString(0xFF & m.getElement(i)) + " ");
            }
            log.debug(buf.toString());
        }
        if (m != null) {
            NceReply r = generateReply(m);
            writeReply(r);
            if (log.isDebugEnabled() && r != null) {
                StringBuffer buf = new StringBuffer();
                buf.append("Nce Simulator Thread sent reply: ");
                for (int i = 0; i < r.getNumDataElements(); i++) {
                    buf.append(Integer.toHexString(0xFF & r.getElement(i)) + " ");
                }
                log.debug(buf.toString());
            }
        }
    }
}
Also used : NceMessage(jmri.jmrix.nce.NceMessage) NceReply(jmri.jmrix.nce.NceReply) IOException(java.io.IOException)

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