Exemplo n.º 1
0
        static public ProjectInfo ReadProjectInfo(string projectFilePath)
        {
            ProjectInfo    retValue       = new ProjectInfo();
            SettingsFileIO settingsFileIO = new SettingsFileIO();

            try
            {
                retValue.controlObjectID.Clear();
                retValue.controlObjectPara.Clear();
                retValue.controlObjectSerialBaudRate.Clear();
                settingsFileIO.SetSettingsFilePath(projectFilePath);
                //Load project
                retValue.projectName     = settingsFileIO.ReadValue(projectSection, "project_name");
                retValue.projectID       = settingsFileIO.ReadValue(projectSection, "project_id");
                retValue.projectDescribe = settingsFileIO.ReadValue(projectSection, "project_describle");
                retValue.projectVersion  = new Version(settingsFileIO.ReadValue(projectSection, "project_version"));
                retValue.projectSimulatorSupportVersion = new Version(settingsFileIO.ReadValue(projectSection, "project_simulator_support_version"));
                retValue.projectAuthor        = settingsFileIO.ReadValue(projectSection, "project_author");
                retValue.projectAuthorWebsite = settingsFileIO.ReadValue(projectSection, "project_author_website");
                retValue.projectPlatform      = settingsFileIO.ReadValue(projectSection, "project_platform");
                retValue.projectDebug         = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(projectSection, "project_debug")));
                retValue.projectDataServer    = settingsFileIO.ReadValue(projectSection, "project_data_server");
                //Load board
                retValue.boardID         = Int32.Parse(settingsFileIO.ReadValue(boardSection, "board_id"));
                retValue.boardPort       = settingsFileIO.ReadValue(boardSection, "board_port");
                retValue.deviceUsedCount = Int32.Parse(settingsFileIO.ReadValue(boardSection, "devices_used"));
                //Load package
                retValue.packageGUID = settingsFileIO.ReadValue(packageSection, "package_id");
                //Load simulator_options
                string projectDir = Path.GetDirectoryName(projectFilePath);
                retValue.simulatorOptionsFilePath = Path.GetFullPath(projectDir + "\\" + settingsFileIO.ReadValue(simulatorOptionsSection, "option_file"));
                //Load record
                retValue.recorderFilePath = Path.GetFullPath(projectDir + "\\" + settingsFileIO.ReadValue(recordSection, "recorder"));
                retValue.recordDir        = Path.GetFullPath(projectDir + "\\" + settingsFileIO.ReadValue(recordSection, "record_dir"));
                try
                {
                    //Load Q&A
                    retValue.QAData = new SAGATManager.QAManagerData();
                    retValue.QAData.Clear();
                    retValue.QAData.questionAnswerEnable = Convert.ToBoolean(Int32.Parse(settingsFileIO.ReadValue(questionAnswerSection, "question_answer_enable")));
                    if (retValue.QAData.questionAnswerEnable)
                    {
                        retValue.QAData.questionAnswerCount    = Int32.Parse(settingsFileIO.ReadValue(questionAnswerSection, "question_answer_count"));
                        retValue.QAData.questionAnswerSavePath = Path.GetFullPath(projectDir + "\\" + settingsFileIO.ReadValue(questionAnswerSection, "question_answer_save_path"));
                        retValue.QAData.questionAnswers.Clear();
                        for (int i = 0; i < retValue.QAData.questionAnswerCount; i++)
                        {
                            string sectionName = questionAnswerListSction + i.ToString();
                            SAGATManager.QAManagerData.QuestionAnswer questionAnswer = new SAGATManager.QAManagerData.QuestionAnswer();
                            questionAnswer.pauseDistance = Double.Parse(settingsFileIO.ReadValue(sectionName, "pause_distance"));
                            questionAnswer.questionCount = Int32.Parse(settingsFileIO.ReadValue(sectionName, "question_count"));
                            questionAnswer.questionAnswerItems.Clear();
                            for (int j = 0; j < questionAnswer.questionCount; j++)
                            {
                                SAGATManager.QAManagerData.QuestionAnswer.QuestionAnswerItem questionAnswerItem = new SAGATManager.QAManagerData.QuestionAnswer.QuestionAnswerItem();
                                questionAnswerItem.questionTimer = Int32.Parse(settingsFileIO.ReadValue(sectionName, "question" + j.ToString() + "_timer"));
                                questionAnswerItem.questionTitle = settingsFileIO.ReadValue(sectionName, "question" + j.ToString() + "_title");
                                questionAnswerItem.questionDesc  = settingsFileIO.ReadValue(sectionName, "question" + j.ToString() + "_describle");
                                questionAnswerItem.questionMode  = (SAGATManager.QAManagerData.QuestionMode)Int32.Parse(settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_mode"));
                                questionAnswerItem.selectionText.Clear();
                                if (questionAnswerItem.questionMode == SAGATManager.QAManagerData.QuestionMode.TEXT_INPUT)
                                {
                                    questionAnswerItem.textboxType = (SAGATManager.QAManagerData.TextboxType)Int32.Parse(settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_textbox_type"));
                                }
                                else if (questionAnswerItem.questionMode == SAGATManager.QAManagerData.QuestionMode.SELECT)
                                {
                                    questionAnswerItem.selectionCount = Int32.Parse(settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_selection_count"));
                                    for (int k = 0; k < questionAnswerItem.selectionCount; k++)
                                    {
                                        questionAnswerItem.selectionText.Add(settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_selection" + k.ToString() + "_text"));
                                    }
                                }
                                questionAnswerItem.submitButtonText = settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_submit_button_text");
                                questionAnswerItem.correctValue     = settingsFileIO.ReadValue(sectionName, "answer" + j.ToString() + "_correct_value");
                                questionAnswer.questionAnswerItems.Add(questionAnswerItem);
                            }
                            retValue.QAData.questionAnswers.Add(questionAnswer);
                        }
                    }
                }
                catch (Exception) { };
                //Load control_objects
                retValue.controlObjectsUsed = Int32.Parse(settingsFileIO.ReadValue(controlObjectsSection, "control_objects_used"));
                retValue.controlObjectID.Clear();
                retValue.controlObjectPara.Clear();
                retValue.controlObjectSerialBaudRate.Clear();
                //Load object setup
                for (int i = 0; i < retValue.controlObjectsUsed; i++)
                {
                    retValue.controlObjectID.Add(Int32.Parse(settingsFileIO.ReadValue(objectProtocolSection + i.ToString(), "object_id")));
                    if (ControlObjects.controlObjectsInfo[retValue.controlObjectID[i]].objectIOMode[0] == DevicesManager.DevicesIOMode.DEVICE_SERIAL)
                    {
                        retValue.controlObjectPara.Add(settingsFileIO.ReadValue(objectProtocolSection + i.ToString(), "object_device_para"));
                        retValue.controlObjectSerialBaudRate.Add(Int32.Parse(settingsFileIO.ReadValue(objectProtocolSection + i.ToString(), "object_baudrate")));
                    }
                    else
                    {
                        List <object> tempPara = new List <object>();
                        tempPara = settingsFileIO.ReadVectorValue(objectProtocolSection + i.ToString(), "object_device_para").ConvertAll <object>(x => (object)x);
                        retValue.controlObjectPara.Add(tempPara);
                        retValue.controlObjectSerialBaudRate.Add(-1);
                    }
                }
                settingsFileIO.Dispose();
            }
            catch (Exception) { };
            settingsFileIO.Dispose();
            return(retValue);
        }
Exemplo n.º 2
0
 void ShowQAFormEvent(SAGATManager.QAManagerData.QuestionAnswer currentQuestionAnswer, int currentQASubItemID)
 {
     questionAnswer = currentQuestionAnswer;
     QASubItemID    = currentQASubItemID;
 }