Search in sources :

Example 81 with DccLocoAddress

use of jmri.DccLocoAddress in project JMRI by JMRI.

the class LnThrottleManager method notifyChangedSlot.

/**
     * Get notification that an address has changed slot. This method creates a
     * throttle for all ThrottleListeners of that address and notifies them via
     * the ThrottleListener.notifyThrottleFound method.
     */
@Override
public void notifyChangedSlot(LocoNetSlot s) {
    DccThrottle throttle = createThrottle((LocoNetSystemConnectionMemo) adapterMemo, s);
    notifyThrottleKnown(throttle, new DccLocoAddress(s.locoAddr(), isLongAddress(s.locoAddr())));
    //end the waiting thread since we got a response
    if (waitingForNotification.containsKey(s.locoAddr())) {
        waitingForNotification.get(s.locoAddr()).interrupt();
        waitingForNotification.remove(s.locoAddr());
    }
}
Also used : DccThrottle(jmri.DccThrottle) DccLocoAddress(jmri.DccLocoAddress)

Example 82 with DccLocoAddress

use of jmri.DccLocoAddress in project JMRI by JMRI.

the class LocoNetConsist method delayedAdd.

private synchronized void delayedAdd() {
    DccLocoAddress LocoAddress = needToWrite.get(0);
    if (ConsistType == ADVANCED_CONSIST) {
        addToAdvancedConsist(LocoAddress, getLocoDirection(LocoAddress));
    } else if (ConsistType == CS_CONSIST) {
        addToCSConsist(LocoAddress, getLocoDirection(LocoAddress));
    }
    needToWrite.remove(LocoAddress);
}
Also used : DccLocoAddress(jmri.DccLocoAddress)

Example 83 with DccLocoAddress

use of jmri.DccLocoAddress in project JMRI by JMRI.

the class LocoNetConsist method notifyChangedSlot.

// slot listener interface functions
@Override
public void notifyChangedSlot(LocoNetSlot s) {
    log.debug(// NOI18N
    "Notified slot " + s.getSlot() + " changed with mode " + // NOI18N
    consistRequestState + // NOI18N
    " slot consist state: " + LnConstants.CONSIST_STAT(s.consistStatus()));
    switch(consistRequestState) {
        case LEADREQUESTSTATE:
            leadSlot = s;
            consistRequestState = IDLESTATE;
            break;
        case LINKSTAGEONESTATE:
            s.addSlotListener(this);
            setSlotModeAdvanced(s);
            consistRequestState = LINKSTAGETWOSTATE;
            break;
        case LINKSTAGETWOSTATE:
            linkSlots(leadSlot, s);
            break;
        case UNLINKSTAGEONESTATE:
            unlinkSlots(leadSlot, s);
            break;
        default:
            s.removeSlotListener(this);
            notifyConsistListeners(new DccLocoAddress(s.locoAddr(), throttleManager.canBeLongAddress(s.locoAddr())), ConsistListener.OPERATION_SUCCESS);
            if (needToWrite.size() != 0) {
                delayedAdd();
            } else {
                consistRequestState = IDLESTATE;
            }
    }
}
Also used : DccLocoAddress(jmri.DccLocoAddress)

Example 84 with DccLocoAddress

use of jmri.DccLocoAddress in project JMRI by JMRI.

the class MrcThrottleManager method requestThrottleSetup.

@Override
public void requestThrottleSetup(LocoAddress a, boolean control) {
    //We do interact
    DccLocoAddress address = (DccLocoAddress) a;
    //IN18N
    log.debug("new MrcThrottle for " + address);
    notifyThrottleKnown(new MrcThrottle((MrcSystemConnectionMemo) adapterMemo, address), address);
}
Also used : DccLocoAddress(jmri.DccLocoAddress)

Example 85 with DccLocoAddress

use of jmri.DccLocoAddress in project JMRI by JMRI.

the class NceConsistEditPanel method rosterBoxSelect.

// load a loco from roster
private void rosterBoxSelect(JComboBox<Object> locoRosterBox, JTextField locoTextField, JButton adrButton) {
    RosterEntry entry = null;
    Object o = locoRosterBox.getSelectedItem();
    if (o.getClass().equals(RosterEntry.class)) {
        entry = (RosterEntry) o;
    }
    if (entry != null) {
        DccLocoAddress a = entry.getDccLocoAddress();
        locoTextField.setText("" + a.getNumber());
        if (a.isLongAddress()) {
            adrButton.setText(rb.getString("KeyLONG"));
        } else {
            adrButton.setText(rb.getString("KeySHORT"));
        }
        // if lead loco get road number and name
        if (locoRosterBox == locoRosterBox1) {
            textConRoadName.setText(entry.getRoadName());
            textConRoadNumber.setText(entry.getRoadNumber());
            textConModel.setText(entry.getModel());
        }
    }
}
Also used : RosterEntry(jmri.jmrit.roster.RosterEntry) DccLocoAddress(jmri.DccLocoAddress)

Aggregations

DccLocoAddress (jmri.DccLocoAddress)96 Consist (jmri.Consist)12 ThrottleManager (jmri.ThrottleManager)7 IOException (java.io.IOException)6 Element (org.jdom2.Element)6 Test (org.junit.Test)6 Matcher (java.util.regex.Matcher)5 DccThrottle (jmri.DccThrottle)5 SystemConnectionMemo (jmri.jmrix.SystemConnectionMemo)5 JsonException (jmri.server.json.JsonException)5 Pattern (java.util.regex.Pattern)4 IdTag (jmri.IdTag)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 JTextField (javax.swing.JTextField)2 CommandStation (jmri.CommandStation)2 ProgrammerException (jmri.ProgrammerException)2