Beispiel #1
0
 static public void ReviewProjectResources(string projectGUID)
 {
     SettingsContent.UpdateSettingsPath();
     ProjectsManager.ResetProjectManager();
     PackagesManager.ResetPackageManager();
     ProjectsManager.UpdateProjectItem();
     PackagesManager.UpdatePackageList();
     ProjectsManager.LoadProjectFile(ProjectsManager.projectList.projectFilePath[ProjectsManager.projectList.projectID.IndexOf(projectGUID)]);
     PackagesManager.LoadPackageFile(ProjectsManager.projectInfo.packageGUID);
     GraphicOptionsManager.LoadGraphicOptionsFile(ProjectsManager.projectInfo.simulatorOptionsFilePath);
     LoadTrainData(PackagesManager.packageInfo.packageTrainDir);
     PackagesManager.packageInfo.trainDetailInfoLoaded = false;
     LoadRouteData(PackagesManager.packageInfo.packageRouteDir);
     PackagesManager.packageInfo.routeDetailInfoLoaded = false;
 }
Beispiel #2
0
        static public bool UpdatePackageList()
        {
            bool retValue = false;

            try
            {
                //Clear package list
                packageList.packageCount = 0;
                packageList.packageDefineFilePath.Clear();
                packageList.packageGUID.Clear();
                packageList.packageName.Clear();
                //Update
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo  boardPath      = new DirectoryInfo(SettingsContent.packagePath);
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                foreach (DirectoryInfo subDirectory in boardPath.GetDirectories())
                {
                    FileInfo[] packageDefinieFiles = subDirectory.GetFiles();
                    foreach (FileInfo fileName in packageDefinieFiles)
                    {
                        if (fileName.Extension == SettingsContent.universalFileExtName)
                        {
                            string packageDefineFilePath = fileName.FullName;
                            settingsFileIO.SetSettingsFilePath(packageDefineFilePath);
                            if (settingsFileIO.GetFileType() == SettingsContent.FileType.RESPACK)
                            {
                                //MessageBox.Show(packageDefineFilePath);
                                packageList.packageCount++;
                                packageList.packageDefineFilePath.Add(packageDefineFilePath);
                                packageList.packageGUID.Add(settingsFileIO.ReadValue(packageInfoSection, "packageguid"));
                                packageList.packageName.Add(settingsFileIO.ReadValue(packageInfoSection, "name"));
                            }
                            settingsFileIO.Dispose();
                        }
                    }
                }
            }
            catch (Exception) { };
            return(retValue);
        }
Beispiel #3
0
        static public bool UpdateProjectItem()
        {
            bool retValue = false;

            try
            {
                //Clear project list
                projectList.projectCount = 0;
                projectList.projectFilePath.Clear();
                projectList.projectID.Clear();
                projectList.projectName.Clear();
                projectList.projectDescribe.Clear();
                projectList.projectDebug.Clear();
                //Update
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo projectPath = new DirectoryInfo(SettingsContent.projectLibPath);
                foreach (DirectoryInfo subDirectory in projectPath.GetDirectories())
                {
                    FileInfo[]     projectFiles   = subDirectory.GetFiles();
                    SettingsFileIO settingsFileIO = new SettingsFileIO();
                    foreach (FileInfo fileName in projectFiles)
                    {
                        if (fileName.Extension == SettingsContent.projectFileExtName)
                        {
                            settingsFileIO.SetSettingsFilePath(fileName.FullName);
                            projectList.projectCount++;
                            projectList.projectFilePath.Add(fileName.FullName);
                            projectList.projectID.Add(settingsFileIO.ReadValue(projectSection, "project_id"));
                            projectList.projectName.Add(settingsFileIO.ReadValue(projectSection, "project_name"));
                            projectList.projectDescribe.Add(settingsFileIO.ReadValue(projectSection, "project_describle"));
                            projectList.projectDebug.Add(Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(projectSection, "project_debug"))));
                            settingsFileIO.Dispose();
                        }
                    }
                }
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }
Beispiel #4
0
        static public bool UpdateBoardItems()
        {
            bool retValue = false;

            try
            {
                //Clear boardList
                boardList.boardCount = 0;
                boardList.boardFilePath.Clear();
                boardList.boardID.Clear();
                boardList.boardName.Clear();
                //Update
                SettingsContent.UpdateSettingsPath();
                DirectoryInfo  boardPath      = new DirectoryInfo(SettingsContent.boardPath);
                FileInfo[]     boardFiles     = boardPath.GetFiles();
                SettingsFileIO settingsFileIO = new SettingsFileIO();
                foreach (FileInfo fileName in boardFiles)
                {
                    if (fileName.Extension == SettingsContent.universalFileExtName)
                    {
                        settingsFileIO.SetSettingsFilePath(fileName.FullName);
                        if (settingsFileIO.GetFileType() == SettingsContent.FileType.BOARD)
                        {
                            boardList.boardCount++;
                            boardList.boardFilePath.Add(fileName.FullName);
                            boardList.boardID.Add(Int32.Parse(settingsFileIO.ReadValue(boardInfoSection, "board_id")));
                            boardList.boardName.Add(settingsFileIO.ReadValue(boardInfoSection, "board_name"));
                        }
                        settingsFileIO.Dispose();
                    }
                }
                retValue = true;
            }
            catch (Exception) { };
            return(retValue);
        }
Beispiel #5
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);
            };
        }