private void RunSLTestCase() { SLTestWorkspace slTestWorkspace = (SLTestWorkspace)testWorkspace; CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand(); mainScriptCommand.LoadFromMatlabScript(templatePath + "\\SingleTestCaseRun.m"); mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath); mainScriptCommand.ReplaceInTemplate("[MiLTester_DsrdOutNo]", slTestCase.dsrdOutNo.ToString()); mainScriptCommand.ReplaceInTemplate("[MiLTester_DsrdTCNo]", slTestCase.dsrdTCNo.ToString()); mainScriptCommand.ReplaceInTemplate("[MiLTester_FilesDirectory]", slTestCase.filesDir); mainScriptCommand.ReplaceInTemplate("[MiLTester_TestSuiteFilepath]", slTestCase.testSuiteDir); mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString()); mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationStepTimesVal]", "0.01"); mainScriptCommand.ReplaceInTemplate("[MiLTester_ModelComltName]", testWorkspace.modelSettings.GetSimulinkModelNameWithNoExtension()); mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath); /*mainScriptCommand.ReplaceInTemplate("[MiLTester_InitialDesiredVal]", ccTestCase.initialDesired.ToString()); * mainScriptCommand.ReplaceInTemplate("[MiLTester_FinalDesiredVal]", ccTestCase.finalDesired.ToString()); * mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName); * mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName); * mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesNamesVar]", ccTestWorkspace.GetCalibrationVariableNamesStr()); * mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesValuesVal]", ccTestWorkspace.GetCalibrationVariableValuesStr());*/ mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m"); }
private bool CreateTestWorkSpace() { bool InvalidName = false; foreach (char c in tbWorkspaceName.Text) { if (Path.GetInvalidFileNameChars().Contains(c)) { InvalidName = true; break; } } if (InvalidName) { MessageBox.Show("The Test Workspace Name is Invalid! Select a name that can be used as the name of a Windows folder.", "Invalid Test Workspace Name", MessageBoxButtons.OK); tbWorkspaceName.Focus(); tbWorkspaceName.SelectAll(); return(false); } if (!TestWorkspaceDataProvider. GetTestWorkspaceDataProvider().IsWorkspaceNameUnique(tbWorkspaceName.Text)) { MessageBox.Show("The Test Workspace Name is Duplicate!", "Dupllicate Test Workspace Name", MessageBoxButtons.OK); return(false); } if (rbContinuousController.Checked) { testWorkspace = new CCTestWorkspace(tbWorkspaceName.Text); } else if (rbSimulink.Checked) { testWorkspace = new SLTestWorkspace(tbWorkspaceName.Text); } else { testWorkspace = new IOTestWorkspace(tbWorkspaceName.Text); } return(true); }
public ModelUnderTestSLSettings(SLTestWorkspace testWorkspace) { InitializeComponent(); this.testWorkspace = testWorkspace; parentSLSettingsForm = new ParentSLSettingsForm(this); parentSLSettingsForm.LoadSLSettings(((SLTestWorkspace)testWorkspace).slSettings); this.Controls.Add(parentSLSettingsForm); //////////////////////////////////// this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); for (int i = 0; i < testWorkspace.outputVariables.Count; ++i) { TestParameter outVar = ((SLTestWorkspace)testWorkspace).outputVariables[i]; cmbPortNums.Items.Add(outVar.blockInfo.blockPortNum); cmbPortNames.Items.Add(outVar.blockInfo.blockTag); } cmbPortNums.SelectedIndex = 0; tbTime.Text = "3600"; btnApply.Enabled = false; }
public override void RunAsync() { MatlabAsyncProgram.KillMatlab(); matlabAsyncProgram = new MatlabAsyncProgram(testWorkspace.modelSettings.MatlabExePath); SLTestWorkspace slTestWorkspace = (SLTestWorkspace)testWorkspace; //if (Directory.Exists(tempPath)) // Directory.Delete(tempPath,true); //Directory.CreateDirectory(tempPath); //File.Delete(outputLogPath); MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(slTestWorkspace.modelSettings); modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m"); CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand(); mainScriptCommand.LoadFromMatlabScript(templatePath + "\\SLTestGeneration\\SLTestGenerationRun.m"); mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath); mainScriptCommand.ReplaceInTemplate("[MiLTester_ModelComltName]", testWorkspace.modelSettings.GetSimulinkModelNameWithNoExtension()); mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.GetSimulinkModelDirectory()); mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m"); AsyncRunMainScript(); }
public CheckResultsForm(SLTestWorkspace slTestWorkspace, bool[] blocksChecks, bool[] paramsChecks) { InitializeComponent(); bool blockCheck = false; for (int i = 0; i < slTestWorkspace.staticChecksBlcoks.Count; ++i) { string checkType = ""; switch (slTestWorkspace.staticChecksBlcoks[i].staticCheckType) { case StaticCheckType.STOF: if (!blocksChecks[0]) { continue; } checkType = "Saturate on overflow not cechekd!"; blockCheck = true; break; case StaticCheckType.FNoG: if (!blocksChecks[1]) { continue; } checkType = "From without GoTo"; blockCheck = true; break; case StaticCheckType.GNoF: if (!blocksChecks[2]) { continue; } checkType = "GoTo without From"; blockCheck = true; break; case StaticCheckType.NoSigRes: if (!blocksChecks[3]) { continue; } checkType = "Signal not resolved"; blockCheck = true; break; case StaticCheckType.ParMultVal: if (!paramsChecks[0]) { continue; } checkType = "Parameter with Multiple Values"; blockCheck = false; break; case StaticCheckType.TblOneVal: if (!paramsChecks[1]) { continue; } checkType = "Table with one Value"; blockCheck = false; break; case StaticCheckType.TblAllTheSame: if (!paramsChecks[2]) { continue; } checkType = "Table with values all the same"; blockCheck = false; break; case StaticCheckType.HighLowConf: if (!paramsChecks[3]) { continue; } checkType = "High low conflict"; blockCheck = false; break; } string[] items = new string[3]; items[0] = checkType; items[1] = slTestWorkspace.staticChecksBlcoks[i].blockInfo.blockTag; items[2] = slTestWorkspace.staticChecksBlcoks[i].blockInfo.blockPath; ListViewItem listViewItem = new ListViewItem(items); if (blockCheck) { lvBlocksCheckResults.Items.Add(listViewItem); } else { lvParamsCheckResults.Items.Add(listViewItem); } } }
public SLTestWorkspaceResultsForm(SLTestWorkspace slTestWorkspace) { this.slTestWorkspace = slTestWorkspace; InitializeComponent(); InitValues(); }
private void LoadSBTestWorkspace(SLTestWorkspace sbTestWorkspace) { XmlReaderSettings xmlSettings = new XmlReaderSettings(); xmlSettings.ValidationType = ValidationType.None; string testWorkspaceName = sbTestWorkspace.ToString(); sbTestWorkspace.slSettings = SettingFilesManager.LoadSBSettings( GetWorkspacePath(testWorkspaceName)); sbTestWorkspace.advancedSBSettings = SettingFilesManager.LoadAdvancedSBSettings( GetWorkspacePath(testWorkspaceName)); XmlReader workspaceReader = XmlReader.Create( GetWorkspaceInfoFilePath(testWorkspaceName), xmlSettings); while (workspaceReader.Read()) { if (workspaceReader.NodeType == XmlNodeType.Element && workspaceReader.Name == "Parameter") { do { workspaceReader.Read(); }while (workspaceReader.Name != "Name"); workspaceReader.Read(); string paremeterName = workspaceReader.Value; do { workspaceReader.Read(); }while (workspaceReader.Name != "Type"); workspaceReader.Read(); ParameteresType paremeterType = (ParameteresType)Enum.Parse(typeof(ParameteresType), workspaceReader.Value, true); do { workspaceReader.Read(); }while (workspaceReader.Name != "From"); workspaceReader.Read(); float from = float.Parse(workspaceReader.Value); do { workspaceReader.Read(); }while (workspaceReader.Name != "To"); workspaceReader.Read(); float to = float.Parse(workspaceReader.Value); float valueForTest = 0; if (paremeterType != ParameteresType.OutputVariable) { do { workspaceReader.Read(); }while (workspaceReader.Name != "ValueForTest"); workspaceReader.Read(); valueForTest = float.Parse(workspaceReader.Value); } string dataType = ""; do { workspaceReader.Read(); }while (workspaceReader.Name != "DataType"); workspaceReader.Read(); dataType = workspaceReader.Value; if (paremeterType == ParameteresType.InputVariable) { sbTestWorkspace.AddInputVariable(new TestParameter(paremeterName, paremeterType, from, to, valueForTest, dataType)); } else if (paremeterType == ParameteresType.CalibrationVariable) { sbTestWorkspace.AddCalibrationVariable(new TestParameter(paremeterName, paremeterType, from, to, valueForTest, dataType)); } else if (paremeterType == ParameteresType.OutputVariable) { sbTestWorkspace.outputVariable = new TestParameter(paremeterName, paremeterType, from, to, dataType); } workspaceReader.Read(); } } workspaceReader.Close(); return; }
public TestWorkspace LoadTestWorkspace(string testWorkspaceName) { XmlReaderSettings xmlSettings = new XmlReaderSettings(); xmlSettings.ValidationType = ValidationType.None; XmlReader workspaceReader = XmlReader.Create( GetWorkspaceInfoFilePath(testWorkspaceName), xmlSettings); FunctionTypeEnum functionType = FunctionTypeEnum.Continuous_Controller; TestWorkspace testWorkspace = null; while (workspaceReader.Read()) { if (workspaceReader.NodeType == XmlNodeType.Element && workspaceReader.Name == "FunctionType") { workspaceReader.Read(); functionType = (FunctionTypeEnum)Enum.Parse(typeof(FunctionTypeEnum), workspaceReader.Value, true); switch (functionType) { case FunctionTypeEnum.Continuous_Controller: testWorkspace = new CCTestWorkspace(testWorkspaceName); break; case FunctionTypeEnum.State_Based_Controller: testWorkspace = new SLTestWorkspace(testWorkspaceName); break; case FunctionTypeEnum.Input_Output: testWorkspace = new IOTestWorkspace(testWorkspaceName); break; } workspaceReader.Read(); } if (workspaceReader.NodeType == XmlNodeType.Element && workspaceReader.Name == "SimulationTime") { workspaceReader.Read(); testWorkspace.SetSimulationTime(Int16.Parse(workspaceReader.Value)); workspaceReader.Read(); } if (workspaceReader.NodeType == XmlNodeType.Element && workspaceReader.Name == "ModelRunningTime") { workspaceReader.Read(); testWorkspace.SetModelRunningTime(Int16.Parse(workspaceReader.Value)); workspaceReader.Read(); } } workspaceReader.Close(); switch (testWorkspace.functionType) { case FunctionTypeEnum.Continuous_Controller: testWorkspace.modelSettings = SettingFilesManager.LoadModelSettings( GetWorkspacePath(testWorkspaceName)); LoadCCTestWorkspace((CCTestWorkspace)testWorkspace); break; case FunctionTypeEnum.State_Based_Controller: testWorkspace.modelSettings = SettingFilesManager.LoadModelSettings( GetWorkspacePath(testWorkspaceName)); LoadSBTestWorkspace((SLTestWorkspace)testWorkspace); break; case FunctionTypeEnum.Input_Output: break; } return(testWorkspace); }
public static void LoadExtractionInfo(SLTestWorkspace testWorkspace, string folderPath, string fileName) { XmlReaderSettings xmlSettings = new XmlReaderSettings(); xmlSettings.ValidationType = ValidationType.None; XmlReader infoReader = XmlReader.Create(folderPath + fileName, xmlSettings); while (infoReader.Read()) { if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "SimInfo") { do { infoReader.Read(); }while (infoReader.Name != "SimTime"); infoReader.Read(); float simTimeMs = float.Parse(infoReader.Value); infoReader.Read(); testWorkspace.SetSimulationTime(simTimeMs); } if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "Input") { ParameterDataType parameterDataType; do { infoReader.Read(); }while (infoReader.Name != "Name"); infoReader.Read(); string blcokName = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "DataTypeName"); infoReader.Read(); string dataTypeName = infoReader.Value; if (!dataTypeName.Equals("TbBOOLEAN")) { do { infoReader.Read(); }while (infoReader.Name != "IsSigned"); infoReader.Read(); bool isSigned = Convert.ToBoolean(Int16.Parse(infoReader.Value)); do { infoReader.Read(); }while (infoReader.Name != "WordLength"); infoReader.Read(); int wordLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "FractionLength"); infoReader.Read(); int fracLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MinType"); infoReader.Read(); float minDataType = (float)Double.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MaxType"); infoReader.Read(); float maxDataType = (float)Double.Parse(infoReader.Value); parameterDataType = new ParameterDataType(dataTypeName, isSigned, wordLength, fracLength, minDataType, maxDataType); } else { parameterDataType = new ParameterDataType(dataTypeName); } BlockInfo blockInfo; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); string bloackPath = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "PortNum"); infoReader.Read(); int blockPortNum = Int16.Parse(infoReader.Value); infoReader.Read(); blockInfo = new BlockInfo(bloackPath, blcokName, blockPortNum); testWorkspace.inputVariables.Add(new TestParameter(blockInfo, parameterDataType)); } if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "Calib") { ParameterDataType parameterDataType; do { infoReader.Read(); }while (infoReader.Name != "Name"); infoReader.Read(); string blcokName = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "DataTypeName"); infoReader.Read(); string dataTypeName = infoReader.Value; if (!dataTypeName.Equals("TbBOOLEAN")) { do { infoReader.Read(); }while (infoReader.Name != "IsSigned"); infoReader.Read(); bool isSigned = Convert.ToBoolean(Int16.Parse(infoReader.Value)); do { infoReader.Read(); }while (infoReader.Name != "WordLength"); infoReader.Read(); int wordLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "FractionLength"); infoReader.Read(); int fracLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MinType"); infoReader.Read(); float minDataType = (float)Double.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MaxType"); infoReader.Read(); float maxDataType = (float)Double.Parse(infoReader.Value); parameterDataType = new ParameterDataType(dataTypeName, isSigned, wordLength, fracLength, minDataType, maxDataType); } else { parameterDataType = new ParameterDataType(dataTypeName); } BlockInfo blockInfo; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); string bloackPath = infoReader.Value; infoReader.Read(); blockInfo = new BlockInfo(bloackPath, blcokName); testWorkspace.calibrationVariables.Add(new TestParameter(blockInfo, parameterDataType)); } if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "Output") { ParameterDataType parameterDataType; do { infoReader.Read(); }while (infoReader.Name != "Name"); infoReader.Read(); string blcokName = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "DataTypeName"); infoReader.Read(); string dataTypeName = infoReader.Value; if (!dataTypeName.Equals("TbBOOLEAN")) { do { infoReader.Read(); }while (infoReader.Name != "IsSigned"); infoReader.Read(); bool isSigned = Convert.ToBoolean(Int16.Parse(infoReader.Value)); do { infoReader.Read(); }while (infoReader.Name != "WordLength"); infoReader.Read(); int wordLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "FractionLength"); infoReader.Read(); int fracLength = Int16.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MinType"); infoReader.Read(); float minDataType = (float)Double.Parse(infoReader.Value); do { infoReader.Read(); }while (infoReader.Name != "MaxType"); infoReader.Read(); float maxDataType = (float)Double.Parse(infoReader.Value); parameterDataType = new ParameterDataType(dataTypeName, isSigned, wordLength, fracLength, minDataType, maxDataType); } else { parameterDataType = new ParameterDataType(dataTypeName); } BlockInfo blockInfo; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); string bloackPath = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "PortNum"); infoReader.Read(); int blockPortNum = Int16.Parse(infoReader.Value); infoReader.Read(); blockInfo = new BlockInfo(bloackPath, blcokName, blockPortNum); testWorkspace.outputVariables.Add(new TestParameter(blockInfo, parameterDataType)); } } infoReader.Close(); return; }
public static void LoadStaticChecks(SLTestWorkspace testWorkspace, string folderPath, string fileName) { XmlReaderSettings xmlSettings = new XmlReaderSettings(); xmlSettings.ValidationType = ValidationType.None; XmlReader infoReader = XmlReader.Create(folderPath + fileName, xmlSettings); while (infoReader.Read()) { StaticCheckBlock staticCheckBlock; if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "NoStOF") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.STOF, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } else if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "GoToNoFrom") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.GNoF, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } else if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "FromNoGoTo") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.FNoG, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } else if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "TblAllTheSame") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.TblAllTheSame, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } else if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "TblOneVal") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.TblOneVal, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } else if (infoReader.NodeType == XmlNodeType.Element && infoReader.Name == "ParMultVal") { do { infoReader.Read(); }while (infoReader.Name != "Tag"); infoReader.Read(); string blockTag = infoReader.Value; do { infoReader.Read(); }while (infoReader.Name != "Path"); infoReader.Read(); staticCheckBlock = new StaticCheckBlock(StaticCheckType.ParMultVal, new BlockInfo(infoReader.Value, blockTag)); infoReader.Read(); testWorkspace.staticChecksBlcoks.Add(staticCheckBlock); } } infoReader.Close(); return; }