Search in sources :

Example 6 with TimeInfoMsg

use of org.openhab.binding.maxcul.internal.messages.TimeInfoMsg in project openhab1-addons by openhab.

the class TimeUpdateRequestSequence method runSequencer.

@Override
public void runSequencer(BaseMsg msg) {
    pktLostCount = 0;
    switch(state) {
        case RESPOND_TO_REQUEST:
            if (BaseMsg.getMsgType(msg.rawMsg) == MaxCulMsgType.TIME_INFO) {
                TimeInfoMsg timeMsg = new TimeInfoMsg(msg.rawMsg);
                if (isValidDeviation(timeMsg.getTimeInfo(), new GregorianCalendar(), TIME_TOLERANCE)) {
                    messageHandler.sendAck(msg);
                    state = TimeUpdateRequestState.FINISHED;
                } else {
                    messageHandler.sendTimeInfo(msg.srcAddrStr, tzStr, this);
                    state = TimeUpdateRequestState.HANDLE_RESPONSE;
                }
            } else {
                state = TimeUpdateRequestState.FINISHED;
                logger.debug("Got invalid message type for Time Update Sequence");
            }
            break;
        case HANDLE_RESPONSE:
            /* check for ACK */
            if (msg.msgType == MaxCulMsgType.ACK) {
                AckMsg ack = new AckMsg(msg.rawMsg);
                if (ack.getIsNack()) {
                    logger.error("TIME_INFO was nacked. Ending sequence");
                    state = TimeUpdateRequestState.FINISHED;
                } else {
                    state = TimeUpdateRequestState.FINISHED;
                }
            }
            state = TimeUpdateRequestState.FINISHED;
            break;
        case FINISHED:
            /* do nothing */
            break;
        default:
            logger.error("Invalid state for PairingInitialisation Message Sequence!");
            break;
    }
}
Also used : TimeInfoMsg(org.openhab.binding.maxcul.internal.messages.TimeInfoMsg) AckMsg(org.openhab.binding.maxcul.internal.messages.AckMsg) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

TimeInfoMsg (org.openhab.binding.maxcul.internal.messages.TimeInfoMsg)6 AckMsg (org.openhab.binding.maxcul.internal.messages.AckMsg)2 PairPingMsg (org.openhab.binding.maxcul.internal.messages.PairPingMsg)2 SetTemperatureMsg (org.openhab.binding.maxcul.internal.messages.SetTemperatureMsg)2 ThermostatStateMsg (org.openhab.binding.maxcul.internal.messages.ThermostatStateMsg)2 WallThermostatControlMsg (org.openhab.binding.maxcul.internal.messages.WallThermostatControlMsg)2 WallThermostatStateMsg (org.openhab.binding.maxcul.internal.messages.WallThermostatStateMsg)2 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 MaxCulBindingProvider (org.openhab.binding.maxcul.MaxCulBindingProvider)1 PairingInitialisationSequence (org.openhab.binding.maxcul.internal.message.sequencers.PairingInitialisationSequence)1 TimeUpdateRequestSequence (org.openhab.binding.maxcul.internal.message.sequencers.TimeUpdateRequestSequence)1 BaseMsg (org.openhab.binding.maxcul.internal.messages.BaseMsg)1 MaxCulMsgType (org.openhab.binding.maxcul.internal.messages.MaxCulMsgType)1 PairPongMsg (org.openhab.binding.maxcul.internal.messages.PairPongMsg)1 PushButtonMsg (org.openhab.binding.maxcul.internal.messages.PushButtonMsg)1 SetGroupIdMsg (org.openhab.binding.maxcul.internal.messages.SetGroupIdMsg)1 ShutterContactStateMsg (org.openhab.binding.maxcul.internal.messages.ShutterContactStateMsg)1