Esempio n. 1
0
        public static bool TryParseTellString(string tell, out ControlState state)
        {
            if (testcache.TryGetValue(tell, out state))
            {
                return(state != null);
            }

            state = null;
            Match match = tellRegex.Match(tell);

            if (!match.Success)
            {
                testcache[tell] = null;
                return(false);
            }

            string p_side  = match.Groups[1].Value;
            char   p_state = match.Groups[2].Value[0];
            string p_true  = match.Groups[3].Value;
            string p_false = match.Groups[4].Value;
            string p_edge  = match.Groups[5].Value;

            DebugLog.Log(String.Format("p_side={0} p_state={1} p_true={2} p_false={3} p_edge={4}", p_side, p_state, p_true, p_false, p_edge));

            UInt64 f_true  = StringToFlags(p_true);
            UInt64 f_false = StringToFlags(p_false);
            UInt64 flags   = f_true;
            UInt64 mask    = f_true | f_false;

            DebugLog.Log("flags={0} mask={1}", flags, mask);

            var left  = new MaskTest(flags << Flags.BitsToShiftForLeft, mask << Flags.BitsToShiftForLeft);
            var right = new MaskTest(flags, mask);

            IFlagTest test;

            switch (p_side)
            {
            case "b": test = left & right; break;

            case "l": test = left; break;

            case "r": test = right; break;

            case "": test = left | right; break;

            default: return(false);
            }

            if (p_state == '0' || p_state == '2')
            {
                test = test.Complement;
            }

            bool constantTrigger = p_state == '2' || p_state == '3';

            testcache[tell] = state = new ControlState(tell, test, StringToFlags(p_edge), constantTrigger);

            return(true);
        }
Esempio n. 2
0
 static MaskTest()
 {
     Tautology = new MaskTest(0, 0, BooleanOp.And);
     Falsehood = new MaskTest(0, 0, BooleanOp.Or);
 }