public bool ProcessCommand(Device device, double value)
 {
     if (device is AnalogInput || device is DigitalInput)
     {
         return(false);
     }
     if (device is AnalogOutput)
     {
         if (validator.Validate(device, value))
         {
             var analogCommand = new AnalogCommand()
             {
                 Address = device.Address, Value = value
             };
             commandExecutor.PutCommand(analogCommand);
         }
         else
         {
             notificationService.ShowNotification("Error", "Value out of range!", Notifications.Wpf.NotificationType.Error);
             logger.Warning($"Value {value} out of range for device at address {device.TypeOfRegister}{device.Address}");
         }
         return(true);
     }
     else
     {
         var digitalCommand = new DigitalCommand()
         {
             Address = device.Address, Value = (byte)value
         };
         commandExecutor.PutCommand(digitalCommand);
         return(true);
     }
 }
Exemplo n.º 2
0
        public void CommandDigitals(DigitalCommand command)
        {
            var all    = repo.GetAllDeviceBindings();
            var result = all.SingleOrDefault(x => x.Address == command.Address);

            if (result != null && result is DigitalOutput)
            {
                repo.Update(result as DigitalOutput, command.Value);
            }
        }
Exemplo n.º 3
0
 public void PutCommand(DigitalCommand command) => CommandManager.GetInstance().PutCommand(command);