static public bool SetupDataServer()
        {
            bool retValue = false;

            try
            {
                if (!projectInfo.fileLoaded)
                {
                    retValue = false;
                    return(retValue);
                }
                CommunicationNetwork.SetupWebSocketServer(projectInfo.projectDataServer);
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }
Exemple #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);
            };
        }