use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.
the class Z21XNetThrottle method sendFunctionGroup5.
/**
* Send the XpressNet message to set the state of functions F21, F22, F23,
* F24, F25, F26, F27, F28
*/
@Override
protected void sendFunctionGroup5() {
// because of the way the z21 wants to see the functions, we
// send all the functions when there is a change in the group.
XNetMessage msg = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 21, f21);
// now, queue the message for sending to the command station
queueMessage(msg, THROTTLEFUNCSENT);
XNetMessage msg1 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 22, f22);
// now, queue the message for sending to the command station
queueMessage(msg1, THROTTLEFUNCSENT);
XNetMessage msg2 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 23, f23);
// now, queue the message for sending to the command station
queueMessage(msg2, THROTTLEFUNCSENT);
XNetMessage msg3 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 24, f24);
// now, queue the message for sending to the command station
queueMessage(msg3, THROTTLEFUNCSENT);
XNetMessage msg4 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 25, f25);
// now, queue the message for sending to the command station
queueMessage(msg4, THROTTLEFUNCSENT);
XNetMessage msg5 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 26, f26);
// now, queue the message for sending to the command station
queueMessage(msg5, THROTTLEFUNCSENT);
XNetMessage msg6 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 27, f27);
// now, queue the message for sending to the command station
queueMessage(msg6, THROTTLEFUNCSENT);
XNetMessage msg7 = Z21XNetMessage.getZ21LocomotiveFunctionOperationMsg(this.getDccAddress(), 28, f28);
// now, queue the message for sending to the command station
queueMessage(msg7, THROTTLEFUNCSENT);
}
use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.
the class XNetSimulatorAdapter method readMessage.
// readMessage reads one incoming message from the buffer
// and sets outputBufferEmpty to true.
private XNetMessage readMessage() {
XNetMessage msg = null;
try {
msg = loadChars();
} catch (java.io.IOException e) {
// should do something meaningful here.
ConnectionStatus.instance().setConnectionState(this.getSystemConnectionMemo().getUserName(), this.getCurrentPortName(), ConnectionStatus.CONNECTION_DOWN);
}
setOutputBufferEmpty(true);
return (msg);
}
use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.
the class Z21SimulatorAdapter method generateReply.
// end of run.
// generateReply is the heart of the simulation. It translates an
// incoming XNetMessage into an outgoing XNetReply.
// document values for specific cases
@SuppressWarnings("fallthrough")
private Z21Reply generateReply(Z21Message m) throws Exception {
log.debug("generate Reply called with message {}", m);
Z21Reply reply;
switch(m.getOpCode()) {
case 0x0010:
// request for serial number
reply = getZ21SerialNumberReply();
break;
case 0x001a:
// request for hardware version info.
reply = getHardwareVersionReply();
break;
case 0x0040:
// XPressNet tunnel message.
XNetMessage xnm = getXNetMessage(m);
log.debug("Received XNet Message: {}", m);
XNetReply xnr = xnetadapter.generateReply(xnm);
reply = getZ21ReplyFromXNet(xnr);
break;
case 0x0030:
// to indicate this.
throw (new Exception());
case 0x0050:
// set broadcast flags
flags[0] = m.getElement(4) & 0xff;
flags[1] = m.getElement(5) & 0xff;
flags[2] = m.getElement(6) & 0xff;
flags[3] = m.getElement(7) & 0xff;
// per the protocol, no reply is generated.
reply = null;
break;
case 0x0051:
// get broadcast flags
reply = getZ21BroadCastFlagsReply();
break;
case 0x0089:
// Get Railcom Data
reply = getZ21RailComDataChangedReply();
break;
case 0x0060:
// get loco mode
case 0x0061:
// set loco mode
case 0x0070:
// get turnout mode
case 0x0071:
// set turnout mode
case 0x0081:
// get RMBus data
case 0x0082:
// program RMBus module
case 0x0085:
// get system state
case 0x00A2:
// loconet data from lan
case 0x00A3:
// loconet dispatch address
case 0x00A4:
// get loconet detector status
default:
reply = getXPressNetUnknownCommandReply();
}
return reply;
}
use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.
the class LI100XNetProgrammer method writeCV.
// programming interface
@Override
public synchronized void writeCV(int CV, int val, jmri.ProgListener p) throws jmri.ProgrammerException {
if (log.isDebugEnabled()) {
log.debug("writeCV " + CV + " listens " + p);
}
useProgrammer(p);
_progRead = false;
// set new state & save values
progState = REQUESTSENT;
_val = val;
_cv = 0xffff & CV;
try {
// start the error timer
restartTimer(XNetProgrammerTimeout);
// format and send message to go to program mode
if (getMode().equals(DefaultProgrammerManager.PAGEMODE)) {
XNetMessage msg = XNetMessage.getWritePagedCVMsg(CV, val);
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
} else if (getMode().equals(DefaultProgrammerManager.DIRECTBITMODE) || getMode().equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
XNetMessage msg = XNetMessage.getWriteDirectCVMsg(CV, val);
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
} else {
// register mode by elimination
XNetMessage msg = XNetMessage.getWriteRegisterMsg(registerFromCV(CV), val);
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
}
} catch (jmri.ProgrammerException e) {
progState = NOTPROGRAMMING;
throw e;
}
}
use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.
the class LI100XNetProgrammer method readCV.
@Override
public synchronized void readCV(int CV, jmri.ProgListener p) throws jmri.ProgrammerException {
if (log.isDebugEnabled()) {
log.debug("readCV " + CV + " listens " + p);
}
if (!getCanRead()) {
// should not invoke this if cant read, but if done anyway set NotImplemented error
p.programmingOpReply(CV, jmri.ProgListener.NotImplemented);
return;
}
useProgrammer(p);
_progRead = true;
// set new state
progState = REQUESTSENT;
_cv = 0xffff & CV;
try {
// start the error timer
restartTimer(XNetProgrammerTimeout);
// format and send message to go to program mode
if (getMode() == DefaultProgrammerManager.PAGEMODE) {
XNetMessage msg = XNetMessage.getReadPagedCVMsg(CV);
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
} else if (getMode().equals(DefaultProgrammerManager.DIRECTBITMODE) || getMode().equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
XNetMessage msg = XNetMessage.getReadDirectCVMsg(CV);
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
} else {
// register mode by elimination
XNetMessage msg = XNetMessage.getReadRegisterMsg(registerFromCV(CV));
msg.setNeededMode(jmri.jmrix.AbstractMRTrafficController.NORMALMODE);
lastRequestMessage = new XNetMessage(msg);
controller().sendXNetMessage(msg, this);
}
} catch (jmri.ProgrammerException e) {
progState = NOTPROGRAMMING;
throw e;
}
}
Aggregations