Exemple #1
0
 private void FormController_Load(object sender, EventArgs e)
 {
     //Load theme
     themeApplier.SetStyle(menuStripMain, WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender.VsVersion.Vs2015, mainTheme);
     if (!UserInterfaceSwap.showFormController)
     {
         this.Left            = 1;
         this.FormBorderStyle = FormBorderStyle.None;
         this.ShowInTaskbar   = false;
         this.Opacity         = 0;
         this.TopMost         = false;
         this.Hide();
     }
     else
     {
         this.Left    = 1;
         this.TopMost = true;
     }
     labelPlanName.Text = "已加载的行车计划:" + RPlatform.ProjectsManager.projectInfo.projectName;
     try
     {
         UserInterfaceSwap.formControllerLeft   = this.Left;
         UserInterfaceSwap.formControllerTop    = this.Top;
         UserInterfaceSwap.formControllerHeight = this.Height;
         UserInterfaceSwap.formControllerWidth  = this.Width;
         textBoxDebugStream.Enabled             = false;
         buttonSendDebugStream.Enabled          = false;
         UpdateButtonEnableState();
         RProxy.SimWorldTrigger.InitTriggerTimer();
         RStatistics.SAGATManager.AttachToTrigger();
         RPlatform.ControlObjects.AttachToTrigger();
         SimCoreClient.AttachToTrigger();
         SimCoreClient.EnableTriggerClient();
         timerEvents.Enabled            = true;
         timerStreamTextUpdater.Enabled = true;
     }
     catch (Exception) { };
 }
Exemple #2
0
 private void menItemContinue_Click(object sender, EventArgs e)
 {
     SimCoreClient.PauseSimulator(false);
 }
Exemple #3
0
 private void menItemPause_Click(object sender, EventArgs e)
 {
     SimCoreClient.PauseSimulator(true);
 }
Exemple #4
0
 private void MenItemRestart_Click(object sender, EventArgs e)
 {
     SimCoreClient.RestartSimulator(RPlatform.SettingsContent.simulatorExcuteFileName, RPlatform.SettingsContent.simulatorUIMode);
 }
Exemple #5
0
        private void TimerEvents_Tick(object sender, EventArgs e)
        {
            timerEvents.Enabled = false;
            try
            {
                labelServerAddress.Text = "嵌入式数据服务器地址:" + RPlatform.CommunicationNetwork.dataServerAddress + " 已连接客户端数量:" +
                                          RPlatform.CommunicationNetwork.GetClientSocketCount().ToString();

                if (boardConnection)
                {
                    buttonBoardConnection.Text = "主板强制断开";
                }
                else
                {
                    buttonBoardConnection.Text = "主板连接保持";
                }
                try
                {
                    if (!RPlatform.CommunicationSerial.serialList[0].IsOpen)
                    {
                        checkBoxStreamDebugEnable.Enabled = false;
                        checkBoxStreamDebugEnable.Checked = false;
                        textBoxDebugStream.Text           = string.Empty;
                        textBoxDebugStream.Enabled        = false;
                        buttonSendDebugStream.Enabled     = false;
                    }
                    else
                    {
                        checkBoxStreamDebugEnable.Enabled = true;
                    }
                }
                catch (Exception) { };

                //Main-form Monitor 240ms
                try
                {
                    findSimualtorWindowTick++;
                    if (findSimualtorWindowTick > 2)
                    {
                        findSimualtorWindowTick = 0;
                        bool simulatorWindowState = SimCoreClient.IsSimulatorInRunning("RAGLINK+");
                        if (!simulatorWindowState && simulatorWindowHasOpened)
                        {
                            this.Close();
                        }
                        else if (simulatorWindowState)
                        {
                            simulatorWindowHasOpened = true;
                        }
                    }
                }
                catch (Exception) { };

                timerEvents.Enabled = true;

                if (!SimCoreClient.GetSimulatorState())
                {
                    buttonDataMonitor.Enabled  = false;
                    menItemDataMonitor.Enabled = false;
                    toolStripLabelMain.Text    = "模拟器载入中...";
                    labelSAGATState.Text       = "内部SAGAT系统状态:正在载入中...\n若加载外部SAGAT,此处将显示内部SAGAT系统未配置。";
                    timerEvents.Enabled        = true;
                    return;
                }

                buttonDataMonitor.Enabled  = true;
                menItemDataMonitor.Enabled = true;
                toolStripLabelMain.Text    = "就绪。";

                if (RPlatform.ProjectsManager.projectInfo.QAData.questionAnswerEnable)
                {
                    if (RStatistics.SAGATManager.GetCurrentTimerMode() == RStatistics.SAGATManager.TimerMode.WAIT_PAUSE)
                    {
                        labelSAGATState.Text = "内部SAGAT系统状态:共 " + RStatistics.SAGATManager.GetQACount().ToString() + " 个问询,已完成 " +
                                               RStatistics.SAGATManager.GetAnsweredCount().ToString() + " 个问询,\n当前轨道位置:" + RStatistics.SAGATManager.currentTrackDistanceFromStart.ToString("f1") +
                                               "m,距下一次问询轨道距离:" + ((RStatistics.SAGATManager.GetAnsweredCount() < RStatistics.SAGATManager.GetQACount()) ? ((RStatistics.SAGATManager.GetNextQuestion().pauseDistance - RStatistics.SAGATManager.currentTrackDistanceFromStart).ToString("f1") +
                                                                                                                                                           "m。") : "无。");
                    }
                    else if (RStatistics.SAGATManager.GetCurrentTimerMode() == RStatistics.SAGATManager.TimerMode.WAIT_ANSWER)
                    {
                        labelSAGATState.Text = "内部SAGAT系统状态:共 " + RStatistics.SAGATManager.GetQACount().ToString() + " 个问询,已完成 " +
                                               RStatistics.SAGATManager.GetAnsweredCount().ToString() + " 个问询,\n当前进行的问询项:" + RStatistics.SAGATManager.GetCurrentQuestionItem().questionTitle +
                                               ",问询项倒计时:" + (RStatistics.SAGATManager.GetCurrentQuestionItem().questionTimer - RStatistics.SAGATManager.GetCurrentWaitAnswerTime()).ToString() +
                                               "s。";
                    }
                }
                else
                {
                    labelSAGATState.Text = "内部SAGAT系统状态:未启用。\n未配置内部SAGAT或已加载外部SAGAT系统。";
                }

                if (applyDataInLoading == false)
                {
                    applyDataInLoading = true;
                    RPlatform.ControlObjects.ControlObjectDoEvents();
                    RPlatform.DataManager.ApplyTrainData();
                    RStatistics.SAGATManager.EnableTriggerClient();
                    RPlatform.ControlObjects.EnableTriggerClient();
                    SimCoreClient.SetupSimulatorLaunchTime();
                }

                UpdateLabels();

                //Try to re-connect if connection failed
                if (boardConnection && !RPlatform.CommunicationSerial.serialList[0].IsOpen)
                {
                    RPlatform.CommunicationSerial.SerialConnect(0);
                    if (RPlatform.CommunicationSerial.serialList[0].IsOpen)
                    {
                        RPlatform.CommunicationSerial.communicationStateList[0] = RPlatform.CommunicationSerial.CommunicationState.STATE1;
                    }
                }
                else if (!boardConnection)
                {
                    try
                    {
                        RPlatform.CommunicationSerial.serialList[0].Dispose();
                        RPlatform.CommunicationSerial.communicationStateList[0] = RPlatform.CommunicationSerial.CommunicationState.STATE0;
                        RPlatform.CommunicationSerial.dealWithBoardSerialStream = false;
                    }
                    catch (Exception) { };
                }
                for (int i = 1; i < RPlatform.CommunicationSerial.serialList.Count; i++)
                {
                    RPlatform.CommunicationSerial.SerialConnect(i);
                }
            }
            catch (Exception) { };
        }