public NewRoute( ServiceIntention currentIntention, List <RouteSection> route, Dictionary <string, SectionRequirement> requirements, Dictionary <string, Resource> resources, List <Connection> ontoNeedsBeSet) { Sections = route; RoutingPenalty = Sections.Select(s => s.penalty ?? 0.0).Sum(); SectionRequirement GetSectionRequirement(RouteSection section) { if (section.section_marker != null) { foreach (string s in section.section_marker) { if (requirements.TryGetValue(s, out var r)) { return(r); } } } return(null); } var dummyEndNode = new RouteSection(); Sections.Add(dummyEndNode); SectionRequirement[] sectionRequirements = Sections.Select(GetSectionRequirement).ToArray(); Sections[0].Setup(currentIntention, null, sectionRequirements[0], resources, ontoNeedsBeSet, false); for (int i = 1; i < Sections.Count; i++) { Sections[i].Setup(currentIntention, sectionRequirements[i - 1], sectionRequirements[i], resources, ontoNeedsBeSet, i == Sections.Count - 2 || i == Sections.Count - 1); } }
internal void Setup( ServiceIntention currentIntention, SectionRequirement previousSectionRequirement, SectionRequirement currentSectionRequirement, Dictionary <string, Resource> idToResource, List <Connection> ontoNeedsBeSet, bool isLast) { Runtime = minimum_running_time == null ? TimeSpan.Zero : XmlConvert.ToTimeSpan(minimum_running_time); if (currentSectionRequirement != null && !string.IsNullOrEmpty(currentSectionRequirement.min_stopping_time)) { Runtime += XmlConvert.ToTimeSpan(currentSectionRequirement.min_stopping_time); } EarliestEntry = currentSectionRequirement?.entry_earliest ?? TimeSpan.MinValue; if (previousSectionRequirement?.exit_earliest != null && previousSectionRequirement.exit_earliest.Value > EarliestEntry) { EarliestEntry = previousSectionRequirement.exit_earliest.Value; } LatestEntry = currentSectionRequirement?.entry_latest ?? TimeSpan.MaxValue; DelayWeight = currentSectionRequirement?.entry_delay_weight ?? 0.0; if (LatestEntry == TimeSpan.MaxValue) { DelayWeight = 0.0; } if (previousSectionRequirement?.exit_latest != null && LatestEntry > previousSectionRequirement.exit_latest.Value) { LatestEntry = previousSectionRequirement.exit_latest.Value; DelayWeight = previousSectionRequirement.exit_delay_weight; } Machines = resource_occupations?.Select(o => idToResource[o.resource]).ToArray() ?? new IMachine[0]; if (currentSectionRequirement?.connections != null) { foreach (Connection connection in currentSectionRequirement.connections.Where(c => c != null)) { connection.From = currentIntention; if (!ontoNeedsBeSet.Contains(connection)) { ontoNeedsBeSet.Add(connection); } } OutgoingConnections = currentSectionRequirement.connections.ToArray(); } else { OutgoingConnections = new Connection[0]; } SbbIncomingConnections = new List <Connection>(); }
protected bool Equals(ServiceIntention other) { return(string.Equals(id, other.id)); }