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);
}
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);
}
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);
}
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;
}
}
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);
}
Aggregations