Beispiel #1
0
 public bool CheckEvents(string eventName, Agent pAgent)
 {
     if (this.m_attachments != null)
     {
         for (int i = 0; i < this.m_attachments.Count; i++)
         {
             AttachmentTask  attachmentTask = this.m_attachments[i];
             Event.EventTask eventTask      = attachmentTask as Event.EventTask;
             if (eventTask != null && !string.IsNullOrEmpty(eventName))
             {
                 string eventName2 = eventTask.GetEventName();
                 if (!string.IsNullOrEmpty(eventName2) && eventName2 == eventName)
                 {
                     EBTStatus eBTStatus = attachmentTask.GetStatus();
                     if (eBTStatus == EBTStatus.BT_RUNNING || eBTStatus == EBTStatus.BT_INVALID)
                     {
                         eBTStatus = attachmentTask.exec(pAgent);
                     }
                     if (eBTStatus == EBTStatus.BT_SUCCESS)
                     {
                         if (eventTask.TriggeredOnce())
                         {
                             return(false);
                         }
                     }
                     else if (eBTStatus == EBTStatus.BT_FAILURE)
                     {
                     }
                 }
             }
         }
     }
     return(true);
 }
Beispiel #2
0
 public bool CheckEvents(string eventName, Agent pAgent)
 {
     if (this.m_attachments != null)
     {
         for (int i = 0; i < this.m_attachments.Count; i++)
         {
             AttachmentTask  task  = this.m_attachments[i];
             Event.EventTask task2 = task as Event.EventTask;
             if ((task2 != null) && !string.IsNullOrEmpty(eventName))
             {
                 string str = task2.GetEventName();
                 if (!string.IsNullOrEmpty(str) && (str == eventName))
                 {
                     EBTStatus status = task.GetStatus();
                     if ((status == EBTStatus.BT_RUNNING) || (status == EBTStatus.BT_INVALID))
                     {
                         status = task.exec(pAgent);
                     }
                     switch (status)
                     {
                     case EBTStatus.BT_SUCCESS:
                         if (!task2.TriggeredOnce())
                         {
                             break;
                         }
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }
Beispiel #3
0
 private void Attach(AttachmentTask pAttachment)
 {
     if (this.m_attachments == null)
     {
         this.m_attachments = new ListView <AttachmentTask>();
     }
     this.m_attachments.Add(pAttachment);
 }
Beispiel #4
0
        public virtual void Init(BehaviorNode node)
        {
            this.m_node = node;
            this.m_id   = this.m_node.GetId();
            int attachmentsCount = node.GetAttachmentsCount();

            if (attachmentsCount > 0)
            {
                for (int i = 0; i < attachmentsCount; i++)
                {
                    AttachmentTask pAttachment = (AttachmentTask)node.GetAttachment(i).CreateAndInitTask();
                    this.Attach(pAttachment);
                }
            }
        }
Beispiel #5
0
        public virtual bool CheckPredicates(Agent pAgent)
        {
            if (this.m_attachments == null || this.m_attachments.Count == 0)
            {
                return(true);
            }

            bool lastCombineValue = false;

            for (int i = 0; i < this.m_attachments.Count; ++i)
            {
                AttachmentTask          attchment     = this.m_attachments[i];
                Predicate.PredicateTask predicateTask = attchment as Predicate.PredicateTask;

                if (predicateTask != null)
                {
                    EBTStatus executeStatus = predicateTask.GetStatus();
                    if (executeStatus == EBTStatus.BT_RUNNING || executeStatus == EBTStatus.BT_INVALID)
                    {
                        executeStatus = predicateTask.exec(pAgent);
                    }

                    bool taskBoolean = getBooleanFromStatus(executeStatus);
                    if (i == 0)
                    {
                        lastCombineValue = taskBoolean;
                    }
                    else
                    {
                        bool andOp = predicateTask.IsAnd();
                        if (andOp)
                        {
                            lastCombineValue = lastCombineValue && taskBoolean;
                        }
                        else
                        {
                            lastCombineValue = lastCombineValue || taskBoolean;
                        }
                    }
                }
            }

            return(lastCombineValue);
        }
Beispiel #6
0
        /**
         * return false if the event handling needs to be stopped
         *
         * an event can be configured to stop being checked if triggered
         */
        public bool CheckEvents(string eventName, Agent pAgent)
        {
            if (this.m_attachments != null)
            {
                //bool bTriggered = false;
                for (int i = 0; i < this.m_attachments.Count; ++i)
                {
                    AttachmentTask  pA = this.m_attachments[i];
                    Event.EventTask pE = pA as Event.EventTask;

                    //check events only
                    if (pE != null && !string.IsNullOrEmpty(eventName))
                    {
                        string pEventName = pE.GetEventName();

                        if (!string.IsNullOrEmpty(pEventName) && pEventName == eventName)
                        {
                            EBTStatus currentStatus = pA.GetStatus();

                            if (currentStatus == EBTStatus.BT_RUNNING || currentStatus == EBTStatus.BT_INVALID)
                            {
                                currentStatus = pA.exec(pAgent);
                            }

                            if (currentStatus == EBTStatus.BT_SUCCESS)
                            {
                                //bTriggered = true;

                                if (pE.TriggeredOnce())
                                {
                                    return(false);
                                }
                            }
                            else if (currentStatus == EBTStatus.BT_FAILURE)
                            {
                            }
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #7
0
        public virtual void Init(BehaviorNode node)
        {
            Debug.Check(node != null);

            this.m_node = node;
            this.m_id   = this.m_node.GetId();

            int attachmentsCount = node.GetAttachmentsCount();

            if (attachmentsCount > 0)
            {
                for (int i = 0; i < attachmentsCount; i++)
                {
                    BehaviorNode   attachmentNode = node.GetAttachment(i);
                    AttachmentTask attachmentTask = (AttachmentTask)attachmentNode.CreateAndInitTask();

                    this.Attach(attachmentTask);
                }
            }
        }
Beispiel #8
0
        public virtual bool CheckPredicates(Agent pAgent)
        {
            if (this.m_attachments == null || this.m_attachments.Count == 0)
            {
                return(true);
            }
            bool flag = false;

            for (int i = 0; i < this.m_attachments.Count; i++)
            {
                AttachmentTask          attachmentTask = this.m_attachments[i];
                Predicate.PredicateTask predicateTask  = attachmentTask as Predicate.PredicateTask;
                if (predicateTask != null)
                {
                    EBTStatus eBTStatus = predicateTask.GetStatus();
                    if (eBTStatus == EBTStatus.BT_RUNNING || eBTStatus == EBTStatus.BT_INVALID)
                    {
                        eBTStatus = predicateTask.exec(pAgent);
                    }
                    bool booleanFromStatus = this.getBooleanFromStatus(eBTStatus);
                    if (i == 0)
                    {
                        flag = booleanFromStatus;
                    }
                    else
                    {
                        bool flag2 = predicateTask.IsAnd();
                        if (flag2)
                        {
                            flag = (flag && booleanFromStatus);
                        }
                        else
                        {
                            flag = (flag || booleanFromStatus);
                        }
                    }
                }
            }
            return(flag);
        }
Beispiel #9
0
        public virtual bool CheckPredicates(Agent pAgent)
        {
            if ((this.m_attachments == null) || (this.m_attachments.Count == 0))
            {
                return(true);
            }
            bool flag = false;

            for (int i = 0; i < this.m_attachments.Count; i++)
            {
                AttachmentTask          task  = this.m_attachments[i];
                Predicate.PredicateTask task2 = task as Predicate.PredicateTask;
                if (task2 != null)
                {
                    EBTStatus status = task2.GetStatus();
                    switch (status)
                    {
                    case EBTStatus.BT_RUNNING:
                    case EBTStatus.BT_INVALID:
                        status = task2.exec(pAgent);
                        break;
                    }
                    bool flag2 = this.getBooleanFromStatus(status);
                    if (i == 0)
                    {
                        flag = flag2;
                    }
                    else if (task2.IsAnd())
                    {
                        flag = flag && flag2;
                    }
                    else
                    {
                        flag = flag || flag2;
                    }
                }
            }
            return(flag);
        }
        private void Attach(AttachmentTask pAttachment)
        {
            if (this.m_attachments == null)
            {
                this.m_attachments = new List<AttachmentTask>();
            }

            this.m_attachments.Add(pAttachment);
        }