コード例 #1
0
ファイル: MicroPlanner.cs プロジェクト: nubix-biz/OsmSharp
        /// <summary>
        /// Creates and plans a new message.
        /// </summary>
        /// <param name="aggregated"></param>
        private void PlanNewMessage(Aggregated aggregated)
        {
            // create the message.
            MicroPlannerMessage message = null;
            if (aggregated is AggregatedPoint)
            {
                MicroPlannerMessagePoint point = new MicroPlannerMessagePoint();
                point.Point = aggregated as AggregatedPoint;

                message = point;
            }
            else if (aggregated is AggregatedArc)
            {
                MicroPlannerMessageArc arc = new MicroPlannerMessageArc();
                arc.Arc = aggregated as AggregatedArc;

                message = arc;
            }

            // plan the message.
            this.Plan(message);
        }
コード例 #2
0
ファイル: MicroPlanner.cs プロジェクト: nubix-biz/OsmSharp
        /// <summary>
        /// Plans all the messages in the aggregated 
        /// </summary>
        /// <param name="p"></param>
        public List<Instruction> Plan(AggregatedPoint p)
        {
            // set the current aggregated object.
            _current = p;

            // loop until the current object is null.
            while (_current != null)
            {
                while (_current != null)
                {
                    // plan the current message.
                    this.PlanNewMessage(_current);

                    // get the next object.
                    _current = _current.GetNext();
                }

                // show the latest success anyway.
                if (_latest_final >= 0)
                { // do the latest succes.
                    this.Success(_latest_machine);

                    // get the next object.
                    if (_current != null)
                    {
                        _current = _current.GetNext();
                    }
                }
                else if(_messagesStack.Count > 0)
                { // no machine matches everything until the end of the route.
                    throw new MicroPlannerException("No machine could be found matching the current stack of messages!", _messagesStack);
                }
            }

            // return the instructions list accumulated in the scentence planner.
            return this.SentencePlanner.Instructions;
        }
コード例 #3
0
ファイル: MicroPlanner.cs プロジェクト: nubix-biz/OsmSharp
        /// <summary>
        /// The given machine was successfull.
        /// </summary>
        /// <param name="machine"></param>
        internal void Success(MicroPlannerMachine machine)
        {
            OsmSharp.Logging.Log.TraceEvent("MicroPlanner", TraceEventType.Information,
                machine.ToString());

            // reset the current point/arc.
            if (_messagesStack.Count > _latest_final + 1)
            {
                MicroPlannerMessage message = _messagesStack[_latest_final];
                if (message is MicroPlannerMessageArc)
                {
                    _current = (message as MicroPlannerMessageArc).Arc;
                }
                if (message is MicroPlannerMessagePoint)
                {
                    _current = (message as MicroPlannerMessagePoint).Point;
                }
            }

            // reset the mesages stack.
            this.ResetMessagesStack(true);

            // tell the machine again it was successfull.
            machine.Succes();

            // re-initialize the machines.
            this.InitializeMachines();

            _succes = true;
        }
コード例 #4
0
ファイル: MicroPlanner.cs プロジェクト: kochizufan/OsmSharp
        /// <summary>
        /// The given machine was successfull.
        /// </summary>
        /// <param name="machine"></param>
        internal void Success(MicroPlannerMachine machine)
        {
            // reset the current point/arc.
            if (_messagesStack.Count > _latestFinal + 1)
            {
                MicroPlannerMessage message = _messagesStack[_latestFinal];
                if (message is MicroPlannerMessageArc)
                {
                    _current = (message as MicroPlannerMessageArc).Arc;
                }
                if (message is MicroPlannerMessagePoint)
                {
                    _current = (message as MicroPlannerMessagePoint).Point;
                }
            }

            // reset the mesages stack.
            this.ResetMessagesStack(true);

            // tell the machine again it was successfull.
            machine.Succes();

            // re-initialize the machines.
            this.InitializeMachines();

            _succes = true;
        }