예제 #1
0
        static public bool SetupBoard()
        {
            bool retValue = false;

            try
            {
                BoardsManager.UpdateBoardItems();
                if (!projectInfo.fileLoaded || BoardsManager.boardList.boardID.IndexOf(projectInfo.boardID) == -1)
                {
                    retValue = false;
                    return(retValue);
                }
                BoardsManager.LoadBoardFile(BoardsManager.boardList.boardFilePath[BoardsManager.boardList.boardID.IndexOf(projectInfo.boardID)]);
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }
예제 #2
0
        static public void ProjectLoaderProcess(LoadingState processValue)
        {
            try
            {
                switch (processValue)
                {
                case LoadingState.WAIT_FOR_START:
                {
                    ProcessEvent(LoadingState.READY);
                    break;
                }

                case LoadingState.READY:
                {
                    //reset data
                    BoardsManager.ResetBoardManager();
                    ControlObjects.ResetControlObjects();
                    CommunicationSerial.ResetSerial();
                    DataManager.ResetTrainData();
                    PackagesManager.ResetPackageManager();
                    GraphicOptionsManager.ResetGraphicOptionsManager();
                    UserInterfaceSwap.errorContent.Clear();
                    RProxy.SimWorldTrigger.ResetTrigger();
                    ProcessEvent(LoadingState.DATA_RESET);
                    break;
                }

                case LoadingState.DATA_RESET:
                {
                    //update list
                    SettingsContent.UpdateSettingsPath();
                    BoardsManager.UpdateBoardItems();
                    ControlObjects.UpdateControlObjectsItem();
                    ProjectsManager.UpdateProjectItem();
                    PackagesManager.UpdatePackageList();
                    ProcessEvent(LoadingState.DATA_UPDATED);
                    break;
                }

                case LoadingState.DATA_UPDATED:
                {
                    //get project define file path
                    int fileIndex = ProjectsManager.projectList.projectID.IndexOf(projectGUIDValue);
                    projectFilePath = ProjectsManager.projectList.projectFilePath[fileIndex];
                    projectDirPath  = Path.GetDirectoryName(projectFilePath);
                    //load project define file
                    ProjectsManager.LoadProjectFile(projectFilePath);
                    ProjectsManager.SetupBoard();
                    ProjectsManager.SetupControlObjects();
                    DevicesManager.UpdateDevicesInitMode();
                    CommunicationSerial.InitializeSerial();
                    ProcessEvent(LoadingState.PROJECT_DEFINE_LOADED);
                    break;
                }

                case LoadingState.PROJECT_DEFINE_LOADED:
                {
                    //load package
                    PackagesManager.LoadPackageFile(ProjectsManager.projectInfo.packageGUID);
                    ProcessEvent(LoadingState.PACKAGE_DEFINE_LOADED);
                    break;
                }

                case LoadingState.PACKAGE_DEFINE_LOADED:
                {
                    //load train
                    PackagesManager.packageInfo.trainDetailInfoLoaded = false;
                    LoadTrainData(PackagesManager.packageInfo.packageTrainDir);
                    ProcessEvent(LoadingState.TRAIN_LOADED);
                    break;
                }

                case LoadingState.TRAIN_LOADED:
                {
                    //load route
                    PackagesManager.packageInfo.routeDetailInfoLoaded = false;
                    routeLoadingStateMonitor.AttachMainTimerInterrupt();
                    routeLoadingStateMonitor.MainTimerEnable = true;
                    LoadRouteData(PackagesManager.packageInfo.packageRouteDir);
                    break;
                }

                case LoadingState.ROUTE_LOADED:
                {
                    //load options
                    GraphicOptionsManager.LoadGraphicOptionsFile(ProjectsManager.projectInfo.simulatorOptionsFilePath);
                    GraphicOptionsLoaderEvent(GraphicOptionsManager.graphicOptionsValue);
                    ProcessEvent(LoadingState.SIM_OPTIONS_LOADED);
                    break;
                }

                case LoadingState.SIM_OPTIONS_LOADED:
                {
                    //check error
                    UserInterfaceSwap.errorContent = ProjectsManager.CheckProjectContent();
                    ProcessEvent(LoadingState.DATA_SERVER_START);
                    break;
                }

                case LoadingState.DATA_SERVER_START:
                {
                    //starting server
                    ProjectsManager.SetupDataServer();
                    ProcessEvent(LoadingState.DONE);
                    break;
                }

                case LoadingState.DONE:
                {
                    CommunicationNetwork.StartWebSocketServer();
                    StartSimulatorEvent();
                    break;
                }
                }
            }
            catch (Exception)
            {
                ProcessEvent(LoadingState.ERROR);
            };
        }
예제 #3
0
        static public List <ProjectErrorProvider> CheckProjectContent()
        {
            List <ProjectErrorProvider> retValue = new List <ProjectErrorProvider>();

            try
            {
                retValue.Clear();
                //Check board
                BoardsManager.UpdateBoardItems();
                if (BoardsManager.boardList.boardID.IndexOf(projectInfo.boardID) == -1)
                {
                    ProjectErrorProvider tempError = new ProjectErrorProvider
                    {
                        errorType  = ErrorType.ERROR,
                        errorTitle = "当前本地主控板库无项目所使用主控板定义。",
                        errorCode  = 100
                    };
                    retValue.Add(tempError);
                }
                //Check board version
                if (BoardsManager.boardInfo.boardSupprtVersion > SettingsContent.simulatorVersion)
                {
                    ProjectErrorProvider tempError = new ProjectErrorProvider
                    {
                        errorType  = ErrorType.WARNING,
                        errorTitle = "当前主控板支持模拟器版本(" +
                                     BoardsManager.boardInfo.boardSupprtVersion.ToString() +
                                     "),可能不兼容当前模拟器版本(" + SettingsContent.simulatorVersion.ToString() + ")。",
                        errorCode = 101
                    };
                    retValue.Add(tempError);
                }
                //Check project support version
                if (ProjectsManager.projectInfo.projectSimulatorSupportVersion != SettingsContent.simulatorVersion)
                {
                    ProjectErrorProvider tempError = new ProjectErrorProvider
                    {
                        errorType  = ErrorType.WARNING,
                        errorTitle = "当前行车计划支持模拟器版本(" +
                                     ProjectsManager.projectInfo.projectSimulatorSupportVersion.ToString() +
                                     "),可能不兼容当前模拟器版本(" + SettingsContent.simulatorVersion.ToString() + ")。",
                        errorCode = 102
                    };
                    retValue.Add(tempError);
                }
                //Check platform
                if (ProjectsManager.projectInfo.projectPlatform.ToUpper() != SettingsContent.simulatorVerification.ToUpper())
                {
                    ProjectErrorProvider tempError = new ProjectErrorProvider
                    {
                        errorType  = ErrorType.ERROR,
                        errorTitle = "当前行车计划模拟器平台(" +
                                     ProjectsManager.projectInfo.projectPlatform +
                                     "),不兼容当前模拟器平台(" + SettingsContent.simulatorVerification + ")。",
                        errorCode = 103
                    };
                    retValue.Add(tempError);
                }
                //Check serial
                foreach (SerialPort serialPort in CommunicationSerial.serialList)
                {
                    if (CommunicationSerial.GetSerialPortNames().IndexOf(serialPort.PortName) == -1)
                    {
                        ProjectErrorProvider tempError = new ProjectErrorProvider
                        {
                            errorType  = ErrorType.ERROR,
                            errorTitle = "当前系统未与端口为“" + serialPort.PortName + "”的设备建立硬件连接。",
                            errorCode  = 104
                        };
                        retValue.Add(tempError);
                    }
                }
                //Check control objects step
                for (int i = 0; i < ControlObjects.controlObjectsCount; i++)
                {
                    if (!ControlObjects.controlObjectsInfo[i].objectSetEnable && !ControlObjects.controlObjectArrange[i].objectEnable)
                    {
                        ProjectErrorProvider tempError = new ProjectErrorProvider
                        {
                            errorType  = ErrorType.ERROR,
                            errorTitle = "必要操作对象“" + ControlObjects.controlObjectsInfo[i].objectName + "”未在项目中定义。",
                            errorCode  = 105
                        };
                        retValue.Add(tempError);
                    }
                    if (ControlObjects.controlObjectArrange[i].objectEnable)
                    {
                        if (ControlObjects.controlObjectArrange[i].objectIO.Count != ControlObjects.controlObjectsInfo[i].objectIOCount)
                        {
                            ProjectErrorProvider tempError = new ProjectErrorProvider
                            {
                                errorType  = ErrorType.ERROR,
                                errorTitle = "操作对象“" + ControlObjects.controlObjectsInfo[i].objectName + "”未完全配置。",
                                errorCode  = 106
                            };
                            retValue.Add(tempError);
                        }
                        if (ControlObjects.controlObjectsInfo[i].objectIOMode[0] == DevicesManager.DevicesIOMode.DEVICE_SERIAL)
                        {
                            if (!(ControlObjects.controlObjectArrange[i].objectIO[0] is string) ||
                                ControlObjects.controlObjectArrange[i].objectIOSerialBaud == 0 ||
                                ControlObjects.controlObjectArrange[i].objectIOSerialID == 0)
                            {
                                ProjectErrorProvider tempError = new ProjectErrorProvider
                                {
                                    errorType  = ErrorType.ERROR,
                                    errorTitle = "操作对象“" + ControlObjects.controlObjectsInfo[i].objectName + "”存在配置错误。",
                                    errorCode  = 107
                                };
                                retValue.Add(tempError);
                            }
                        }
                    }
                }
            }
            catch (Exception) { };
            return(retValue);
        }