Пример #1
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);
        }
        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);
        }