use of jmri.DccLocoAddress in project JMRI by JMRI.
the class NceConsist method getLocoAddressByPosition.
public DccLocoAddress getLocoAddressByPosition(int position) {
DccLocoAddress locoAddress;
ArrayList<DccLocoAddress> list = getConsistList();
for (int i = 0; i < list.size(); i++) {
locoAddress = list.get(i);
if (getPosition(locoAddress) == position) {
return locoAddress;
}
}
return null;
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class NceConsist method dispose.
// Clean Up local storage
@Override
public void dispose() {
if (ConsistList.size() > 0) {
// kill this consist
DccLocoAddress locoAddress = ConsistList.get(0);
killConsist(locoAddress.getNumber(), locoAddress.isLongAddress());
}
stopReadNCEconsistThread();
super.dispose();
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class NceConsist method setConsistType.
// Set the Consist Type
@Override
public void setConsistType(int consist_type) {
if (consist_type == Consist.ADVANCED_CONSIST) {
ConsistType = consist_type;
} else {
log.error("Consist Type Not Supported");
notifyConsistListeners(new DccLocoAddress(0, false), ConsistListener.NotImplemented);
}
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class DccLocoAddressXml method store.
/**
* Default implementation for storing the contents of a DccLocoAddress
*
* @param o Object to store, of type DccLocoAddress
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
DccLocoAddress p = (DccLocoAddress) o;
Element element = new Element("dcclocoaddress");
// include contents
if (p != null) {
element.setAttribute("number", "" + p.getNumber());
if (p.isLongAddress()) {
element.setAttribute("longaddress", "yes");
} else {
element.setAttribute("longaddress", "no");
}
} else {
element.setAttribute("number", "");
element.setAttribute("longaddress", "no");
}
return element;
}
use of jmri.DccLocoAddress in project JMRI by JMRI.
the class JsonConsistServer method parseRequest.
public void parseRequest(Locale locale, JsonNode data) throws IOException, JsonException {
DccLocoAddress address;
if (data.path(ADDRESS).canConvertToInt()) {
address = new DccLocoAddress(data.path(ADDRESS).asInt(), data.path(IS_LONG_ADDRESS).asBoolean(false));
} else {
address = JsonUtil.addressForString(data.path(ADDRESS).asText());
}
if (data.path(METHOD).asText().equals(PUT)) {
JsonUtil.putConsist(locale, address, data);
} else if (data.path(METHOD).asText().equals(DELETE)) {
JsonUtil.delConsist(locale, address);
} else {
JsonUtil.setConsist(locale, address, data);
}
this.connection.sendMessage(this.mapper.writeValueAsString(JsonUtil.getConsist(locale, address)));
InstanceManager.getDefault(jmri.ConsistManager.class).getConsist(address).addConsistListener(new JsonConsistListener(address));
}
Aggregations