private void OpenRoutingTool(IBlock start, RoutingMode requestMode) { _routingToolOpen = true; _routeToolMode = requestMode; var popup = new Form(); popup.Text = "Routing Tool"; popup.AutoSize = true; popup.FormClosed += Popup_RoutingTool_FormClosed; var rt = new RoutingTool(this, _ctcOffice, _environment, start, false); //create special for dispatch if (requestMode == RoutingMode.Dispatch) { rt = new RoutingTool(this, _ctcOffice, _environment, start, true); } //set ctc gui ref _routeTool = rt; _routeTool.EnablePointSelection += Rt_EnablePointSelection; _routeTool.SubmitRoute += Rt_SubmitRoute; popup.Controls.Add(_routeTool); popup.Show(); }
/// <summary> /// Initializes a new instance of the <see cref="TransporterRouter"/> class. /// </summary> /// <param name="sourceTransporter">The source transporter.</param> /// <param name="targetTransporter">The target transporter.</param> /// <param name="routingMode">The routing mode.</param> /// <param name="writingMode">The writing mode.</param> public TransporterRouter(IResonanceTransporter sourceTransporter, IResonanceTransporter targetTransporter, RoutingMode routingMode, WritingMode writingMode) : this() { SourceTransporter = sourceTransporter; TargetTransporter = targetTransporter; RoutingMode = routingMode; WritingMode = writingMode; }
/// <summary> /// Deletes audio routing groups asynchronously. /// </summary> /// <param name="callLegId">which call to add audio routing group.</param> /// <param name="routingMode">The audio group id to delete.</param> /// <returns>The routing group id.</returns> public async Task DeleteAudioRoutingGroupAsync(string callLegId, RoutingMode routingMode) { if (string.IsNullOrEmpty(callLegId)) { throw new ArgumentNullException(nameof(callLegId)); } await this.Client.Calls()[callLegId].AudioRoutingGroups[routingMode.ToString()].DeleteAsync().ConfigureAwait(false); }
/// <summary> /// Layouts an edge between the given points. /// </summary> /// <param name="startPoint">Start point.</param> /// <param name="endPoint">End point.</param> /// <param name="rMode">Routing mode.</param> /// <returns>Edge point collection.</returns> public override EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode) { double middle = startPoint.X + (endPoint.X - startPoint.X) / 2.0; EdgePointCollection points = new EdgePointCollection(); points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(middle, startPoint.Y)); points.Add(new EdgePoint(middle, endPoint.Y)); points.Add(new EdgePoint(endPoint)); return points; }
public static List <RoutePoint> Navigate(string From, string To, bool UseJumpGates, bool UseThera, RoutingMode routingMode) { if (!(MapNodes.Keys.Contains(From)) || !(MapNodes.Keys.Contains(To)) || From == "" || To == "") { return(null); } // clear the scores, values and parents from the list foreach (MapNode mapNode in MapNodes.Values) { mapNode.NearestToStart = null; mapNode.MinCostToStart = 0; mapNode.Visited = false; switch (routingMode) { case RoutingMode.PreferLow: { if (mapNode.HighSec) { mapNode.Cost = 1000; } } break; case RoutingMode.Safest: { if (!mapNode.HighSec) { mapNode.Cost = 1000; } } break; case RoutingMode.Shortest: mapNode.Cost = 1; break; } } MapNode Start = MapNodes[From]; MapNode End = MapNodes[To]; List <MapNode> OpenList = new List <MapNode>(); List <MapNode> ClosedList = new List <MapNode>(); MapNode CurrentNode = null; // add the start to the open list OpenList.Add(Start); while (OpenList.Count > 0) { // get the MapNode with the lowest F score double lowest = OpenList.Min(mn => mn.MinCostToStart); CurrentNode = OpenList.First(mn => mn.MinCostToStart == lowest); // add the list to the closed list ClosedList.Add(CurrentNode); // remove it from the open list OpenList.Remove(CurrentNode); // walk the connections foreach (string connectionName in CurrentNode.Connections) { MapNode CMN = MapNodes[connectionName]; if (CMN.Visited) { continue; } if (CMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + CMN.Cost < CMN.MinCostToStart) { CMN.MinCostToStart = CurrentNode.MinCostToStart + CMN.Cost; CMN.NearestToStart = CurrentNode; if (!OpenList.Contains(CMN)) { OpenList.Add(CMN); } } } if (UseJumpGates && CurrentNode.JBConnection != null) { MapNode JMN = MapNodes[CurrentNode.JBConnection]; if (!JMN.Visited && JMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + JMN.Cost < JMN.MinCostToStart) { JMN.MinCostToStart = CurrentNode.MinCostToStart + JMN.Cost; JMN.NearestToStart = CurrentNode; if (!OpenList.Contains(JMN)) { OpenList.Add(JMN); } } } if (UseThera && CurrentNode.TheraConnections != null) { foreach (string theraConnection in CurrentNode.TheraConnections) { MapNode CMN = MapNodes[theraConnection]; if (CMN.Visited) { continue; } if (CMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + CMN.Cost < CMN.MinCostToStart) { CMN.MinCostToStart = CurrentNode.MinCostToStart + CMN.Cost; CMN.NearestToStart = CurrentNode; if (!OpenList.Contains(CMN)) { OpenList.Add(CMN); } } } } /* Todo : Additional error checking * if (UseThera && !string.IsNullOrEmptyCurrent(Node.TheraInSig)) * { * //SJS HERE ERROR * } */ CurrentNode.Visited = true; } // build the path List <string> Route = new List <string>(); bool rootError = false; CurrentNode = End; if (End.NearestToStart != null) { while (CurrentNode != null) { Route.Add(CurrentNode.Name); CurrentNode = CurrentNode.NearestToStart; if (Route.Count > 2000) { rootError = true; break; } } Route.Reverse(); } List <RoutePoint> ActualRoute = new List <RoutePoint>(); if (!rootError) { for (int i = 0; i < Route.Count; i++) { RoutePoint RP = new RoutePoint(); RP.SystemName = Route[i]; RP.ActualSystem = EveManager.Instance.GetEveSystem(Route[i]); RP.GateToTake = GateType.StarGate; RP.LY = 0.0; if (i < Route.Count - 1) { MapNode mn = MapNodes[RP.SystemName]; if (mn.JBConnection != null && mn.JBConnection == Route[i + 1]) { RP.GateToTake = GateType.Ansiblex; } if (UseThera && mn.TheraConnections != null && mn.TheraConnections.Contains(Route[i + 1])) { RP.GateToTake = GateType.Thera; } } ActualRoute.Add(RP); } } return(ActualRoute); }
/// <summary> /// Layouts the edge betweend the given points. This method is used to calculate a path that is displayed /// when any of the anchors is changed (via drag&drop). /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> /// <param name="rMode">Routing mode. TODO: Not yet supported.</param> /// <returns></returns> public virtual EdgePointCollection CalcLayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode) { EdgePointCollection points = new EdgePointCollection(); /*if (rMode == RoutingMode.Orthogonal) * { * try * { * // calculate points between start and end * List<PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLineSimple(this, this.FromShape, startPoint, this.ToShape, endPoint, GetLinkPlacement(this.ToShape.AbsoluteBounds, endPoint)); * * foreach (PointD p in calcPoints) * points.Add(new EdgePoint(p.X, p.Y)); * } * catch * { * points.Add(new EdgePoint(startPoint)); * points.Add(new EdgePoint(endPoint)); * } * } * else * {*/ points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(endPoint)); //} return(points); }
/// <summary> /// Layouts the edge betweend the given points. /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> /// <param name="rMode">Routing mode.</param> /// <returns></returns> public virtual EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode) { EdgePointCollection points = new EdgePointCollection(); if (rMode == RoutingMode.Orthogonal) { try { // calculate points between start and end List <PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLine(this, this.FromShape, startPoint, this.ToShape, endPoint); foreach (PointD p in calcPoints) { points.Add(new EdgePoint(p.X, p.Y)); } } catch { points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(endPoint)); } } else { points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(endPoint)); } return(points); }
public SimPacket(AHAddress source, AHAddress destination, RoutingMode mode) { this.Source = source; this.Destination = destination; this.Mode = mode; this.Hops = 0; }
public CTCOfficeGUI(ISimulationEnvironment env, CTCOffice ctc) { InitializeComponent(); //set refs to ctc office and environment _ctcOffice = ctc; _environment = env; _speedState = 0; _res = _ctcOffice.Resource; _ctcOffice.LoadData += new EventHandler<EventArgs>(_ctcOffice_LoadData); _ctcOffice.UnlockLogin += new EventHandler<EventArgs>(_ctcOffice_UnlockLogin); _ctcOffice.MessagesReady += new EventHandler<EventArgs>(_ctcOffice_MessagesReady); _ctcOffice.UpdatedData += new EventHandler<EventArgs>(_ctcOffice_UpdatedData); _loginState = false; _btnLoginLogout.Enabled = _loginState; _txtPassword.Enabled = _loginState; _txtUsername.Enabled = _loginState; _rate = 100; _tickCount = 0; //init routing vars _routeTool = null; _inRoutingPoint = false; _routingToolOpen = false; _routeToolMode = RoutingMode.Dispatch; _lastRightClickContainer = null; _keyForm = null; _keyOpen = false; //subscribe to Environment Tick _environment.Tick += _environment_Tick; //ensure the user is logged out _ctcOffice.Logout(); //change button text _btnLoginLogout.Text = "Login"; //show team logo (block out user) MainDisplayLogo(); DisableUserControls(); _loginStatusImage.Image = _res.RedLight; _imageTeamLogo.Image = Properties.Resources.TerminalVelocity; UpdateMetrics(); RefreshStatus(); //populate red line and green line panel //parseLineData(); //enables double buffering for control drawings //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); //post to log that the gui has loaded _environment.SendLogEntry("CTCOffice: GUI Loaded"); _tt = null; }
/// <summary> /// Calculates a path geometry between the source and the target points. /// </summary> /// <param name="sourcePoint">Source point (Absolute location).</param> /// <param name="targetPoint">Target point (Absolute location).</param> /// <param name="fixedPoints">Fixed points.</param> /// <param name="routingMode">Routing mode.</param> /// <returns>Calculated path geometry.</returns> public virtual PathGeometry CalcPathGeometry(PointD sourcePoint, PointD targetPoint, FixedGeometryPoints fixedPoints, RoutingMode routingMode) { // fixedPoints: not required yet... EdgePointCollection col = this.ShapeElement.CalcLayoutEdge(sourcePoint, targetPoint, routingMode); PathGeometry geometry = new PathGeometry(); PathFigure figure = new PathFigure(); figure.StartPoint = new System.Windows.Point(col[0].X, col[0].Y); List <System.Windows.Point> points = new List <System.Windows.Point>(); for (int i = 1; i < col.Count; i++) { points.Add(new System.Windows.Point(col[i].X, col[i].Y)); } figure.Segments.Add(new PolyLineSegment(points, true)); geometry.Figures.Add(figure); return(geometry); }
/// <summary> /// Layouts an edge between the given points. /// </summary> /// <param name="startPoint">Start point.</param> /// <param name="endPoint">End point.</param> /// <param name="rMode">Routing mode.</param> /// <returns>Edge point collection.</returns> public override EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode) { double middle = startPoint.X + (endPoint.X - startPoint.X) / 2.0; EdgePointCollection points = new EdgePointCollection(); points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(middle, startPoint.Y)); points.Add(new EdgePoint(middle, endPoint.Y)); points.Add(new EdgePoint(endPoint)); return(points); }
/// <summary> /// Calculates a path geometry between the source and the target points. /// </summary> /// <param name="sourcePoint">Source point (Absolute location).</param> /// <param name="targetPoint">Target point (Absolute location).</param> /// <param name="fixedPoints">Fixed points.</param> /// <param name="routingMode">Routing mode.</param> /// <returns>Calculated path geometry.</returns> public virtual PathGeometry CalcPathGeometry(PointD sourcePoint, PointD targetPoint, FixedGeometryPoints fixedPoints, RoutingMode routingMode) { // fixedPoints: not required yet... EdgePointCollection col = this.ShapeElement.CalcLayoutEdge(sourcePoint, targetPoint, routingMode); PathGeometry geometry = new PathGeometry(); PathFigure figure = new PathFigure(); figure.StartPoint = new System.Windows.Point(col[0].X, col[0].Y); List<System.Windows.Point> points = new List<System.Windows.Point>(); for (int i = 1; i < col.Count; i++) { points.Add(new System.Windows.Point(col[i].X, col[i].Y)); } figure.Segments.Add(new PolyLineSegment(points, true)); geometry.Figures.Add(figure); return geometry; }
/// <summary> /// Layouts the edge betweend the given points. This method is used to calculate a path that is displayed /// when any of the anchors is changed (via drag&drop). /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> /// <param name="rMode">Routing mode. TODO: Not yet supported.</param> /// <returns></returns> public virtual EdgePointCollection CalcLayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode) { EdgePointCollection points = new EdgePointCollection(); /*if (rMode == RoutingMode.Orthogonal) { try { // calculate points between start and end List<PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLineSimple(this, this.FromShape, startPoint, this.ToShape, endPoint, GetLinkPlacement(this.ToShape.AbsoluteBounds, endPoint)); foreach (PointD p in calcPoints) points.Add(new EdgePoint(p.X, p.Y)); } catch { points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(endPoint)); } } else {*/ points.Add(new EdgePoint(startPoint)); points.Add(new EdgePoint(endPoint)); //} return points; }
private void ProcessNode(BinaryNode <T> node, Action <BinaryNode <T> > action, RoutingMode routing, DirectionMode direction) { if (node == null) { return; } switch (routing) { case RoutingMode.Direct: { action?.Invoke(node); if (direction == DirectionMode.Left) { ProcessNode(node.LeftSon, action, routing, direction); ProcessNode(node.RightSon, action, routing, direction); } else if (direction == DirectionMode.Right) { ProcessNode(node.RightSon, action, routing, direction); ProcessNode(node.LeftSon, action, routing, direction); } break; } case RoutingMode.Internal: { if (direction == DirectionMode.Left) { ProcessNode(node.LeftSon, action, routing, direction); action?.Invoke(node); ProcessNode(node.RightSon, action, routing, direction); } else if (direction == DirectionMode.Right) { ProcessNode(node.RightSon, action, routing, direction); action?.Invoke(node); ProcessNode(node.LeftSon, action, routing, direction); } break; } case RoutingMode.Inverted: { if (direction == DirectionMode.Left) { ProcessNode(node.LeftSon, action, routing, direction); ProcessNode(node.RightSon, action, routing, direction); } else if (direction == DirectionMode.Right) { ProcessNode(node.RightSon, action, routing, direction); ProcessNode(node.LeftSon, action, routing, direction); } action?.Invoke(node); break; } } }
public void ProcessTree(Action <BinaryNode <T> > action, RoutingMode routing, DirectionMode direction) { ProcessNode(Root, action, routing, direction); }
public CTCOfficeGUI(ISimulationEnvironment env, CTCOffice ctc) { InitializeComponent(); //set refs to ctc office and environment _ctcOffice = ctc; _environment = env; _speedState = 0; _res = _ctcOffice.Resource; _ctcOffice.LoadData += new EventHandler <EventArgs>(_ctcOffice_LoadData); _ctcOffice.UnlockLogin += new EventHandler <EventArgs>(_ctcOffice_UnlockLogin); _ctcOffice.MessagesReady += new EventHandler <EventArgs>(_ctcOffice_MessagesReady); _ctcOffice.UpdatedData += new EventHandler <EventArgs>(_ctcOffice_UpdatedData); _loginState = false; _btnLoginLogout.Enabled = _loginState; _txtPassword.Enabled = _loginState; _txtUsername.Enabled = _loginState; _rate = 100; _tickCount = 0; //init routing vars _routeTool = null; _inRoutingPoint = false; _routingToolOpen = false; _routeToolMode = RoutingMode.Dispatch; _lastRightClickContainer = null; _keyForm = null; _keyOpen = false; //subscribe to Environment Tick _environment.Tick += _environment_Tick; //ensure the user is logged out _ctcOffice.Logout(); //change button text _btnLoginLogout.Text = "Login"; //show team logo (block out user) MainDisplayLogo(); DisableUserControls(); _loginStatusImage.Image = _res.RedLight; _imageTeamLogo.Image = Properties.Resources.TerminalVelocity; UpdateMetrics(); RefreshStatus(); //populate red line and green line panel //parseLineData(); //enables double buffering for control drawings //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); //post to log that the gui has loaded _environment.SendLogEntry("CTCOffice: GUI Loaded"); _tt = null; }
public static List <RoutePoint> Navigate(string From, string To, bool UseJumpGates, RoutingMode routingMode) { if (!(MapNodes.Keys.Contains(From) || MapNodes.Keys.Contains(To)) || From == "" || To == "") { return(null); } // clear the scores, values and parents from the list foreach (MapNode mapNode in MapNodes.Values) { mapNode.NearestToStart = null; mapNode.MinCostToStart = 0; mapNode.Visited = false; switch (routingMode) { case RoutingMode.PreferLow: { if (mapNode.HighSec) { mapNode.Cost = 1000; } } break; case RoutingMode.Safest: { if (!mapNode.HighSec) { mapNode.Cost = 1000; } } break; case RoutingMode.Shortest: mapNode.Cost = 1; break; } } MapNode Start = MapNodes[From]; MapNode End = MapNodes[To]; List <MapNode> OpenList = new List <MapNode>(); List <MapNode> ClosedList = new List <MapNode>(); MapNode CurrentNode = null; // add the start to the open list OpenList.Add(Start); while (OpenList.Count > 0) { // get the MapNode with the lowest F score int lowest = OpenList.Min(mn => mn.MinCostToStart); CurrentNode = OpenList.First(mn => mn.MinCostToStart == lowest); // add the list to the closed list ClosedList.Add(CurrentNode); // remove it from the open list OpenList.Remove(CurrentNode); // walk the connections foreach (string connectionName in CurrentNode.Connections) { MapNode CMN = MapNodes[connectionName]; if (CMN.Visited) { continue; } if (CMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + CMN.Cost < CMN.MinCostToStart) { CMN.MinCostToStart = CurrentNode.MinCostToStart + CMN.Cost; CMN.NearestToStart = CurrentNode; if (!OpenList.Contains(CMN)) { OpenList.Add(CMN); } } } if (UseJumpGates && CurrentNode.JBConnection != null) { MapNode JMN = MapNodes[CurrentNode.JBConnection]; if (!JMN.Visited && JMN.MinCostToStart == 0 || CurrentNode.MinCostToStart + JMN.Cost < JMN.MinCostToStart) { JMN.MinCostToStart = CurrentNode.MinCostToStart + JMN.Cost; JMN.NearestToStart = CurrentNode; if (!OpenList.Contains(JMN)) { OpenList.Add(JMN); } } } CurrentNode.Visited = true; } // build the path List <string> Route = new List <string>(); CurrentNode = End; if (End.NearestToStart != null) { while (CurrentNode != null) { Route.Add(CurrentNode.Name); CurrentNode = CurrentNode.NearestToStart; } Route.Reverse(); } List <RoutePoint> ActualRoute = new List <RoutePoint>(); for (int i = 0; i < Route.Count; i++) { RoutePoint RP = new RoutePoint(); RP.SystemName = Route[i]; RP.GateToTake = GateType.StarGate; if (i < Route.Count - 1) { MapNode mn = MapNodes[RP.SystemName]; if (mn.JBConnection != null && mn.JBConnection == Route[i + 1]) { RP.GateToTake = GateType.Ansibex; } } ActualRoute.Add(RP); } return(ActualRoute); }