static void Main(string[] args) { #region MainMWE //Setup a network controller and choose a network definition file // appropriate to the simulator in use NetworkController controller = new NetworkController(new OpenDSSSimulator()); //Set this to the absolute path to the IEEE13mod.dss file, e.g. controller.NetworkFilename = @"C:\temp\IEEE13mod.dss"; //Add our new experiment, with +10% load scaling. controller.ExperimentDriver = new LoadScalingExperimentor(1.1); //Use a DifferenceTransform so that the controller returns the // differences between pre- and post- experiment voltages. controller.ResultsTransformer = new DifferenceTransform(); //Run the simulation controller.Execute(); //Output the change in voltage at every network bus. foreach (var bus in controller.Network.Buses.Values) { Console.WriteLine( "Bus " + bus.ID + " has changed in voltage (pu) by " + bus.VoltagePU.Magnitude); } #endregion #region MainGraphing var graph = new ValueTransformableTreeGraph(); // make a new graph. graph.Network = controller.Network; // assign the output of the experiment to the graph. GraphHostWindow.StartGraphHostWindow(graph); // put the graph in a window and display it. #endregion otherGraph(controller.Network); }
// gets a PresentationMode-compliant graph. private ValueTransformableTreeGraph GetAccessibleGraph() { ValueTransformableTreeGraph newGraph = (ValueTransformableTreeGraph)this.MemberwiseClone(); newGraph.BusSizeTransform = newGraph.BusColorTransform; newGraph.BusSizeMin = newGraph.LineThickness + 1; newGraph.BusSizeMax = newGraph.LineThickness + 10; newGraph.PresentationMode = false; return(newGraph); }
static void otherGraph(NetworkModel network) { #region ValueTransform var graph = new ValueTransformableTreeGraph(); //new graph graph.BusSizeMin = 2; graph.BusSizeMax = 10; graph.BusSizeTransform = bus => bus.VoltagePU.Magnitude; graph.BusColorTransform = bus => bus.VoltagePU.Magnitude; graph.RingEnabledTransform = bus => bus.ConnectedTo.OfType<Generator>().Any(); graph.RingDistanceTransform = bus => 2; //constant graph.Network = network; #endregion GraphHostWindow.StartGraphHostWindow(graph); }
/// <inheritdoc /> public override Visual Draw() { if (Network == null) { throw new Exception("Network is Null"); } if (PresentationMode && ColorConveysMostInformation()) { ValueTransformableTreeGraph newGraph = GetAccessibleGraph(); return(newGraph.Draw()); } ProtectInitialise(); Limits busSizeLimits = GetBusSizeLimits(); AdaptiveGradientMap <Tuple <Brush, Pen> > colorMap = BuildGradientMap(Network); Pen ringColorPen = GetRingPen(); //Create drawing target DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); //enables clicks to be registered all throughout the drawing (i.e. // no holes) but simultaneously remains transparent. drawingContext.DrawRectangle(Brushes.Transparent, null, ImgCoords); DrawLines(Network, colorMap, drawingContext); DrawBuses(Network, colorMap, busSizeLimits, ringColorPen, drawingContext); //free up resources drawingContext.Close(); return(drawingVisual); }