/// <summary>
        /// Plan the given message.
        /// </summary>
        /// <param name="message"></param>
        private void Plan(MicroPlannerMessage message)
        {
            OsmSharp.Logging.Log.TraceEvent("MicroPlanner", TraceEventType.Information,
                                            message.ToString());

            // add the message to the stack.
            _messagesStack.Add(message);

            // put the message through the machine.
            foreach (MicroPlannerMachine machine in _machines)
            {
                if (!_invalid_machines.Contains(machine) &&
                    !_valid_machines.Contains(machine))
                { // only use machines that are still valid!
                    machine.Consume(message);

                    if (_succes)
                    {
                        break;
                    }

                    if (_error)
                    {
                        break;
                    }
                }
            }
            _succes = false;
            _error  = false;
        }
        /// <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;
        }
Exemple #3
0
        /// <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();
            machine.IsSuccesfull = true;

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

            _succes = true;
        }
Exemple #4
0
        /// <summary>
        /// Plan the given message.
        /// </summary>
        /// <param name="message"></param>
        private void Plan(MicroPlannerMessage message)
        {
            _succes = false;
            _error  = false;
            // add the message to the stack.
            _messagesStack.Add(message);

            // put the message through the machine.
            foreach (var machine in _machines)
            {
                if (!_invalidMachines.Contains(machine) &&
                    !_validMachines.Contains(machine))
                { // only use machines that are still valid!
                    machine.Consume(message);

                    if (_succes)
                    {
                        break;
                    }

                    if (_error)
                    {
                        break;
                    }
                }
            }
            _succes = false;
            _error  = false;
        }
        /// <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);
        }
Exemple #6
0
        /// <summary>
        /// Plan the given message.
        /// </summary>
        /// <param name="message"></param>
        private void Plan(MicroPlannerMessage message)
        {
            OsmSharp.Logging.Log.TraceEvent("MicroPlanner", TraceEventType.Information,
                message.ToString());

            // add the message to the stack.
            _messagesStack.Add(message);

            // put the message through the machine.
            foreach (MicroPlannerMachine machine in _machines)
            {
                if (!_invalid_machines.Contains(machine)
                    && !_valid_machines.Contains(machine))
                { // only use machines that are still valid!
                    machine.Consume(message);

                    if (_succes)
                    {
                        break;
                    }

                    if (_error)
                    {
                        break;
                    }
                }
            }
            _succes = false;
            _error = false;
        }
Exemple #7
0
        /// <summary>
        /// Plan the given message.
        /// </summary>
        /// <param name="message"></param>
        private void Plan(MicroPlannerMessage message)
        {
            _succes = false;
            _error = false;
            // add the message to the stack.
            _messagesStack.Add(message);

            // put the message through the machine.
            foreach (var machine in _machines)
            {
                if (!_invalidMachines.Contains(machine)
                    && !_validMachines.Contains(machine))
                { // only use machines that are still valid!
                    machine.Consume(message);

                    if (_succes)
                    {
                        break;
                    }

                    if (_error)
                    {
                        break;
                    }
                }
            }
            _succes = false;
            _error = false;
        }