Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 /// <summary>
 /// Updates the system to setup next cycle
 /// </summary>
 private void NextCycle()
 {
     if (TimeInModel != null)
     {
         // Use the time in the model for checking deadlines
         Range range = TimeInModel.Type as Range;
         if (range != null)
         {
             Time = range.getValueAsDouble(TimeInModel.Value);
         }
     }
     else
     {
         // Increase time if it is not taken into account in the model
         Time += 0.1;
     }
 }