private void UpdateSensorLabels(byte sensor_id, u8_f32T data) { string str = string.Format("{0:f} C", data.f32); switch (sensor_id) { case 0: case 4: case 8: case 12: this.ctrlTemp1Edit.Text = str; return; case 1: case 5: case 9: case 13: this.ctrlTemp2Edit.Text = str; return; case 2: case 6: case 10: case 14: this.ctrlTemp3Edit.Text = str; return; case 3: case 7: case 11: case 15: this.ctrlTemp4Edit.Text = str; return; } }
public int telegramFromPortHandler(Telegram telegram) { switch (telegram.type) { case TelegramType.AcknowledgeOK: switch (telegram.protocol) { case Protocol.Write: case Protocol.WriteRegister: goto Label_02E7; } GlobalServices.ErrMsg("AppWin_EZLinkTempDemo.telegramFromPortHandler", "Unexpected protocol in handling AcknowledgeOK"); return -1; case TelegramType.AcknowledgeERROR: case TelegramType.DataAcknowledgeERROR: case TelegramType.DeviceFailure: GlobalServices.ErrMsg("AppWin_EZLinkTempDemo.telegramFromPortHandler", "ERROR status received: type: " + ((TelegramType) telegram.type).ToString() + " protocol: " + telegram.protocol.ToString() + " error code: " + ((int) telegram.userData).ToString("X")); return -1; case TelegramType.DataAcknowledgeOK: switch (telegram.protocol) { case Protocol.ReadRegister: uint num; uint num2; telegram.data.appWin_getReply_ReadRegister(out num, out num2); goto Label_02E7; case Protocol.ReadStatus: string str; telegram.data.appWin_getReply_ReadIEEEAddress(out str); this.IEEEAddrStatus.Text = " IEEE Address: " + str; this._ioph.controlReadRxPacket(true, 10); goto Label_02E7; case Protocol.Read: switch (telegram.data[3]) { case 2: { u8_f32T data = new u8_f32T { byte3 = telegram.data[4], byte2 = telegram.data[5], byte1 = telegram.data[6], byte0 = 0 }; this.UpdateSensorLabels(telegram.data[1], data); break; } case 4: if (this.ctrlPushBtn.Checked) { this._key_monitor = 0; switch (telegram.data[1]) { case 4: this.lblKeyPressed.Text = "Left Button Pressed"; break; case 5: this.lblKeyPressed.Text = "Up Button Pressed"; break; case 6: this.lblKeyPressed.Text = "Down Button Pressed"; break; case 7: this.lblKeyPressed.Text = "Right Button Pressed"; break; } } break; } goto Label_02E7; } GlobalServices.ErrMsg("AppWin_EZLinkTempDemo.telegramFromPortHandler", "Unexpected protocol in handling DataAcknowledgeOK"); return -1; case TelegramType.SeriesEndOK: case TelegramType.SeriesEndERROR: goto Label_02E7; case TelegramType.PortHandlerTerminated: this._closeCtrl.portHandlerClosed(telegram.portHandler); return 0; } GlobalServices.ErrMsg("AppWin_EZLinkTempDemo.telegramFromPortHandler", "Unexpected telegram type received: type: " + ((TelegramType) telegram.type).ToString() + " protocol: " + telegram.protocol.ToString()); return -1; Label_02E7: return 0; }