private void DistributeBaggage(string destination)
        {
            var nextNode = _listOfNextNode[destination];

            nextNode.OnNodeStatusChangedToFree += () =>
            {
                if (_transporterQueues[destination].Count > 0)
                {
                    if (nextNode.NodeStatus == NodeStatus.Free)
                    {
                        IBaggage tempBag = null;

                        if (_transporterQueues.Count != 0)
                        {
                            tempBag = _transporterQueues[destination].Dequeue();

                            if (tempBag == null)
                            {
                                return;
                            }
                        }

                        tempBag.TransportationStartTime = TimerService.GetTicksSinceSimulationStart();
                        nextNode.PassBaggage(tempBag);
                    }
                }
            };
        }
示例#2
0
        public override void Process(IBaggage baggage)
        {
            var logMessage = $"{Destination} processing - ";

            if (baggage.Flight.FlightState == FlightState.Landed)
            {
                baggage.Destination = typeof(BagCollector).Name;
                if (baggage.Flight.FlightState == FlightState.Departed)
                {
                    double delayInMinutes =
                        (TimerService.GetTimeSinceSimulationStart() - baggage.Flight.TimeToFlightSinceSimulationStart)
                        .TotalMinutes;
                    logMessage += LoggingConstants.BagArrivedLateAtAirportArea + $" with {delayInMinutes:F2} minutes";
                    baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                                        TimerService.ConvertMillisecondsToTimeSpan(1000), logMessage, delayInMinutes);
                }
                else
                {
                    logMessage += LoggingConstants.BagArrivedOnTimeAtAirportArea;
                    baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                                        TimerService.ConvertMillisecondsToTimeSpan(1000), logMessage);
                }
            }
            else
            {
                logMessage += LoggingConstants.BagRedirectedToAnotherFlight;

                baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                                    TimerService.ConvertMillisecondsToTimeSpan(1000), logMessage);
            }
        }
 public override void Process(IBaggage baggage)
 {
     baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                         TimerService.ConvertMillisecondsToTimeSpan(1000),
                         "CheckIn processing");
     baggage.Destination = typeof(Psc).Name;
 }
示例#4
0
        protected void Add(IBaggage baggage, int index = 0)
        {
            Condition.Requires(CanAdd(), "conveyor")
            .IsEqualTo(true, "Trying to add to {0}, while full.");

            _conveyorBelt[index] = baggage;
        }
        public override void Process(IBaggage b)
        {
            System.Diagnostics.Debug.WriteLine("psc" + b.Destination);

            _isFail = _randomGen.Next(0, 101) < _psSettings.PercentageFailedBags;

            b.AddLog(TimerService.GetTimeSinceSimulationStart(), TimerService.ConvertMillisecondsToTimeSpan(_psSettings.ProcessingSpeed),
                     $"Primary security check ID-{NodeId} processing - { (_isFail ? LoggingConstants.PrimarySecurityCheckFailed : LoggingConstants.PrimarySecurityCheckSucceeded)}");
        }
        public override void Process(IBaggage baggage)
        {
            var isFail = _randomGen.Next(0, 101) < _ascSettings.AscInvalidationPercentage;

            baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                                TimerService.ConvertMillisecondsToTimeSpan(_ascSettings.ProcessingRateInMilliseconds),
                                $"Advanced security check ID-{NodeId} processing - { (isFail ? LoggingConstants.AscCheckFailed : LoggingConstants.AscCheckSucceeded) }");

            _currentBaggage.Destination = isFail ? typeof(BagCollector).Name : typeof(Mpa).Name;
        }
 private void SortBaggageToTransporterNode(IBaggage b)
 {
     foreach (var node in _listOfNextNode)
     {
         if (node.Value.NextNode.Destination == b.Flight.DropoffId)
         {
             b.Destination = node.Value.NextNode.Destination;
         }
     }
 }
        public override void PassBaggage(IBaggage b)
        {
            AddBagTransportationLog(b);

            SortBaggageToTransporterNode(b);

            b.AddLog(TimerService.GetTimeSinceSimulationStart(), TimerService.ConvertMillisecondsToTimeSpan(1000), "Mda processing. Sorted to dropoff " + b.Destination);

            _transporterQueues[b.Destination].Enqueue(b);
        }
        public void PassBaggage(IBaggage baggage, IConveyorConnector predecessor)
        {
            var index = _incomingConnections[predecessor];

            if (CanAdd(index))
            {
                baggage.TransporterId = NodeId;
                Add(baggage, index);
            }
        }
示例#10
0
        public override void PassBaggage(IBaggage baggage)
        {
            AddTransportationLog(baggage);

            SortToDestinationDistributor(baggage);

            baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(), TimerService.ConvertMillisecondsToTimeSpan(1000),
                                "MPA processing. Sorted to Gate " + baggage.Destination + ". Enqueuing for distribution.");

            _baggageDistributors[baggage.Destination].Enqueue(baggage);
        }
示例#11
0
        public void Add(IBaggage bag, int index = 0)
        {
            var canAdd = CanAdd();

            while (!canAdd)
            {
                canAdd = CanAdd();
            }
            Condition.Requires(canAdd, "conveyor").IsEqualTo(true, "Trying to add to a full conveyor");
            _conveyorBelt[index] = bag;
        }
示例#12
0
 private void ProcessInternal(IBaggage b)
 {
     Process(b);
     if (currentBag == null)
     {
         NodeStatus = NodeStatus.Free;
         return;
     }
     NextNode = nextNodes.FirstOrDefault(n => n.Destination == currentBag.Destination);
     currentBag.TransportationStartTime = TimerService.GetTicksSinceSimulationStart();
     Move();
 }
示例#13
0
 private void AddTransportationLog(IBaggage baggage)
 {
     if (baggage.TransportationStartTime != null)
     {
         var transportationStart     = baggage.TransportationStartTime ?? 0;
         var transportingTimeElapsed = TimerService.GetTicksSinceSimulationStart() - transportationStart;
         baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                             new TimeSpan(transportingTimeElapsed),
                             string.Format(LoggingConstants.BagReceivedInTemplate, Destination, baggage.TransporterId));
         baggage.TransportationStartTime = null;
     }
 }
示例#14
0
        public override void Process(IBaggage b)
        {
            base.Process(b);
            if (!_isFail)
            {
                //b.Destination = typeof(Mda).Name;
                b.Destination = typeof(SecondSecurity).Name;
                return;
            }

            bagsTaken.Add(b);
            currentBag = null;
        }
示例#15
0
        public override void Process(IBaggage b)
        {
            base.Process(b);
            if (!_isFail)
            {
                //b.Destination = typeof(Mda).Name;
                b.Destination = typeof(Mda).Name;
                return;
            }

            bagsTaken.Add(b);
            currentBag = null;
            this._dangerousBaggage.Add(b);
        }
        private void ProcessInternal(IBaggage baggage)
        {
            Process(baggage);

            NextLink = _allSuccessors
                       .FirstOrDefault(x => x.Destination == baggage.Destination);

            //Condition
            //    .Requires(NextLink)
            //    .IsNotNull();

            _currentBaggage.TransportationStartTime = TimerService.GetTicksSinceSimulationStart();

            Move();
        }
        public override void PassBaggage(IBaggage baggage)
        {
            Status          = NodeState.Busy;
            _currentBaggage = baggage;
            if (baggage.TransportationStartTime != null)
            {
                var transportationStart     = baggage.TransportationStartTime ?? 0;
                var transportingTimeElapsed = TimerService.GetTicksSinceSimulationStart() - transportationStart;
                baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                                    new TimeSpan(transportingTimeElapsed),
                                    string.Format(LoggingConstants.BagReceivedInTemplate, Destination, baggage.TransporterId));
                baggage.TransportationStartTime = null;
            }

            ProcessInternal(baggage);
        }
示例#18
0
        private void SortToDestinationDistributor(IBaggage baggage)
        {
            var timeToFlight = (baggage.Flight.TimeToFlightSinceSimulationStart - TimerService.GetTimeSinceSimulationStart()).TotalMilliseconds;

            if (baggage.Flight.FlightState == FlightState.Landed)
            {
                baggage.Destination = baggage.Flight.PickUpArea;
            }
            else if (baggage.Flight.FlightState == FlightState.WaitingForPreparation) //If timeToFlight is bigger than 1/5 of total timeToFlight //Make customizable?/Calculate?
            {
                baggage.Destination = typeof(BSU).Name;
            }
            else if (baggage.Flight.FlightState == FlightState.InPreparation || baggage.Flight.FlightState == FlightState.Departed)
            {
                baggage.Destination = baggage.Flight.Gate;
            }
        }
 private void PassOrEnqueueBaggage(IChainLink gate, IBaggage bag)
 {
     bag.TransportationStartTime = TimerService.GetTicksSinceSimulationStart();
     bag.TransporterId           = "Queue AA";
     if (gate.Status == NodeState.Free)
     {
         gate.PassBaggage(bag);
     }
     else
     {
         if (gate.OnStatusChangedToFree == null)
         {
             gate.OnStatusChangedToFree += () => { PassQueuedBaggage(gate); }
         }
         ;
         _gateQueues[gate].Enqueue(bag);
     }
 }
示例#20
0
        public override void Process(IBaggage b)
        {
            System.Diagnostics.Debug.WriteLine("psc" + b.Destination);

            var isFail = _rand.Next(0, 101) < _psSettings.PercentageFailedBags;

            b.AddLog(TimerService.GetTimeSinceSimulationStart(), TimerService.ConvertMillisecondsToTimeSpan(_psSettings.ProcessingSpeed),
                     $"Final security check ID-{NodeId} processing - { (isFail ? LoggingConstants.FinalSecurityCheckFailed: LoggingConstants.FinalSecurityCheckSucceeded)}");
            if (!isFail)
            {
                b.Destination = typeof(Mda).Name;
                return;
            }

            bagsTaken.Enqueue(b);
            currentBag = null;
            this._dangerousBaggage.Add(b);
        }
示例#21
0
 public override void PassBaggage(IBaggage b)
 {
     NodeStatus = NodeStatus.Busy;
     currentBag = b;
     if (b == null)
     {
         NodeStatus = NodeStatus.Free;
         return;
     }
     if (b.TransportationStartTime != null)
     {
         var transportationStart     = b.TransportationStartTime ?? 0;
         var transportingTimeElapsed = TimerService.GetTicksSinceSimulationStart() - transportationStart;
         b.AddLog(TimerService.GetTimeSinceSimulationStart(),
                  new TimeSpan(transportingTimeElapsed),
                  string.Format(LoggingConstants.BagReceivedInTemplate, Destination, b.TransporterId));
         b.TransportationStartTime = null;
     }
     ProcessInternal(currentBag);
 }
 public override void Process(IBaggage baggage)
 {
     baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                         TimerService.ConvertMillisecondsToTimeSpan(1000),
                         string.Format(LoggingConstants.ReceivedInRobotSendingTo, (baggage.Destination == typeof(Mpa).Name ? baggage.Destination : $"{typeof(BaggageBucket).Name} #" + baggage.Destination)));
 }
 public override void PassBaggage(IBaggage baggage)
 {
     Baggages.Enqueue(baggage);
 }
 public abstract void Process(IBaggage baggage);
示例#25
0
 public abstract void PassBaggage(IBaggage b);
 public override void PassBaggage(IBaggage baggage)
 {
     Status = NodeState.Busy;
     baggage.TransporterId = NodeId;
     Add(baggage);
 }
 public override void PassBaggage(IBaggage b)
 {
     b.Destination = Destination;
     _pickedUpBags.Add(b);
     b.AddLog(TimerService.GetTimeSinceSimulationStart() + new TimeSpan(ProcessingSpeed), TimerService.ConvertMillisecondsToTimeSpan(ProcessingSpeed), "drop off processing");
 }
 public override void PassBaggage(IBaggage baggage)
 {
     _pickedUpBags.Add(baggage);
 }
 public override void PassBaggage(IBaggage baggage)
 {
     throw new NotImplementedException();
 }
示例#30
0
 public void SubmitBaggage(IBaggage baggege)
 {
     Baggage = baggege;
     CurrentState.SubmitBaggage();
 }