Esempio n. 1
0
        private string EventNodeStateVariable(Cdn.EventLogicalNode node,
                                              EventNodeState.StateType type,
                                              Context context)
        {
            var st = d_program.StateTable[EventNodeState.Key(node, type)];

            return(String.Format("{0}[{1}]", context.This(d_program.StateTable), st.AliasOrIndex));
        }
Esempio n. 2
0
        private string EventConditionHolds(Cdn.Event ev,
                                           Cdn.EventLogicalNode node,
                                           EventNodeState.StateType type,
                                           Context context)
        {
            var st = EventNodeStateVariable(node, type, context);

            switch (node.CompareType)
            {
            case Cdn.MathFunctionType.Less:
            case Cdn.MathFunctionType.Greater:
                return(String.Format("{0} > 0",
                                     st));

            case Cdn.MathFunctionType.LessOrEqual:
            case Cdn.MathFunctionType.GreaterOrEqual:
            case Cdn.MathFunctionType.And:
            case Cdn.MathFunctionType.Or:
                return(String.Format("{0} >= 0",
                                     st));

            case Cdn.MathFunctionType.Equal:
                if (ev.Approximation != Double.MaxValue)
                {
                    var approx = context.TranslateNumber(ev.Approximation);

                    return(String.Format("{0}({1}) <= {2}",
                                         context.MathFunction(MathFunctionType.Abs, 1),
                                         st,
                                         approx));
                }
                else
                {
                    return("1");
                }

            default:
                return("0");
            }
        }
Esempio n. 3
0
 public static string Key(Cdn.EventLogicalNode node, StateType type)
 {
     return(String.Format("{0}@{1}", node.Handle, type));
 }
Esempio n. 4
0
 public EventNodeState(Cdn.Event ev, Cdn.EventLogicalNode node, StateType type) : base(node, (Cdn.Expression)(type == StateType.Current ? node.Expression : null), State.Flags.EventNode)
 {
     d_type  = type;
     d_node  = node;
     d_event = ev;
 }