Beispiel #1
0
 private bool IsAcAdapterNotExist()
 {
     while (PublicFunction.IsCharging)
     {
         if (IsFixtureExisted)
         {
             if (!PublicFunction.EnableRTS())
             {
                 return(false);
             }
         }
         else
         {
             MessageBoxResult Result = ShowDialogMessageBox("Please un-plug an AC adapter.", "Attention", MessageBoxButton.YesNo, MessageBoxImage.Information);
             if (Result.Equals(MessageBoxResult.No))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Beispiel #2
0
        private void TimerBattery_Tick(object sender, EventArgs e)
        {
            //Thread Timer = Thread.CurrentThread; // 取得目前執行的執行緒
            //Timer.IsBackground = true; // 將thread設定為背景執行緒 (如果設定為false, 按[X]關閉Form, 執行緒仍在背景繼續執行, 故要設定為true. )

            NowTestCount++;
            UpdatingBatteryInfo();
            Trace.WriteLine("IsTwoMainBatteryCorrect: " + IsTwoMainBatteryCorrect());
            Trace.WriteLine("IsSingleBatteryCorrect: " + IsSingleBatteryCorrect());
            Trace.WriteLine("IsMainBatteryCorrect: " + IsMainBatteryCorrect());
            Trace.WriteLine("IsSecondBatteryCorrect: " + IsSecondBatteryCorrect());
            if (IsTwoMainBatteryCorrect() || IsSingleBatteryCorrect() || IsMainBatteryCorrect() || IsSecondBatteryCorrect())
            {
                CorrectCount++;
            }

            IdentifyTestingBatteryInUI();

            TestCount.Content        = "Total : " + NowTestCount.ToString();
            ReadCorrectCount.Content = "Correct : " + CorrectCount.ToString();

            if (NowTestCount.Equals(BatteryTotalCount) && CorrectCount >= BatteryTotalCount * CorrectTolerance)
            {
                TimerBattery.Stop();
                // 測完 AC Mode 改測 Battery Mode
                if (Title.Content.Equals(AC_Mode_Test)) // 測完 MBAT 充電 ->  MBAT 放電
                {
                    if (!IsAcAdapterNotExist())
                    {
                        checkTestStatus("IsAcAdapterExist - Can't switch AC In/Out.");
                        return;
                    }

                    WaitBatteryInit();
                }
                else if (BatteryAmount.Equals(2) && Title.Content.Equals(Battery_Mode_Test)) // 測完 MBAT 放電 -> SBAT 放電
                {
                    if (!IsSecondBatteryTesting)
                    {
                        IsSecondBatteryTesting = true;
                    }

                    if (IsTwoMainBatteryProduct())
                    {
                        SetInternalBatteryDischarge();
                    }
                    else
                    {
                        while (Battery1Status > 0)
                        {
                            PublicFunction.CloseRTSPort();
                            MessageBoxResult Result = ShowDialogMessageBox("Please remove Main Battery.", "Attention", MessageBoxButton.YesNo, MessageBoxImage.Information);

                            WaitBatteryInit();

                            if (Result.Equals(MessageBoxResult.No))
                            {
                                checkTestStatus("Is Main Battery Exist");
                                return;
                            }
                        }
                    }
                }
                else if (BatteryAmount.Equals(2) && Title.Content.Equals(SBAT_Discharge_Test)) // 測完 SBAT 放電 -> SBAT 充電
                {
                    if (IsTwoMainBatteryProduct())
                    {
                        if (IsFixtureExisted)
                        {
                            if (!PublicFunction.DisableRTS())
                            {
                                checkTestStatus("Can't control RTS Pin.");
                                return;
                            }
                        }
                        else
                        {
                            IsAcAdapterExist();
                        }
                    }
                    else
                    {
                        // SBAT 的剩餘容量大於充電Threshold直接當作小電池可以充電, 不多做確認
                        if (/*!GetBatteryChangeThreshold() || */ !IsMainBatteryInserted())
                        {
                            return;
                        }
                    }
                }
                else if (Title.Content.Equals(SBAT_Charge_Test) && IsTwoMainBatteryProduct())
                {
                    if (!IsAcAdapterNotExist())
                    {
                        checkTestStatus("IsAcAdapterExist");
                        return;
                    }

                    if (!SetInternalBatteryDischarge())
                    {
                        checkTestStatus("IsInternalBatteryDischarge");
                        return;
                    }

                    while (Battery2Status > 0)
                    {
                        MessageBoxResult Result = ShowDialogMessageBox("Please remove Extend Battery.", "Attention", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (Result.Equals(MessageBoxResult.No))
                        {
                            checkTestStatus("Is Extend Battery Exist");
                            return;
                        }
                    }
                }

                CorrectCount = 0;
                NowTestCount = 0;

                if ((BatteryAmount.Equals(1) && Title.Content.Equals(Battery_Mode_Test)) ||
                    Title.Content.Equals(SBAT_Charge_Test))
                {
                    checkTestStatus("PASS");
                }
                else
                {
                    if (!IsSecondBatteryTesting)
                    {
                        Title.Content = Battery_Mode_Test;
                        Trace.WriteLine(Battery_Mode_Test.PadRight(40, '='));
                    }
                    else if (Title.Content.Equals(Battery_Mode_Test))
                    {
                        Title.Content = SBAT_Discharge_Test;
                        Trace.WriteLine(SBAT_Discharge_Test.PadRight(40, '='));
                    }
                    else if (Title.Content.Equals(SBAT_Discharge_Test))
                    {
                        Title.Content = SBAT_Charge_Test;
                        Trace.WriteLine(SBAT_Charge_Test.PadRight(40, '='));
                    }

                    if (IsEcPollingSlowProduct())
                    {
                        WaitBatteryInit();
                    }

                    TimerBattery.Start();
                }
            }
            else if (NowTestCount >= BatteryTotalCount)
            {
                if (IsDebugMode)
                {
                    Trace.WriteLine("Battery : " + NowTestCount + " , TotalCount : " + BatteryTotalCount);
                }
                checkTestStatus("FAIL");
            }
        }