Esempio n. 1
0
        internal StateMachineContext Build()
        {
            var machine = new ControllerStateMachine(actions, deviceControllerOptions, new SystemDateTimeUtcClock(), logger);

            machine.ShutterStepPosition  = shutterStepPosition;
            machine.ShutterLimitSwitches = shutterSensorState;
            var context = new StateMachineContext {
                Actions = actions, Machine = machine
            };

            if (initializeRotatorStateMachine)
            {
                var rotatorState = Activator.CreateInstance(rotatorStartType, machine) as IRotatorState;
                machine.Initialize(rotatorState);
            }

            if (initializeShuttterStateMachine)
            {
                var shutterState = Activator.CreateInstance(shutterStartType, machine) as IShutterState;
                machine.Initialize(shutterState);
            }

            if (rotatorIsRotating)
            {
                machine.AzimuthMotorActive     = true;
                machine.AtHome                 = false;
                machine.AzimuthDirection       = RotationDirection.Clockwise; // Arbitrary choice
                machine.AzimuthEncoderPosition = 100;                         // Arbitrary choice
            }

            return(context);
        }
 public DeviceController(ICommunicationChannel channel, ControllerStatusFactory factory,
                         ControllerStateMachine machine, DeviceControllerOptions configuration)
 {
     this.channel       = channel;
     statusFactory      = factory;
     stateMachine       = machine;
     this.configuration = configuration;
 }
Esempio n. 3
0
 // Start is called before the first frame update
 void Awake()
 {
     if (GameObject.FindGameObjectsWithTag("PlaySpace").Length > 1)
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(transform.gameObject);
     Instance = this;
 }
    public static IEnumerable <ControllerState> GetStatesRecursive(ControllerStateMachine sm)
    {
        foreach (var i in sm.states.AsEnumerable())
        {
            yield return(i);
        }

        foreach (var i in sm.subStateMachines.SelectMany(i => GetStatesRecursive(i)))
        {
            yield return(i);
        }
    }
Esempio n. 5
0
 public DeviceController(
     ICommunicationChannel channel,
     ControllerStatusFactory factory,
     ControllerStateMachine machine,
     DeviceControllerOptions configuration,
     ITransactionProcessor processor)
 {
     this.channel       = channel;
     statusFactory      = factory;
     stateMachine       = machine;
     this.configuration = configuration;
     this.processor     = processor;
 }
Esempio n. 6
0
        public DeviceControllerContext Build()
        {
            // Build the communications channel
            var channel = channelFactory.FromConnectionString(connectionString);

            if (channelShouldBeOpen)
            {
                channel.Open();
            }

            // Build the ControllerStatusFactory
            var statusFactory = new ControllerStatusFactory(timeSource);

            var fakeTransactionProcessor = new FakeTransactionProcessor(Enumerable.Empty <string>());
            var controllerActions        = new RxControllerActions(channel, fakeTransactionProcessor);
            var controllerStateMachine   =
                new ControllerStateMachine(controllerActions, controllerOptions, timeSource, this.logger);

            controllerStateMachine.ShutterLimitSwitches = initialShutterState;

            // Build the device controller
            var controller = new DeviceController(
                channel,
                statusFactory,
                controllerStateMachine,
                controllerOptions,
                fakeTransactionProcessor, logger);

            // Assemble the device controller test context
            var context = new DeviceControllerContext
            {
                Channel      = channel,
                Controller   = controller,
                StateMachine = controllerStateMachine,
                Actions      = controllerActions
            };

            // Wire up any Property Changed notifications
            if (propertyChangedAction != null)
            {
                controller.PropertyChanged += propertyChangedAction;
            }

            return(context);
        }
Esempio n. 7
0
    // Start is called before the first frame update
    void Start()
    {
        LocalizationController = new LocalizationController(_localizationData);
        LocalizationController.setLanguage(_defaultLanguageCode);

        _eventList = new Dictionary <EngineEvents, AEvent>();
        _eventList.Add(EngineEvents.ENGINE_CHECKPOINT_REACHED, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_GAME_OVER, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_GAME_INIT, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_GAME_PAUSE, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_GAME_START, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_GAME_RESUME, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_LOAD_FINISH, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_LOAD_START, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_STAGE_COMPLETE, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_CUTSCENE_START, new AEvent());
        _eventList.Add(EngineEvents.ENGINE_CUTSCENE_END, new AEvent());
        stateMachine = new ControllerStateMachine(); // Must be created After events
    }
        public DeviceControllerContext Build()
        {
            // Build the communications channel
            var channel = channelFactory.FromConnectionString(connectionString);

            if (channelShouldBeOpen)
            {
                channel.Open();
            }

            // Build the ControllerStatusFactory
            var statusFactory = new ControllerStatusFactory(timeSource);

            var controllerActions      = new RxControllerActions(channel);
            var controllerStateMachine = new ControllerStateMachine(controllerActions, controllerOptions, timeSource);

            controllerStateMachine.ShutterPosition = initialShutterState;
            if (startInReadyState)
            {
                controllerStateMachine.Initialize(new Ready(controllerStateMachine));
            }

            // Build the device controller
            var controller = new DeviceController(channel, statusFactory, controllerStateMachine, controllerOptions);

            // Assemble the device controller test context
            var context = new DeviceControllerContext
            {
                Channel      = channel,
                Controller   = controller,
                StateMachine = controllerStateMachine,
                Actions      = controllerActions
            };

            // Wire up any Property Changed notifications
            if (propertyChangedAction != null)
            {
                controller.PropertyChanged += propertyChangedAction;
            }

            return(context);
        }
Esempio n. 9
0
 public ReadyState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 10
0
 /// <inheritdoc />
 public RotatingState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 11
0
 public TestableClosingState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 12
0
 /// <inheritdoc />
 public TestableRequestStatusState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 13
0
 /// <inheritdoc />
 public ClosedState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 14
0
 /// <inheritdoc />
 public OfflineState(ControllerStateMachine machine)
     : base(machine)
 {
 }
Esempio n. 15
0
 protected RotatorStateBase(ControllerStateMachine machine)
 {
     Machine = machine;
 }
Esempio n. 16
0
 protected ShutterStateBase(ControllerStateMachine machine)
 {
     Machine = machine;
 }
Esempio n. 17
0
 protected RotatorStateBase(ControllerStateMachine machine)
 {
     Machine = machine;
     Log     = machine.Logger;
 }
Esempio n. 18
0
 /// <inheritdoc />
 public OpenState(ControllerStateMachine machine)
     : base(machine)
 {
 }
    public static IEnumerable<ControllerState> GetStatesRecursive(ControllerStateMachine sm)
    {
        foreach(var i in sm.states.AsEnumerable())
            yield return i;

        foreach(var i in sm.subStateMachines.SelectMany(i => GetStatesRecursive(i)))
            yield return i;
    }