Пример #1
0
        static IEnumerable <SimEvent> CondTester(SimEnvironment env)
        {
            var aProc = env.Process(AProcess(env));
            var cond  = env.AllOf(env.Timeout(5, "VAL_T"), aProc);

            yield return(cond);

            Console.WriteLine("ALL: {0}", cond.Value.Select(x => x.Value).Aggregate((s1, s2) => s1 + ", " + s2));

            aProc = env.Process(AProcess(env));
            cond  = env.AnyOf(env.Timeout(5, "VAL_T"), aProc);
            yield return(cond);

            Console.WriteLine("ANY: {0}", cond.Value.Select(x => x.Value).Aggregate((s1, s2) => s1 + ", " + s2));

            aProc = env.Process(AProcess(env));
            var aTime = env.Timeout(5, "VAL_T");
            ConditionEval <Timeout <string>, SimProcess> pred =
                c => c.Ev1.Succeeded && c.Ev2.Succeeded && c.Ev1.Value.Equals("VAL_T") && c.Ev2.Value.Equals("VAL_P");

            cond = env.Condition(aTime, aProc, pred);
            yield return(cond);

            Console.WriteLine("CUSTOM: {0}", cond.Value.Select(x => x.Value).Aggregate((s1, s2) => s1 + ", " + s2));
        }
Пример #2
0
 internal Condition(ConditionEval <T1> eval, T1 ev1) : base(ev1.Env)
 {
     _eval = eval;
     // Some events may have already succeeded (like store put events,
     // container put events, conditions and generic events); therefore,
     // we have to check the condition immediately.
     _ev1 = ev1;
     if (ev1)
     {
         (this as IParentCondition).Trigger(ev1);
     }
     else
     {
         ev1.AddParent(this);
     }
 }