use of jmri.jmrix.tams.TamsMessage in project JMRI by JMRI.
the class PacketGenPanel method createPacket.
TamsMessage createPacket(String s) {
// gather bytes in result
byte[] b;
try {
b = StringUtil.bytesFromHexString(s);
} catch (NumberFormatException e) {
return null;
}
if (b.length == 0) {
// no such thing as a zero-length message
return null;
}
TamsMessage m = new TamsMessage(b.length);
for (int i = 0; i < b.length; i++) {
m.setElement(i, b[i]);
}
return m;
}
use of jmri.jmrix.tams.TamsMessage in project JMRI by JMRI.
the class StatusPanel method sendButtonActionPerformed.
public void sendButtonActionPerformed(java.awt.event.ActionEvent e) {
reset();
TamsMessage m = new TamsMessage("xV");
tc.sendTamsMessage(m, this);
}
use of jmri.jmrix.tams.TamsMessage 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 TamsMessage loadChars() throws java.io.IOException {
int nchars;
byte[] rcvBuffer = new byte[32];
nchars = inpipe.read(rcvBuffer, 0, 32);
//log.debug("new message received");
TamsMessage msg = new TamsMessage(nchars);
for (int i = 0; i < nchars; i++) {
msg.setElement(i, rcvBuffer[i] & 0xFF);
}
return msg;
}
use of jmri.jmrix.tams.TamsMessage in project JMRI by JMRI.
the class LocoDataPane method addLoco.
void addLoco() {
if (addr.getText() == null || addr.getText().equals("")) {
log.error("Require an address to be entered");
JOptionPane.showMessageDialog(null, rb.getString("ErrorNullAddress"), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
Integer.valueOf(addr.getText());
} catch (NumberFormatException nx) {
log.error("Unable to convert " + addr.getText() + " to a number");
JOptionPane.showMessageDialog(null, rb.getString("ErrorNotNumber"), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
StringBuilder sb = new StringBuilder();
sb.append("xLOCADD ");
sb.append(addr.getText());
sb.append(",");
sb.append(speedBox.getSelectedItem());
sb.append(",");
sb.append(formatBox.getSelectedItem());
sb.append(",'");
sb.append(name.getText());
sb.append("'");
TamsMessage m = new TamsMessage(sb.toString());
locoModel.addLoco(m);
}
Aggregations