public void ProcessEvent(EventWrittenEventArgs e)
        {
            switch (_eventPairTimerConnections.TryGetDuration(e, out var duration1))
            {
            case DurationResult.Start:
                ConnectionStart?.Invoke(Events.ConnectionStartEvent.Instance);
                break;

            case DurationResult.FinalWithDuration:
                ConnectionStop?.InvokeManyTimes(_samplingRate.SampleEvery, Events.ConnectionStopEvent.GetFrom(duration1));
                break;

            default:
                break;
            }

            switch (_eventPairTimerRequests.TryGetDuration(e, out var duration2))
            {
            case DurationResult.Start:
                ConnectionStart?.Invoke(Events.ConnectionStartEvent.Instance);
                break;

            case DurationResult.FinalWithDuration:
                ConnectionStop?.InvokeManyTimes(_samplingRate.SampleEvery, Events.ConnectionStopEvent.GetFrom(duration2));
                break;

            default:
                break;
            }

            if (e.EventId == EventIdConnectionStart)
            {
                ConnectionStart?.Invoke(Events.ConnectionStartEvent.ParseFrom(e));
                return;
            }

            if (e.EventId == EventIdConnectionStop)
            {
                ConnectionStop?.Invoke(Events.ConnectionStopEvent.ParseFrom(e));
                return;
            }

            if (e.EventId == EventIdRequestStart)
            {
                RequestStart?.Invoke(Events.RequestStartEvent.ParseFrom(e));
                return;
            }

            if (e.EventId == EventIdRequestStop)
            {
                RequestStop?.Invoke(Events.RequestStopEvent.ParseFrom(e));
                return;
            }

            if (e.EventId == EventIdConnectionRejected)
            {
                ConnectionRejected?.Invoke(Events.ConnectionRejectedEvent.ParseFrom(e));
                return;
            }
        }
示例#2
0
 //Solicitud de detener el componente
 internal void Stop(RequestStop req)
 {
     Builder.Output("Deteniendo DbHandler.");
     StopComponent();
     Builder.Output("DbHandler detenido.");
     MessageBus.Send(new ReplyStop());
 }
示例#3
0
 internal RequestStopEvent(int stationIndex, int maxCars, bool fullSpeed, RequestStop onTime, RequestStop early, RequestStop late)
 {
     this.FullSpeed    = fullSpeed;
     this.OnTime       = onTime;
     this.StationIndex = stationIndex;
     this.Early        = early;
     this.Late         = late;
     this.MaxCars      = maxCars;
 }
示例#4
0
        public RequestStopEvent(CurrentRoute CurrentRoute, int StationIndex, int MaxCars, bool FullSpeed, RequestStop OnTime, RequestStop Early, RequestStop Late)
        {
            currentRoute = CurrentRoute;

            fullSpeed    = FullSpeed;
            onTime       = OnTime;
            stationIndex = StationIndex;
            early        = Early;
            late         = Late;
            maxCars      = MaxCars;
        }
示例#5
0
        /// <summary>
        /// Call to request stop.
        /// </summary>
        public void RequestStop()
        {
            try
            {
                var r = new RequestStop();
                airTrafficController.aqmRequestProcess(r);
                SetOutput("Stopped");
            }
            catch (AirTrafficControlException aex)
            {
                HandleAirTrafficControlException(aex);
            }

            UpdateAircraftQueue();
        }
示例#6
0
            /// <inheritdoc/>
            public override void RequestStop(RequestStop stopRequest)
            {
                if (stopRequest.MaxCars != 0 && NumberOfCars > stopRequest.MaxCars)
                {
                    //Check whether our train length is valid for this before doing anything else
                    Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[2], 1.0, 1.0, Cars[DriverCar], false);
                    return;
                }
                if (Program.RandomNumberGenerator.Next(0, 100) <= stopRequest.Probability)
                {
                    //We have hit our probability roll
                    if (Program.CurrentRoute.Stations[stopRequest.StationIndex].StopMode == StationStopMode.AllRequestStop || (IsPlayerTrain && Program.CurrentRoute.Stations[stopRequest.StationIndex].StopMode == StationStopMode.PlayerRequestStop))
                    {
                        //If our train can stop at this station, set it's index accordingly
                        Station         = stopRequest.StationIndex;
                        NextStopSkipped = StopSkipMode.None;
                        //Play sound
                        Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[0], 1.0, 1.0, Cars[DriverCar], false);
                    }
                    else
                    {
                        //We don't meet the conditions for this request stop
                        if (stopRequest.FullSpeed)
                        {
                            //Pass at linespeed, rather than braking as if for stop
                            NextStopSkipped = StopSkipMode.Linespeed;
                        }
                        else
                        {
                            NextStopSkipped = StopSkipMode.Decelerate;
                        }

                        //Play sound
                        Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[1], 1.0, 1.0, Cars[DriverCar], false);
                        //If message is not empty, add it
                        if (!string.IsNullOrEmpty(stopRequest.PassMessage) && IsPlayerTrain)
                        {
                            MessageManager.AddMessage(stopRequest.PassMessage, MessageDependency.None, GameMode.Normal, MessageColor.White, Program.CurrentRoute.SecondsSinceMidnight + 10.0, null);
                        }

                        return;
                    }

                    //Play sound
                    Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[0], 1.0, 1.0, Cars[DriverCar], false);
                    //If message is not empty, add it
                    if (!string.IsNullOrEmpty(stopRequest.StopMessage) && IsPlayerTrain)
                    {
                        MessageManager.AddMessage(stopRequest.StopMessage, MessageDependency.None, GameMode.Normal, MessageColor.White, Program.CurrentRoute.SecondsSinceMidnight + 10.0, null);
                    }
                }
                else
                {
                    Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[1], 1.0, 1.0, Cars[DriverCar], false);
                    if (stopRequest.FullSpeed)
                    {
                        //Pass at linespeed, rather than braking as if for stop
                        NextStopSkipped = StopSkipMode.Linespeed;
                    }
                    else
                    {
                        NextStopSkipped = StopSkipMode.Decelerate;
                    }

                    //Play sound
                    Program.Sounds.PlayCarSound(Cars[DriverCar].Sounds.RequestStop[1], 1.0, 1.0, Cars[DriverCar], false);
                    //If message is not empty, add it
                    if (!string.IsNullOrEmpty(stopRequest.PassMessage) && IsPlayerTrain)
                    {
                        MessageManager.AddMessage(stopRequest.PassMessage, MessageDependency.None, GameMode.Normal, MessageColor.White, Program.CurrentRoute.SecondsSinceMidnight + 10.0, null);
                    }
                }
            }
 internal void Stop(RequestStop req)
 {
     Builder.Output("Deteniendo ClientManager..");
     StopComponent();
     Builder.Output("ClientManager detenido..");
 }
示例#8
0
 internal void Stop(RequestStop req)
 {
     Builder.Output("Deteniendo Notifier.");
     StopComponent();
     Builder.Output("Notifier detenido.");
 }
示例#9
0
 private void Process(RequestStop req)
 {
     EnsureStarted();
     IsRunning = false;
 }
示例#10
0
        public async Task <IActionResult> Stop([FromBody] RequestStop model)
        {
            var winners = await _service.Stop(model.UserId, model.GameId);

            return(Ok(winners));
        }
 /// <summary>
 /// 引发 <see cref="RequestStop" /> 事件
 /// </summary>
 public virtual void OnRequestStop()
 {
     RequestStop?.Invoke(this, EventArgs.Empty);
 }