コード例 #1
0
        /// <summary>
        /// Handle VehicleExitRegistered message.
        /// </summary>
        /// <param name="msg">The message to handle.</param>
        private void Handle(VehicleExitRegistered msg)
        {
            _exitTimestamp = msg.Timestamp;

            // check speed limit
            int speedingViolation = DetermineSpeedingViolation();

            // log exit
            if (speedingViolation > 0)
            {
                FluentConsole.Red.Line($"{_color} {_brand} '{msg.VehicleId}' exited at {msg.Timestamp.ToString("HH:mm:ss.ffffff")}" +
                                       $"(avg speed {_avgSpeedInKmh} km/h - {speedingViolation} km/h over speed-limit (after correction))");

                // register speeding violation
                _cjcaActor = Context.ActorSelection("/user/cjcaactor");
                var rsv = new RegisterSpeedingViolation(_vehicleId, _roadInfo.RoadId, speedingViolation);
                _cjcaActor.Tell(rsv);
            }
            else
            {
                FluentConsole.Yellow.Line($"{_color} {_brand} '{msg.VehicleId}' exited at {msg.Timestamp.ToString("HH:mm:ss.ffffff")}" +
                                          $"(avg speed {_avgSpeedInKmh} km/h)");
            }

            Self.Tell(new Shutdown());
        }
コード例 #2
0
        /// <summary>
        /// Handle a RegisterSpeedingViolation message.
        /// </summary>
        /// <param name="msg">The message to handle.</param>
        private void Handle(RegisterSpeedingViolation msg)
        {
            decimal fine = CalculateFine(msg.ViolationInKmh);

            _totalAmountFined += fine;

            string fineString = fine == 0 ? "tbd by the prosecutor" : fine.ToString();

            System.Console.WriteLine($"Sent speeding ticket. Road: {msg.RoadId}, Licensenumber: {msg.VehicleId}" +
                                     $", Violation: {msg.ViolationInKmh} Km/h, Fine: € {fineString}");

            PrintAtLocation(0, 2, $"Total amount fined: € {_totalAmountFined}");
        }
コード例 #3
0
        private void Handle(RegisterSpeedingViolation message)
        {
            int fine;

            if (message.Speed <= 100)
            {
                fine = 2000;
            }
            else
            {
                fine = 5000;
            }
            Console.WriteLine($"Porušena povolená rychlost vozem {message.Brand} {message.Color} barvy s poznávací značkou {message.Registration}. Naměřena rychlost {message.Speed} km/h. Udělena pokuta {fine}Kč.");
        }
コード例 #4
0
        /// <summary>
        /// Handle a RegisterSpeedingViolation message.
        /// </summary>
        /// <param name="msg">The message to handle.</param>
        private void Handle(RegisterSpeedingViolation msg)
        {
            decimal fine = CJCALogic.CalculateFine(msg.ViolationInKmh);

            _totalAmountFined += fine;

            if (!IsRecovering)
            {
                string fineString = fine == 0 ? "tbd by the prosecutor" : fine.ToString();
                System.Console.WriteLine($"Sent speeding ticket. Road: {msg.RoadId}, Licensenumber: {msg.VehicleId}" +
                                         $", Violation: {msg.ViolationInKmh} Km/h, Fine: € {fineString}");

                ShowTotal();
            }
        }