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());
}
}
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);
}
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;
}
}
}
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);
}
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());
}
}
}
Aggregations