Search in sources :

Example 11 with RailCom

use of jmri.RailCom in project JMRI by JMRI.

the class Dcc4PcReporter method decodeAddress.

RailCom decodeAddress() {
    RailCom rcTag;
    if ((address_part_1 & 0x80) == 0x80) {
        addr_type = Dcc4PcSensorManager.LONG_ADDRESS;
        addr = (address_part_1 & 0x3f) << 8;
        addr |= address_part_2;
    } else if ((address_part_1 & 0x20) == 0x20) {
        addr_type = Dcc4PcSensorManager.CONSIST_ADDRESS;
        addr = address_part_2;
    } else {
        addr_type = Dcc4PcSensorManager.SHORT_ADDRESS;
        addr = address_part_2 & 0x7F;
    }
    if (log.isDebugEnabled()) {
        log.debug(this.getDisplayName() + " Address part 2 " + addr_type + " " + addr);
        log.debug(this.getDisplayName() + " Create/Get id tag for " + addr);
    }
    rcTag = jmri.InstanceManager.getDefault(jmri.RailComManager.class).provideIdTag("" + addr);
    rcTag.setWhereLastSeen(this);
    rcTag.setAddressType(addr_type);
    if ((fuelLevel != -1)) {
        rcTag.setFuelLevel(fuelLevel);
    }
    if ((waterLevel != -1)) {
        rcTag.setWaterLevel(waterLevel);
    }
    if ((routing_no != -1)) {
        rcTag.setRoutingNo(routing_no);
    }
    if ((location != -1)) {
        rcTag.setLocation(location);
    }
    if ((actual_temperature != -1)) {
        rcTag.setActualTemperature(actual_temperature);
    }
    if ((actual_load != -1)) {
        rcTag.setActualLoad(actual_load);
    }
    if ((actual_speed != -1)) {
        rcTag.setActualSpeed(actual_speed);
    }
    for (Integer cv : cvValues.keySet()) {
        rcTag.setCv(cv, cvValues.get(cv));
        if (cvvalue != -1) {
            rcTag.setCvValue(cvvalue);
        }
    }
    address_part_1 = 0;
    address_part_2 = -1;
    setReport(rcTag);
    return rcTag;
}
Also used : RailCom(jmri.RailCom)

Example 12 with RailCom

use of jmri.RailCom in project JMRI by JMRI.

the class DefaultRailComManager method getIdTag.

@Override
public RailCom getIdTag(String name) {
    RailCom t = getBySystemName(makeSystemName(name));
    if (t != null) {
        return t;
    }
    t = getByUserName(name);
    if (t != null) {
        return t;
    }
    return getBySystemName(name);
}
Also used : DefaultRailCom(jmri.implementation.DefaultRailCom) RailCom(jmri.RailCom)

Aggregations

RailCom (jmri.RailCom)12 Test (org.junit.Test)6 DefaultRailCom (jmri.implementation.DefaultRailCom)2 Date (java.util.Date)1 DccLocoAddress (jmri.DccLocoAddress)1 RailComManager (jmri.RailComManager)1 Reporter (jmri.Reporter)1