Example #1
0
        public void CommandsWithFunctions()
        {
            var tv = new ExternalDisplay();
            var measurementnDevice = new LaboratoryDevice();

            var deviceOnCommand = new Action <Device>(d => d.TurnOn());

            var tvOnCommand = new Action(() => deviceOnCommand(tv));
            var mdOnCommand = new Action(() => deviceOnCommand(measurementnDevice));

            var commands = new List <Action> {
                tvOnCommand, mdOnCommand
            };

            foreach (var cmd in commands)
            {
                cmd();
            }
        }
Example #2
0
        public void Test()
        {
            var tv = new ExternalDisplay();
            var measurementnDevice = new LaboratoryDevice();

            var tvOnCommand       = new DeviceOnCommand(tv);
            var deviceOnCommand   = new DeviceOnCommand(measurementnDevice);
            var programOneCommand = new StartMesurementProgramCommand(measurementnDevice, 1);
            var programTwoCommand = new StartMesurementProgramCommand(measurementnDevice, 2);
            var deviceOffCommand  = new DeviceOffCommand(measurementnDevice);

            var commandProcessor = new CommandExecutor();

            commandProcessor.AddCommand(tvOnCommand);
            commandProcessor.AddCommand(deviceOnCommand);
            commandProcessor.AddCommand(programOneCommand);
            commandProcessor.AddCommand(programTwoCommand);
            commandProcessor.AddCommand(deviceOffCommand);

            while (commandProcessor.HasCommands)
            {
                Thread.Sleep(10);
            }
        }
Example #3
0
 public StartMesurementProgramCommand(LaboratoryDevice device, int protocolId)
 {
     _device            = device;
     _protocolToExecute = protocolId;
 }