コード例 #1
0
ファイル: lightsensor.cs プロジェクト: icprog/WinDiagnostic
        void checkTestStatus(String testResult)
        {
            Trace.WriteLine(testResult);
            if (TimerLightSensor.Enabled)
            {
                TimerLightSensor.Stop();
            }
            if (IsDebugMode)
            {
                Trace.WriteLine("MaxValue : " + lightSensorMaxValue.ToString().PadRight(4, ' ') + "\tMaxThreshold : " + LightSensorMaxThreshold);
                Trace.WriteLine("MinValue : " + lightSensorMinValue.ToString().PadRight(4, ' ') + "\tMinThreshold : " + LightSensorMinThreshold);
            }

            labelTitle.Text      = "LightSensor";
            labelTitle.ForeColor = Color.Black;
            labelTitle.Update();

            if (testResult.Equals("PASS"))
            {
                labelResult.ForeColor = Color.Green;
                labelResult.Text      = "PASS";
                result["result"]      = "PASS";
                result["EIPLog"]      = new JObject
                {
                    { "LightSensor", "PASS" },
                    { "LightSensor_Info", "PASS" }
                };
            }
            else
            {
                labelResult.ForeColor = Color.Red;
                labelResult.Text      = "FAIL";
                result["result"]      = "FAIL";
                result["EIPLog"]      = new JObject
                {
                    { "LightSensor", "FAIL" },
                    { "LightSensor_Info", testResult }
                };
            }

            buttonPASS.Enabled = false;
            buttonFAIL.Enabled = false;
            buttonCheckLightSensorValue.Enabled = false;
            buttonSensorHub.Enabled             = false;
            Deinit();
            File.WriteAllText(GetFullPath("result.json"), result.ToString());
            Thread.Sleep(200);
            File.Create(GetFullPath("completed"));
            if (!ShowWindow)
            {
                Exit();
            }
        }
コード例 #2
0
ファイル: lightsensor.cs プロジェクト: icprog/WinDiagnostic
 void buttonCheckLightSensorValue_Click(object sender, EventArgs e)
 {
     try
     {
         if (buttonCheckLightSensorValue.Enabled)
         {
             if (isSensorHubExist) // 不管在AC模式或是電池模式都要把Lightsensor設成開啟(true)
             {
                 if (IsDebugMode)
                 {
                     Trace.WriteLine("isLightSensorHub, SetAutoBrightnessStatus = TRUE");
                 }
                 SetAutoBrightnessStatus(true, 1);
                 SetAutoBrightnessStatus(true, 0);
             }
             else
             {
                 SetLightSensorOnOff(1);  // 不是走SensorHub的
             }
             if (IsFixtureExisted)
             {
                 CountReadLightSensor = 0;
             }
             TimerLightSensor.Interval = TimerIntervalLightSensor;
             TimerLightSensor.Start();
         }
         else
         {
             DisableLightSensorDetect();
             labelLightSensor.Text = "";
             TimerLightSensor.Stop();
         }
         buttonCheckLightSensorValue.Enabled = false;
     }
     catch (Exception ex)
     {
         buttonCheckLightSensorValue.Enabled = false;
         checkTestStatus("Error! Please check LightSensor firmware version.");
         if (IsDebugMode)
         {
             Trace.WriteLine(ex.Message);
         }
     }
 }