示例#1
0
 private void CloseFormAndCount(object Sender, EventArgs e)
 {
     if (testFinished)
     {
         closeAndElapseTimer.Stop();
         if (testErrorResult.errorCode == ErrorCode.Success)
         {
             MatlabAsyncProgram.KillMatlab();
             Hide();
             if (testWorkspace.functionType == FunctionTypeEnum.Continuous_Controller)
             {
                 new CCTestWorkspaceResultsForm((CCTestWorkspace)testWorkspace).ShowDialog();
             }
             return;
         }
         else
         {
             MessageBox.Show("Error in running test! See more details about the error in Matlab!",
                             "Error in Running the Test", MessageBoxButtons.OK);
             Close();
             return;
         }
     }
     this.Invoke((MethodInvoker) delegate
     {
         UpdateProgressBars();
     });
 }
示例#2
0
        /*public override void RunSync()
         * {
         *  if (!Directory.Exists(tempPath))
         *      Directory.CreateDirectory(tempPath);
         *  File.Delete(outputLogPath);
         *
         *  if(testWorkspace is CCTestWorkspace)
         *      RunCCTestCase();
         *  if (testWorkspace is SBTestWorkspace)
         *      RunSBTestCase();
         *
         *  MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(testWorkspace.modelSettings);
         *  modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");
         *  SyncRunMainScript();
         * }*/

        public override void RunAsync()
        {
            MatlabAsyncProgram.KillMatlab();
            matlabAsyncProgram = new MatlabAsyncProgram(testWorkspace.modelSettings.MatlabExePath);


            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }
            File.Delete(outputLogPath);

            if (testWorkspace is CCTestWorkspace)
            {
                RunCCTestCase();
            }
            if (testWorkspace is SLTestWorkspace)
            {
                RunSBTestCase();
            }

            MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(testWorkspace.modelSettings);

            modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");
            AsyncRunMainScript();
        }
        public override void RunAsync()
        {
            MatlabAsyncProgram.KillMatlab();
            CCTestWorkspace ccTestWorkspace = (CCTestWorkspace)testWorkspace;

            if (Directory.Exists(tempPath))
            {
                Directory.Delete(tempPath, true);
            }
            Directory.CreateDirectory(tempPath);
            File.Delete(outputLogPath);

            MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(ccTestWorkspace.modelSettings);

            modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");

            CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand();

            mainScriptCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-Common.m");
            CompositeMatlabCommand GenerateNewValueCommand = new CompositeMatlabCommand();

            if (ccTestWorkspace.advancedCCSettings.randomExplorationAlgorithm == RandomExplorationAlgorithmsEnum.RandomSearch)
            {
                GenerateNewValueCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-RandomSearchGenerateValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.randomExplorationAlgorithm == RandomExplorationAlgorithmsEnum.AdaptiveRandomSearch)
            {
                GenerateNewValueCommand.LoadFromMatlabScript(templatePath + "\\RandomExploration\\RandomExplorationRun-AdaptiveRandomSearchGenerateNewValues.m");
                GenerateNewValueCommand.ReplaceInTemplate("[NumCandidatePointsInAdaptiveRandomVal]", "5");
            }
            mainScriptCommand.ReplaceInTemplate("[MiLTester_GenerateNewValuesCode]", GenerateNewValueCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_MinAlgorithmIterationsVal]", ccTestWorkspace.GetRandomExplorationMinAlgorithmIterations().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_MaxAlgorithmIterationsVal]", ccTestWorkspace.GetRandomExplorationMaxAlgorithmIterations().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_NumberOfPointsInEachRegionVal]", ccTestWorkspace.ccSettings.numberOfPointsInEachRegion.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_HeatMapDiagramDivisionFactorVal]", ccTestWorkspace.ccSettings.heatMapDiagramDivisionFactor.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStartVal]", ccTestWorkspace.GetDesiredValueVariable().from.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStopVal]", ccTestWorkspace.GetDesiredValueVariable().to.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesNamesVar]", ccTestWorkspace.GetCalibrationVariableNamesStr());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesMinimumsVal]", ccTestWorkspace.GetCalibrationVariableMinimumsStr());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CalibrationVariablesMaximumsVal]", ccTestWorkspace.GetCalibrationVariableMaximumsStr());

            mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m");

            AsyncRunMainScript();
        }
        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();
        }
示例#5
0
        public void RunSingleStateSearchInRegion(HeatMapRegion heatMapRegion)
        {
            MatlabAsyncProgram.KillMatlab();
            matlabAsyncProgram = new MatlabAsyncProgram(testWorkspace.modelSettings.MatlabExePath);
            CCTestWorkspace ccTestWorkspace = (CCTestWorkspace)testWorkspace;

            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }
            File.Delete(outputLogPath);

            MatlabCommand modelSettingsCommand = MatlabCommandBuilder.GetModelSettingsMatlabCommand(ccTestWorkspace.modelSettings);

            modelSettingsCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.ModelSettingsScriptFileName + ".m");

            CompositeMatlabCommand mainScriptCommand = new CompositeMatlabCommand();

            mainScriptCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SingleStateSearch-Common.m");
            CompositeMatlabCommand GenerateNewValuesCommand = new CompositeMatlabCommand();
            CompositeMatlabCommand ReplaceValuesCommand     = new CompositeMatlabCommand();

            if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.RandomSearch)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\RandomSearch\\SingleStateSearch-RandomSearchGenerateValues.m");
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\RandomSearch\\SingleStateSearch-RandomSearchReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.HillClimbing)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HillClimbing\\SingleStateSearch-HillClimbingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HillClimbing\\SingleStateSearch-HillClimbingReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.HCRR)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HCRR\\SingleStateSearch-HillClimbingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\HCRR\\SingleStateSearch-HillClimbingReplaceValues.m");
            }
            else if (ccTestWorkspace.advancedCCSettings.singelStateSearchAlgorithm == SingelStateSearchAlgorithmsEnum.SimulatedAnnealing)
            {
                GenerateNewValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SimulatedAnnealing\\SingleStateSearch-SimulatedAnnealingGenerateValues.m");
                GenerateNewValuesCommand.ReplaceInTemplate("[MiLTester_EASigmalVal]", ccTestWorkspace.GetSigmaForSingleStateSearch().ToString());
                ReplaceValuesCommand.LoadFromMatlabScript(templatePath + "\\SingleStateSearch\\SimulatedAnnealing\\SingleStateSearch-SimulatedAnnealingReplaceValues.m");
                ReplaceValuesCommand.ReplaceInTemplate("[MiLTester_AnnealingScheduleVal]", ccTestWorkspace.GetAnnealingScheduleForSingleStateSearch().ToString());
            }

            mainScriptCommand.ReplaceInTemplate("[MiLTester_GenerateNewValuesCode]", GenerateNewValuesCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ReplaceValuesCode]", ReplaceValuesCommand);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_CodeRootVal]", codePath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulationTimeVal]", testWorkspace.GetSimulationTime().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SimulinkModelPathVal]", testWorkspace.modelSettings.SimulinkModelPath);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SearchVariablesCntVal]", ccTestWorkspace.GetSearchVariablesCnt().ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthRangeStartVal]", heatMapRegion.xStart.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthRangeStopVal]", heatMapRegion.xEnd.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightRangeStartVal]", heatMapRegion.yStart.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightRangeStopVal]", heatMapRegion.yEnd.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_WorstPointFromRandomExplorationInitialDesiredVal]", heatMapRegion.worstCasePointFromRandomExploration.x.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_WorstPointFromRandomExplorationFinalDesiredVal]", heatMapRegion.worstCasePointFromRandomExploration.y.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AlgorithmRoundsVal]", ccTestWorkspace.advancedCCSettings.algorithmRounds.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AlgorithmIterationsVal]", ccTestWorkspace.advancedCCSettings.algorithmIterations.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_SelectedObjectiveFunction]", heatMapRegion.requirementName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_DesiredValueVar]", ccTestWorkspace.GetDesiredValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_ActualValueVar]", ccTestWorkspace.GetActualValueVariable().parameterName);
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionWidthIndexVal]", heatMapRegion.indexX.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RegionHeightIndexVal]", heatMapRegion.indexY.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStartVal]", ccTestWorkspace.GetDesiredValueVariable().from.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_RangeStopVal]", ccTestWorkspace.GetDesiredValueVariable().to.ToString());
            mainScriptCommand.ReplaceInTemplate("[MiLTester_AnnealingStartTemprature]", ccTestWorkspace.GetAnnealingStartTemprature().ToString());

            mainScriptCommand.SaveToMatlabScript(tempPath + "\\" + MatlabCommandBuilder.MainScriptFileName + ".m");

            AsyncRunMainScript();
        }
示例#6
0
 public void CancelRun()
 {
     MatlabAsyncProgram.KillMatlab();
     runCanceled = true;
 }