Exemplo n.º 1
0
        public static async Task <bool> CheckSerial()
        {
            bool result;

            try
            {
                return(result = await Task <bool> .Run(() =>
                {
                    var tm = new GeneralTimer(15000);
                    tm.start();
                    while (true)
                    {
                        //うめきのバグ
                        //通信が不安定なのでなんかいかリトライする
                        if (tm.FlagTimeout)
                        {
                            return false;
                        }
                        if (!Target.SendData("RS401", Wait: 500, DoAnalysis: false))
                        {
                            continue;
                        }
                        if (!Target.RecieveData.Contains("U2TXMSG"))
                        {
                            continue;
                        }
                        if (Target.SendData("u2msg"))
                        {
                            break;
                        }
                    }
                    return true;
                }));
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
        public static async Task <bool> CheckVer()
        {
            var result = false;

            try
            {
                Sleep(1000);
                General.PowSupply(true);
                return(result = await Task <bool> .Run(() =>
                {
                    Sleep(1000);
                    var tm = new GeneralTimer(5000);
                    tm.start();
                    while (true)
                    {
                        if (tm.FlagTimeout || Flags.ClickStopButton)
                        {
                            return false;
                        }
                        if (Target.SendDataForVerCheck(State.TestSpec.Ver))
                        {
                            return true;
                        }
                        Sleep(100);
                    }
                }));
            }
            catch
            {
                return(false);
            }
            finally
            {
                General.PowSupply(false);
            }
        }
Exemplo n.º 3
0
        public static async Task <bool> CheckVolt(VOL_CH ch)
        {
            bool   result   = false;
            Double measData = 0;
            double Max      = 0;
            double Min      = 0;

            try
            {
                return(await Task <bool> .Run(() =>
                {
                    try
                    {
                        SetRelay(ch);
                        Thread.Sleep(400);

                        switch (ch)
                        {
                        case VOL_CH.P12V:
                            Max = State.TestSpec.V12_HI;
                            Min = State.TestSpec.V12_LO;
                            break;

                        case VOL_CH.P5V:
                            Max = State.TestSpec.Vp5_HI;
                            Min = State.TestSpec.Vp5_LO;
                            break;

                        case VOL_CH.P3_3V:
                            Max = State.TestSpec.V3_3_HI;
                            Min = State.TestSpec.V3_3_LO;
                            break;

                        case VOL_CH.M5V:
                            Max = State.TestSpec.Vm5_HI;
                            Min = State.TestSpec.Vm5_LO;
                            break;
                        }

                        var tm = new GeneralTimer(5000);
                        tm.start();
                        while (true)
                        {
                            if (tm.FlagTimeout)
                            {
                                return false;
                            }
                            if (!General._34401.GetDcVoltage())
                            {
                                continue;
                            }

                            measData = General._34401.VoltData;
                            if (Min < measData && measData < Max)
                            {
                                break;
                            }
                            Thread.Sleep(200);
                        }

                        if (!General._34401.GetDcVoltage())
                        {
                            return false;
                        }
                        measData = General._34401.VoltData;

                        return result = (Min < measData && measData < Max);
                    }
                    catch
                    {
                        return result = false;
                    }
                }));
            }
            finally
            {
                //ビューモデルの更新
                switch (ch)
                {
                case VOL_CH.P12V:
                    State.VmTestResults.Vol12v    = measData.ToString("F2") + "V";
                    State.VmTestResults.ColVol12v = result ? General.OffBrush : General.NgBrush;
                    break;

                case VOL_CH.P5V:
                    State.VmTestResults.VolP5v    = measData.ToString("F2") + "V";
                    State.VmTestResults.ColVolP5v = result ? General.OffBrush : General.NgBrush;
                    break;

                case VOL_CH.P3_3V:
                    State.VmTestResults.VolP33v    = measData.ToString("F2") + "V";
                    State.VmTestResults.ColVolP33v = result ? General.OffBrush : General.NgBrush;
                    break;

                case VOL_CH.M5V:
                    State.VmTestResults.VolM5v    = measData.ToString("F2") + "V";
                    State.VmTestResults.ColVolM5v = result ? General.OffBrush : General.NgBrush;
                    break;
                }

                //NGだった場合、エラー詳細情報の規格値を更新する
                if (!result)
                {
                    //switch (ch)
                    //{
                    //    case VOL_CH.P12V:
                    //        State.VmTestStatus.Spec = $"規格値 : {State.TestSpec.V12_LO.ToString("F2")} ~ {State.TestSpec.V12_HI.ToString("F2")}V";
                    //        break;
                    //    case VOL_CH.P5V:
                    //        State.VmTestStatus.Spec = $"規格値 : {State.TestSpec.Vp5_LO.ToString("F2")} ~ {State.TestSpec.Vp5_HI.ToString("F2")}V";
                    //        break;
                    //    case VOL_CH.P3_3V:
                    //        State.VmTestStatus.Spec = $"規格値 : {State.TestSpec.V3_3_LO.ToString("F2")} ~ {State.TestSpec.V3_3_HI.ToString("F2")}V";
                    //        break;
                    //    case VOL_CH.M5V:
                    //        State.VmTestStatus.Spec = $"規格値 : {State.TestSpec.Vm5_LO.ToString("F2")} ~ {State.TestSpec.Vm5_HI.ToString("F2")}V";
                    //        break;
                    //}

                    State.VmTestStatus.Spec      = $"規格値 : {Min.ToString("F2")} ~ {Max.ToString("F2")}V";
                    State.VmTestStatus.MeasValue = "計測値 : " + measData.ToString("F2") + "V";
                }
            }
        }
Exemplo n.º 4
0
        public static async Task <bool> WriteFirmware(string WorkSpacePath, string checkSum = null)
        {
            //フラグの初期化
            FlagWrite    = false;
            FlagSum      = false;
            ReadSumValue = "---";
            var re = await Task.Run <bool>(() =>
            {
                var Fdt = new Process();

                try
                {
                    //外部でE8aエミュレータを接続する(クラス外部で処理する)

                    //プロセスを作成してFDTを立ち上げる

                    Fdt.StartInfo.FileName = WorkSpacePath;
                    Fdt.Start();
                    Fdt.WaitForInputIdle();//指定されたプロセスで未処理の入力が存在せず、ユーザーからの入力を待っている状態になるまで、またはタイムアウト時間が経過するまで待機します。

                    //FDTのウィンドウハンドル取得
                    FlagTimer = true;
                    Tm.Start();
                    IntPtr hWnd = IntPtr.Zero;//メインウィンドウのハンドル
                    while (hWnd == IntPtr.Zero)
                    {
                        //Application.DoEvents();
                        if (!FlagTimer)
                        {
                            return(false);
                        }
                        hWnd = FindWindow(null, "FDT Simple Interface   (Supported Version)");
                    }

                    IntPtr ログテキストハンドル = FindWindowEx(hWnd, IntPtr.Zero, "RICHEDIT", "");

                    //FDTを最前面に表示してアクティブにする(センドキー送るため)
                    SetForegroundWindow(hWnd);
                    Sleep(1000);

                    SendKeys.SendWait("{TAB}");
                    Sleep(100);
                    SendKeys.SendWait("{ENTER}");
                    Sleep(400);
                    //E8aからの電源供給では不安定で書き込みできないことがある
                    //必ず試験機側から電源供給すること
                    ////SendKeys.SendWait("P");
                    ////Sleep(400);
                    ////SendKeys.SendWait("5");
                    ////Sleep(400);
                    SendKeys.SendWait("{ENTER}");
                    Sleep(2000);
                    SendKeys.SendWait("{ENTER}");
                    Sleep(3000);
                    SendKeys.SendWait("{ENTER}");//追加 ID入力画面が出ていたら押す

                    int MaxSize      = 10000;
                    StringBuilder sb = new StringBuilder(MaxSize);
                    string LogBuff   = "";

                    var tm = new GeneralTimer(60000);
                    tm.start();//念のため無限ループ防止
                    while (true)
                    {
                        if (tm.FlagTimeout)
                        {
                            return(false);
                        }
                        Sleep(1000);//インターバル1秒 ※インターバル無しの場合FDTがこける
                        SendMessage(ログテキストハンドル, WM_GETTEXT, MaxSize - 1, sb);
                        LogBuff = sb.ToString();
                        if (LogBuff.Contains("IDコードが不一致です"))
                        {
                            return(false);
                        }
                        if (LogBuff.Contains("Error"))
                        {
                            return(false);
                        }
                        if (LogBuff.Contains("Disconnected"))
                        {
                            break;
                        }
                    }

                    FlagWrite = (LogBuff.IndexOf("書き込みが完了しました") >= 0);
                    if (!FlagWrite)
                    {
                        return(false);
                    }

                    //チェックサムがあっているかの判定
                    if (checkSum == null)
                    {
                        return(true);
                    }
                    FlagSum = LogBuff.Contains("User Flash 1 = 0x" + checkSum);

                    //読み出したチェックサム値を求めておく(NG判定時に使用する)
                    var index    = LogBuff.IndexOf("User Flash 1 = 0x");//17
                    ReadSumValue = LogBuff.Substring(index + 17, 8);

                    return(FlagSum);
                }
                catch
                {
                    return(false);
                }
                finally
                {
                    if (Fdt != null)
                    {
                        Fdt.Kill();
                        Fdt.Close();
                        Fdt.Dispose();
                        Sleep(700);//FDT閉じてすぐにE8a外すとダメ! ダメよぉ ダメダメ!!! ※2014年流行語大賞
                    }
                }
            });

            return(re);
            //E1エミュレータを切り離すする(クラス外部で処理する)
        }
Exemplo n.º 5
0
        public static async Task <bool> CheckPwmOut(OUTPUT_NAME ch)
        {
            bool   result   = false;
            Double measData = 0;
            double Max      = 0;
            double Min      = 0;

            try
            {
                return(await Task <bool> .Run(() =>
                {
                    try
                    {
                        //製品にコマンドを送ると、PWM出力させ、マルチメータに出力端子を接続します
                        if (!Target.SendData(SetRelay(ch), Wait: 10000))
                        {
                            return false;
                        }

                        switch (ch)
                        {
                        case OUTPUT_NAME.PWM1_I_50:
                        case OUTPUT_NAME.PWM2_I_50:
                            Max = State.TestSpec.PWM_I50_HI;
                            Min = State.TestSpec.PWM_I50_LO;
                            break;

                        case OUTPUT_NAME.PWM1_I_100:
                        case OUTPUT_NAME.PWM2_I_100:
                            Max = State.TestSpec.PWM_I100_HI;
                            Min = State.TestSpec.PWM_I100_LO;
                            break;

                        case OUTPUT_NAME.PWM1_V_50:
                        case OUTPUT_NAME.PWM2_V_50:
                            Max = State.TestSpec.PWM_V50_HI;
                            Min = State.TestSpec.PWM_V50_LO;
                            break;

                        case OUTPUT_NAME.PWM1_V_100:
                        case OUTPUT_NAME.PWM2_V_100:
                            Max = State.TestSpec.PWM_V100_HI;
                            Min = State.TestSpec.PWM_V100_LO;
                            break;
                        }

                        var tm = new GeneralTimer(5000);
                        tm.start();
                        while (true)
                        {
                            if (tm.FlagTimeout)
                            {
                                return false;
                            }
                            if (!General._34401.GetDcVoltage())
                            {
                                continue;
                            }

                            measData = General._34401.VoltData;
                            if (Min < measData && measData < Max)
                            {
                                break;
                            }
                            Sleep(200);
                        }

                        if (!General._34401.GetDcVoltage())
                        {
                            return false;
                        }
                        measData = General._34401.VoltData;

                        return result = (Min < measData && measData < Max);
                    }
                    catch
                    {
                        return result = false;
                    }
                }));
            }
            finally
            {
                //ビューモデルの更新
                switch (ch)
                {
                case OUTPUT_NAME.PWM1_I_50:
                    State.VmTestResults.VolPwm1_I_50 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm1_I_50 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM1_I_100:
                    State.VmTestResults.VolPwm1_I_100 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm1_I_100 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM2_I_50:
                    State.VmTestResults.VolPwm2_I_50 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm2_I_50 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM2_I_100:
                    State.VmTestResults.VolPwm2_I_100 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm2_I_100 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM1_V_50:
                    State.VmTestResults.VolPwm1_V_50 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm1_V_50 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM1_V_100:
                    State.VmTestResults.VolPwm1_V_100 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm1_V_100 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM2_V_50:
                    State.VmTestResults.VolPwm2_V_50 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm2_V_50 = result ? General.OffBrush : General.NgBrush;
                    break;

                case OUTPUT_NAME.PWM2_V_100:
                    State.VmTestResults.VolPwm2_V_100 = measData.ToString("F2") + "V";
                    State.VmTestResults.ColPwm2_V_100 = result ? General.OffBrush : General.NgBrush;
                    break;
                }

                //NGだった場合、エラー詳細情報の規格値を更新する
                if (!result)
                {
                    State.VmTestStatus.Spec      = $"規格値 : {Min.ToString("F2")} ~ {Max.ToString("F2")}V";
                    State.VmTestStatus.MeasValue = "計測値 : " + measData.ToString("F2") + "V";
                }
            }
        }