internal override void RecoverFromStateDescriptor(string stateDescriptor) { try { int indexOfDot = stateDescriptor.IndexOf('.'); string substr = indexOfDot >= 0 ? stateDescriptor.Substring(0, indexOfDot) : stateDescriptor; ActiveStateId = Convert.ToInt32(substr); if (ActiveStateId == EntryStateId) { EntryNode.RecoveryEnter(); } else if (ActiveStateId == ExitStateId) { ExitNode.RecoveryEnter(); } else { states[ActiveStateId].RecoverFromStateDescriptor(stateDescriptor.Substring(indexOfDot + 1)); } } catch { throw new ArgumentException("Infra.Algorithm.StateMachine.StateMachine: stateDescriptor is invalid"); } }
public Type Visit(ExitNode node) { if (!inLoopOrFor) { throw new SemanticError("Unexpected exit statement", node.AnchorToken); } return(Type.VOID); }
//TODO use NodeType to categorize Types. public static BaseNode CreateNode(ActionNodeData aData) { if (aData.NodeType == null) { Debug.LogError("Type not set"); return(null); } aData.GUID = string.IsNullOrEmpty(aData.GUID) ? Guid.NewGuid().ToString() : aData.GUID; aData.OutputPortIDs = aData.OutputPortIDs ?? new List <string>(); //The copy prevent the node to modify the list in the ActionNodeData List <string> copy = new List <string>(); foreach (var outputPort in aData.OutputPortIDs) { copy.Add(outputPort); } BaseNode node; Type type = Type.GetType(aData.NodeType); if (type == typeof(ChangeSceneNode)) { node = ChangeSceneNode.Create("Change Scene", aData.Position, aData.GUID, copy); } else if (type == typeof(StartNode)) { node = StartNode.Create("Start Node", aData.Position, aData.GUID, copy); } else if (type == typeof(ConditionalNode)) { node = ConditionalNode.Create("Conditional", aData.Position, aData.GUID, copy); } else if (type == typeof(MultiNode)) { node = MultiNode.Create("Multi Output", aData.Position, aData.GUID, copy); } else if (type == typeof(ExitNode)) { node = ExitNode.Create("Exit Node", aData.Position, aData.GUID, copy); } else if (type == typeof(RandomNode)) { node = RandomNode.Create("Random Node", aData.Position, aData.GUID, copy); } else if (type == typeof(TakeObjectNode)) { node = TakeObjectNode.Create("Take Object", aData.Position, aData.GUID, copy); } else { throw new NotImplementedException($"Node type {type} not handled in NodeFactory"); } node?.SetSerializedScript(aData.SerializedScript); return(node); }
public ExitBuilder(ExitNode exitnode) { node = exitnode; DotDefinition = new List <IDotElement>(); CreateNode(); CreateEdgeToNextSibling(); CreateSpecialEdge(); }
public Node ExitStatement() { var exit_node = new ExitNode() { AnchorToken = Expect(TokenCategory.EXIT) }; Expect(TokenCategory.SEMICOLON); return(exit_node); }
public VisualExitNode(ExitNode node, VisualFloor floor) : base(node, floor) { Width = 60; Height = 60; normalBrush = Brushes.Orange; selectBrush = normalBrush; normalPen.Brush = Brushes.Red; selectPen = normalPen; Draw(); }
/// <summary> /// Initializes a new instance of the <see cref="ProcedureDescription"/> class. /// </summary> /// <param name="methodDefinition">The <see cref="MethodDefinition"/> from which to create /// the description.</param> /// <param name="cfg">The CFG with which this procedure description is associated.</param> public ProcedureDescription(MethodDefinition methodDefinition, Cfg cfg) { PdId = NextId; var parameters = methodDefinition.Parameters.Select( p => new VariableDescription(p.Name, Typ.FromTypeReference(p.ParameterType))); if (!methodDefinition.IsStatic) { parameters = parameters.Prepend( new VariableDescription(Identifier.ThisIdentifier, Typ.FromTypeReference( methodDefinition.DeclaringType))); } var location = Location.FromSequencePoint( methodDefinition.DebugInformation.SequencePoints.FirstOrDefault()); PdAttributes = new ProcedureAttributes() { Access = methodDefinition.IsPublic ? ProcedureAttributes.ProcedureAccessKind.Public : methodDefinition.IsPrivate ? ProcedureAttributes.ProcedureAccessKind.Private : ProcedureAttributes.ProcedureAccessKind.Default, Formals = parameters.ToList(), RetType = Typ.FromTypeReference(methodDefinition.ReturnType), Loc = location, ProcName = new ProcedureName(methodDefinition) }; Nodes = new List <CfgNode>(); StartNode = new StartNode(location, this); ExitNode = new ExitNode(Location.FromSequencePoint(methodDefinition .DebugInformation .SequencePoints .FirstOrDefault()), this); ExceptionSinkNode = new StatementNode(location, StatementNode.StatementNodeKind.ExceptionsSink, proc: this); cfg.RegisterNode(StartNode); cfg.RegisterNode(ExitNode); cfg.RegisterNode(ExceptionSinkNode); }
public List <MovementDirectionCode> GetPath(EntryNode _Origin, ExitNode _Destination) { NetworkData network = new NetworkData(); List <NodeData> nodes = new List <NodeData>(); List <LinkData> links = new List <LinkData>(); //NetworkTopologyParking.CreateNetworkTopology(network, node, link); //Path p = new Path(link, node); Path p = new Path(); p.CalcUEassignment(links, nodes); List <ushort> _nodesIndex = new List <ushort>(); float _dis = 0; List <ushort> _pathNodes = new List <ushort>(); List <uint> _pathLinks = new List <uint>(); List <MovementDirectionCode> TurningMovementList = new List <MovementDirectionCode>(); p.PathGeneration(_Origin, _Destination, 1, ref _nodesIndex, ref _pathLinks, ref _dis); foreach (ushort index_i in _nodesIndex) { _pathNodes.Add(nodes[index_i].Id); } for (int i = 1; i < _pathLinks.Count; i++) { if (links[i - 1].DownstreamLinkIds[0] == links[i].Id) { TurningMovementList.Add(MovementDirectionCode.Left); } else if (links[i - 1].DownstreamLinkIds[1] == links[i].Id) { TurningMovementList.Add(MovementDirectionCode.Through); } else { TurningMovementList.Add(MovementDirectionCode.Right); } } return(TurningMovementList); }
public void PathGeneration(EntryNode _Origin, ExitNode _Destination, UInt16 _Type, ref List <ushort> _NodesIndex, ref List <uint> _LinksID, ref float _Dis) { if (_Type == 1) //Shortest Path { graph.FindShortestPath(_Origin.ListIndex, _Destination.ListIndex); _NodesIndex = graph.Result; _Dis = graph.Dist[_Origin.ListIndex, _Destination.ListIndex]; for (ushort i = 0; i < _NodesIndex.Count - 1; i++) { _LinksID.Add(linkId[_NodesIndex[i], _NodesIndex[i + 1]]); } } else //Other Path Schemes { graph.FindShortestPath(_Origin.ListIndex, _Destination.ListIndex); _NodesIndex = graph.Result; _Dis = graph.Dist[_Origin.ListIndex, _Destination.ListIndex]; for (ushort i = 0; i < _NodesIndex.Count - 1; i++) { _LinksID.Add(linkId[_NodesIndex[i], _NodesIndex[i + 1]]); } } }
public override DynValue Visit(ExitNode exitNode) { throw new ExitStatementException(); }
/* * * 701-->(19)==(1)===(2)==========================================(3)===(4)====================================(5) * \\ \\ \\ * \\ \\ \\ * (6) (7) (8) * || || || * || || || * || || || * || || || * || || || * (9) (10) (11) * \\ // // * \\ // // * (12)================(13) (14)================(15)===(16)=================================(17) * \\ // * \\ // * (18) * || * || * 801 */ public static void CreateNetworkTopology(NetworkData network, List <NodeData> nodes, List <LinkData> links) { network.NumLinks = 0; const int XcoordStart = 5; const int YcoordStart = 5; const int EntryLinkLength = 250; const int ExitLinkLength = 500; const int IntersectionX = 6; const int IntersectionY = 6; const int LongLinkLength = 1000; const int ShortLinkLength = LongLinkLength / 2 - 2 * IntersectionX; const float GradePct_Left = 0; const float GradePct_Right = 0; const float GradePct_Down = 0; const float GradePct_DownLeft = 0; const float GradePct_DownRight = 0; const float FlowSpeed = 51.3f; //35 mi/h * 1.467 List <float> EnteringPctTrucks = new List <float> { 100, 0, 0, 0, 0 }; List <float> EnteringDriverTypePcts = new List <float> { 5, 8, 10, 12, 15, 15, 12, 10, 8, 5 }; float[] MinEntryHeadway = new float[] { 2.0f, 2.5f, 3.0f, 3.5f }; bool UsePctTurnsByFleet = true; float[] TurningPcts = new float[3]; List <float[]> PctTurnsAtLinkEnd = new List <float[]>(); // connector node network.NumNodes++; LinkConnectorNode NewConnectorNode = new LinkConnectorNode(1, NodeType.LinkConnector, 0, XcoordStart + EntryLinkLength, YcoordStart); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(2, NodeType.LinkConnector, 1, XcoordStart + EntryLinkLength + 2 * IntersectionX, YcoordStart); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(3, NodeType.LinkConnector, 2, XcoordStart + EntryLinkLength + 2 * IntersectionX + LongLinkLength, YcoordStart); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(4, NodeType.LinkConnector, 3, XcoordStart + EntryLinkLength + 2 * IntersectionX + LongLinkLength + 2 * IntersectionX, YcoordStart - IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(5, NodeType.LinkConnector, 4, XcoordStart + EntryLinkLength + 2 * IntersectionX + LongLinkLength + 2 * IntersectionX + LongLinkLength, YcoordStart - IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(6, NodeType.LinkConnector, 5, XcoordStart + EntryLinkLength + IntersectionX, YcoordStart + 2 * IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(7, NodeType.LinkConnector, 6, XcoordStart + EntryLinkLength + IntersectionX + LongLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(8, NodeType.LinkConnector, 7, XcoordStart + EntryLinkLength + IntersectionX + LongLinkLength + 2 * IntersectionX + LongLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(9, NodeType.LinkConnector, 8, XcoordStart + EntryLinkLength + IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(10, NodeType.LinkConnector, 9, XcoordStart + EntryLinkLength + IntersectionX + LongLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(11, NodeType.LinkConnector, 10, XcoordStart + EntryLinkLength + IntersectionX + LongLinkLength + 2 * IntersectionX + LongLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(12, NodeType.LinkConnector, 11, XcoordStart + EntryLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(13, NodeType.LinkConnector, 12, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(14, NodeType.LinkConnector, 13, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 4 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(15, NodeType.LinkConnector, 14, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 4 * IntersectionX + ShortLinkLength, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(16, NodeType.LinkConnector, 15, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 4 * IntersectionX + ShortLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(17, NodeType.LinkConnector, 16, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 4 * IntersectionX + ShortLinkLength + 2 * IntersectionX + LongLinkLength, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(18, NodeType.LinkConnector, 17, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY + IntersectionY); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // connector node network.NumNodes++; NewConnectorNode = new LinkConnectorNode(19, NodeType.LinkConnector, 18, XcoordStart + EntryLinkLength / 2, YcoordStart); nodes.Add(NewConnectorNode); network.NodeIdList.Add(NewConnectorNode.Id); // entry node network.NumNodes++; EntryNode NewEntryNode = new EntryNode(701, NodeType.Entry, 19, XcoordStart, YcoordStart, 70119, 1, MinEntryHeadway, 400, 400, EnteringPctTrucks, EnteringDriverTypePcts, false, 100, FlowSpeed); nodes.Add(NewEntryNode); network.NodeIdList.Add(NewEntryNode.Id); // exit node network.NumNodes++; ExitNode NewExitNode = new ExitNode(801, NodeType.Exit, 20, XcoordStart + EntryLinkLength + 2 * IntersectionX + ShortLinkLength + 2 * IntersectionX, YcoordStart + 2 * IntersectionY + LongLinkLength + IntersectionY + IntersectionY + ExitLinkLength); nodes.Add(NewExitNode); network.NodeIdList.Add(NewExitNode.Id); // link 1->2 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; LinkData NewLink = new LinkData(0, nodes[0], nodes[1], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 2, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 191, 0, 0, 23, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[1].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[1].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 2, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[1].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 2, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 2->3 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 67, 33 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(1, nodes[1], nodes[2], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 2, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 12, 0, 0, 34, 37, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[1].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[1].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 2, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[1].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[0].Type = LaneType.AuxFull; links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 3->4 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(2, nodes[2], nodes[3], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 23, 0, 0, 45, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 4->5 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 0, 100 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(3, nodes[3], nodes[4], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 34, 0, 0, 0, 58, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 0, 1); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 1->6 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(4, nodes[0], nodes[5], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownRight, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 191, 0, 69, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[0].PositionX, nodes[0].PositionY + 6, nodes[0].PositionX + 6, nodes[0].PositionY + 6, nodes[0].PositionX + 6, nodes[0].PositionY + 12); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 3->7 network.NumLinks++; NewLink = new LinkData(5, nodes[2], nodes[6], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownRight, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 23, 0, 710, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[2].PositionX, nodes[2].PositionY + 6, nodes[2].PositionX + 6, nodes[2].PositionY + 6, nodes[2].PositionX + 6, nodes[2].PositionY + 12); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 5->8 network.NumLinks++; NewLink = new LinkData(6, nodes[4], nodes[7], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownRight, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 45, 0, 811, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[4].PositionX, nodes[4].PositionY, nodes[4].PositionX + 6, nodes[4].PositionY, nodes[4].PositionX + 6, nodes[4].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 6->9 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 100, 0, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(7, nodes[5], nodes[8], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Down, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 16, 0, 912, 0, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Left); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(1, 0, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 7->10 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 0, 100 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(8, nodes[6], nodes[9], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Down, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 37, 0, 0, 0, 1015, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 0, 1); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 8->11 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 0, 100 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(9, nodes[7], nodes[10], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Down, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 58, 0, 0, 0, 1117, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 0, 1); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 9->12 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 100, 0, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(10, nodes[8], nodes[11], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownRight, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 69, 0, 0, 0, 1213, 0, TravelDirection.LeftTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[8].PositionX, nodes[8].PositionY, nodes[8].PositionX, nodes[8].PositionY + 6, nodes[8].PositionX + 6, nodes[8].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 10->15 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(11, nodes[9], nodes[14], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownLeft, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 710, 0, 1514, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[9].PositionX, nodes[9].PositionY, nodes[9].PositionX, nodes[9].PositionY + 6, nodes[9].PositionX - 6, nodes[9].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 11->17 network.NumLinks++; NewLink = new LinkData(12, nodes[10], nodes[16], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownLeft, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 811, 0, 0, 0, 1716, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[10].PositionX, nodes[10].PositionY, nodes[10].PositionX, nodes[10].PositionY + 6, nodes[10].PositionX - 6, nodes[10].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 12->13 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 0, 100 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(13, nodes[11], nodes[12], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 912, 0, 0, 0, 0, 1318, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 0, 1); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 15->14 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 100, 0, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(14, nodes[14], nodes[13], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Left, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 1615, 1015, 1418, 0, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Left); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(1, 0, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 16->15 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(15, nodes[15], nodes[14], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Left, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 1716, 0, 0, 1514, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 17->16 network.NumLinks++; NewLink = new LinkData(16, nodes[16], nodes[15], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Left, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 1117, 0, 1615, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 13->18 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 0, 100 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(17, nodes[12], nodes[17], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_DownRight, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 1213, 0, 18801, 0, TravelDirection.RightTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[12].PositionX, nodes[12].PositionY, nodes[12].PositionX + 6, nodes[12].PositionY, nodes[12].PositionX + 6, nodes[12].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 14->18 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 100, 0, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(18, nodes[13], nodes[17], LinkType.ArterialConnector, LinkCurveType.Bezier, GradePct_Left, FlowSpeed, 1, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 1514, 0, 0, 0, 18801, 0, TravelDirection.LeftTurn, FreeFlowSpeedMethod.Measured, TwoLaneLinkPassingDesignation.NotAllowed, TwoLaneLinkPassingRule.None, nodes[13].PositionX, nodes[13].PositionY, nodes[13].PositionX - 6, nodes[13].PositionY, nodes[13].PositionX - 6, nodes[13].PositionY + 6); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 2, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // link 19->1 PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 50, 50 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(19, nodes[18], nodes[0], LinkType.ArterialConnector, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 2, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 70119, 0, 0, 12, 16, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Right); NewLink.Lanes[1].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[1].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 2, 0); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 1); NewLink.Lanes[1].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 2, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // entry link PctTurnsAtLinkEnd = new List <float[]>(); for (int k = 0; k <= 4; k++) { TurningPcts = new float[] { 0, 100, 0 }; PctTurnsAtLinkEnd.Add(TurningPcts); } network.NumLinks++; NewLink = new LinkData(20, nodes[19], nodes[18], LinkType.ArterialEntry, LinkCurveType.Linear, GradePct_Right, FlowSpeed, 2, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 0, 0, 0, 0, 191, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[1].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 1, 0); NewLink.Lanes[1].ConnectingLaneIdsDownstream = LaneData.SetConnectingLaneIds(0, 2, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); // exit link network.NumLinks++; NewLink = new LinkData(21, nodes[17], nodes[20], LinkType.ArterialExit, LinkCurveType.Linear, 0, FlowSpeed, 2, UsePctTurnsByFleet, PctTurnsAtLinkEnd, 1318, 0, 1418, 0, 0, 0, TravelDirection.Straight); NewLink.Lanes[0].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[1].AllowedTurnMovements.Add(MovementDirectionCode.Through); NewLink.Lanes[0].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(0, 0, 1); NewLink.Lanes[1].ConnectingLaneIdsUpstream = LaneData.SetConnectingLaneIds(1, 0, 0); links.Add(NewLink); network.LinkIdList.Add(NewLink.Id); }
public abstract DynValue Visit(ExitNode exitNode);
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { if (CurrentFloor == null) { return; } e.Handled = true; var position = GetAbsolutePosition(e.GetPosition(this)); try { switch (SelectedActionMode) { case ActionMode.AddStart: { var start = new StartNode(CurrentFloor.Model, position); AddVisualEntity(new VisualStartNode(start, CurrentFloor)); break; } case ActionMode.AddExit: { var exit = new ExitNode(CurrentFloor.Model, position); AddVisualEntity(new VisualExitNode(exit, CurrentFloor)); break; } case ActionMode.AddEntry: { var entry = new EntryNode(CurrentFloor.Model, position); AddVisualEntity(new VisualEntryNode(entry, CurrentFloor)); break; } case ActionMode.AddStairs: case ActionMode.AddRoad: { CreatingSection(position); break; } case ActionMode.Move: { var entity = CurrentFloor.GetVisualEntity(position); if (entity != null) { moveInformation = new MoveInformation(entity.GetUnit(position), position); entity.Model.IsSelected = true; } else if (Shell != null) { moveInformation = new MoveInformation(Shell, e.GetPosition(this), true); e.Handled = false; } e.Handled = true; break; } case ActionMode.Remove: { var entity = CurrentFloor.GetVisualEntity(position); CurrentFloor.RemoveVisualEntity(entity); break; } case ActionMode.SetScale: { if (IsCreatingLine) { CreatingLineInf.LastPosition = position; SetScale(); } else { CreatingLineInf = new CreatingLineInformation(new VisualThumb(position)); } break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Visit(ExitNode node) { builder.AppendLine($"\t\tbr end_{currentId}"); }
protected override void OnEnable() { base.OnEnable(); m_exitNode = (ExitNode)target; m_infoMessageNotConnected = new InfoMessage(InfoMessage.MessageType.Error, UILabels.NotConnectedTitle, UILabels.NotConnectedMessage); }
public Building Load(string filename) { var formatter = new BinaryFormatter(); var files = new List <SavedFile>(); using (var fs = new FileStream(filename, FileMode.OpenOrCreate)) { files = (List <SavedFile>)formatter.Deserialize(fs); } Type t = typeof(Building); var sBuilding = (BuildingSavedFile)files.FirstOrDefault(x => x.FileType == typeof(Building)); if (sBuilding == null) { return(null); } Building building = new Building(sBuilding.Title); var dictionary = new Dictionary <int, dynamic>(); foreach (var file in files.Where(x => x.FileType == typeof(ZoomTool))) { var sScale = file as ZoomToolSavedFile; dictionary.Add(sScale.HashCode, new ZoomTool(sScale.ActualLength, sScale.GraphicLength)); } foreach (var file in files.Where(x => x.FileType == typeof(Floor))) { var sFloor = file as FloorSavedFile; var floor = new Floor(sFloor.Title, building) { Scale = dictionary[sFloor.Scale], FloorPlanImage = SettingsManager.GetBitmapImage(sFloor.FloorPlanImage) }; dictionary.Add(sFloor.HashCode, floor); building.AddFloor(floor); } foreach (var file in files) { if (file is StartNodeSavedFile) { var sNode = file as StartNodeSavedFile; Floor floor = dictionary[sNode.ParentHashCode]; var node = new StartNode(floor, sNode.Position, sNode.Title) { PeopleCount = sNode.PeopleCount, ProjectionArea = sNode.ProjectionArea, AutoSize = sNode.AutoSize }; dictionary.Add(sNode.HashCode, node); floor.AddObject(node); continue; } if (file is EntryNodeSavedFile) { var sNode = file as EntryNodeSavedFile; Floor floor = dictionary[sNode.ParentHashCode]; var node = new EntryNode(floor, sNode.Position, sNode.Title) { AutoSize = sNode.AutoSize, Width = sNode.Width }; dictionary.Add(sNode.HashCode, node); floor.AddObject(node); continue; } if (file is StairsNodeSavedFile) { var sNode = file as StairsNodeSavedFile; Floor floor = dictionary[sNode.ParentHashCode]; var node = new StairsNode(floor, sNode.Position, sNode.Title) { AutoSize = sNode.AutoSize, IsFloorsConnected = sNode.IsFloorsConnected }; dictionary.Add(sNode.HashCode, node); floor.AddObject(node); continue; } if (file is NodeSavedFile) { var sNode = file as NodeSavedFile; Floor floor = dictionary[sNode.ParentHashCode]; Node node = null; if (sNode.FileType == typeof(ExitNode)) { node = new ExitNode(floor, sNode.Position, sNode.Title) { AutoSize = sNode.AutoSize } } ; if (sNode.FileType == typeof(RoadNode)) { node = new RoadNode(floor, sNode.Position, sNode.Title) { AutoSize = sNode.AutoSize } } ; dictionary.Add(sNode.HashCode, node); floor.AddObject(node); continue; } if (file is SectionSavedFile) { var sSection = file as SectionSavedFile; Floor floor = dictionary[sSection.ParentHashCode]; Section section = null; if (sSection.FileType == typeof(RoadSection)) { section = new RoadSection((Node)dictionary[sSection.FirstNodeHashCode], (Node)dictionary[sSection.LastNodeHashCode], floor, sSection.Title) { AutoSize = sSection.AutoSize, Length = sSection.Length, Width = sSection.Width } } ; else if (sSection.FileType == typeof(StairsSection)) { section = new StairsSection((Node)dictionary[sSection.FirstNodeHashCode], (Node)dictionary[sSection.LastNodeHashCode], floor, sSection.Title) { AutoSize = sSection.AutoSize, Length = sSection.Length, Width = sSection.Width } } ; else if (sSection.FileType == typeof(FloorsConnectionSection)) { continue; // следует произвести добавление в самом конце } dictionary.Add(sSection.HashCode, section); floor.AddObject(section); continue; } } foreach (var file in files.Where(x => x.FileType == typeof(FloorsConnectionSection))) { var sSection = file as SectionSavedFile; Floor floor = dictionary[sSection.ParentHashCode]; var section = new FloorsConnectionSection((Node)dictionary[sSection.FirstNodeHashCode], (Node)dictionary[sSection.LastNodeHashCode], floor); dictionary.Add(sSection.HashCode, section); floor.AddObject(section); } return(building); } } }