예제 #1
0
        public static void Init周辺機器()//TODO:
        {
            Flags.Initializing周辺機器 = true;

            Target.OpenPort();//COM1のため、無条件でOKとする 判定はしない

            //EPX64Sの初期化
            bool StopEpx64 = false;

            Task.Run(() =>
            {
                //IOボードの初期化
                io = new EPX64R();
                while (true)
                {
                    if (Flags.StopInit周辺機器)
                    {
                        break;
                    }

                    Flags.StateEpx64 = General.io.InitEpx64R(0x7F);//0111 1111  ※P7入力 その他出力
                    if (Flags.StateEpx64)
                    {
                        //IOボードのリセット(出力をすべてLする)
                        ResetIo();
                        break;
                    }

                    Sleep(500);
                }
                StopEpx64 = true;
            });

            //ファンクションジェネレータの初期化
            bool StopWavGen = false;

            Task.Run(() =>
            {
                while (true)
                {
                    if (Flags.StopInit周辺機器)
                    {
                        break;
                    }

                    Flags.StateWavGen = WaveFormGenerator.Initialize();
                    if (Flags.StateWavGen)
                    {
                        break;
                    }

                    Thread.Sleep(400);
                }

                StopWavGen = true;
            });

            //HIOKI7012の初期化
            bool Stop7012 = false;

            Task.Run(() =>
            {
                while (true)
                {
                    if (Flags.StopInit周辺機器)
                    {
                        break;
                    }

                    Flags.State7012 = HIOKI7012.Init7012();
                    if (Flags.State7012)
                    {
                        HIOKI7012.StopSource();
                        break;
                    }
                    Sleep(500);
                }

                Stop7012 = true;
            });

            //USBシリアル変換器を使うので、通信がかち合わないように順番に初期化を行う
            //マルチメータの初期化
            //オシロスコープの初期化
            bool Stop323x  = false;
            bool Stop5107B = false;

            osc = new DS_5107B();
            Task.Run(() =>
            {
                while (true)
                {
                    if (Flags.StopInit周辺機器 || (Flags.State323x && Flags.State5107B))
                    {
                        break;
                    }


                    if (!Flags.State323x)
                    {
                        Flags.State323x = Hioki3239.Init323x();
                    }

                    if (!Flags.State5107B)
                    {
                        Flags.State5107B = osc.Init();
                        if (Flags.State5107B)
                        {
                            osc.SetBasicConf();
                        }
                    }
                    Sleep(500);
                }
                Stop323x = Stop5107B = true;
            });

            Task.Run(() =>
            {
                while (true)
                {
                    CheckAll周辺機器フラグ();

                    //EPX64Sの初期化の中で、K100、K101の溶着チェックを行っているが、これがNGだとしてもInit周辺機器()は終了する
                    var IsAllStopped = StopEpx64 && Stop7012 && Stop5107B && Stop323x && StopWavGen;

                    if (Flags.AllOk周辺機器接続 || IsAllStopped)
                    {
                        break;
                    }
                    Thread.Sleep(400);
                }
                Flags.Initializing周辺機器 = false;
            });
        }
예제 #2
0
 public void ConnectOscilloscope(IOscilloscope osc)
 {
     oscilloscope = osc;
 }
예제 #3
0
        private void ENET_Constructor()
        {
            string FG_IP     = "";
            string OSCOPE_IP = "";

            // #Saved IP Addresses, do not edit
            // FGIP=0.0.0.0
            // OSIP=0.0.0.0
            if (File.Exists("enet.cfg"))
            {
                string[] configInput = File.ReadAllLines("enet.cfg");
                if (configInput.Length < 3)
                {
                    // someone messed with the config file >:(
                    FG_IP     = "0.0.0.0";
                    OSCOPE_IP = "0.0.0.0"; // set to default IP
                }
                else
                {
                    FG_IP     = configInput[1].Substring(5); // get the actual IP strings from config file
                    OSCOPE_IP = configInput[2].Substring(5);
                }
            }
            IPInputWindow IPWindow = new IPInputWindow();

            IPWindow.FunctionGenIPInputBox.Text  = FG_IP;
            IPWindow.OscilloscopeIPInputBox.Text = OSCOPE_IP;
            IPWindow.ShowDialog();
            FG_IP     = IPWindow.FunctionGenIPInputBox.Text;
            OSCOPE_IP = IPWindow.OscilloscopeIPInputBox.Text;                                                         // get the results after the user clicked okay

            File.WriteAllText("enet.cfg", "#Saved IP Addresses, do not edit\nFGIP=" + FG_IP + "\nOSIP=" + OSCOPE_IP); // write the user's specified IP addresses
            // to the file, where they can be read from again.
            string             FG_VISA     = "TCPIP0::" + FG_IP + "::inst0::INSTR";                                   // generate the two VISA ids for devices at the given IP addresses
            string             OSCOPE_VISA = "TCPIP0::" + OSCOPE_IP + "::inst0::INSTR";
            IOscilloscope      tempScope   = VISAOscilloscope.TryOpen(OSCOPE_VISA);
            IFunctionGenerator tempFG      = VISAFunctionGenerator.TryOpen(FG_VISA); // attempt to open the devices at the specified IP addresses

            if (tempFG == null)
            {
                MessageBoxResult result = MessageBox.Show("Error: Could not open function generator at " + FG_IP,
                                                          appName, MessageBoxButton.OK);
                switch (result)
                {
                case MessageBoxResult.OK: // there's only one case
                    ExitAll();            // let the user try again without exiting probably, but we'll do that logic in a sec
                    return;
                }
            }
            if (tempScope == null)
            {
                MessageBoxResult result = MessageBox.Show("Error: Could not open oscilloscope at " + OSCOPE_IP,
                                                          appName, MessageBoxButton.OK);
                switch (result)
                {
                case MessageBoxResult.OK: // there's only one case
                    ExitAll();            // let the user try again without exiting probably, but we'll do that logic in a sec
                    return;
                }
            }
            // if we made it down here, both the scope and function generator are initialized, so we can set the global variables and return from this function
            fg    = tempFG;
            scope = tempScope;
            // yay!
        }