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);
     }
 }
Example #2
0
        public void CommandAnalogs(AnalogCommand command)
        {
            var all    = repo.GetAllDeviceBindings();
            var result = all.SingleOrDefault(x => x.Address == command.Address);

            if (result != null && result is AnalogOutput)
            {
                repo.Update(result as AnalogOutput, command.Value);
            }
        }
Example #3
0
 public void PutCommand(AnalogCommand command) => CommandManager.GetInstance().PutCommand(command);