Beispiel #1
0
 /// <summary>
 ///     Starts this instance.
 /// </summary>
 public void Start()
 {
     if (_stateMachine.CanChangeState(ProcessorStatus.Started))
     {
         _stateMachine.ChangeState(ProcessorStatus.Started);
     }
 }
Beispiel #2
0
 /// <summary>
 ///     Starts this instance.
 /// </summary>
 public void Start()
 {
     if (_stateMachine.CanChangeState(ServiceStatus.StandBy))
     {
         _stateMachine.ChangeState(ServiceStatus.StandBy);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Starts this instance.
 /// </summary>
 public void Start()
 {
     Logger.Debug(string.Format("Starting Channel..."));
     if (_endPointStateMachine.CanChangeState(EndPointStatus.Receiving))
     {
         _endPointStateMachine.ChangeState(EndPointStatus.Receiving);
         Logger.Debug(string.Format("Channel - Started"));
     }
     else
     {
         Logger.Debug(string.Format("Can't change state channel to Started, current state {0}", _endPointStateMachine.CurrentState));
     }
 }
Beispiel #4
0
 /// <summary>
 ///     Starts this instance.
 /// </summary>
 public void Start()
 {
     Logger.Debug("Starting.. Router Processor");
     if (_stateMachine.CanChangeState(ProcessorStatus.Started))
     {
         _stateMachine.ChangeState(ProcessorStatus.Started);
         Logger.Debug("Router Processor Started");
     }
     else
     {
         Logger.Debug("Don't Change state to Start");
     }
 }
Beispiel #5
0
        /// <summary>
        ///     Configures the state machine.
        /// </summary>
        private void ConfigureStateMachine()
        {
            _stateMachine = StateMachineFactory.Create(ServiceStatus.Initializing)
                            .Permit(ServiceStatus.Initializing, ServiceStatus.StandBy, StartControl)
                            .Permit(ServiceStatus.StandBy, ServiceStatus.Started, StartProcessor)
                            .Permit(ServiceStatus.StandBy, ServiceStatus.Stopped, StopControl)
                            .Permit(ServiceStatus.Started, ServiceStatus.StandBy, StopProcessor)
                            .Permit(ServiceStatus.Started, ServiceStatus.Stopped, StopAll)
                            .Permit(ServiceStatus.Stopped, ServiceStatus.StandBy, StartControl);

            _controller.OnStart += (sender, args) =>
            {
                //El processor es un bus no un servicio, los servicios arrancan cuando el controller acaba de configurarlos
                if (_processor is ISubscriber)
                {
                    if (_stateMachine.CanChangeState(ServiceStatus.Started))
                    {
                        _stateMachine.ChangeState(ServiceStatus.Started);
                    }
                }
            };

            _processor.OnStart += (sender, args) =>
            {
                if (_stateMachine.CanChangeState(ServiceStatus.Started))
                {
                    _stateMachine.ChangeState(ServiceStatus.Started);
                }
            };

            _processor.OnStop += (sender, args) =>
            {
                if (_stateMachine.CanChangeState(ServiceStatus.StandBy))
                {
                    _stateMachine.ChangeState(ServiceStatus.StandBy);
                }
            };
        }
Beispiel #6
0
        /// <summary>
        ///     Configures the state machine.
        /// </summary>
        private void ConfigureStateMachine()
        {
            _stateMachine = StateMachineFactory.Create(ServiceStatus.Initializing)
                                               .Permit(ServiceStatus.Initializing, ServiceStatus.StandBy, StartControl)
                                               .Permit(ServiceStatus.StandBy, ServiceStatus.Started, StartProcessor)
                                               .Permit(ServiceStatus.StandBy, ServiceStatus.Stopped, StopControl)
                                               .Permit(ServiceStatus.Started, ServiceStatus.StandBy, StopProcessor)
                                               .Permit(ServiceStatus.Started, ServiceStatus.Stopped, StopAll)
                                               .Permit(ServiceStatus.Stopped, ServiceStatus.StandBy, StartControl);

            _controller.OnStart += (sender, args) =>
                {
                    //El processor es un bus no un servicio, los servicios arrancan cuando el controller acaba de configurarlos
                    if (_processor is ISubscriber)
                    {
                        if (_stateMachine.CanChangeState(ServiceStatus.Started))
                        {
                            _stateMachine.ChangeState(ServiceStatus.Started);
                        }
                    }
                };

            _processor.OnStart += (sender, args) =>
                {
                    if (_stateMachine.CanChangeState(ServiceStatus.Started))
                    {
                        _stateMachine.ChangeState(ServiceStatus.Started);
                    }
                };

            _processor.OnStop += (sender, args) =>
                {
                    if (_stateMachine.CanChangeState(ServiceStatus.StandBy))
                    {
                        _stateMachine.ChangeState(ServiceStatus.StandBy);
                    }
                };
        }