public override void Process(IBaggage baggage)
 {
     baggage.AddEventLog(TimerService.GetTimeSinceSimulationStart(),
                         TimerService.ConvertMillisecondsToTimeSpan(1000),
                         "CheckIn processing");
     baggage.Destination = typeof(Psc).Name;
 }
        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 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;
        }
        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);
        }
Exemple #6
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);
        }
Exemple #7
0
        public void TimerService_ShouldRunNewTimer_OnRunNewTimer()
        {
            var timerService = new TimerService();
            var settingsMock = new Mock <ISimulationSettings>();

            settingsMock.Setup(s => s.IncomingFlights).Returns(new Mock <List <Flight> >().Object);
            settingsMock.Setup(s => s.OutgoingFlights).Returns(new Mock <List <Flight> >().Object);
            settingsMock.Setup(s => s.Multiplier).Returns(1);

            timerService.SetSettings(settingsMock.Object);

            timerService.RunNewTimer();
            Thread.Sleep(2000);
            timerService.Stop();

            timerService.GetTimeSinceSimulationStart().TotalMilliseconds.ShouldBeGreaterThan(2000);

            timerService.RunNewTimer();
            timerService.Stop();
            timerService.GetTimeSinceSimulationStart().TotalMilliseconds.ShouldBeLessThan(2000);
        }
Exemple #8
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;
     }
 }
        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);
        }
Exemple #10
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;
            }
        }
Exemple #11
0
        public void TimerService_ShouldShouldReturnSameTimeSinceStart_FromBothMethods()
        {
            var timerService = new TimerService();
            var settingsMock = new Mock <ISimulationSettings>();

            settingsMock.Setup(s => s.IncomingFlights).Returns(new Mock <List <Flight> >().Object);
            settingsMock.Setup(s => s.OutgoingFlights).Returns(new Mock <List <Flight> >().Object);
            settingsMock.Setup(s => s.Multiplier).Returns(1);

            timerService.SetSettings(settingsMock.Object);

            timerService.Start();
            Thread.Sleep(2000);
            timerService.Stop();

            timerService.GetTicksSinceSimulationStart().ShouldBeInRange(timerService.GetTimeSinceSimulationStart().Ticks - 5, timerService.GetTimeSinceSimulationStart().Ticks + 5);
        }
Exemple #12
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);
        }
Exemple #13
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)));
 }
        private void DispatchFlightBaggage(Flight flight)
        {
            var gate = FindGate(flight.Gate);

            var randomGen = new Random(0);

            foreach (var i in Enumerable.Range(1, flight.BaggageCount))
            {
                var isTrans = randomGen.Next(0, 101) < _flightManagement.TransBaggagePercentage;

                var bag = new Baggage
                {
                    BaggageType = BaggageType.Small,
                    Destination = typeof(Mpa).Name,
                    Flight      = flight,
                    Owner       = "Someone"
                };

                if (isTrans)
                {
                    var transFlights = _flightManagement
                                       .OutgoingFlights
                                       .Where(f => f.TimeToFlightSinceSimulationStart > TimerService.GetTimeSinceSimulationStart() &&
                                              f.BaggageCount > f.DispatchedBaggageCount)
                                       .ToList();

                    var index       = randomGen.Next(0, transFlights.Count());
                    var transFlight = transFlights[index];

                    bag.Flight = transFlight;
                    transFlight.DispatchedBaggageCount++;
                }

                PassOrEnqueueBaggage(gate, bag);
            }
        }
 public override void Process(IBaggage b)
 {
     System.Diagnostics.Debug.WriteLine("checkin" + b.Destination);
     b.AddLog(TimerService.GetTimeSinceSimulationStart(), TimerService.ConvertMillisecondsToTimeSpan(1000), $"Checkin processing");
     b.Destination = typeof(PrimarySecurity).Name;
 }
 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");
 }