use of jmri.DccLocoAddress in project JMRI by JMRI.
the class JsonConsistHttpService method doPut.
@Override
public JsonNode doPut(String type, String name, JsonNode data, Locale locale) throws JsonException {
if (!this.manager.isConsistManager()) {
// NOI18N
throw new JsonException(503, Bundle.getMessage(locale, "ErrorNoConsistManager"));
}
DccLocoAddress address;
if (data.path(ADDRESS).canConvertToInt()) {
address = new DccLocoAddress(data.path(ADDRESS).asInt(), data.path(IS_LONG_ADDRESS).asBoolean(false));
} else {
address = JsonUtilHttpService.addressForString(data.path(ADDRESS).asText());
}
this.manager.getConsist(address);
return this.doPost(type, name, data, locale);
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class DccConsistTest method testCtor.
@Test
public void testCtor() {
// NmraLocoAddress constructor test.
DccConsist c = new DccConsist(new DccLocoAddress(12, true));
Assert.assertNotNull(c);
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class DccLocoAddressSelectorTest method testSetNumByField1.
// try setting the address after creation
public void testSetNumByField1() {
setThrottleManager();
DccLocoAddressSelector sel = new DccLocoAddressSelector();
JTextField f = sel.getTextField();
f.setText("123");
Assert.assertEquals("check initial number ", 123, sel.getAddress().getNumber());
sel.setAddress(new DccLocoAddress(2000, true));
Assert.assertEquals("check updated number ", 2000, sel.getAddress().getNumber());
Assert.assertEquals("check updated type ", true, sel.getAddress().isLongAddress());
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class AbstractThrottleServer method releaseThrottle.
/*
* Release a throttle for the specified address from the default
* Throttle Manager.
*
* @param l LocoAddress of the locomotive to request.
*/
public void releaseThrottle(LocoAddress l) {
ThrottleManager t = InstanceManager.throttleManagerInstance();
t.cancelThrottleRequest(l.getNumber(), this);
if (l instanceof DccLocoAddress) {
throttleList.forEach(throttle -> {
if (throttle.getLocoAddress() == l) {
t.releaseThrottle((DccThrottle) throttle, this);
throttleList.remove(throttle);
try {
sendThrottleReleased(l);
} catch (IOException ioe) {
log.error("Error writing to network port");
}
}
});
}
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class AbstractThrottleServer method requestThrottle.
/*
* Request a throttle for the specified address from the default
* Throttle Manager.
*
* @param l LocoAddress of the locomotive to request.
*/
public void requestThrottle(LocoAddress l) {
ThrottleManager t = InstanceManager.throttleManagerInstance();
boolean result;
if (l instanceof DccLocoAddress) {
result = t.requestThrottle(((DccLocoAddress) l), this);
} else {
result = t.requestThrottle(l.getNumber(), t.canBeLongAddress(l.getNumber()), this);
}
if (!result) {
try {
sendErrorStatus();
} catch (IOException ioe) {
log.error("Error writing to network port");
}
}
}
Aggregations