Beispiel #1
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "ReferenceBehavior")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_referencedBehaviorPath = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_referencedBehaviorPath = AgentMeta.ParseMethod(p.value);
                    }

                    string szTreePath = this.GetReferencedTree(null);

                    //conservatively make it true
                    bool bHasEvents = true;
                    if (!string.IsNullOrEmpty(szTreePath))
                    {
                        BehaviorTree behaviorTree = Workspace.Instance.LoadBehaviorTree(szTreePath);
                        Debug.Check(behaviorTree != null);

                        if (behaviorTree != null)
                        {
                            bHasEvents = behaviorTree.HasEvents();
                        }

                        this.m_bHasEvents |= bHasEvents;
                    }
                }
                else if (p.name == "Task")
                {
                    this.m_taskMethod = AgentMeta.ParseMethod(p.value);
                }
            }
        }
Beispiel #2
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Task")
                {
                    //method
                    this.m_event = Action.LoadMethod(p.value);
                }
                else if (p.name == "ReferenceFilename")
                {
                    this.m_referencedBehaviorPath = p.value;
                }
                else if (p.name == "TriggeredOnce")
                {
                    if (p.value == "true")
                    {
                        this.m_bTriggeredOnce = true;
                    }
                }
                else if (p.name == "TriggerMode")
                {
                    if (p.value == "Transfer")
                    {
                        this.m_triggerMode = TriggerMode.TM_Transfer;
                    }
                    else if (p.value == "Return")
                    {
                        this.m_triggerMode = TriggerMode.TM_Return;
                    }
                    else
                    {
                        Debug.Check(false, string.Format("unrecognised trigger mode {0}", p.value));
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
Beispiel #3
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "Method")
                {
                    if (!string.IsNullOrEmpty(p.value))
                    {
                        this.m_method = AgentMeta.ParseMethod(p.value);
                    }
                }
                else if (p.name == "ResultOption")
                {
                    if (p.value == "BT_INVALID")
                    {
                        m_resultOption = EBTStatus.BT_INVALID;
                    }
                    else if (p.value == "BT_FAILURE")
                    {
                        m_resultOption = EBTStatus.BT_FAILURE;
                    }
                    else if (p.value == "BT_RUNNING")
                    {
                        m_resultOption = EBTStatus.BT_RUNNING;
                    }
                    else
                    {
                        m_resultOption = EBTStatus.BT_SUCCESS;
                    }
                }
                else if (p.name == "ResultFunctor")
                {
                    if (!string.IsNullOrEmpty(p.value))
                    {
                        this.m_resultFunctor = AgentMeta.ParseMethod(p.value);;
                    }
                }
            }
        }
Beispiel #4
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "Task")
                {
                    this.m_event = AgentMeta.ParseMethod(p.value, ref this.m_eventName);
                }
                else if (p.name == "ReferenceFilename")
                {
                    this.m_referencedBehaviorPath = p.value;

                    if (Config.PreloadBehaviors)
                    {
                        BehaviorTree behaviorTree = Workspace.Instance.LoadBehaviorTree(this.m_referencedBehaviorPath);
                        Debug.Check(behaviorTree != null);
                    }
                }
                else if (p.name == "TriggeredOnce")
                {
                    this.m_bTriggeredOnce = (p.value == "true");
                }
                else if (p.name == "TriggerMode")
                {
                    if (p.value == "Transfer")
                    {
                        this.m_triggerMode = TriggerMode.TM_Transfer;
                    }
                    else if (p.value == "Return")
                    {
                        this.m_triggerMode = TriggerMode.TM_Return;
                    }
                    else
                    {
                        Debug.Check(false, string.Format("unrecognised trigger mode {0}", p.value));
                    }
                }
            }
        }
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            string typeName = null;

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Opl")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opl = Condition.LoadLeft(p.value);
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "Opr")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_opr_m = Action.LoadMethod(p.value);
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "RandomGenerator")
                {
                    if (p.value[0] != '\0')
                    {
                        this.m_method = Action.LoadMethod(p.value);
                    }//if (p.value[0] != '\0')
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
Beispiel #7
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Until")
                {
                    if (p.value == "true")
                    {
                        this.m_until = true;
                    }
                    else if (p.value == "false")
                    {
                        this.m_until = false;
                    }
                }
            }
        }
Beispiel #8
0
            public override bool load(List <property_t> properties)
            {
                bool loaded = base.load(properties);

                try
                {
                    for (int i = 0; i < properties.Count; ++i)
                    {
                        property_t p = properties[i];

                        if (p.name == "Phase")
                        {
                            if (p.value == "Success")
                            {
                                this.m_phase = EPhase.E_SUCCESS;
                            }
                            else if (p.value == "Failure")
                            {
                                this.m_phase = EPhase.E_FAILURE;
                            }
                            else if (p.value == "Both")
                            {
                                this.m_phase = EPhase.E_BOTH;
                            }
                            else
                            {
                                Debug.Check(false);
                            }

                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Check(false, ex.Message);
                    loaded = false;
                }

                return(loaded);
            }
Beispiel #9
0
 protected override void load(int version, string agentType, List <property_t> properties)
 {
     base.load(version, agentType, properties);
     using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             property_t current = enumerator.get_Current();
             if (current.name == "IgnoreTimeScale")
             {
                 this.m_ignoreTimeScale = (current.value == "true");
             }
             else if (current.name == "Time")
             {
                 string text         = null;
                 string propertyName = null;
                 this.m_time_var = Condition.LoadRight(current.value, propertyName, ref text);
             }
         }
     }
 }
Beispiel #10
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "Opl")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opl = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opl = AgentMeta.ParseMethod(p.value);
                    }
                }
                else if (p.name == "Operator")
                {
                    this.m_operator = OperationUtils.ParseOperatorType(p.value);
                }
                else if (p.name == "Opr")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
Beispiel #11
0
		protected override void load(int version, string agentType, List<property_t> properties)
		{
			base.load(version, agentType, properties);
			using (List<property_t>.Enumerator enumerator = properties.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					property_t current = enumerator.get_Current();
					if (current.name == "Until")
					{
						if (current.value == "true")
						{
							this.m_until = true;
						}
						else if (current.value == "false")
						{
							this.m_until = false;
						}
					}
				}
			}
		}
Beispiel #12
0
 protected override void load(int version, string agentType, List <property_t> properties)
 {
     base.load(version, agentType, properties);
     if (properties.get_Count() > 0)
     {
         using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 property_t current = enumerator.get_Current();
                 if (current.name == "Domain")
                 {
                     this.m_domain = current.value;
                 }
                 else if (current.name == "Descriptors")
                 {
                     this.SetDescriptors(current.value);
                 }
             }
         }
     }
 }
Beispiel #13
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);
            string typeName     = null;
            string propertyName = null;
            string text         = null;

            using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    property_t current = enumerator.get_Current();
                    if (current.name == "Operator")
                    {
                        text = current.value;
                    }
                    else if (current.name == "Opl")
                    {
                        int num = current.value.IndexOf('(');
                        if (num == -1)
                        {
                            this.m_opl = Condition.LoadLeft(current.value, ref propertyName, null);
                        }
                        else
                        {
                            this.m_opl_m = Action.LoadMethod(current.value);
                        }
                    }
                    else if (current.name == "Opr")
                    {
                        this.m_opr = Condition.LoadRight(current.value, propertyName, ref typeName);
                    }
                }
            }
            if (!string.IsNullOrEmpty(text) && (this.m_opl != null || this.m_opl_m != null) && this.m_opr != null)
            {
                this.m_comparator = Condition.Create(typeName, text, this.m_opl, this.m_opr);
            }
        }
Beispiel #14
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Frames")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_frames = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_frames = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
Beispiel #15
0
 protected override void load(int version, string agentType, List <property_t> properties)
 {
     base.load(version, agentType, properties);
     using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             property_t current = enumerator.get_Current();
             if (current.name == "EventName")
             {
                 this.m_event = Action.LoadMethod(current.value);
             }
             else if (current.name == "ReferenceFilename")
             {
                 this.m_referencedBehaviorPath = current.value;
             }
             else if (current.name == "TriggeredOnce")
             {
                 if (current.value == "true")
                 {
                     this.m_bTriggeredOnce = true;
                 }
             }
             else if (current.name == "TriggerMode")
             {
                 if (current.value == "Transfer")
                 {
                     this.m_triggerMode = TriggerMode.TM_Transfer;
                 }
                 else if (current.value == "Return")
                 {
                     this.m_triggerMode = TriggerMode.TM_Return;
                 }
             }
         }
     }
 }
Beispiel #16
0
 private bool load_property_pars(ref List <property_t> properties, SecurityElement c, int version, string agentType)
 {
     if (c.get_Tag() == "property")
     {
         if (c.get_Attributes().get_Count() == 1)
         {
             IEnumerator enumerator = c.get_Attributes().get_Keys().GetEnumerator();
             if (enumerator.MoveNext())
             {
                 string     text       = (string)enumerator.get_Current();
                 string     v          = (string)c.get_Attributes().get_Item(text);
                 property_t property_t = new property_t(text, v);
                 properties.Add(property_t);
             }
         }
         return(true);
     }
     if (c.get_Tag() == "pars")
     {
         if (c.get_Children() != null)
         {
             using (IEnumerator enumerator2 = c.get_Children().GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     SecurityElement securityElement = (SecurityElement)enumerator2.get_Current();
                     if (securityElement.get_Tag() == "par")
                     {
                         this.load_par(version, agentType, securityElement);
                     }
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Beispiel #17
0
        protected virtual void load(int version, string agentType, List <property_t> properties)
        {
            using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    property_t current = enumerator.get_Current();
                    if (current.name == "EnterAction")
                    {
                        if (!string.IsNullOrEmpty(current.value))
                        {
                            this.m_enterAction = Action.LoadMethod(current.value);
                        }
                    }
                    else if (current.name == "ExitAction" && !string.IsNullOrEmpty(current.value))
                    {
                        this.m_exitAction = Action.LoadMethod(current.value);
                    }
                }
            }
            string nodeType = this.GetClassNameString().Replace(".", "::");

            Workspace.HandleNodeLoaded(nodeType, properties);
        }
Beispiel #18
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            if (properties.Count > 0)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];
                    if (p.name == "Domain")
                    {
                        m_domain = p.value;
                    }
                    else if (p.name == "Descriptors")
                    {
                        SetDescriptors(p.value);
                    }
                    else
                    {
                        //Debug.Check(0, "unrecognised property %s", p.name);
                    }
                }
            }
        }
Beispiel #19
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Frames")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        string typeName = null;
                        this.m_frames_var = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_frames_method = Action.LoadMethod(p.value);
                    }
                }
            }
        }
Beispiel #20
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Prototype")
                {
                    if (!string.IsNullOrEmpty(p.value))
                    {
                        CMethodBase m = Action.LoadMethod(p.value);
                        this.m_task = m as CTaskMethod;
                    }//if (p.value[0] != '\0')
                }
                else if (p.name == "IsHTN")
                {
                    if (p.value == "true")
                    {
                        this.m_bHTN = true;
                    }
                }
            }
        }
Beispiel #21
0
            public virtual bool load(List <property_t> properties)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];
                    if (p.name == "Mode")
                    {
                        switch (p.value)
                        {
                        case "Condition":
                            this.m_mode = TransitionMode.Condition;
                            break;

                        case "Success":
                            this.m_mode = TransitionMode.Success;
                            break;

                        case "Failure":
                            this.m_mode = TransitionMode.Failure;
                            break;

                        case "End":
                            this.m_mode = TransitionMode.End;
                            break;
                        }
                    }
                    else if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
Beispiel #22
0
            public virtual bool load(List <property_t> properties)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];

                    if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
Beispiel #23
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);
            string propertyName = null;

            using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    property_t current = enumerator.get_Current();
                    if (current.name == "Opl")
                    {
                        this.m_opl = Condition.LoadLeft(current.value, ref propertyName, null);
                    }
                    else if (current.name == "Operator")
                    {
                        if (current.value == "Add")
                        {
                            this.m_operator = EComputeOperator.E_ADD;
                        }
                        else if (current.value == "Sub")
                        {
                            this.m_operator = EComputeOperator.E_SUB;
                        }
                        else if (current.value == "Mul")
                        {
                            this.m_operator = EComputeOperator.E_MUL;
                        }
                        else if (current.value == "Div")
                        {
                            this.m_operator = EComputeOperator.E_DIV;
                        }
                    }
                    else if (current.name == "Opr1")
                    {
                        int num = current.value.IndexOf('(');
                        if (num == -1)
                        {
                            string text = null;
                            this.m_opr1 = Condition.LoadRight(current.value, propertyName, ref text);
                        }
                        else
                        {
                            this.m_opr1_m = Action.LoadMethod(current.value);
                        }
                    }
                    else if (current.name == "Opr2")
                    {
                        int num2 = current.value.IndexOf('(');
                        if (num2 == -1)
                        {
                            string text2 = null;
                            this.m_opr2 = Condition.LoadRight(current.value, propertyName, ref text2);
                        }
                        else
                        {
                            this.m_opr2_m = Action.LoadMethod(current.value);
                        }
                    }
                }
            }
        }
Beispiel #24
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];
                if (p.name == "Opl")
                {
                    this.m_opl = Condition.LoadLeft(p.value);
                }
                else if (p.name == "Operator")
                {
                    if (p.value == "Add")
                    {
                        this.m_operator = EComputeOperator.E_ADD;
                    }
                    else if (p.value == "Sub")
                    {
                        this.m_operator = EComputeOperator.E_SUB;
                    }
                    else if (p.value == "Mul")
                    {
                        this.m_operator = EComputeOperator.E_MUL;
                    }
                    else if (p.value == "Div")
                    {
                        this.m_operator = EComputeOperator.E_DIV;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "Opr1")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        string typeName = null;
                        this.m_opr1 = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_opr1_m = Action.LoadMethod(p.value);
                    }
                }
                else if (p.name == "Opr2")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        string typeName = null;
                        this.m_opr2 = Condition.LoadRight(p.value, ref typeName);
                    }
                    else
                    {
                        //method
                        this.m_opr2_m = Action.LoadMethod(p.value);
                    }
                }
                else
                {
                    //Debug.Check(0, "unrecognised property %s", p.name);
                }
            }
        }
Beispiel #25
0
        private bool load_property_pars(ref List<property_t> properties, SecurityElement c, int version, string agentType)
        {
            try
            {
                if (c.Tag == "property")
                {
                    Debug.Check(c.Attributes.Count == 1);
                    foreach(string propName in c.Attributes.Keys)
                    {
                        string propValue = (string)c.Attributes[propName];
                        property_t p = new property_t(propName, propValue);
                        properties.Add(p);
                        break;
                    }

                    return true;
                }
                else if (c.Tag == "pars")
                {
                    if (c.Children != null)
                    {
                        foreach(SecurityElement parNode in c.Children)
                        {
                            if (parNode.Tag == "par")
                            {
                                this.load_par(version, agentType, parNode);
                            }
                        }
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                Debug.Check(false, ex.Message);
            }

            return false;
        }
Beispiel #26
0
        private bool load_property_pars(ref List<property_t> properties, XmlNode node, int version, string agentType)
        {
            try
            {
                if (node.Name == "property")
                {
                    Debug.Check(node.Attributes.Count == 1);

                    if (node.Attributes.Count == 1)
                    {
                        XmlAttribute attr = node.Attributes[0];

                        property_t p = new property_t(attr.Name, attr.Value);
                        properties.Add(p);
                    }

                    return true;
                }
                else if (node.Name == "pars")
                {
                    foreach(XmlNode parNode in node.ChildNodes)
                    {
                        if (parNode.Name == "par")
                        {
                            this.load_par(version, agentType, parNode);
                        }
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                Debug.Check(false, ex.Message);
            }

            return false;
        }
Beispiel #27
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "FailurePolicy")
                {
                    if (p.value == "FAIL_ON_ONE")
                    {
                        this.m_failPolicy = FAILURE_POLICY.FAIL_ON_ONE;
                    }
                    else if (p.value == "FAIL_ON_ALL")
                    {
                        this.m_failPolicy = FAILURE_POLICY.FAIL_ON_ALL;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "SuccessPolicy")
                {
                    if (p.value == "SUCCEED_ON_ONE")
                    {
                        this.m_succeedPolicy = SUCCESS_POLICY.SUCCEED_ON_ONE;
                    }
                    else if (p.value == "SUCCEED_ON_ALL")
                    {
                        this.m_succeedPolicy = SUCCESS_POLICY.SUCCEED_ON_ALL;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "ExitPolicy")
                {
                    if (p.value == "EXIT_NONE")
                    {
                        this.m_exitPolicy = EXIT_POLICY.EXIT_NONE;
                    }
                    else if (p.value == "EXIT_ABORT_RUNNINGSIBLINGS")
                    {
                        this.m_exitPolicy = EXIT_POLICY.EXIT_ABORT_RUNNINGSIBLINGS;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else if (p.name == "ChildFinishPolicy")
                {
                    if (p.value == "CHILDFINISH_ONCE")
                    {
                        this.m_childFinishPolicy = CHILDFINISH_POLICY.CHILDFINISH_ONCE;
                    }
                    else if (p.value == "CHILDFINISH_LOOP")
                    {
                        this.m_childFinishPolicy = CHILDFINISH_POLICY.CHILDFINISH_LOOP;
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
                else
                {
                    // todo: enter exit action failed here by mistake
                    //Debug.Check(false);
                }
            }
        }
Beispiel #28
0
            public virtual bool load(List <property_t> properties)
            {
                string opr2TypeName   = null;
                string comparatorName = null;

                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];
                    if (p.name == "Mode")
                    {
                        switch (p.value)
                        {
                        case "Condition":
                            this.m_mode = TransitionMode.Condition;
                            break;

                        case "Success":
                            this.m_mode = TransitionMode.Success;
                            break;

                        case "Failure":
                            this.m_mode = TransitionMode.Failure;
                            break;

                        case "End":
                            this.m_mode = TransitionMode.End;
                            break;
                        }
                    }
                    else if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                string typeName = null;
                                this.m_opl = Condition.LoadRight(p.value, ref typeName);
                            }
                            else
                            {
                                //method
                                this.m_opl_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                string typeName = null;
                                this.m_opr1 = Condition.LoadRight(p.value, ref typeName);
                            }
                            else
                            {
                                //method
                                this.m_opr1_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        comparatorName = p.value;

                        switch (p.value)
                        {
                        case "Invalid":
                            this.m_operator = EOperatorType.E_INVALID;
                            break;

                        case "Assign":
                            this.m_operator = EOperatorType.E_ASSIGN;
                            break;

                        case "Add":
                            this.m_operator = EOperatorType.E_ADD;
                            break;

                        case "Sub":
                            this.m_operator = EOperatorType.E_SUB;
                            break;

                        case "Mul":
                            this.m_operator = EOperatorType.E_MUL;
                            break;

                        case "Div":
                            this.m_operator = EOperatorType.E_DIV;
                            break;

                        case "Equal":
                            this.m_operator = EOperatorType.E_EQUAL;
                            break;

                        case "NotEqual":
                            this.m_operator = EOperatorType.E_NOTEQUAL;
                            break;

                        case "Greater":
                            this.m_operator = EOperatorType.E_GREATER;
                            break;

                        case "Less":
                            this.m_operator = EOperatorType.E_LESS;
                            break;

                        case "GreaterEqual":
                            this.m_operator = EOperatorType.E_GREATEREQUAL;
                            break;

                        case "LessEqual":
                            this.m_operator = EOperatorType.E_LESSEQUAL;
                            break;
                        }
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = Condition.LoadRight(p.value, ref opr2TypeName);
                            }
                            else
                            {
                                //method
                                this.m_opr2_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else
                    {
                        //Debug.Check(0, "unrecognised property %s", p.name);
                    }
                }

                // compare
                if (this.m_operator >= EOperatorType.E_EQUAL && this.m_operator <= EOperatorType.E_LESSEQUAL)
                {
                    if (!string.IsNullOrEmpty(comparatorName) && (this.m_opl != null || this.m_opl_m != null) &&
                        (this.m_opr2 != null || this.m_opr2_m != null))
                    {
                        this.m_comparator = Condition.Create(comparatorName, this.m_opl, this.m_opl_m, this.m_opr2, this.m_opr2_m);
                    }
                }

                return(this.m_opl != null);
            }