/* decode une trame en Message */ public MessageProtocol DecodeTrame(TrameProtocole trame) { MessageProtocol message = new MessageProtocol(); switch (trame.data[0]) // Header { case (byte)EMBtoPCmessHeads.ACK: message = new EMBtoPCMessageGlobalAck(); message.headerMess = trame.data[0]; ((EMBtoPCMessageGlobalAck)message).idTrame = (ushort)(trame.data[1] << 8); ((EMBtoPCMessageGlobalAck)message).idTrame += trame.data[2]; ((EMBtoPCMessageGlobalAck)message).valueAck = trame.data[3]; break; case (byte)EMBtoPCmessHeads.ASK_CONN: message = new EMBtoPCMessageAskConn(); message.headerMess = trame.data[0]; break; case (byte)EMBtoPCmessHeads.RESP_PING: message = new EMBtoPCMessageRespPing(); message.headerMess = trame.data[0]; break; case (byte)EMBtoPCmessHeads.RESP_SENSOR: message = new EMBtoPCMessageRespSensor(); message.headerMess = trame.data[0]; ((EMBtoPCMessageRespSensor)message).idSensor = trame.data[1]; ((EMBtoPCMessageRespSensor)message).valueSensor = trame.data[2]; break; case (byte)EMBtoPCmessHeads.AUTO_MODE_OFF: message = new EMBtoPCMessageAutoModeOff(); message.headerMess = trame.data[0]; break; default: Logger.GlobalLogger.error("Erreur Message recu inconnu !"); break; } return(message); }
private void TraiterMessageASK_CONN(EMBtoPCMessageAskConn message) { if (_stateBot == StateBot.STATE_NONE) //On viens juste de connecter { } }