public override void RunStrategy() { Assert.Ignore(); CleanupFiles(); StartGUIThread(); Starter starter = new HistoricalStarter(); // Set run properties as in the GUI. starter.ProjectProperties.Starter.StartTime = new TimeStamp(2009, 8, 3); starter.ProjectProperties.Starter.EndTime = new TimeStamp(2009, 8, 4); starter.DataFolder = "Test\\DataCache"; starter.ProjectProperties.Starter.SetSymbols("TXF.Test"); starter.ProjectProperties.Starter.IntervalDefault = Intervals.Minute1; starter.CreateChartCallback = new CreateChartCallback(HistoricalCreateChart); starter.ShowChartCallback = new ShowChartCallback(HistoricalShowChart); // Run the loader. ExampleReversalLoader loader = new ExampleReversalLoader(); starter.Run(loader); // Get the stategy strategy = loader.TopModel as ExampleReversalStrategy; IList <DiagramAttribute> aspects = DiagramHelper.GetAspectsByCalls(); for (int i = 0; i < aspects.Count && i < 100; i++) { var aspect = aspects[i]; log.Notice(aspect.TypeName + "." + aspect.MethodSignature + ": " + aspect.CallCount); } }
internal CardinalDirection GetDirection() { var rectangle = new Rectangle(ParentElement.Location, ParentElement.Size); var point = new Point(location.X - ParentElement.Location.X + size.Width / 2, location.Y - ParentElement.Location.Y + size.Height / 2); return(DiagramHelper.GetDirection(rectangle, point)); }
private void UpdateUpperSelectionPoint() { var points = new Point[_document.SelectedElements.Count]; var p = 0; foreach (BaseElement element in _document.SelectedElements) { points[p] = element.Location; p++; } _upperSelPoint = DiagramHelper.GetUpperPoint(points); }
public override void SelectIndicatorValues() { this.IndicatorValues.ClearOnUI(); // Duration var durations = (from p in this.Indicators where p.Name == "Duration" from q in p.IndicatorValues select q); this.Duration.BeginAddRange(DiagramHelper.filterDiagramValues(durations)); }
public static void SetTextBoxLocation(BaseElement element, TextBox textBox) { if (!(element is ILabelElement)) { return; } var label = ((ILabelElement)element).Label; element.Invalidate(); label.Invalidate(); if (label.Text.Length > 0) { textBox.Location = element.Location; textBox.Size = element.Size; } else { var sizeTmp = DiagramHelper.MeasureString("XXXXXXX", label.Font, label.Size.Width, label.Format); if (element is BaseLinkElement) { textBox.Size = sizeTmp; textBox.Location = new Point( element.Location.X + element.Size.Width / 2 - sizeTmp.Width / 2, element.Location.Y + element.Size.Height / 2 - sizeTmp.Height / 2); } else { sizeTmp.Width = element.Size.Width; textBox.Size = sizeTmp; textBox.Location = new Point(element.Location.X, element.Location.Y + element.Size.Height / 2 - sizeTmp.Height / 2); } } var rectangle = new Rectangle(textBox.Location, textBox.Size); rectangle.Inflate(3, 3); textBox.Location = rectangle.Location; textBox.Size = rectangle.Size; }
private Size MeasureTextSize() { var sizeTmp = Size.Empty; switch (_direction) { case LabelEditDirection.UpDown: sizeTmp = DiagramHelper.MeasureString(_labelTextBox.Text, _labelElement.Font, _labelTextBox.Size.Width, _labelElement.Format); break; case LabelEditDirection.Both: sizeTmp = DiagramHelper.MeasureString(_labelTextBox.Text, _labelElement.Font); break; } sizeTmp.Height += 30; return(sizeTmp); }
public static Size GetTextSize(BaseElement element) { var sizeTmp = Size.Empty; var direction = element is BaseLinkElement ? LabelEditDirection.Both : LabelEditDirection.UpDown; var labelElement = ((ILabelElement)element).Label; switch (direction) { case LabelEditDirection.UpDown: sizeTmp = DiagramHelper.MeasureString(labelElement.Text, labelElement.Font, labelElement.Size.Width, labelElement.Format); break; case LabelEditDirection.Both: sizeTmp = DiagramHelper.MeasureString(labelElement.Text, labelElement.Font); break; } sizeTmp.Height += 30; return(sizeTmp); }
public override void SelectIndicatorValues() { this.Load.ClearOnUI(); this.CapacityPerDrive.ClearOnUI(); this.LoadPerDrive.ClearOnUI(); try { // Capacity var capacity = (from p in this.Indicators where p.Name == "Capacity" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (capacity != null && !capacity.Value.ToString().Equals("")) { this.Capacity = capacity.Value.ToString() + " MB"; } else { this.Capacity = " - "; } } catch (Exception) { Console.WriteLine("STORAGE VIS PLUGIN: Problem at getting Capacity"); this.Capacity = " - "; } try { // Load var loads = (from p in this.Indicators where p.Name == "Load" from q in p.IndicatorValues select q); ExtendedObservableCollection <IndicatorValue> filteredLoad = DiagramHelper.filterDiagramValues(loads); this.Load.BeginAddRange(filteredLoad); } catch (Exception) { Console.WriteLine("STORAGE VIS PLUGIN: Problem at getting Load"); } try { // NumberOfDrives var numberOfDrives = (from p in this.Indicators where p.Name == "NumberOfDrives" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (numberOfDrives != null && !numberOfDrives.Value.ToString().Equals("")) { this.NumberOfDrives = numberOfDrives.Value.ToString(); } else { this.NumberOfDrives = " - "; } } catch (Exception) { Console.WriteLine("STORAGE VIS PLUGIN: Problem at getting NumberOfDrives"); this.NumberOfDrives = " - "; } try { // CapacityPerDrive var capacityPerDrive = (from p in this.Indicators where p.Name == "CapacityPerDrive" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (capacityPerDrive != null && !capacityPerDrive.Value.ToString().Equals("")) { for (int i = 0; i < capacityPerDrive.Value.ToString().Split(';').Length; i++) { CapacityPerDrive.BeginAddOnUI(new IndicatorValue(Convert.ToInt32(capacityPerDrive.Value.ToString().Split(';')[i]), capacityPerDrive.DataType, capacityPerDrive.Timestamp, capacityPerDrive.MappingState)); } } } catch (Exception) { Console.WriteLine("STORAGE VIS PLUGIN: Problem at getting CapacityPerDrive"); } try { // LoadPerDrive var loadPerDrive = (from p in this.Indicators where p.Name == "LoadPerDrive" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (loadPerDrive != null && !loadPerDrive.Value.ToString().Equals("")) { for (int i = 0; i < loadPerDrive.Value.ToString().Split(';').Length; i++) { LoadPerDrive.BeginAddOnUI(new IndicatorValue(Convert.ToByte(loadPerDrive.Value.ToString().Split(';')[i]), loadPerDrive.DataType, DateTime.Now.AddDays(i), loadPerDrive.MappingState)); } } } catch (Exception) { Console.WriteLine("STORAGE VIS PLUGIN: Problem at getting LoadPerDrive"); } }
public void MainTest() { using (Form1 form = new Form1()) { string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\..\..\Test\XMLStore\Failed"); for (int testId = 0, failedId = files.Count(); testId < 1000; testId++) { InitializeDiagramItemsAndRelations(form); helper = form.helper; string file = Directory.GetCurrentDirectory() + @"\..\..\Test\XMLStore\Failed\Failed_" + failedId.ToString() + ".xml"; helper.SerializeToXMLFile(file); for (int i = 0; i < 100; i++) helper.DoBestFit(); bool isFailed = IsWrongBestFit(ref failedId); if (!isFailed) File.Delete(file); form.clear(null, null); } } }
public void TearDown() { helper = null; }
public void SetUp() { helper = new DiagramHelper(); }
public void RunFailedTest() { string[] files = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\..\..\Test\XMLStore\Failed"); foreach (string file in files) { helper = new DiagramHelper(); helper.DeserializeFromXMLFile(file); helper.PrepareForBestFit(new Size(1000, 1000)); for (int i = 0; i < 2000; i++) helper.DoBestFit(); PointF[] initialLocations = new PointF[helper.DiagramItems.Count]; int j = 0; foreach (var item in helper.DiagramItems) { initialLocations[j] = item.Location; j++; } helper.DoBestFit(); j = 0; foreach (var item in helper.DiagramItems) { Assert.AreEqual(Math.Round(initialLocations[j].X, 0), Math.Round(item.Location.X, 0), file); Assert.AreEqual(Math.Round(initialLocations[j].Y, 0), Math.Round(item.Location.Y, 0), file); j++; } } }
public override void SelectIndicatorValues() { this.IndicatorValues.ClearOnUI(); this.Temperature.ClearOnUI(); this.TemperaturePerCore.ClearOnUI(); this.Load.ClearOnUI(); this.LoadPerCore.ClearOnUI(); try { // Name var name = (from p in this.Indicators where p.Name == "ProcessorName" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (name != null) { this.Name = name.Value as string; } else { this.Name = " - "; } } catch (Exception) { Console.WriteLine("CPU VIS PLUGIN: Problem at getting ProcessorName"); this.Name = " - "; } try { var temperatures = (from p in this.Indicators where p.Name == "Temperature" from q in p.IndicatorValues orderby q.Timestamp descending select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState)); ExtendedObservableCollection <IndicatorValue> filteredTemps = DiagramHelper.filterDiagramValues(temperatures); Temperature.BeginAddRange(filteredTemps); // this adds all values to the diagram, way too much for wpf toolkit diagrams // Temperature //this.Temperature.BeginAddRange(from p in this.Indicators // where p.Name == "Temperature" // from q in p.IndicatorValues // select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState)); } catch (Exception) { Console.WriteLine("CPU VIS PLUGIN: Problem at getting Temperature"); } try { // Temperature Per Core var temperatures = from p in this.Indicators where p.Name == "TemperaturePerCore" from q in p.IndicatorValues select q; if (temperatures.Count() > 0) { IndicatorValue first = null; int z = 0; while (first == null) { if (!temperatures.ElementAt(z).Value.ToString().Equals("")) { first = temperatures.ElementAt(z); } z++; } for (int i = 0; i < first.Value.ToString().Split(';').Length; i++) { ExtendedObservableCollection <IndicatorValue> rawValues = new ExtendedObservableCollection <IndicatorValue>(); ExtendedObservableCollection <IndicatorValue> filteredValues; foreach (IndicatorValue tempValue in temperatures) { string[] temps = tempValue.Value.ToString().Split(';'); if (temps.Length > 0 && temps.Length == first.Value.ToString().Split(';').Length&& !temps[i].Equals("")) { rawValues.Add(new IndicatorValue(Convert.ToByte(temps[i]), tempValue.DataType, tempValue.Timestamp, tempValue.MappingState)); } } filteredValues = DiagramHelper.filterDiagramValues(rawValues); this.TemperaturePerCore.BeginAddOnUI(filteredValues); } } } catch (Exception) { Console.WriteLine("CPU VIS PLUGIN: Problem at getting TemperaturePerCore"); } try { // Load var load = (from p in this.Indicators where p.Name == "Load" from q in p.IndicatorValues select new IndicatorValue(Convert.ToByte(q.Value), q.DataType, q.Timestamp, q.MappingState)); this.Load.BeginAddRange(DiagramHelper.filterDiagramValues(load)); } catch (Exception) { Console.WriteLine("CPU VIS PLUGIN: Problem at getting Load"); } try { // Load Per Core var loadValues = from p in this.Indicators where p.Name == "LoadPerCore" from q in p.IndicatorValues select q; if (loadValues.Count() > 0) { IndicatorValue first = null; int z = 0; while (first == null) { if (!loadValues.ElementAt(z).Value.ToString().Equals("")) { first = loadValues.ElementAt(z); } z++; } for (int i = 0; i < first.Value.ToString().Split(';').Length; i++) { ExtendedObservableCollection <IndicatorValue> rawValues = new ExtendedObservableCollection <IndicatorValue>(); ExtendedObservableCollection <IndicatorValue> filteredValues; foreach (IndicatorValue value in loadValues) { string[] loads = value.Value.ToString().Split(';'); if (loads.Length > 0 && loads.Length == (first.Value as string).Split(';').Length&& !loads[i].Equals("")) { rawValues.Add(new IndicatorValue(Convert.ToByte(loads[i]), value.DataType, value.Timestamp, value.MappingState)); } } filteredValues = DiagramHelper.filterDiagramValues(rawValues); this.LoadPerCore.BeginAddOnUI(filteredValues); } } } catch (Exception) { Console.WriteLine("CPU VIS PLUGIN: Problem at getting LoadPerCore"); } }
public override void SelectIndicatorValues() { this.Load.ClearOnUI(); this.SwapLoad.ClearOnUI(); try { // Size var size = (from p in this.Indicators where p.Name == "Size" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (size != null && !size.Value.ToString().Equals("")) { this.Size = size.Value.ToString() + " MB"; } else { this.Size = " - "; } } catch (Exception) { Console.WriteLine("RAM VIS PLUGIN: Problem at getting Size"); this.Size = " - "; } try { // Load var loads = (from p in this.Indicators where p.Name == "Load" from q in p.IndicatorValues select q); this.Load.BeginAddRange(DiagramHelper.filterDiagramValues(loads)); } catch (Exception) { Console.WriteLine("RAM VIS PLUGIN: Problem at getting Load"); } try { // SwapSize var swapSize = (from p in this.Indicators where p.Name == "SwapSize" from q in p.IndicatorValues orderby q.Timestamp descending select q).FirstOrDefault(); if (swapSize != null && !swapSize.Value.ToString().Equals("")) { this.SwapSize = swapSize.Value.ToString() + " MB"; } else { this.SwapSize = " - "; } } catch (Exception) { Console.WriteLine("RAM VIS PLUGIN: Problem at getting SwapSize"); this.SwapSize = " - "; } try { // SwapLoad var swapLoads = (from p in this.Indicators where p.Name == "SwapLoad" from q in p.IndicatorValues select q); this.SwapLoad.BeginAddRange(DiagramHelper.filterDiagramValues(swapLoads)); } catch (Exception) { Console.WriteLine("RAM VIS PLUGIN: Problem at getting SwapLoad"); } }