Search in sources :

Example 46 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.

the class Z21XNetProgrammer method writeCV.

// programming interface
@Override
public synchronized void writeCV(int CV, int val, jmri.ProgListener p) throws jmri.ProgrammerException {
    if (getMode().equals(DefaultProgrammerManager.DIRECTBITMODE) || getMode().equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
        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;
        // start the error timer
        restartTimer(XNetProgrammerTimeout);
        XNetMessage msg = Z21XNetMessage.getZ21WriteDirectCVMsg(CV, val);
        controller().sendXNetMessage(msg, this);
    } else {
        super.writeCV(CV, val, p);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage)

Example 47 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.

the class Z21XNetProgrammer method readCV.

@Override
public synchronized void readCV(int CV, jmri.ProgListener p) throws jmri.ProgrammerException {
    if (getMode().equals(DefaultProgrammerManager.DIRECTBITMODE) || getMode().equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
        if (log.isDebugEnabled()) {
            log.debug("readCV " + CV + " listens " + p);
        }
        useProgrammer(p);
        _cv = 0xffff & CV;
        _progRead = true;
        // set new state
        progState = REQUESTSENT;
        // start the error timer
        restartTimer(XNetProgrammerTimeout);
        // format and send message to go to program mode
        XNetMessage msg = Z21XNetMessage.getZ21ReadDirectCVMsg(CV);
        controller().sendXNetMessage(msg, this);
    } else {
        super.readCV(CV, p);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage)

Example 48 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.

the class LZ100InternalFrame method message.

// listen for responses from the LZ100
@Override
public synchronized void message(XNetReply l) {
    if (l.isOkMessage()) {
        /* this was an "OK" message
             We're only paying attention to it if we're 
             resetting the command station 
             */
        if (status.getText().equals(rb.getString("LZ100StatusSetMode"))) {
            status.setText(rb.getString("LZ100StatusOK"));
        }
        if (resetMode == OFFSENT) {
            XNetMessage msgon = XNetMessage.getFunctionGroup1OpsMsg(0, false, false, false, false, true);
            sendCount--;
            resetMode = ONSENT;
            tc.sendXNetMessage(msgon, this);
        } else if (resetMode == ONSENT) {
            XNetMessage msgoff = XNetMessage.getFunctionGroup1OpsMsg(0, false, false, false, false, false);
            if (sendCount >= 0) {
                resetMode = OFFSENT;
            } else {
                resetMode = IDLE;
                resetCSButton.setEnabled(true);
                status.setText(rb.getString("LZ100ResetFinished"));
            }
            tc.sendXNetMessage(msgoff, this);
        }
    } else if (l.getElement(0) == XNetConstants.CS_REQUEST_RESPONSE && l.getElement(1) == XNetConstants.CS_STATUS_RESPONSE) {
        int statusByte = l.getElement(2);
        if ((statusByte & 0x04) == 0x04) {
            isAutoMode.setSelected(true);
            isManualMode.setSelected(false);
            autoMode = true;
            status.setText(rb.getString("LZ100StatusOK"));
        } else {
            isAutoMode.setSelected(false);
            isManualMode.setSelected(true);
            autoMode = false;
            status.setText(rb.getString("LZ100StatusOK"));
        }
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage)

Example 49 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.

the class LI101Frame method readLI101Settings.

//Send Information request to LI101
void readLI101Settings() {
    /* First, we request setting an out of range address
         to get the current value. */
    XNetMessage msg = XNetMessage.getLIAddressRequestMsg(32);
    //Then send to the controller
    tc.sendXNetMessage(msg, this);
    /* Next, we request setting an out of range speed request
         to get the current value. */
    XNetMessage msg2 = XNetMessage.getLISpeedRequestMsg(6);
    //Then send to the controller
    tc.sendXNetMessage(msg2, this);
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage)

Example 50 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage in project JMRI by JMRI.

the class LI101Frame method writeLI101Settings.

//Send new address/baud rate to LI101
void writeLI101Settings() {
    if (!(((String) addrBox.getSelectedItem()).equals("")) && (String) addrBox.getSelectedItem() != null) {
        /* First, we take care of generating an address request */
        XNetMessage msg = XNetMessage.getLIAddressRequestMsg(addrBox.getSelectedIndex());
        //Then send to the controller
        tc.sendXNetMessage(msg, this);
    }
    if (!(((String) speedBox.getSelectedItem()).equals("")) && (String) speedBox.getSelectedItem() != null) {
        /* Now, we can send a baud rate request */
        XNetMessage msg = XNetMessage.getLISpeedRequestMsg(speedBox.getSelectedIndex() + 1);
        //Then send to the controller
        tc.sendXNetMessage(msg, this);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage)

Aggregations

XNetMessage (jmri.jmrix.lenz.XNetMessage)55 XNetReply (jmri.jmrix.lenz.XNetReply)14 Test (org.junit.Test)14 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 IOException (java.io.IOException)1 XNetListenerScaffold (jmri.jmrix.lenz.XNetListenerScaffold)1 Z21Reply (jmri.jmrix.roco.z21.Z21Reply)1