private void btnOk_Click(object sender, EventArgs e) { CCSettings ccSettings = parentCCSettingsForm.ReadCCSettings(); SettingFilesManager.SaveCCSettings(SettingFilesManager.SettingsFolderPath, ccSettings); Close(); }
private void InitValues() { lblWorkspaceName.Text = ccTestWorkspace.ToString(); heatMapDiagram = TestWorkspaceDataProvider.GetTestWorkspaceDataProvider(). LoadHeatMapDiagramToTestWorkspace(ccTestWorkspace.ToString()); worstTestCases = TestWorkspaceDataProvider.GetTestWorkspaceDataProvider(). LoadWorstTestCasesToCCTestWorkspace(ccTestWorkspace.ToString()); CCSettings ccSettings = ccTestWorkspace.ccSettings; for (int i = 0; i < ccSettings.Requirements.Count; ++i) { if (ccSettings.Requirements.ElementAt(i).Value) { cmbRequirements.Items.Add(ccSettings.Requirements.ElementAt(i).Key); } } cmbRequirements.SelectedIndex = 0; if (!ccSettings.reportWorstTestCases) { gbWorstTestCases.Enabled = false; } ParentCCSettingsForm.CreateAndShowLabels(labels, HeatMapPanel, ccTestWorkspace.ccSettings.heatMapDiagramDivisionFactor, ccTestWorkspace.GetDesiredValueVariable().from, ccTestWorkspace.GetDesiredValueVariable().to, gbHeatMap); }
public TimeSpan GetRandomExplorationEstimatedRunningTime(CCSettings givenCCSettings) { long miliSecondsOfTest = 0; if (givenCCSettings.GetNumberOfSelectedRequirements() > 0) { miliSecondsOfTest = (long)(givenCCSettings.heatMapDiagramDivisionFactor * givenCCSettings.heatMapDiagramDivisionFactor * givenCCSettings.numberOfPointsInEachRegion * modelRunningTime); if (advancedCCSettings.randomExplorationAlgorithm == RandomExplorationAlgorithmsEnum.AdaptiveRandomSearch) { miliSecondsOfTest = (long)(1.5 * miliSecondsOfTest); } else { miliSecondsOfTest = (long)(3 * miliSecondsOfTest); } miliSecondsOfTest += givenCCSettings.GetNumberOfSelectedRequirements() * 1000;//for creating heatmaps if (givenCCSettings.reportPotentialAnomalies) { miliSecondsOfTest += givenCCSettings.GetNumberOfSelectedRequirements() * 1000; } } TimeSpan testTunningTime = new TimeSpan(0, 0, (int)(miliSecondsOfTest / 1000)); return(testTunningTime); }
public CCSettings ReadCCSettings() { CCSettings ccSettings = new CCSettings(false); for (int i = 0; i < chlbRequirements.Items.Count; ++i) { ccSettings.Requirements[chlbRequirements.Items[i].ToString()] = (chlbRequirements.GetItemChecked(i)); } ccSettings.heatMapDiagramDivisionFactor = (int)sbHMAxesDivisionFactor.Value; ccSettings.numberOfPointsInEachRegion = (int)sbPointsInRegion.Value; ccSettings.reportWorstTestCases = cbReportWostCases.Checked; ccSettings.numberOfWorstTestCases = (int)sbWorstTestCasesNumber.Value; ccSettings.includeOrExcludeRegions = rbIncludeRegions.Checked; ccSettings.unionOrIntersectionOfRegions = rbUnionSliders.Checked; for (int i = 0; i < ccSettings.heatMapDiagramDivisionFactor; ++i) { for (int j = 0; j < ccSettings.heatMapDiagramDivisionFactor; ++j) { ccSettings.normalOrIncludedExcludedRegion[i][j] = HeatMapLayout.GetLayoutRegionNormalOrIncludeExcluded(i, j); } } return(ccSettings); }
private void UpdateTimeEstimates() { CCSettings CCSettings = parentCCSettingsForm.ReadCCSettings(); TimeSpan timeSpan = ((CCTestWorkspace)testWorkspace).GetTestEstimatedRunningTimeWithThisSettings(CCSettings); DateTime finisheTime = DateTime.Now + timeSpan; lblRunninTime.Text = timeSpan.ToString(); lblFinishTime.Text = finisheTime.ToString(); if (timeSpan.TotalSeconds == 0) btnStart.Enabled = false; else btnStart.Enabled = true; }
public CCTestWorkspace(String workspaceName) : base(workspaceName, FunctionTypeEnum.Continuous_Controller) { if (SettingFilesManager.CCSettingsExists(SettingFilesManager.SettingsFolderPath)) { ccSettings = SettingFilesManager.LoadCCSettings(SettingFilesManager.SettingsFolderPath); advancedCCSettings = SettingFilesManager.LoadAdvancedCCSettings(SettingFilesManager.SettingsFolderPath); } else { ccSettings = new CCSettings(true); advancedCCSettings = new AdvancedCCSettings(); } }
public TimeSpan GetSingleStateSearchEstimatedRunningTime(CCSettings givenCCSettings) { long miliSecondsOfTest = 0; if (givenCCSettings.GetNumberOfSelectedRequirements() > 0) { if (givenCCSettings.reportWorstTestCases) { miliSecondsOfTest += givenCCSettings.GetNumberOfSelectedRequirements() * givenCCSettings.numberOfWorstTestCases * advancedCCSettings.algorithmIterations * modelRunningTime * advancedCCSettings.algorithmRounds; } } TimeSpan testTunningTime = new TimeSpan(0, 0, (int)(miliSecondsOfTest / 1000)); return(testTunningTime); }
public CCSettingsForm() { InitializeComponent(); CCSettings ccSettings; if (SettingFilesManager.CCSettingsExists(SettingFilesManager.SettingsFolderPath)) { ccSettings = SettingFilesManager.LoadCCSettings(SettingFilesManager.SettingsFolderPath); } else { ccSettings = new CCSettings(true); } parentCCSettingsForm = new ParentCCSettingsForm(this); parentCCSettingsForm.LoadCCSettings(ccSettings); this.Controls.Add(parentCCSettingsForm); }
public TimeSpan GetTestEstimatedRunningTimeWithThisSettings(CCSettings givenCCSettings) { return(GetRandomExplorationEstimatedRunningTime(givenCCSettings) + GetSingleStateSearchEstimatedRunningTime(givenCCSettings)); }
public void LoadCCSettings(CCSettings ccSettings) { for (int i = 0; i < ccSettings.Requirements.Count; ++i) { chlbRequirements.Items.Add(ccSettings.Requirements.ElementAt(i).Key, ccSettings.Requirements.ElementAt(i).Value); } sbHMAxesDivisionFactor.Minimum = CCSettings.MinHMDivisionFactor; sbHMAxesDivisionFactor.Maximum = CCSettings.MaxHMDivisionFactor; sbHMAxesDivisionFactor.Value = ccSettings.heatMapDiagramDivisionFactor; sbPointsInRegion.Minimum = CCSettings.MinPointsInEachRegion; sbPointsInRegion.Maximum = CCSettings.MaxPointsInEachRegion; sbPointsInRegion.Value = ccSettings.numberOfPointsInEachRegion; cbReportWostCases.Checked = ccSettings.reportWorstTestCases; sbWorstTestCasesNumber.Minimum = CCSettings.MinWorstTestCases; sbWorstTestCasesNumber.Maximum = sbHMAxesDivisionFactor.Value * sbHMAxesDivisionFactor.Value; sbWorstTestCasesNumber.Value = ccSettings.numberOfWorstTestCases; rbExcludeRegions.Checked = !ccSettings.includeOrExcludeRegions; rbIncludeRegions.Checked = ccSettings.includeOrExcludeRegions; rbIntersectionSliders.Checked = !ccSettings.unionOrIntersectionOfRegions; rbUnionSliders.Checked = ccSettings.unionOrIntersectionOfRegions; for (int i = 0; i < ccSettings.heatMapDiagramDivisionFactor; ++i) { for (int j = 0; j < ccSettings.heatMapDiagramDivisionFactor; ++j) { if (ccSettings.normalOrIncludedExcludedRegion[i][j]) { HeatMapLayout.ChangeLayoutRegionToNormal(i, j); } else { HeatMapLayout.ChangeLayoutRegionToIncludeorExlcude(i, j); } } } CreateAndShowHeatMapSliders(ccSettings.heatMapDiagramDivisionFactor, ccSettings.includeOrExcludeRegions); if (showLabels) { CreateAndShowLabels(labels, HeatMapPanel, ccSettings.heatMapDiagramDivisionFactor, desiredValueStart, desiredValueEnd, gbWorstTestCases); } ChangeInReportWorstCases(ccSettings.reportWorstTestCases); ChangeInIncludeorExcludeRegions(ccSettings.includeOrExcludeRegions); for (int i = 0; i < ccSettings.heatMapDiagramDivisionFactor; ++i) { for (int j = 0; j < ccSettings.heatMapDiagramDivisionFactor; ++j) { if (ccSettings.normalOrIncludedExcludedRegion[i][j]) { HeatMapLayout.ChangeLayoutRegionToNormal(i, j); } else { HeatMapLayout.ChangeLayoutRegionToIncludeorExlcude(i, j); } } } }
public static void SaveCCSettings(string folderPath, CCSettings ccSettings) { XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } XmlWriter settingsWriter = XmlWriter.Create(folderPath + CCSettingsFileName, xmlSettings); settingsWriter.WriteStartElement("body"); settingsWriter.WriteStartElement("HeatMapDiagramDivisionFactor"); settingsWriter.WriteValue(ccSettings.heatMapDiagramDivisionFactor); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("NumberOfPointsInEachRegion"); settingsWriter.WriteValue(ccSettings.numberOfPointsInEachRegion); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("ReportPotentialAnomalies"); settingsWriter.WriteValue(ccSettings.reportPotentialAnomalies); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("ReportWorstTestCases"); settingsWriter.WriteValue(ccSettings.reportWorstTestCases); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("NumberOfWorstTestCases"); settingsWriter.WriteValue(ccSettings.numberOfWorstTestCases); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("IncludeOrExcludeRegions"); settingsWriter.WriteValue(ccSettings.includeOrExcludeRegions); settingsWriter.WriteEndElement(); for (int i = 0; i < CCSettings.MaxHMDivisionFactor; ++i) { for (int j = 0; j < CCSettings.MaxHMDivisionFactor; ++j) { if (!ccSettings.normalOrIncludedExcludedRegion[i][j]) { settingsWriter.WriteStartElement("Region"); settingsWriter.WriteStartElement("IndexI"); settingsWriter.WriteValue(i); settingsWriter.WriteEndElement(); settingsWriter.WriteStartElement("IndexJ"); settingsWriter.WriteValue(j); settingsWriter.WriteEndElement(); settingsWriter.WriteEndElement(); } } } settingsWriter.WriteStartElement("UnionOrIntersectionOfSliders"); settingsWriter.WriteValue(ccSettings.unionOrIntersectionOfRegions); settingsWriter.WriteEndElement(); foreach (string req in ccSettings.Requirements.Keys) { if (ccSettings.Requirements[req]) { settingsWriter.WriteStartElement("Requirement"); settingsWriter.WriteValue(req); settingsWriter.WriteEndElement(); } } settingsWriter.WriteEndElement(); settingsWriter.Close(); }
public static CCSettings LoadCCSettings(string folderPath) { CCSettings ccSettings = new CCSettings(false); XmlReaderSettings xmlSettings = new XmlReaderSettings(); xmlSettings.ValidationType = ValidationType.None; XmlReader settingsReader = XmlReader.Create(folderPath + CCSettingsFileName, xmlSettings); while (settingsReader.Read()) { if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "HeatMapDiagramDivisionFactor") { settingsReader.Read(); ccSettings.heatMapDiagramDivisionFactor = Int16.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "NumberOfPointsInEachRegion") { settingsReader.Read(); ccSettings.numberOfPointsInEachRegion = Int16.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "ReportPotentialAnomalies") { settingsReader.Read(); ccSettings.reportPotentialAnomalies = Boolean.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "ReportWorstTestCases") { settingsReader.Read(); ccSettings.reportWorstTestCases = Boolean.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "NumberOfWorstTestCases") { settingsReader.Read(); ccSettings.numberOfWorstTestCases = Int16.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "IncludeOrExcludeRegions") { settingsReader.Read(); ccSettings.includeOrExcludeRegions = Boolean.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "Region") { do { settingsReader.Read(); }while (settingsReader.Name != "IndexI"); settingsReader.Read(); int indexI = Int16.Parse(settingsReader.Value); do { settingsReader.Read(); }while (settingsReader.Name != "IndexJ"); settingsReader.Read(); int indexJ = Int16.Parse(settingsReader.Value); ccSettings.normalOrIncludedExcludedRegion[indexI][indexJ] = false; settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "UnionOrIntersectionOfSliders") { settingsReader.Read(); ccSettings.unionOrIntersectionOfRegions = Boolean.Parse(settingsReader.Value); settingsReader.Read(); } if (settingsReader.NodeType == XmlNodeType.Element && settingsReader.Name == "Requirement") { settingsReader.Read(); ccSettings.Requirements[settingsReader.Value] = true; settingsReader.Read(); } } settingsReader.Close(); return(ccSettings); }