예제 #1
0
        /// <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);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        ///     Computes targets from the function and stores them in 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)
                {
                    for (int i = 0; i < graph.Segments.Count; i++)
                    {
                        Graph.Segment  s     = graph.Segments[i];
                        StructureValue value = CreateTarget(s.Start, s.End - s.Start, s.Evaluate(s.Start));

                        collection.Val.Add(value);
                    }
                }
            }
        }