use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class LocoIdPanel method createSetPacket.
/**
* Create a LocoNet packet to set the LocoNet ID.
*
* @param s The desired value as a string in decimal
* @return The packet, with contents filled-in
*/
LocoNetMessage createSetPacket(String s) {
// convert to int value
int data = Integer.parseInt(s);
// format packet
LocoNetMessage m = new LocoNetMessage(6);
m.setElement(0, 0xDF);
m.setElement(1, 0x40);
m.setElement(2, 0x1F);
m.setElement(3, data);
m.setElement(4, 0x00);
return m;
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class LnMessageClientPollThread method run.
@Override
public void run() {
try {
Object[] lnMessages = null;
while (!Thread.interrupted()) {
lnMessages = parent.lnMessageBuffer.getMessages(parent.pollTimeout);
if (lnMessages != null) {
log.debug("Recieved Message Array Size: " + lnMessages.length);
for (int lnMessageIndex = 0; lnMessageIndex < lnMessages.length; lnMessageIndex++) {
LocoNetMessage message = (LocoNetMessage) lnMessages[lnMessageIndex];
parent.message(message);
}
}
}
} catch (Exception ex) {
log.warn("Exception: " + ex);
}
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class CmdStnConfigPane method writeButtonActionPerformed.
public void writeButtonActionPerformed(java.awt.event.ActionEvent e) {
LocoNetMessage msg = new LocoNetMessage(14);
msg.setElement(0, LnConstants.OPC_WR_SL_DATA);
msg.setElement(1, 0x0E);
msg.setElement(2, CONFIG_SLOT);
// load last seen contents into message
for (int i = 0; i < 10; i++) {
msg.setElement(3 + i, oldcontent[i]);
}
// load contents to message
for (int i = 0; i <= (MAX_OPTION - MIN_OPTION); i++) {
// i indexes over closed buttons
// byteIndex = 0 is the first payload byte
int byteIndex = i / 8;
if (byteIndex > 3) {
// Skip the 4th payload byte for some reason
byteIndex++;
}
// Add base offset into slot message to first data byte
byteIndex += 3;
int bitIndex = i % 8;
int bitMask = 0x01 << bitIndex;
if (closedButtons[i].isSelected()) {
msg.setElement(byteIndex, msg.getElement(byteIndex) | bitMask);
} else {
msg.setElement(byteIndex, msg.getElement(byteIndex) & ~bitMask);
}
}
// send message
memo.getLnTrafficController().sendLocoNetMessage(msg);
return;
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class CmdStnConfigPane method start.
/**
*
* Start the Frame operating by asking for a read
*/
public void start() {
// format and send request for slot contents
LocoNetMessage l = new LocoNetMessage(4);
l.setElement(0, LnConstants.OPC_RQ_SL_DATA);
l.setElement(1, CONFIG_SLOT);
l.setElement(2, 0);
l.setElement(3, 0);
memo.getLnTrafficController().sendLocoNetMessage(l);
}
use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.
the class DuplexGroupScanPanel method createDuplexScanQueryPacket.
/**
* Creates a LocoNet message containing a channel-specific query for signal
* information from UR92 device(s).
* <p>
* @param channelNum - integer between 11 and 26, inclusive
* @return LocoNetMessage - query for Dulpex Channel Scan information
*/
private LocoNetMessage createDuplexScanQueryPacket(int channelNum) {
int i = 0;
LocoNetMessage m = new LocoNetMessage(LnConstants.RE_DPLX_OP_LEN);
m.setElement(i++, LnConstants.OPC_PEER_XFER);
// 20-byte message
m.setElement(i++, LnConstants.RE_DPLX_OP_LEN);
// Duplex Group Scan Query type
m.setElement(i++, LnConstants.RE_DPLX_SCAN_QUERY_B2);
// Query Operation
m.setElement(i++, LnConstants.RE_DPLX_SCAN_QUERY_B3);
m.setElement(i++, LnConstants.RE_DPLX_SCAN_QUERY_B4);
// Duplex Channel Number
m.setElement(i++, channelNum);
for (; i < (LnConstants.RE_DPLX_OP_LEN - 1); i++) {
// always 0 for duplex group ID write
m.setElement(i, 0);
}
// LocoNet send process will compute and add checksum byte in correct location
return m;
}
Aggregations