public LaneChangeBehavior(LaneID startLane, LaneID endLane, double dist, LaneSpeedCommand speedCommand) { this.startLane = startLane; this.endLane = endLane; this.distance = dist; this.speedCommand = speedCommand; }
private void OnCreateFileInWatchedFolder(object sender, FileSystemEventArgs e) { //e.FullPath = Z:\\Test.xml //e.Name = Test.xml WatchedFiles.Enqueue(e.Name); Log4.PrinterLogger.InfoFormat("+[{0}] Watched Target:{1} => Create:{2}", LaneID.ToString(), Target, e.Name); switch (LaneID) { case eAssignedLane_Printer.Lane1: // 第一軌 System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModelLocator.Atom.FlowHostVM.Lane1WFList.Add(e.Name); })); break; case eAssignedLane_Printer.Lane2: System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { ViewModelLocator.Atom.FlowHostVM.Lane2WFList.Add(e.Name); })); break; } }
/// <summary> /// Constructor /// </summary> /// <param name="lane"></param> /// <param name="waypoint"></param> /// <param name="stopType"></param> public StoppingState(LaneID lane, RndfWaypointID waypoint, StopType stopType, LaneDescription currentLane) : base(lane, lane) { this.stopType = stopType; this.waypoint = waypoint; this.currentLane = currentLane; }
/// <summary> /// Constructor. /// Assumes not in intersection and lane confidence 1 /// </summary> /// <param name="initialLane"></param> /// <param name="targetLane"></param> public LaneEstimate(LaneID initialLane, LaneID targetLane) { this.initialLane = initialLane; this.targetLane = targetLane; this.confidence = 1; this.inIntersection = false; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane">Lane of origination</param> /// <param name="targetLane">Target lane of vehicle</param> /// <param name="confidence">Confidence of this beign a proper estimate</param> public LaneEstimate(LaneID initialLane, LaneID targetLane, double confidence, bool inIntersection) { this.initialLane = initialLane; this.targetLane = targetLane; this.confidence = confidence; this.inIntersection = inIntersection; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> public ChangeLanesState(bool initialIsOncoming, LaneID initialLane, LaneID finalLane, Path changeLanesPath, PointOnPath initialPosition, PointOnPath lowerBound, PointOnPath upperBound) : base(initialLane, finalLane) { this.initialIsOncoming = initialIsOncoming; this.ChangeLanesPath = changeLanesPath; this.InitialPosition = initialPosition; this.LowerBound = lowerBound; this.UpperBound = upperBound; }
private void OnRenameFileInWatchedFolder(object sender, RenamedEventArgs e) { //e.FullPath = Z:\\Test.xml //e.Name = Test.xml Log4.PrinterLogger.InfoFormat("+[{0}] Watched Target:{1} => Rename:{2} => {3}" , LaneID.ToString(), Target , Path.GetFileName(e.OldFullPath) //取檔名 , Path.GetFileName(e.FullPath)); //取檔名 for (int i = 0; i < WatchedFiles.Count; i++) { if (WatchedFiles[i] == Path.GetFileName(e.OldFullPath)) { WatchedFiles[i] = Path.GetFileName(e.FullPath); } } switch (LaneID) { case eAssignedLane_Printer.Lane1: // 第一軌 System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { var lst = ViewModelLocator.Atom.FlowHostVM.Lane1WFList; for (int i = 0; i < lst.Count; i++) { if (Path.GetFileName(lst[i].Value) == Path.GetFileName(e.OldFullPath)) { lst[i].Value = Path.GetFileName(e.FullPath); } } })); break; case eAssignedLane_Printer.Lane2: System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { var lst = ViewModelLocator.Atom.FlowHostVM.Lane2WFList; for (int i = 0; i < lst.Count; i++) { if (Path.GetFileName(lst[i].Value) == Path.GetFileName(e.OldFullPath)) { lst[i].Value = Path.GetFileName(e.FullPath); } } })); break; } }
/// <summary> /// Determines the lane adjacency /// </summary> /// <param name="rndf"></param> /// <returns></returns> private RndfNetwork DetermineLaneAdjacency(RndfNetwork rndf) { // loop over segment foreach (Segment segment in rndf.Segments.Values) { // make sure both ways valid if (segment.Way1.IsValid && segment.Way2.IsValid) { // dictionary of lanes in the segment Dictionary <LaneID, Lane> segmentLanes = new Dictionary <LaneID, Lane>(); // construct dictionary foreach (Way way in segment.Ways.Values) { foreach (Lane lane in way.Lanes.Values) { segmentLanes.Add(lane.LaneID, lane); } } // check sample lane in way1 Lane way1SampleLane = null; foreach (Lane tmp in segment.Way1.Lanes.Values) { way1SampleLane = tmp; } // check sample lane in way2 Lane way2SampleLane = null; foreach (Lane tmp in segment.Way2.Lanes.Values) { way2SampleLane = tmp; } // modifies to denote increasing or decreasing form way1 to way 2 int modifier = 1; // check if way2 has lower numbers if (way1SampleLane.LaneID.LaneNumber > way2SampleLane.LaneID.LaneNumber) { modifier = -1; } int i = 1; LaneID currentLaneID = new LaneID(way1SampleLane.LaneID.WayID, i); // loop over lanes while (segmentLanes.ContainsKey(currentLaneID)) { Lane currentLane = segmentLanes[currentLaneID]; // increasing lane LaneID increasingLaneID1 = new LaneID(segment.Way1.WayID, i + (modifier * 1)); LaneID increasingLaneID2 = new LaneID(segment.Way2.WayID, i + (modifier * 1)); if (segmentLanes.ContainsKey(increasingLaneID1)) { if (currentLaneID.WayID.WayNumber == 1) { currentLane.OnLeft = segmentLanes[increasingLaneID1]; } else { currentLane.OnRight = segmentLanes[increasingLaneID1]; } } else if (segmentLanes.ContainsKey(increasingLaneID2)) { if (currentLaneID.WayID.WayNumber == 1) { currentLane.OnLeft = segmentLanes[increasingLaneID2]; } else { currentLane.OnRight = segmentLanes[increasingLaneID2]; } } // check for decreasing // increasing lane increasingLaneID1 = new LaneID(segment.Way1.WayID, i - (modifier * 1)); increasingLaneID2 = new LaneID(segment.Way2.WayID, i - (modifier * 1)); if (segmentLanes.ContainsKey(increasingLaneID1)) { if (currentLaneID.WayID.WayNumber == 1) { currentLane.OnRight = segmentLanes[increasingLaneID1]; } else { currentLane.OnLeft = segmentLanes[increasingLaneID1]; } } else if (segmentLanes.ContainsKey(increasingLaneID2)) { if (currentLaneID.WayID.WayNumber == 1) { currentLane.OnRight = segmentLanes[increasingLaneID2]; } else { currentLane.OnLeft = segmentLanes[increasingLaneID2]; } } if (currentLane.OnLeft != null) { Console.WriteLine("Lane: " + currentLane.LaneID.ToString() + ". On Left: " + currentLane.OnLeft.LaneID.ToString()); } i++; currentLaneID = new LaneID(segment.Way1.WayID, i); if (segmentLanes.ContainsKey(new LaneID(segment.Way2.WayID, i))) { currentLaneID = new LaneID(segment.Way2.WayID, i); } } } else { // HACK //throw new Exception("single way lane!"); } } return(rndf); }
/// <summary> /// Constructor if we are to stay in the current lane /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="interconnect"></param> public IntersectionState(LaneID initialLane, LaneID finalLane) { this.initialLane = initialLane; this.finalLane = finalLane; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="interconnect"></param> public TurnState(LaneID initialLane, LaneID finalLane, InterconnectID interconnect, TurnDirection turnDirection) : base(initialLane, finalLane, interconnect) { this.TurnDirection = turnDirection; }
/// <summary> /// Constructor /// </summary> /// <param name="lane">Lane to stay in</param> public StayInLaneState(LaneID lane) : base(lane, lane) { }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> public TravelState(LaneID initialLane, LaneID finalLane) { this.initialLane = initialLane; this.finalLane = finalLane; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="closestGoodLane"></param> public OpposingLaneState(LaneID lane, LaneID closestGoodLane) : base(lane, lane) { this.closestGoodLane = closestGoodLane; }
public UTurnState(LaneID initialLane, LaneID finalLane, InterconnectID interconnect, UTurnBehavior uTurn) : base(initialLane, finalLane, interconnect, TurnDirection.Straight) { this.UTurn = uTurn; }
public StayInLaneBehavior(LaneID lane, LaneSpeedCommand speedCommand) { this.lane = lane; this.speedCommand = speedCommand; }
/// <summary> /// Analyzes a lane to find the closest point to the coordinate passed in /// </summary> /// <param name="coordinate">coordinate to analyze the lane against</param> /// <param name="lane">lane to reference the coordinate to</param> /// <returns>vector consisting of relative and absolute rndf localization information</returns> public static LocationAnalysis ClosestPartitionOnLane(Coordinates coordinate, LaneID laneId, RndfNetwork rndfNetwork) { // get the lane Lane lane = rndfNetwork.Segments[laneId.WayID.SegmentID].Ways[laneId.WayID].Lanes[laneId]; // set the value to return LocationAnalysis closest = null; // values for comparing partitions double offsetMin = Double.MaxValue; // iterate over lanePartitions within the lane foreach (LanePartition lanePartition in lane.LanePartitions) { // if there are user partitions, operate over them if (lanePartition.UserPartitions != null && lanePartition.UserPartitions.Count > 1) { foreach (UserPartition userPartiton in lanePartition.UserPartitions) { throw new Exception("user partition relation to vehicle absolute coordinates not implemented yet"); } } // otherwise look at how close lane partition is else { // analyze the partition LocationAnalysis partitionAnalysis = AnalyzePartition(coordinate, (IWaypoint)lanePartition.InitialWaypoint, (IWaypoint)lanePartition.FinalWaypoint); // if this partition has less of an offset from the vehicle than the current best, set as current if (partitionAnalysis.Offset < offsetMin) { offsetMin = partitionAnalysis.Offset; closest = partitionAnalysis; // set partition of result closest.Partition = lanePartition; } // otherwise, if the vehicle is relatively close to this partition // and the closest Coordinates are not those of the initial final waypoitns of the lane // and this error is less than the current best offset else if (partitionAnalysis.Offset == 1234567 && (partitionAnalysis.RelativeRndfPosition != lane.LanePartitions[0].InitialWaypoint.Position) && (partitionAnalysis.RelativeRndfPosition != lane.LanePartitions[lane.LanePartitions.Count - 1].FinalWaypoint.Position) && (partitionAnalysis.Error < offsetMin)) { offsetMin = partitionAnalysis.Error; closest = partitionAnalysis; // set partition of result closest.Partition = lanePartition; } } } // return closest value found return(closest); }
/// <summary> /// Constructor /// </summary> /// <param name="lane">Lane to stay in</param> public ZoneState(LaneID inLane, LaneID outLane) { // set lane this.inLane = inLane; this.outLane = outLane; }
/// <summary> /// Get the Rndf Relative location of a Coordinate to a given LaneID /// </summary> /// <param name="laneEstimate"></param> /// <param name="absolutePosition"></param> /// <returns></returns> /// <remarks>Algorithm already done, needs cleanup</remarks> public static RndfLocation RndfLocation(LaneID laneEstimate, Coordinates absolutePosition) { throw new Exception("This method has not yet been implemented!"); }
/// 5. Output </summary> public virtual void StartProcess() { try { Log4.PrinterLogger.InfoFormat("StartProcess()"); var currentPanel = InspectedPanels.Dequeue(); Log4.PrinterLogger.InfoFormat(" -Dequeue [{0}] SPI Data InspectTime = {1}", LaneID.ToString(), currentPanel.InspectStartTime); Log4.PrinterLogger.InfoFormat(" 1.Match()"); var file = Match(currentPanel); Log4.PrinterLogger.InfoFormat(" 2.Calculate()"); Calculate(currentPanel, file); double dxLimit = ViewModelLocator.Atom.ChartHostVM.DxSetting.XAxis.Maximun - ViewModelLocator.Atom.ChartHostVM.DxSetting.XAxis.Minimun + 1; double dyLimit = ViewModelLocator.Atom.ChartHostVM.DySetting.XAxis.Maximun - ViewModelLocator.Atom.ChartHostVM.DySetting.XAxis.Minimun + 1; double thLimit = ViewModelLocator.Atom.ChartHostVM.ThetaSetting.XAxis.Maximun - ViewModelLocator.Atom.ChartHostVM.ThetaSetting.XAxis.Minimun + 1; Log4.PrinterLogger.InfoFormat(" 3.BackupRoutine()"); BackupRoutine((int)dxLimit, (int)dyLimit, (int)thLimit); //計算出Dx、Dy、Theta的累加器 Log4.PrinterLogger.InfoFormat(" 4.UpdateHistory()"); //累加 //Accumulation++; UpdateHistory(); Log4.PrinterLogger.InfoFormat(" 5.Output()"); Output(currentPanel, file); bool bCus = CustomOutput(currentPanel, file); if (bCus) { Log4.PrinterLogger.InfoFormat(" 6.CustomOutput() DONE"); } ViewModelLocator.Atom.PrinterWindowVM.SN++; } catch (Exception e) { if (e is MatchException) { Log4.PrinterLogger.ErrorFormat("[!] MatchException:" + e.Message); } else if (e is CaculateException) { Log4.PrinterLogger.ErrorFormat("[!] CaculateException:" + e.Message); } else if (e is UpdateHistoryException) { Log4.PrinterLogger.ErrorFormat("[!] UpdateHistoryException:" + e.Message); } else if (e is OutputException) { Log4.PrinterLogger.ErrorFormat("[!] OutputException:" + e.Message); } else if (e is CustomOutputException) { Log4.PrinterLogger.ErrorFormat("[!] CustomOutputException:" + e.Message); } } }
/// <summary> /// Gets the closest position to the coordinates on a specific lane in the rndf network /// </summary> /// <param name="coordinate"></param> /// <param name="lane"></param> /// <param name="rndfNetwork"></param> /// <returns></returns> public static LocationAnalysis ClosestRndfRelativeParition(Coordinates coordinate, LaneID lane, RndfNetwork rndfNetwork) { // use point analysis tool return(PointAnalysis.ClosestPartitionOnLane(coordinate, lane, rndfNetwork)); }
/// <summary> /// Constructor /// </summary> /// <param name="initial"></param> /// <param name="final"></param> /// <param name="interconnect"></param> /// <param name="turnDirection"></param> public WaitingAtStopState(LaneID initial, LaneID final, InterconnectID interconnect, TurnDirection turnDirection) : base(initial, final, interconnect) { this.TurnDirection = turnDirection; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="interconnect"></param> public StoppedAtStopState(LaneID lane, LaneDescription currentLaneDescription) : base(lane, lane) { this.currentLaneDescription = currentLaneDescription; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="interconnect"></param> public StoppedAtExitState(LaneID initialLane, LaneID finalLane, InterconnectID interconnect, LaneDescription currentLaneDescription) : base(initialLane, finalLane, interconnect) { this.currentLaneDescription = currentLaneDescription; }
/// <summary> /// Constructor /// </summary> /// <param name="initialLane"></param> /// <param name="finalLane"></param> /// <param name="interconnect"></param> public IntersectionState(LaneID initialLane, LaneID finalLane, InterconnectID interconnect) { this.initialLane = initialLane; this.finalLane = finalLane; this.interconnect = interconnect; }