コード例 #1
0
ファイル: frmMeasureMain.cs プロジェクト: kse-jp/RM-3000
        /// <summary>
        /// 測定ステータス変更イベント
        /// </summary>
        /// <param name="status"></param>
        private void MeasureStatusChangedCallback(frmMeasureController.MeasureStatus status)
        {
            System.Threading.Thread Methodth = null;
            try
            {
                switch (status)
                {
                    case frmMeasureController.MeasureStatus.Start:      // 測定開始

                        //for (int i = 0; i < this.graph2DList.Length; i++)
                        //{
                        //    if (this.graph2DList[i] != null)
                        //    {
                        //        this.graph2DList[i].IsRealTime = true;
                        //    }
                        //}

                        if (this.systemSetting.IsSimulationMode)
                        {
                            // シミュレーション開始
                            if (this.measSetting.Mode == 1)
                            {
                                RealTimeData.StartSimulatorMode(1);
                            }
                            else if (this.measSetting.Mode == 2)
                            {
                                RealTimeData.StartSimulatorMode(2);
                            }
                            else if (this.measSetting.Mode == 3)
                            {
                                RealTimeData.StartSimulatorMode(3);
                            }
                        }
                        else
                        {
                            if (bAllReadyStart)
                            {
                                //Methodth = new System.Threading.Thread();
                                //測定開始処理
                                testSquence.ResumeTest();
                            }
                            else
                            {
                                //測定開始処理
                                testSquence.StartTest();
                            }
                        }

                        //Simulatorモードならば開始状態処理をここにいれる。
                        if (this.systemSetting.IsSimulationMode)
                        {
                            if (!bAllReadyStart)
                            {
                                //時間設定
                                RealTimeData.SetStartTime(DateTime.Now);
                            }

                            RealTimeData.Cond_StartTime_Mode1 = RealTimeData.GetStartTime();
                            RealTimeData.Cond_StopTime_Mode1 = RealTimeData.GetStartTime();
                            RealTimeData.bMode1_Now_Record = true;

                            bAllReadyStart = true;

                            this.measureTask.Start();

                            this.swMeasure.Reset();
                            this.swMeasure.Start();

                            ShowStatusMessage(AppResource.GetString("TXT_MEASURE_START"));
                        }
                        break;

                    case frmMeasureController.MeasureStatus.Stop:       // 測定停止

                        if (this.systemSetting.IsSimulationMode)
                        {
                            RealTimeData.StopSimulator();

                            ////Simulatorモードならばここで後処理をする
                            //for (int i = 0; i < this.graph2DList.Length; i++)
                            //{
                            //    if (this.graph2DList[i] != null)
                            //    {
                            //        this.graph2DList[i].IsRealTime = false;
                            //    }
                            //}
                            ShowStatusMessage(AppResource.GetString("MSG_MEAS_STOP_TEST"));
                            this.measureTask.Pause();

                            ////測定設定ファイル群及びデータファイルを保存する
                            //SaveMeasureFiles();
                        }
                        else
                        {
                            //測定停止処理
                            testSquence.StopTest();
                        }

                        break;

                    case frmMeasureController.MeasureStatus.Exit:       // 終了

                        if (!this.systemSetting.IsSimulationMode)
                        {
                            if (testSquence.TestStatus == Sequences.TestSequence.TestStatusType.Stop)
                            {
                                //既に測定は停止しているため、強制的に停止した事にする。
                                testSquence_StatusChanged(Sequences.TestSequence.TestStatusType.Stop);
                            }
                            else
                            {
                                //測定終了処理
                                if (!testSquence.EndTest())
                                {
                                    //停止処理が失敗しても終了として処理を行う
                                    testSquence.TestStatus = Sequences.TestSequence.TestStatusType.Stop;
                                }
                            }
                        }
                        else
                        {
                            bool bret = true;

                            //Simulatorモードならばここで終了
                            RealTimeData.EndData();
                            this.measureTask.Pause();

                            //データが一つでも受信されていればデータ保存する。
                            if (RealTimeData.receiveCount != 0)
                            {
                                ShowStatusMessage(AppResource.GetString("MSG_MEAS_SAVE_FILES"));
                                // 測定設定ファイル群及びデータファイルを保存する
                                bret = SaveMeasureFiles();
                            }

                            if (bret)
                            {
                                //測定終了後処理
                                testSquence.ExitTest();

                                //測定完了フラグオン
                                bMeasureClosed = true;
                                //画面終了
                                this.Close();
                            }
                            else
                            {
                                //リアルタイム保存の再開
                                RealTimeData.ResumeData();
                            }
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
コード例 #2
0
ファイル: frmMeasureMain.cs プロジェクト: kse-jp/RM-3000
        /// <summary>
        /// フォームロードイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMeasureMain_Load(object sender, EventArgs e)
        {
            if (this.log != null) this.log.PutLog("frmMeasureMain.frmMeasureMain_Load() - 測定中画面のロードを開始しました。");

            try
            {
                RealTimeData.DataTagSetting = (DataTagSetting)SystemSetting.DataTagSetting.Clone();
                // 言語切替
                AppResource.SetControlsText(this);

                // 測定設定ファイル読み込み
                var xmlFilePath = CommonLib.SystemDirectoryPath.SystemPath + MeasureSetting.FileName;
                if (System.IO.File.Exists(xmlFilePath))
                {
                    this.measSetting = (MeasureSetting)MeasureSetting.Deserialize(xmlFilePath);
                }
                else
                {
                    MessageBox.Show(AppResource.GetString("ERROR_MEASURE_SETTING_FILE_NOT_FOUND"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                    return;
                }

                // 2Dグラフの設定
                for (int i = 0; i < this.graph2DList.Length; i++)
                {
                    if (this.measSetting.GraphSettingList.Length <= i) break;

                    if (this.measSetting.GraphSettingList[i].IsValid)
                    {
                        this.graph2DList[i] = new frmGraph2D(this.log, i) { MdiParent = this, CurrentValueLineChanged = Graph2DCurrentValueLineChanged, FormHidden = Graph2DFormHidden };
                        this.graph2DList[i].Resize += new EventHandler(this.graph_Resize);
                        this.graph2DList[i].FormClosed += new FormClosedEventHandler(this.graph2D_FormClosed);
                    }
                }

                // 各種表示フォームの設定
                this.tagValueListForm = new frmTagValueList(this.log) { MdiParent = this, Top = 80, Left = 0 };
                this.controllerForm = new frmMeasureController(this.log) { MdiParent = this, Top = 0, Left = 0, MeasureStatusChanged = MeasureStatusChangedCallback, Mode = this.measSetting.Mode };
                this.measInfoForm = new frmMeasureInfo(this.log) { MdiParent = this, Top = 0, Left = 1000, MeasSetting = this.measSetting };
                this.graphControllerForm = new frmGraphController(this.log) { MdiParent = this, Left = 0, Mode = this.measSetting.Mode, GraphFormList = this.graph2DList, GraphZoomInOccurred = this.Graph2DZoomIn, GraphZoomOutOccurred = this.Graph2DZoomOut, GraphArrangeOccurred = this.Graph2DArrange };

                // 測定データ収集タスク
                this.measureTask = new MeasureDataTask(this.log);
                this.measureTask.GotCondition += new MeasureDataTask.GotConditionDelegate(this.GotCondition);
                this.measureTask.DataReceived += new MeasureDataTask.DataReceivedDelegate(this.SetMeasureData);
                this.measureTask.DataReceived += new MeasureDataTask.DataReceivedDelegate(this.tagValueListForm.SetMeasureData);
                for (int i = 0; i < this.graph2DList.Length; i++)
                {
                    if (this.graph2DList[i] != null)
                    {
                        this.measureTask.DataReceived += new MeasureDataTask.DataReceivedDelegate(this.graph2DList[i].SetMeasureData);
                    }
                }

                ArrangeGraphForms();
                SetMaximumGraphArea(null);

                // 測定処理クラス初期化
                testSquence.InitPreMeasure(true);
                ShowStatusMessage(AppResource.GetString("MSG_MEAS_INIT"));
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }

            if (this.log != null) this.log.PutLog("frmMeasureMain.frmMeasureMain_Load() - 測定中画面のロードを終了しました。");
        }