Search in sources :

Example 1 with VSMode

use of org.openhab.binding.modbus.studer.internal.StuderParser.VSMode in project openhab-addons by openhab.

the class StuderHandler method handlePolledDataVarioString.

/**
 * This method is called each time new data has been polled from the VarioString slave
 * The register array is first parsed, then each of the channels are updated
 * to the new values
 */
protected void handlePolledDataVarioString(int registerNumber, DecimalType quantity) {
    switch(CHANNELS_VARIOSTRING.get(registerNumber)) {
        case CHANNEL_PV_OPERATING_MODE:
        case CHANNEL_PV1_OPERATING_MODE:
        case CHANNEL_PV2_OPERATING_MODE:
            VSMode vsmode = StuderParser.getVSModeByCode(quantity.intValue());
            if (vsmode == VSMode.UNKNOWN) {
                internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), UnDefType.UNDEF);
            } else {
                internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new StringType(vsmode.name()));
            }
            break;
        case CHANNEL_STATE_VARIOSTRING:
            OnOffType vsstate = StuderParser.getStateByCode(quantity.intValue());
            internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), vsstate);
            break;
        default:
            Unit<?> unit = UNIT_CHANNELS_VARIOSTRING.get(registerNumber);
            if (unit != null) {
                internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new QuantityType<>(quantity, unit));
            }
    }
}
Also used : StringType(org.openhab.core.library.types.StringType) OnOffType(org.openhab.core.library.types.OnOffType) VSMode(org.openhab.binding.modbus.studer.internal.StuderParser.VSMode)

Aggregations

VSMode (org.openhab.binding.modbus.studer.internal.StuderParser.VSMode)1 OnOffType (org.openhab.core.library.types.OnOffType)1 StringType (org.openhab.core.library.types.StringType)1