private void timerPolling_Tick(object sender, EventArgs e) { if (MyController.Connected) { try { int regValue; if (timerPolling.Interval != 250) { timerPolling.Interval = 250; // Initialize info from controller regValue = MyController.Read(Controller.regVersionHW); int major = (int)(((uint)regValue & 0xff000000) >> 24); int minor = (int)(((uint)regValue & 0xff0000) >> 16); int rev = (int)(((uint)regValue & 0xff00) >> 8); int bug = (int)((uint)regValue & 0xff); this.labelHWVersion.Text = major.ToString() + "." + minor.ToString() + "." + rev.ToString() + "." + bug.ToString(); regValue = MyController.Read(Controller.regVersionSW); major = (int)(((uint)regValue & 0xff000000) >> 24); minor = (int)(((uint)regValue & 0xff0000) >> 16); rev = (int)(((uint)regValue & 0xff00) >> 8); bug = (int)((uint)regValue & 0xff); this.labelFWVersion.Text = major.ToString() + "." + minor.ToString() + "." + rev.ToString() + "." + bug.ToString(); regValue = MyController.Read(Controller.regVersionDate); major = (int)(((uint)regValue & 0xff000000) >> 24); minor = (int)(((uint)regValue & 0xff0000) >> 16); rev = (int)(((uint)regValue & 0xff00) >> 8); bug = (int)((uint)regValue & 0xff); DateTime date = new DateTime(rev + 2000, major, minor); this.labelDateOfManufacture.Text = date.ToShortDateString(); regValue = MyController.Read(Controller.regSetupConfig_2); if ((regValue & 0x04) != 0) { this.motionAxis2.Enabled = false; } if (MyController.Generation == 1) { label4.Hide(); labelSerialNumber.Hide(); label5.Hide(); label6.Hide(); textBoxLED1.Hide(); textBoxLED2.Hide(); } else if (MyController.Generation == 2) { regValue = MyController.Read(Controller.regProductSerialNum); labelSerialNumber.Text = regValue.ToString(); } } textBoxOnLine.Text = "On-Line"; textBoxOnLine.BackColor = Color.Green; this.Enabled = true; // TODO: Add polling for LED1 & LED2 status int status = MyController.Read(Controller.regStatus_1); textBoxLED1.BackColor = (((uint)status & 0x00000400) != 0) ? Color.Green : Color.LightGray; textBoxLED2.BackColor = (((uint)status & 0x00000800) != 0) ? Color.Red : Color.LightGray; motionAxis1.UpdateAxis(); // Check for disabled 2nd axis here regValue = MyController.Read(Controller.regSetupConfig_2); if ((regValue & 0x04) == 0) { motionAxis2.UpdateAxis(); } else { this.motionAxis2.Enabled = false; } } catch (Exception) { MyController.Disconnect(); } } else { textBoxOnLine.Text = "Off-Line"; textBoxOnLine.BackColor = Color.Gray; this.Enabled = false; if (timerPolling.Interval != 5000) { // Poll much more slowly if we are not connected timerPolling.Interval = 5000; } // Attempt to reconnect try { MyController.Connect(); } catch (Exception) { } } }