Example #1
0
        /// <summary>
        /// Initialises the drive collection.
        /// 
        /// The log domain is set to [AgentId].DC.[collection_name]
        /// 
        /// If no goal is given (goal = None), then it can never be satisfied.
        /// </summary>
        /// <param name="agent">The collection's agent.</param>
        /// <param name="collectionName">The name of the drive collection.</param>
        /// <param name="priorityElements">The drive elements in order of their
        ///         priority, starting with the highest priority.</param>
        /// <param name="goal">The goal of the drive collection.</param>
        public DriveCollection(Agent agent, string collectionName, DrivePriorityElement [] priorityElements, Trigger goal)
            : base(string.Format( "DC.{0}", collectionName),agent)
        {
            name = collectionName;
            elements = priorityElements;
            this.goal = goal;

            log.Debug("Created");
        }
Example #2
0
        // TODO: replace root which should be a polymoph type (maybe create superclass)
        /// <summary>
        /// Initialises the drive element.
        /// 
        /// The log domain is set to [AgentName].DE.[element_name]
        /// </summary>
        /// <param name="agent">The element's agent.</param>
        /// <param name="elementName">The name of the drive element.</param>
        /// <param name="trigger">The trigger of the element.</param>
        /// <param name="root">The element's root element.
        ///     root is either POSH.scheduled.Action, POSH.scheduled.Competence or POSH.scheduled.ActionPattern
        ///     </param>
        /// <param name="maxFreq">The maximum frequency at which is element is
        ///     fired. The frequency is given in milliseconds between
        ///     invocation. A negative number disables this feature.</param>
        public DriveElement(Agent agent, string elementName, Trigger trigger, Object root, long maxFreq)
            : base(string.Format("DE.{0}", elementName), agent)
        {
            this.name = elementName;
            this.trigger = trigger;
            this.root = root;
            this.element = root;
            this.maxFreq = maxFreq;

            // the timestamp when it was last fired
            this.lastFired = -100000L;

            log.Debug("Created");
            this.agent = agent;
            this.isLatched = false;

            this.behaviours = new List<Behaviour>();

            foreach (POSHSense sense in trigger.senses)
                this.behaviours.Add(sense.behaviour);
        }