Beispiel #1
0
        public static void TestRef()
        {
            UInt16 a = 0x200;
            InsertElement e = new InsertElement("", LEVEL.Building, InsertMode.AutoLevel | InsertMode.AutoPlace);
            Console.WriteLine("a is  = " + Convert.ToString(a,2));

            MatchHelper.Assert(true, "aaaa");
            Console.ReadLine();
        }
Beispiel #2
0
        //Preliminary check element is legality or not
        private State PreliminaryCheck(InsertElement el)
        {
            State resultState = _addrset.FindNodeInHashTable(el.Name);

            if (defualtRule(resultState, el))
            {
                return(resultState);
            }
            else
            {
                throw new TrainException(el, @"element is not legality");
            }
        }
Beispiel #3
0
        // TODO  uncompleted
        private bool defualtRule(State state, InsertElement el)
        {
            if ((el.Mode & PlaceMask) == (UInt16)InsertMode.OldPlace)
            {
                if (state.NodeCount == 0)
                {
                    //throw new TrainException(el, "Existed Node is not found, rule failed");
                    return false;
                }
                //LEVEL judgement
                if ((el.Mode & LevelMask) == (UInt16)InsertMode.ExactlyLevel && el.Level != LEVEL.Uncertainty)
                {
                    if (el.Level < state.MinStateLEVEL || el.Level > state.MaxStateLEVEL)
                    {
                        //throw new TrainException(el, "Existed Node is not found, rule failed");
                        return false;
                    }
                }
                //LEVEL judgement
                //if ((el.Mode & LevelMask) == (UInt16)InsertMode.DegradeLevel && el.Level != LEVEL.Uncertainty)
                //{
                //    if (el.Level < state.MinStateLEVEL)
                //    {
                //        //throw new TrainException(el, "Existed Node is not found, rule failed");
                //        return false;
                //    }
                //}
                ////LEVEL judgement
                //if ((el.Mode & LevelMask) == (UInt16)InsertMode.UpgradeLevel && el.Level != LEVEL.Uncertainty)
                //{
                //    if (el.Level > state.MaxStateLEVEL)
                //    {
                //        //throw new TrainException(el, "Existed Node is not found, rule failed");
                //        return false;
                //    }
                //}
            }
            else if ((el.Mode & PlaceMask) == (UInt16)InsertMode.NewPlace)
            {

            }
            else if ((el.Mode & PlaceMask) == (UInt16)InsertMode.AutoPlace)
            {

            }

            return true;
        }
Beispiel #4
0
        // TODO  uncompleted
        private bool defualtRule(State state, InsertElement el)
        {
            if ((el.Mode & PlaceMask) == (UInt16)InsertMode.OldPlace)
            {
                if (state.NodeCount == 0)
                {
                    //throw new TrainException(el, "Existed Node is not found, rule failed");
                    return(false);
                }
                //LEVEL judgement
                if ((el.Mode & LevelMask) == (UInt16)InsertMode.ExactlyLevel && el.Level != LEVEL.Uncertainty)
                {
                    if (el.Level < state.MinStateLEVEL || el.Level > state.MaxStateLEVEL)
                    {
                        //throw new TrainException(el, "Existed Node is not found, rule failed");
                        return(false);
                    }
                }
                //LEVEL judgement
                //if ((el.Mode & LevelMask) == (UInt16)InsertMode.DegradeLevel && el.Level != LEVEL.Uncertainty)
                //{
                //    if (el.Level < state.MinStateLEVEL)
                //    {
                //        //throw new TrainException(el, "Existed Node is not found, rule failed");
                //        return false;
                //    }
                //}
                ////LEVEL judgement
                //if ((el.Mode & LevelMask) == (UInt16)InsertMode.UpgradeLevel && el.Level != LEVEL.Uncertainty)
                //{
                //    if (el.Level > state.MaxStateLEVEL)
                //    {
                //        //throw new TrainException(el, "Existed Node is not found, rule failed");
                //        return false;
                //    }
                //}
            }
            else if ((el.Mode & PlaceMask) == (UInt16)InsertMode.NewPlace)
            {
            }
            else if ((el.Mode & PlaceMask) == (UInt16)InsertMode.AutoPlace)
            {
            }

            return(true);
        }
Beispiel #5
0
 public TrainException(InsertElement el, string message)
     : base(message)
 {
     _el = el;
 }
Beispiel #6
0
 public TrainException(InsertElement el, string message)
     : base(message)
 {
     _el = el;
 }
Beispiel #7
0
        //Preliminary check element is legality or not
        private State PreliminaryCheck(InsertElement el)
        {
            State resultState = _addrset.FindNodeInHashTable(el.Name);

            if (defualtRule(resultState, el))
            {
                return resultState;
            }
            else
            {
                throw new TrainException(el, @"element is not legality");
            }
        }