public void SetDeviceId(string a) { try { a = a.Substring(0, 4); int num = (((Convert.ToInt16(a.Substring(0, 1)) * 0x1000) + (Convert.ToInt16(a.Substring(1, 1)) * 0x100)) + (Convert.ToInt16(a.Substring(2, 1)) * 0x10)) + Convert.ToInt16(a.Substring(3, 1)); for (int i = 0; i < (identification.Length / 4); i++) { if (num == identification[i, 3]) { device_ID = (deviceID)identification[i, 0]; device_Addr = (DevAddress)identification[i, 1]; return; } } } catch (Exception) { } }
private void UpdateCommStrip() { if (DoReconnect) { DoReconnect = false; timer1.Enabled = false; Thread.Sleep(100); Reconnect(); } string commStatus = dv.GetCommStatus(); switch (dv.GetCommState()) { case CommunicationState.HWFind: CommMode = eCommMode.FindingHW; break; case CommunicationState.Idle: CommMode = eCommMode.Closed; break; case CommunicationState.Ready: CommMode = eCommMode.Running; string hwid = commStatus.Substring(commStatus.IndexOf("HW:") + 3, 4); if (hwid != "3002" && hwid != "3003" && hwid != "3004" && hwid != "3005" && hwid != "3006" && hwid != "3009" ) { dv.Close(); DoReconnect = true; } break; default: CommMode = eCommMode.Closed; break; } toolStripStatusLabel.Text = commStatus; if (ControllerObj.DeviceID != deviceID.Unsupported && ControllerObj.DeviceID != m_DeviceID) { m_DeviceID = ControllerObj.DeviceID; groupBoxApplicationSelection.Text = ControllerObj.DeviceID.ToString(); } pnlBootloader.Visible = false; switch (CommMode) { case eCommMode.Bootloader: groupBoxApplicationSelection.Enabled = false; CommStripButton.Image = ImageGreen; pnlBootloader.Visible = true; break; case eCommMode.FindingHW: groupBoxApplicationSelection.Enabled = false; CommStripButton.Image = ImageYellow; break; case eCommMode.Running: groupBoxApplicationSelection.Enabled = true; CommStripButton.Image = ImageGreen; break; case eCommMode.Closed: groupBoxApplicationSelection.Enabled = false; CommStripButton.Image = ImageRed; DoReconnect = true; break; } CommStrip.Refresh(); }