//================================================================================================// // // Constructor from other route element // public TrackCircuitRouteElement(TrackCircuitRouteElement source) { if (null == source) { throw new ArgumentNullException(nameof(source)); } TrackCircuitSection = source.TrackCircuitSection; Direction = source.Direction; OutPin = new EnumArray <TrackDirection, Location>(source.OutPin); if (source.StartAlternativePath != null) { StartAlternativePath = new AlternativePath() { PathIndex = source.StartAlternativePath.PathIndex, TrackCircuitSection = source.StartAlternativePath.TrackCircuitSection, }; } if (source.EndAlternativePath != null) { EndAlternativePath = new AlternativePath() { PathIndex = source.EndAlternativePath.PathIndex, TrackCircuitSection = source.EndAlternativePath.TrackCircuitSection, }; } FacingPoint = source.FacingPoint; UsedAlternativePath = source.UsedAlternativePath; MovingTableApproachPath = source.MovingTableApproachPath; }
private ISparqlPath TryParsePathAlternative(SparqlQueryParserContext context, Queue <IToken> tokens) { ISparqlPath path = TryParsePathSequence(context, tokens); IToken next; while (tokens.Count > 0) { next = tokens.Dequeue(); if (next.TokenType == Token.BITWISEOR) { path = new AlternativePath(path, TryParsePathSequence(context, tokens)); } else { throw new RdfParseException("Unexpected Token '" + next.GetType().ToString() + "' encountered, expected a valid path sequence/alternative token", next); } } return(path); }
//================================================================================================// // // Restore // public TrackCircuitRouteElement(BinaryReader inf) { if (null == inf) { throw new ArgumentNullException(nameof(inf)); } TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()]; Direction = (TrackDirection)inf.ReadInt32(); OutPin = new EnumArray <TrackDirection, Location>(new TrackDirection[] { (TrackDirection)inf.ReadInt32(), (TrackDirection)inf.ReadInt32() }); int altindex = inf.ReadInt32(); if (altindex >= 0) { StartAlternativePath = new AlternativePath() { PathIndex = altindex, TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()], }; } altindex = inf.ReadInt32(); if (altindex >= 0) { EndAlternativePath = new AlternativePath() { PathIndex = altindex, TrackCircuitSection = TrackCircuitSection.TrackCircuitList[inf.ReadInt32()], }; } FacingPoint = inf.ReadBoolean(); UsedAlternativePath = inf.ReadInt32(); MovingTableApproachPath = inf.ReadInt32(); }
/// <summary> /// Formats a SPARQL Property Path /// </summary> /// <param name="path">SPARQL Property Path</param> /// <returns></returns> protected virtual String FormatPath(ISparqlPath path) { StringBuilder output = new StringBuilder(); if (path is AlternativePath) { AlternativePath alt = (AlternativePath)path; output.Append('('); output.Append(this.FormatPath(alt.LhsPath)); output.Append(" | "); output.Append(this.FormatPath(alt.RhsPath)); output.Append(')'); } else if (path is FixedCardinality) { FixedCardinality card = (FixedCardinality)path; if (card.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(card.Path)); if (card.Path is BaseBinaryPath) { output.Append(')'); } output.Append('{'); output.Append(card.MaxCardinality); output.Append('}'); } else if (path is InversePath) { InversePath inv = (InversePath)path; output.Append('^'); if (inv.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(inv.Path)); if (inv.Path is BaseBinaryPath) { output.Append(')'); } } else if (path is NOrMore) { NOrMore nOrMore = (NOrMore)path; if (nOrMore.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(nOrMore.Path)); if (nOrMore.Path is BaseBinaryPath) { output.Append(')'); } output.Append('{'); output.Append(nOrMore.MinCardinality); output.Append(",}"); } else if (path is NToM) { NToM nToM = (NToM)path; if (nToM.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(nToM.Path)); if (nToM.Path is BaseBinaryPath) { output.Append(')'); } output.Append('{'); output.Append(nToM.MinCardinality); output.Append(','); output.Append(nToM.MaxCardinality); output.Append('}'); } else if (path is OneOrMore) { OneOrMore oneOrMore = (OneOrMore)path; if (oneOrMore.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(oneOrMore.Path)); if (oneOrMore.Path is BaseBinaryPath) { output.Append(')'); } output.Append('+'); } else if (path is Property) { Property prop = (Property)path; output.Append(this.Format(prop.Predicate, TripleSegment.Predicate)); } else if (path is SequencePath) { SequencePath seq = (SequencePath)path; output.Append(this.FormatPath(seq.LhsPath)); output.Append(" / "); output.Append(this.FormatPath(seq.RhsPath)); } else if (path is ZeroOrMore) { ZeroOrMore zeroOrMore = (ZeroOrMore)path; if (zeroOrMore.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(zeroOrMore.Path)); if (zeroOrMore.Path is BaseBinaryPath) { output.Append(')'); } output.Append('*'); } else if (path is ZeroOrOne) { ZeroOrOne zeroOrOne = (ZeroOrOne)path; if (zeroOrOne.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(zeroOrOne.Path)); if (zeroOrOne.Path is BaseBinaryPath) { output.Append(')'); } output.Append('?'); } else if (path is ZeroToN) { ZeroToN zeroToN = (ZeroToN)path; if (zeroToN.Path is BaseBinaryPath) { output.Append('('); } output.Append(this.FormatPath(zeroToN.Path)); if (zeroToN.Path is BaseBinaryPath) { output.Append(')'); } output.Append("{,"); output.Append(zeroToN.MaxCardinality); output.Append('}'); } else if (path is NegatedSet) { NegatedSet negSet = (NegatedSet)path; output.Append('!'); if (negSet.Properties.Count() + negSet.InverseProperties.Count() > 1) { output.Append('('); } foreach (Property p in negSet.Properties) { output.Append(this.FormatPath(p)); output.Append(" | "); } foreach (Property p in negSet.InverseProperties) { output.Append(this.FormatPath(p)); output.Append(" | "); } output.Remove(output.Length - 3, 3); if (negSet.Properties.Count() + negSet.InverseProperties.Count() > 1) { output.Append(')'); } } else { throw new RdfOutputException("Unable to Format an unknown ISparqlPath implementations as a String"); } return(output.ToString()); }
private IAlternativePath BuildAlternativePathObject(string path, string tagName, string friendlyName) { var alternativePath = new AlternativePath(path, Exists(path)); return(alternativePath); }
public void SparqlPropertyPathTransformationAlternative() { AlternativePath path = new AlternativePath(new Property(this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "label"))), new Property(this._factory.CreateUriNode(new Uri(NamespaceMapper.RDFS + "comment")))); this.RunTest(path, new String[] { "BGP", "Union" }); }
private IAlternativePath BuildAlternativePathObject(string path) { var alternativePath = new AlternativePath(path, Exists(path)); return(alternativePath); }
public static void ShowModifiers() { Seeker seeker = m_AI.GetComponent <Seeker>(); AlternativePath altPath = m_AI.GetComponent <AlternativePath>(); FunnelModifier funnel = m_AI.GetComponent <FunnelModifier>(); SimpleSmoothModifier simpleSmooth = m_AI.GetComponent <SimpleSmoothModifier>(); GUILayout.BeginHorizontal(); GUILayout.Space(25); // seeker if (seeker == null) { if (GUILayout.Button("Add Seeker", GUILayout.Height(25), GUILayout.MinWidth(150))) { seeker = m_AI.gameObject.AddComponent <Seeker>(); } } else if (GUILayout.Button("Remove Seeker", GUILayout.Height(25), GUILayout.MinWidth(150))) { DestroyImmediate(seeker); } // funnel modifier if (funnel == null) { if (GUILayout.Button("Add Funnel", GUILayout.Height(25), GUILayout.MinWidth(150))) { funnel = m_AI.gameObject.AddComponent <FunnelModifier>(); } } else if (GUILayout.Button("Remove Funnel", GUILayout.Height(25), GUILayout.MinWidth(150))) { DestroyImmediate(funnel); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(25); // simple smooth if (simpleSmooth == null) { if (GUILayout.Button("Add Simple Smooth", GUILayout.Height(25), GUILayout.MinWidth(150))) { simpleSmooth = m_AI.gameObject.AddComponent <SimpleSmoothModifier>(); } } else if (GUILayout.Button("Remove Simple Smooth", GUILayout.Height(25), GUILayout.MinWidth(150))) { DestroyImmediate(simpleSmooth); } // alternative path if (altPath == null) { if (GUILayout.Button("Add Alternative Path", GUILayout.Height(25), GUILayout.MinWidth(150))) { altPath = m_AI.gameObject.AddComponent <AlternativePath>(); } } else if (GUILayout.Button("Remove Alternative Path", GUILayout.Height(25), GUILayout.MinWidth(150))) { DestroyImmediate(altPath); } GUILayout.EndHorizontal(); GUILayout.Space(5); if (m_AI.AStarAutoPrioritize) { int priority = 1; if (simpleSmooth != null) { simpleSmooth.priority = priority++; } if (funnel != null) { funnel.priority = priority++; } if (altPath != null) { altPath.priority = priority++; } } }