Beispiel #1
0
        /// <summary>
        /// Loads the plan and creates the drive collection tree.
        ///
        /// The method parses the plan file, and then uses the plan builder to
        /// build the drive collection tree.
        /// </summary>
        /// <param name="planFile">Filename of the plan file that is loaded.</param>
        /// <returns></returns>
        internal override void LoadPlan(string planName)
        {
            // if setTimer() is not called, then the first use of
            // the timer will fail. setTimer() is called when the drive
            // collection is built.
            timer = null;
            // read plan, parse it and build drive collection
            PlanBuilder builder = new LAPParser().Parse(AssemblyControl.GetControl().GetPlanFile(library, planName));

            dc = builder.build(this);
        }
Beispiel #2
0
 public void CreateLAPParser()
 {
     parser = new LAPParser();
 }
        /// <summary>
        /// Fires the drive prority element.
        ///
        /// This method fires the first ready drive element in its
        /// list and returns FireResult(False, None). If no
        /// drive element was ready, then None is returned.
        /// </summary>
        /// <returns>The result of firing the element.</returns>
        public override FireResult fire()
        {
            log.Debug("Fired");
            long timeStamp = timer.Time();

            elements = LAPParser.ShuffleList(elements);
            // new_elements=self.get_sorted_drive()

            if (elements.Contains(agent.dc.lastTriggeredElement))
            {
                if (agent.dc.lastTriggeredElement.isReady(timeStamp))
                {
                    //if not self.agent._dc.last_triggered_element._behaviours[0].wants_to_interrupt():
                    //    for element in new_elements:
                    //        if element.isReady(timestamp) and element._behaviours[0].wants_to_interrupt():#and element!=self.agent._dc.last_triggered_element
                    //            self.agent._dc.last_triggered_element=element
                    //            element.fire()
                    //            return FireResult(False, None)
                    agent.dc.lastTriggeredElement.fire();
                    return(new FireResult(false, null));
                }
            }
            // for element in new_elements:
            foreach (DriveElement element in elements)
            {
                if (element.isReady(timeStamp))
                {
                    if (element != agent.dc.lastTriggeredElement)
                    {
                        if (agent.dc.lastTriggeredElement == null)
                        {
                            if (element.isLatched)
                            {
                                agent.dc.lastTriggeredElement = element;
                            }
                        }
                        else if (!agent.dc.lastTriggeredElement.isReady(timeStamp))
                        {
                            // event finished natually
                            agent.dc.lastTriggeredElement = null;
                        }
                        else
                        {
                            behaviours = agent.dc.lastTriggeredElement.behaviours;

                            // TODO: check this latching behaviour thing
                            foreach (Behaviour b in behaviours)
                            {
                                if (b.GetType().IsSubclassOf(typeof(LatchedBehaviour)))
                                {
                                    ((LatchedBehaviour)b).signalInterrupt();
                                }
                            }

                            if (element.isLatched)
                            {
                                agent.dc.lastTriggeredElement = element;
                            }
                            else
                            {
                                agent.dc.lastTriggeredElement = null;
                            }
                        }
                    }
                    element.fire();
                    return(new FireResult(false, null));
                }
            }

            return(null);
        }