/// <summary> /// Constructor /// </summary> /// <param name="system"></param> public TestsCoverageReportHandler(EFSSystem system) : base(null) { __efsSystem = system; init(); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public Override(EFSSystem efsSystem) : base(efsSystem, "Override") { DefaultFunction = (Parameter)Generated.acceptor.getFactory().createParameter(); DefaultFunction.Name = "Default"; DefaultFunction.Type = EFSSystem.AnyType; DefaultFunction.setFather(this); FormalParameters.Add(DefaultFunction); OverrideFunction = (Parameter)Generated.acceptor.getFactory().createParameter(); OverrideFunction.Name = "Override"; OverrideFunction.Type = EFSSystem.AnyType; OverrideFunction.setFather(this); FormalParameters.Add(OverrideFunction); Returns = (Function)Generated.acceptor.getFactory().createFunction(); Returns.Name = "Override"; Returns.ReturnType = EFSSystem.DoubleType; Returns.setFather(this); Parameter distanceParam = (Parameter)Generated.acceptor.getFactory().createParameter(); distanceParam.Name = "Distance"; distanceParam.Type = EFSSystem.DoubleType; distanceParam.setFather(Returns); Returns.appendParameters(distanceParam); Parameter speedParameter = (Parameter)Generated.acceptor.getFactory().createParameter(); speedParameter.Name = "Speed"; speedParameter.Type = EFSSystem.DoubleType; speedParameter.setFather(Returns); Returns.appendParameters(speedParameter); }
/// <summary> /// Provides the value of the function /// </summary> /// <param name="context"></param> /// <param name="actuals">the actual parameters values</param> /// <param name="explain"></param> /// <returns>The value for the function application</returns> public override IValue Evaluate(InterpretationContext context, Dictionary <Actual, IValue> actuals, ExplanationPart explain) { IValue retVal = null; int token = context.LocalScope.PushContext(); AssignParameters(context, actuals); Collection collectionType = (Collection) EFSSystem.FindType( OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default"), "TargetsCol"); ListValue collection = new ListValue(collectionType, new List <IValue>()); Function function = context.FindOnStack(Targets).Value as Function; if (function != null && !function.Name.Equals("EMPTY")) { Graph graph1 = createGraphForValue(context, function, explain); ComputeTargets(graph1.Function, collection); } context.LocalScope.PopContext(token); retVal = collection; return(retVal); }
/// <summary> /// Provides the graph of this function if it has been statically defined /// </summary> /// <param name="context">the context used to create the graph</param> /// <param name="parameter"></param> /// <param name="explain"></param> /// <returns></returns> public override Graph CreateGraph(InterpretationContext context, Parameter parameter, ExplanationPart explain) { Graph retVal = null; Graph graph = createGraphForValue(context, context.FindOnStack(Function).Value, explain, parameter); if (graph != null) { double speed = GetDoubleValue(context.FindOnStack(Speed).Value); double solutionX = graph.SolutionX(speed); if (solutionX == double.MaxValue) { // No value found, return Unknown Range distanceType = (Range)EFSSystem.FindByFullName("Default.BaseTypes.Distance"); EnumValue unknownDistance = distanceType.findEnumValue("Unknown"); retVal = Graph.createGraph(distanceType.getValueAsDouble(unknownDistance)); } else { // Create the graph for this solution retVal = Graph.createGraph(solutionX); } } else { Function.AddError("Cannot create graph for " + Function); } return(retVal); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { // Creates a new dictionary OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Create new dictionary. Select dictionary file location"; openFileDialog.Filter = "EFS Files (*.efs)|*.efs"; openFileDialog.CheckFileExists = false; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string filePath = openFileDialog.FileName; DataDictionary.Dictionary dictionary = new DataDictionary.Dictionary(); dictionary.FilePath = filePath; dictionary.Name = Path.GetFileNameWithoutExtension(filePath); EFSSystem.AddDictionary(dictionary); RefreshModel(); // Open a data dictionary window if none is yet present bool found = false; foreach (IBaseForm form in SubWindows) { if (form is DataDictionaryView.Window) { found = true; break; } } if (!found) { AddChildWindow(new DataDictionaryView.Window(dictionary)); } } }
/// <summary> /// Creates a single target /// </summary> /// <param name="start"></param> /// <param name="length"></param> /// <param name="speed"></param> /// <returns></returns> private StructureValue CreateTarget(double start, double length, double speed) { NameSpace defaultNameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default"); Structure structureType = (Structure) EFSSystem.FindType( defaultNameSpace, "TargetStruct"); StructureValue value = new StructureValue(structureType); Field speedV = value.CreateField(value, "Speed", structureType); speedV.Value = new DoubleValue(EFSSystem.DoubleType, speed); Field location = value.CreateField(value, "Location", structureType); location.Value = new DoubleValue(EFSSystem.DoubleType, start); Field lengthV = value.CreateField(value, "Length", structureType); lengthV.Value = new DoubleValue(EFSSystem.DoubleType, length); Enum targetType = (Enum)EFSSystem.FindType(defaultNameSpace, "TargetTypeEnum"); Field type = value.CreateField(value, "Type", structureType); type.Value = targetType.DefaultValue; return(value); }
/// <summary> /// Constructor /// </summary> /// <param name="system"></param> public FunctionGraphCache(EFSSystem system) { // Fill the list of functions to be cleared foreach (DataDictionary.Dictionary dictionnary in EFSSystem.INSTANCE.Dictionaries) { visit(dictionnary); } }
/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> public BoolType(EFSSystem efsSystem) : base(efsSystem, "Boolean") { True = new Values.BoolValue(this, true); False = new Values.BoolValue(this, false); InitDeclaredElements(); }
/// <summary> /// Constructor /// </summary> /// <param name="rebuild"></param> public Compiler(EFSSystem system) { EFSSystem = system; DoCompile = true; CompilerThread = ThreadUtil.CreateThread("Compiler", CompileContinuously); CompilerThread.Start(); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public Targets(EFSSystem efsSystem) : base(efsSystem, "TARGETS") { SpeedRestrictions = (Parameter) acceptor.getFactory().createParameter(); SpeedRestrictions.Name = "SpeedRestrictions"; SpeedRestrictions.Type = EFSSystem.AnyType; SpeedRestrictions.setFather(this); FormalParameters.Add(SpeedRestrictions); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public Not(EFSSystem efsSystem) : base(efsSystem, "NOT") { Value = (Parameter)Generated.acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.BoolType; Value.setFather(this); FormalParameters.Add(Value); }
/// <summary> /// Constructor /// </summary> public Allocate(EFSSystem efsSystem) : base(efsSystem, "Allocate") { Collection = (Parameter) acceptor.getFactory().createParameter(); Collection.Name = "Collection"; Collection.Type = EFSSystem.GenericCollection; Collection.setFather(this); FormalParameters.Add(Collection); }
/// <summary> /// Constructor /// </summary> public Allocate(EFSSystem efsSystem) : base(efsSystem, "Allocate") { Collection = (Parameter)Generated.acceptor.getFactory().createParameter(); Collection.Name = "Collection"; Collection.Type = EFSSystem.GenericCollection; Collection.setFather(this); FormalParameters.Add(Collection); }
/// <summary> /// Constructor /// </summary> public Available(EFSSystem efsSystem) : base(efsSystem, "Available") { Element = (Parameter)Generated.acceptor.getFactory().createParameter(); Element.Name = "Element"; Element.Type = EFSSystem.AnyType; Element.setFather(this); FormalParameters.Add(Element); }
/// <summary> /// Constructor /// </summary> /// <param name="system"></param> public InitDeclaredElements(EFSSystem system) { system.InitDeclaredElements(); foreach (Dictionary dictionary in system.Dictionaries) { visit(dictionary, true); } }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public Not(EFSSystem efsSystem) : base(efsSystem, "NOT") { Value = (Parameter) acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.BoolType; Value.setFather(this); FormalParameters.Add(Value); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public EmptyDoubleToDoubleFunction(EFSSystem efsSystem) : base(efsSystem, "EmptyDoubleToDoubleFunction") { Value = (Parameter)Generated.acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.DoubleType; Value.setFather(this); FormalParameters.Add(Value); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public CheckNumber(EFSSystem efsSystem) : base(efsSystem, "CheckNumber") { Number = (Parameter) acceptor.getFactory().createParameter(); Number.Name = "Number"; Number.Type = EFSSystem.AnyType; Number.setFather(this); FormalParameters.Add(Number); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public Discontinuities(EFSSystem efsSystem) : base(efsSystem, "Discontinuities") { Targets = (Parameter) acceptor.getFactory().createParameter(); Targets.Name = "SpeedRestrictions"; Targets.Type = EFSSystem.AnyType; Targets.setFather(this); FormalParameters.Add(Targets); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public DoubleToInteger(EFSSystem efsSystem) : base(efsSystem, "DoubleToInteger") { Value = (Parameter) acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.DoubleType; Value.setFather(this); FormalParameters.Add(Value); }
/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> public FunctionDoubleToDouble(EFSSystem efsSystem) : base() { Enclosing = efsSystem; Name = "FunctionDoubleToDouble"; Parameter param = (Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter(); param.Name = "Distance"; param.Type = EFSSystem.DoubleType; FormalParameters.Add(param); ReturnType = EFSSystem.DoubleType; }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the function</param> public FunctionOnGraph(EFSSystem efsSystem, string name) : base(efsSystem, name) { Returns = (Function)Generated.acceptor.getFactory().createFunction(); Returns.Name = Name + "ReturnType"; Returns.ReturnType = EFSSystem.DoubleType; Returns.setFather(this); Parameter returnTypeParam = (Parameter)Generated.acceptor.getFactory().createParameter(); returnTypeParam.Name = Name + "ReturnTypeParam"; returnTypeParam.Type = EFSSystem.DoubleType; returnTypeParam.setFather(Returns); Returns.appendParameters(returnTypeParam); }
/// <summary> /// Coputes targets from the function and adds them to the collection /// </summary> /// <param name="function">Function containing targets</param> /// <param name="collection">Collection to be filled with targets</param> private void ComputeTargets(Function function, Values.ListValue collection) { if (function != null) { Graph graph = function.Graph; if (graph != null && graph.Segments.Count > 1) { double prevSpeed = Double.MaxValue; for (int i = 1; i < graph.Segments.Count; i++) { Graph.Segment s = graph.Segments[i]; Types.Structure structureType = (Types.Structure)EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Kernel.SpeedAndDistanceMonitoring.TargetSupervision"), "Kernel.SpeedAndDistanceMonitoring.TargetSupervision.Target"); Values.StructureValue value = new Values.StructureValue(structureType, structureType.NameSpace); Variables.Variable speed = (Variables.Variable)DataDictionary.Generated.acceptor.getFactory().createVariable(); speed.Type = EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default.BaseTypes"), "Default.BaseTypes.Speed"); speed.Name = "Speed"; speed.Mode = Generated.acceptor.VariableModeEnumType.aInternal; speed.Default = "0.0"; speed.Enclosing = value; speed.Value = new Values.DoubleValue(EFSSystem.DoubleType, s.Val(s.Start)); value.set(speed); Variables.Variable location = (Variables.Variable)DataDictionary.Generated.acceptor.getFactory().createVariable(); location.Type = EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default.BaseTypes"), "Default.BaseTypes.Distance"); location.Name = "Location"; location.Mode = Generated.acceptor.VariableModeEnumType.aInternal; location.Default = "0.0"; location.Enclosing = value; location.Value = new Values.DoubleValue(EFSSystem.DoubleType, s.Start); value.set(location); Variables.Variable length = (Variables.Variable)DataDictionary.Generated.acceptor.getFactory().createVariable(); length.Type = EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default.BaseTypes"), "Default.BaseTypes.Length"); length.Name = "Length"; length.Mode = Generated.acceptor.VariableModeEnumType.aInternal; length.Default = "0.0"; length.Enclosing = value; length.Value = new Values.DoubleValue(EFSSystem.DoubleType, s.End); value.set(length); if (s.Val(s.Start) < prevSpeed) { collection.Val.Add(value); } prevSpeed = s.Val(s.Start); } } } }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public IntersectAt(EFSSystem efsSystem) : base(efsSystem, "IntersectAt") { FunctionA = (Parameter)Generated.acceptor.getFactory().createParameter(); FunctionA.Name = "FunctionA"; FunctionA.Type = EFSSystem.AnyType; FunctionA.setFather(this); FormalParameters.Add(FunctionA); FunctionB = (Parameter)Generated.acceptor.getFactory().createParameter(); FunctionB.Name = "FunctionB"; FunctionB.Type = EFSSystem.AnyType; FunctionB.setFather(this); FormalParameters.Add(FunctionB); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public DecelerationProfile(EFSSystem efsSystem) : base(efsSystem, "DecelerationProfile") { SpeedRestrictions = (Parameter)Generated.acceptor.getFactory().createParameter(); SpeedRestrictions.Name = "SpeedRestrictions"; SpeedRestrictions.Type = EFSSystem.AnyType; SpeedRestrictions.setFather(this); FormalParameters.Add(SpeedRestrictions); DecelerationFactor = (Parameter)Generated.acceptor.getFactory().createParameter(); DecelerationFactor.Name = "DecelerationFactor"; DecelerationFactor.Type = EFSSystem.AnyType; DecelerationFactor.setFather(this); FormalParameters.Add(DecelerationFactor); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public DistanceForSpeed(EFSSystem efsSystem) : base(efsSystem, "DistanceForSpeed") { Function = (Parameter)Generated.acceptor.getFactory().createParameter(); Function.Name = "Function"; Function.Type = EFSSystem.AnyType; Function.setFather(this); FormalParameters.Add(Function); Speed = (Parameter)Generated.acceptor.getFactory().createParameter(); Speed.Name = "Speed"; Speed.Type = EFSSystem.DoubleType; Speed.setFather(this); FormalParameters.Add(Speed); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public DistanceForSpeed(EFSSystem efsSystem) : base(efsSystem, "DistanceForSpeed") { Function = (Parameter) acceptor.getFactory().createParameter(); Function.Name = "Function"; Function.Type = EFSSystem.AnyType; Function.setFather(this); FormalParameters.Add(Function); Speed = (Parameter) acceptor.getFactory().createParameter(); Speed.Name = "Speed"; Speed.Type = EFSSystem.DoubleType; Speed.setFather(this); FormalParameters.Add(Speed); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public MinSurface(EFSSystem efsSystem) : base(efsSystem, "MINSURFACE") { First = (Parameter) acceptor.getFactory().createParameter(); First.Name = "First"; First.Type = EFSSystem.AnyType; First.setFather(this); FormalParameters.Add(First); Second = (Parameter) acceptor.getFactory().createParameter(); Second.Name = "Second"; Second.Type = EFSSystem.AnyType; Second.setFather(this); FormalParameters.Add(Second); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public MinSurface(EFSSystem efsSystem) : base(efsSystem, "MINSURFACE") { First = (Parameter)Generated.acceptor.getFactory().createParameter(); First.Name = "First"; First.Type = EFSSystem.AnyType; First.setFather(this); FormalParameters.Add(First); Second = (Parameter)Generated.acceptor.getFactory().createParameter(); Second.Name = "Second"; Second.Type = EFSSystem.AnyType; Second.setFather(this); FormalParameters.Add(Second); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public Max(EFSSystem efsSystem) : base(efsSystem, "MAX") { First = (Parameter)Generated.acceptor.getFactory().createParameter(); First.Name = "First"; First.Type = EFSSystem.AnyType; First.setFather(this); FormalParameters.Add(First); Second = (Parameter)Generated.acceptor.getFactory().createParameter(); Second.Name = "Second"; Second.Type = EFSSystem.AnyType; Second.setFather(this); FormalParameters.Add(Second); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> /// <param name="name">the name of the cast function</param> public AddIncrement(EFSSystem efsSystem) : base(efsSystem, "AddIncrement") { Function = (Parameter)Generated.acceptor.getFactory().createParameter(); Function.Name = "Function"; Function.Type = EFSSystem.AnyType; Function.setFather(this); FormalParameters.Add(Function); Increment = (Parameter)Generated.acceptor.getFactory().createParameter(); Increment.Name = "Increment"; Increment.Type = EFSSystem.AnyType; Increment.setFather(this); FormalParameters.Add(Increment); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public AddToDate(EFSSystem efsSystem) : base(efsSystem, "AddToDate") { StartDate = (Parameter) acceptor.getFactory().createParameter(); StartDate.Name = "StartDate"; StartDate.Type = EFSSystem.AnyType; StartDate.setFather(this); FormalParameters.Add(StartDate); Increment = (Parameter) acceptor.getFactory().createParameter(); Increment.Name = "Increment"; Increment.Type = EFSSystem.DoubleType; Increment.setFather(this); FormalParameters.Add(Increment); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public RoundToMultiple(EFSSystem efsSystem) : base(efsSystem, "RoundToMultiple") { Value = (Parameter)Generated.acceptor.getFactory().createParameter(); Value.Name = "Value"; Value.Type = EFSSystem.DoubleType; Value.setFather(this); FormalParameters.Add(Value); Multiple = (Parameter)Generated.acceptor.getFactory().createParameter(); Multiple.Name = "Multiple"; Multiple.Type = EFSSystem.DoubleType; Multiple.setFather(this); FormalParameters.Add(Multiple); }
/// <summary> /// Provides the set of rules which uses this variable /// </summary> /// <param name="node">the element to find in rules</param> /// <returns>the list of rules which use the element provided</returns> public static HashSet <Rules.RuleCondition> RulesUsingThisElement(Variables.IVariable node) { UsageVisitor visitor = new UsageVisitor(node); EFSSystem efsSystem = Utils.EnclosingFinder <EFSSystem> .find(node); if (efsSystem != null) { foreach (Dictionary dictionary in efsSystem.Dictionaries) { visitor.visit(dictionary); } } return(visitor.Usages); }
/// <summary> /// Provides the set of typed elements which uses this type /// </summary> /// <param name="type">the type to be referenced by the typed elements</param> /// <returns>the set of typed elements which have 'type' as type</returns> public static HashSet <ITypedElement> ElementsOfType(Types.Type type) { TypeUsageFinder visitor = new TypeUsageFinder(type); EFSSystem efsSystem = Utils.EnclosingFinder <EFSSystem> .find(type); if (efsSystem != null) { foreach (Dictionary dictionary in efsSystem.Dictionaries) { visitor.visit(dictionary); } } return(visitor.Usages); }
/// <summary> /// Coputes targets from the function and adds them to the collection /// </summary> /// <param name="function">Function containing targets</param> /// <param name="collection">Collection to be filled with targets</param> private void ComputeTargets(Function function, ListValue collection) { if (function != null) { Graph graph = function.Graph; if (graph != null && graph.Segments.Count > 1) { NameSpace defaultNameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Default"); Structure structureType = (Structure) EFSSystem.FindType( defaultNameSpace, "TargetStruct" ); double prevSpeed = graph.Segments[0].Evaluate(graph.Segments[0].Start); for (int i = 1; i < graph.Segments.Count; i++) { Graph.Segment s = graph.Segments[i]; StructureValue value = new StructureValue(structureType); Field speed = value.CreateField(value, "Speed", structureType); speed.Value = new DoubleValue(EFSSystem.DoubleType, s.Evaluate(s.Start)); Field location = value.CreateField(value, "Location", structureType); location.Value = new DoubleValue(EFSSystem.DoubleType, s.Start); Field length = value.CreateField(value, "Length", structureType); length.Value = SegmentLength(s.End); Enum targetType = (Enum)EFSSystem.FindType(defaultNameSpace, "TargetTypeEnum"); Field type = value.CreateField(value, "Type", structureType); type.Value = targetType.DefaultValue; // Only add the target for the current segment to the collection if it brings a reduction in permitted speed if (s.Evaluate(s.Start) < prevSpeed) { collection.Val.Add(value); } // But even if it is not added to the collection of targets, this segment is now the reference speed prevSpeed = s.Evaluate(s.Start); } } } }
/// <summary> /// Provides the value of the function /// </summary> /// <param name="context"></param> /// <param name="actuals">the actual parameters values</param> /// <param name="explain"></param> /// <returns>The value for the function application</returns> public override IValue Evaluate(InterpretationContext context, Dictionary <Actual, IValue> actuals, ExplanationPart explain) { IValue retVal = null; int token = context.LocalScope.PushContext(); AssignParameters(context, actuals); Function function = context.FindOnStack(Function).Value as Function; if (function != null) { double speed = GetDoubleValue(context.FindOnStack(Speed).Value); Parameter parameter = (Parameter)function.FormalParameters[0]; int token2 = context.LocalScope.PushContext(); context.LocalScope.SetGraphParameter(parameter); Graph graph = function.CreateGraph(context, (Parameter)function.FormalParameters[0], explain); context.LocalScope.PopContext(token2); if (graph != null) { double solutionX = graph.SolutionX(speed); if (solutionX == double.MaxValue) { Range distanceType = (Range)EFSSystem.FindByFullName("Default.BaseTypes.Distance"); retVal = distanceType.findEnumValue("Unknown"); } else { retVal = new DoubleValue(EFSSystem.DoubleType, solutionX); } } else { Function.AddError("Cannot evaluate graph for function while computing the distance for the given speed"); } } else { Function.AddError("Cannot get function for " + Function); } context.LocalScope.PopContext(token); return(retVal); }
/// <summary> /// Finds the type of the structure corresponding to the provided NID_PACKET /// </summary> /// <param name="nameSpace">The namespace where the type has to be found</param> /// <param name="nidPacket">The id of the packet</param> /// <returns></returns> private Values.StructureValue FindStructure(int nidPacket) { Types.Structure structure = null; DataDictionary.Types.NameSpace nameSpace; if (nidPacket != 44) { nameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Messages.PACKET.TRACK_TO_TRAIN"); foreach (DataDictionary.Types.NameSpace subNameSpace in nameSpace.SubNameSpaces) { Types.Structure structureType = (Types.Structure)EFSSystem.findType(subNameSpace, subNameSpace.FullName + ".Message"); Values.StructureValue structureValue = new Values.StructureValue(structureType, nameSpace); foreach (KeyValuePair <string, Variables.IVariable> pair in structureValue.SubVariables) { string variableName = pair.Key; if (variableName.Equals("NID_PACKET")) { Values.IntValue value = pair.Value.Value as Values.IntValue; if (value.Val == nidPacket) { structure = structureType; } } if (structure != null) { break; } } } } else { nameSpace = OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Messages.PACKET.DATA_USED_BY_APPLICATIONS_OUTSIDE_THE_ERTMS_ETCS_SYSTEM"); structure = (Types.Structure)EFSSystem.findType(nameSpace, nameSpace.FullName + ".Message"); } Values.StructureValue retVal = null; if (structure != null) { retVal = new Values.StructureValue(structure, nameSpace); } return(retVal); }
/// <summary> /// Provides the value of the function /// </summary> /// <param name="instance">the instance on which the function is evaluated</param> /// <param name="actuals">the actual parameters values</param> /// <returns>The value for the function application</returns> public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary <Variables.Actual, Values.IValue> actuals) { Values.IValue retVal = null; int token = context.LocalScope.PushContext(); AssignParameters(context, actuals); Types.Collection collectionType = (Types.Collection)EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Kernel.SpeedAndDistanceMonitoring.TargetSupervision"), "Kernel.SpeedAndDistanceMonitoring.TargetSupervision.Targets"); Values.ListValue collection = new Values.ListValue(collectionType, new List <Values.IValue>()); // compute targets from the MRSP Function function1 = context.findOnStack(Targets1).Value as Functions.Function; if (function1 != null && !function1.Name.Equals("EMPTY")) { Graph graph1 = createGraphForValue(context, function1); ComputeTargets(graph1.Function, collection); } // compute targets from the MA Function function2 = context.findOnStack(Targets2).Value as Functions.Function; if (function2 != null && !function2.Name.Equals("EMPTY")) { Graph graph2 = createGraphForValue(context, function2); ComputeTargets(graph2.Function, collection); } // compute targets from the SR Function function3 = context.findOnStack(Targets3).Value as Functions.Function; if (function3 != null && !function3.Name.Equals("EMPTY")) { Graph graph3 = createGraphForValue(context, function3); ComputeTargets(graph3.Function, collection); } context.LocalScope.PopContext(token); retVal = collection; return(retVal); }
/// <summary> /// Constructor /// </summary> public Before(EFSSystem efsSystem) : base(efsSystem, "Before") { ExpectedFirst = (Parameter) acceptor.getFactory().createParameter(); ExpectedFirst.Name = "ExpectedFirst"; ExpectedFirst.Type = EFSSystem.AnyType; ExpectedFirst.setFather(this); FormalParameters.Add(ExpectedFirst); ExpectedSecond = (Parameter) acceptor.getFactory().createParameter(); ExpectedSecond.Name = "ExpectedSecond"; ExpectedSecond.Type = EFSSystem.AnyType; ExpectedSecond.setFather(this); FormalParameters.Add(ExpectedSecond); Collection = (Parameter) acceptor.getFactory().createParameter(); Collection.Name = "Collection"; Collection.Type = EFSSystem.GenericCollection; Collection.setFather(this); FormalParameters.Add(Collection); }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public Targets(EFSSystem efsSystem) : base(efsSystem, "TARGETS") { Targets1 = (Parameter)Generated.acceptor.getFactory().createParameter(); Targets1.Name = "Targets1"; Targets1.Type = EFSSystem.AnyType; Targets1.setFather(this); FormalParameters.Add(Targets1); Targets2 = (Parameter)Generated.acceptor.getFactory().createParameter(); Targets2.Name = "Targets2"; Targets2.Type = EFSSystem.AnyType; Targets2.setFather(this); FormalParameters.Add(Targets2); Targets3 = (Parameter)Generated.acceptor.getFactory().createParameter(); Targets3.Name = "Targets3"; Targets3.Type = EFSSystem.AnyType; Targets3.setFather(this); FormalParameters.Add(Targets3); }
/// <summary> /// Constructor /// </summary> public Before(EFSSystem efsSystem) : base(efsSystem, "Before") { ExpectedFirst = (Parameter)Generated.acceptor.getFactory().createParameter(); ExpectedFirst.Name = "ExpectedFirst"; ExpectedFirst.Type = EFSSystem.AnyType; ExpectedFirst.setFather(this); FormalParameters.Add(ExpectedFirst); ExpectedSecond = (Parameter)Generated.acceptor.getFactory().createParameter(); ExpectedSecond.Name = "ExpectedSecond"; ExpectedSecond.Type = EFSSystem.AnyType; ExpectedSecond.setFather(this); FormalParameters.Add(ExpectedSecond); Collection = (Parameter)Generated.acceptor.getFactory().createParameter(); Collection.Name = "Collection"; Collection.Type = EFSSystem.GenericCollection; Collection.setFather(this); FormalParameters.Add(Collection); }
public FullDecelerationForTarget(EFSSystem efsSystem) : base(efsSystem, "FullDecelerationForTarget") { Target = (Parameter) acceptor.getFactory().createParameter(); Target.Name = "Target"; Target.Type = EFSSystem.AnyType; Target.setFather(this); FormalParameters.Add(Target); DecelerationFactor = (Parameter) acceptor.getFactory().createParameter(); DecelerationFactor.Name = "DecelerationFactor"; DecelerationFactor.Type = EFSSystem.AnyType; DecelerationFactor.setFather(this); FormalParameters.Add(DecelerationFactor); // Third parameter end speed EndSpeed = (Parameter)acceptor.getFactory().createParameter(); EndSpeed.Name = "EndSpeed"; EndSpeed.Type = EFSSystem.AnyType; EndSpeed.setFather(this); FormalParameters.Add(EndSpeed); }
/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> /// <param name="name"></param> public PredefinedType(EFSSystem system, string name) { Enclosing = system; Name = name; }
/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> public DoubleType(EFSSystem efsSystem) : base(efsSystem, "Double") { }
public StringType(EFSSystem efsSystem) : base(efsSystem, "String") { }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem">The system for which this function is created</param> /// <param name="name">The name of the predefined function</param> public PredefinedFunction(EFSSystem efsSystem, string name) { Enclosing = efsSystem; Name = name; }
/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> public IntegerType(EFSSystem efsSystem) : base(efsSystem, "Integer") { }
/// <summary> /// Constructor /// </summary> /// <param name="efsSystem"></param> public GenericCollection(EFSSystem efsSystem) { Enclosing = efsSystem; }