Esempio n. 1
0
        public bool GetNextTran(StateNodeBase cur_node, int action, out StateNodeBase next_node)
        {
            //find transitions of _cur_node
            Dictionary <int, ST_CondSet> action_trans_map;
            bool suc = _tran_map.TryGetValue(cur_node, out action_trans_map);

            if (!suc)
            {
                LogManager.Warning("transgraph[{0}] : cur_node[{1}] has no transitions", _name, cur_node._name);
                next_node = null;
                return(false);
            }
            LogManager.Assert(action_trans_map != null, "GetNextTran Error111");
            //find transition of (_cur_node, action)
            ST_CondSet cond_set;

            suc = action_trans_map.TryGetValue(action, out cond_set);
            if (!suc)
            {
                //                my.warning("_cur_node[{0}]--action[{1}] has no transition", cur_node._name, action);
                next_node = null;
                return(false);
            }
            LogManager.Assert(cond_set != null, "GetNextTran Error222");
            next_node = cond_set.GetResult();

            return(next_node != null);
        }
Esempio n. 2
0
        public bool ConflictWith(StateTransition trans)
        {
            ST_Condition cond1 = _st_cond;
            ST_Condition cond2 = trans._st_cond;
            // 两个condition都不是fullpass,那么没有冲突的可能
            bool atleast_1_fullpass = (cond1 == ST_Condition.FullPass || cond2 == ST_Condition.FullPass);

            List <StateNodeBase> from_list_1 = GetFromNodes();
            List <StateNodeBase> from_list_2 = trans.GetFromNodes();

            StateNodeBase to_1 = GetToNode();
            StateNodeBase to_2 = trans.GetToNode();

            int action_1 = _action;
            int action_2 = trans._action;

            // 两层循环判断冲突
            foreach (var from_i in from_list_1)
            {
                foreach (var from_j in from_list_2)
                {
                    if (from_i == from_j)
                    {
                        // action一样,并且两个condition中至少有一个fullpass
                        if (action_1 == action_2 && atleast_1_fullpass)
                        {
                            LogManager.Warning("transition conflict, from[{0}] and action[{1}] to node[{2},{3}] duplicate!", from_i, action_1, to_1, to_2);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }