コード例 #1
0
        private void led_Load(object sender, RoutedEventArgs routedEventArgs)
        {
            result["result"] = "FAIL";
            var jsonconfig = GetFullPath("config.json");

            if (!File.Exists(jsonconfig))
            {
                MessageBox.Show("config.json not founded");
                Application.Current.Shutdown();
            }

            dynamic jobject = JObject.Parse(File.ReadAllText(jsonconfig));

            TestProduct           = jobject.TestProduct.ToString();
            IsAutoModeBatteryLED  = (bool)jobject.IsAutoModeBatteryLED;
            EnablePower           = (bool)jobject.EnablePower;
            EnableHDD             = (bool)jobject.EnableHDD;
            EnableRF              = (bool)jobject.EnableRF;
            EnableBattery         = (int)jobject.EnableBattery;
            IsBiosTestModeEnabled = (bool)jobject.IsBiosTestModeEnabled;

            if (IsDebugMode)
            {
                Trace.WriteLine("LED_Load");
            }

            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 750;
            timer.Tick    += new EventHandler(Timer_Tick);
            timer.Start();

            // 當MCU測項有打開就連到MCU_Comport
            if (TestProduct.Equals("IBWD"))
            {
                if (HotTabDLL.DeviceConnect(9600, MCU_Comport) == 0)
                {
                    if (IsDebugMode)
                    {
                        Trace.WriteLine("MCU_Comport : " + MCU_Comport);
                    }
                    //groupBoxWindyBox.Visible = true;
                    //groupBoxWindyBox.Location = new Point(652, 304);
                }
                else
                {
                    if (IsDebugMode)
                    {
                        Trace.WriteLine("Can't connect to MCU_Comport : " + MCU_Comport);
                    }
                    ShowDialogMessageBox("Can't connect to MCU comport : " + MCU_Comport, "Attention", MessageBoxButton.OK, MessageBoxImage.Error);
                    checkSuccessCount = -1;
                    checkTestStatus("CheckIt");
                }
            }
            else
            {
                if (EnablePower)
                {
                    TotalTestLEDCount++;
                    groupPower.Visibility = Visibility.Visible;
                }

                if (EnableBattery.Equals(1))
                {
                    TotalTestLEDCount++;
                    BatteryLED.Visibility = Visibility.Visible;
                    if (IsFixtureExisted && IsAutoModeBatteryLED)
                    {
                        buttonBatteryLEDPass.IsEnabled  = false;
                        buttonBatteryLEDFail.IsEnabled  = false;
                        buttonBatteryLEDTest.Visibility = Visibility.Visible;
                        TotalTestLEDCount++; // Battery LED 需要各偵測ON/OFF狀態各1次
                    }
                    else
                    {
                        //buttonBatteryLEDPass.IsEnabled = true;
                        labelTestBattery.Visibility = Visibility.Visible;
                    }
                }
                else if (EnableBattery.Equals(2))
                {
                    TotalTestLEDCount    += 2;
                    BatteryLED.Visibility = Visibility.Visible;
                    //groupBattery2.Visible = true;
                }

                if (EnableHDD)
                {
                    TotalTestLEDCount++;
                    groupHDD.Visibility = Visibility.Visible;
                }

                if (EnableGPS) // 除ID82 / IB10X 外, 其他機種不顯示GPS LED項目
                {
                    TotalTestLEDCount++;
                    //groupGPS.Visible = true;
                }

                // SupportModelName, LED
                if (TestProduct.Equals("FMB8"))
                {
                    TotalTestLEDCount += 3;
                    groupRF.Visibility = Visibility.Visible;
                    //groupBoxBluetooth.Visible = true;
                    //groupBoxWiFi.Visible = true;
                    //groupBoxStop.Visible = true;
                    // 預設將 BT / WiFi / Stop LED 先開啟
                    HotTabDLL.WinIO_WriteToECSpace(0x46, 0x01); // BTLED
                    HotTabDLL.WinIO_WriteToECSpace(0x3D, 0x01); // WIFILED
                    HotTabDLL.WinIO_WriteToECSpace(0x47, 0x01); // STOPLED
                }
                else if (EnableRF)
                {
                    if (TestProduct.Equals("IBWH")) // HandHeld 8"
                    {
                        groupRF.Content = "Custom LED";
                    }
                    TotalTestLEDCount        += 2; // RF 需要各偵測ON/OFF狀態各1次
                    groupRF.Visibility        = Visibility.Visible;
                    buttonRFLEDPass.IsEnabled = false;
                    buttonRFLEDFail.IsEnabled = false;
                }

                if (IsBiosTestModeEnabled)
                {
                    // TotalTestLEDCount ++; // Battery LED 需要各偵測ON/OFF狀態各1次
                    TestMode.SetTestModeLED(0x07);
                    buttonBatteryLEDTest.Visibility = Visibility.Visible;
                    buttonBatteryLEDTest.IsEnabled  = true;
                    buttonBatteryLEDTest.Content    = "Test";
                    buttonBatteryLEDTest.Foreground = Brushes.Blue;
                    buttonRFLEDTest.Content         = "Test";
                    buttonRFLEDTest.Foreground      = Brushes.Blue;
                    buttonBatteryLEDPass.IsEnabled  = false;
                    buttonBatteryLEDFail.IsEnabled  = false;
                    // buttonRFLEDPass.Enabled = false;
                    // buttonRFLEDFail.Enabled = false;
                }
            }
        }