Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        //from + action是【因】
        //to 是【果】
        public ST_Single(StateNodeBase from_node, StateNodeBase to_node, int action, ST_Condition st_cond = null)
        {
            LogManager.Assert(from_node != null, "from node is null");
            LogManager.Assert(to_node != null, "to node is null");
            LogManager.Assert(action > 0, "action <= 0");

            LogManager.Assert(!string.Equals(from_node._name, to_node._name), string.Format("same type of node: [{0}]", from_node._name));

            _from_node = from_node;
            _to_node   = to_node;
            _action    = action;

            _st_cond = st_cond ?? ST_Condition.FullPass;
        }
Exemplo n.º 4
0
        public ST_Group(StateNodeGroup from_group, int action, StateNodeBase to_node)
        {
            LogManager.Assert(!StateNodeGroup.IsNullOrEmpty(from_group), "from node is null or empty");
            LogManager.Assert(to_node != null, "to node is null");
            LogManager.Assert(action > 0, "action <= 0");
            LogManager.Assert(!string.Equals(from_group._name, to_node._name), string.Format("same type of node: [{0}]", from_group._name));

            _from_group = from_group;
            _to_node    = to_node;
            _action     = action;
            foreach (var node in _from_group)
            {
                trans_list.Add(new ST_Single(node, _to_node, _action));
            }

            _st_cond = ST_Condition.FullPass;
        }
Exemplo n.º 5
0
 public override void Destroy()
 {
     _from_group.Destroy();
     _from_group = null;
     _to_node    = null;
 }
Exemplo n.º 6
0
 public override void Destroy()
 {
     _from_node = null;
     _to_node   = null;
 }