forked from amkovkov/GranuSightSoftware2
feat: IlluminatorController
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using GSS2.Core.Hardware;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
using Avalonia.Layout;
|
||||
|
||||
namespace GSS2.UI.Core.ViewModels;
|
||||
|
||||
public partial class IlluminatorControllerViewModel : ViewModelBase
|
||||
{
|
||||
private readonly IlluminatorService _illuminatorService;
|
||||
private readonly ILogger<IlluminatorControllerViewModel> _logger;
|
||||
|
||||
private bool _whiteIntencityChanging = false;
|
||||
private bool _uv365IntencityChanging = false;
|
||||
private bool _uv254IntencityChanging = false;
|
||||
|
||||
[ObservableProperty] private double _whiteIntencity;
|
||||
[ObservableProperty] private double _uv365Intencity;
|
||||
[ObservableProperty] private double _uv254Intencity;
|
||||
[ObservableProperty] private bool _enabled;
|
||||
[ObservableProperty] Orientation _orientation;
|
||||
|
||||
public IlluminatorControllerViewModel(IlluminatorService illuminatorService, ILogger<IlluminatorControllerViewModel> logger)
|
||||
{
|
||||
_illuminatorService = illuminatorService;
|
||||
_logger = logger;
|
||||
|
||||
WhiteIntencity = 0;
|
||||
Uv365Intencity = 0;
|
||||
Uv254Intencity = 0;
|
||||
Orientation = Orientation.Horizontal;
|
||||
Enabled = false;
|
||||
_logger.LogInformation("Initialized");
|
||||
}
|
||||
|
||||
partial void OnWhiteIntencityChanged(double value)
|
||||
{
|
||||
if (_whiteIntencityChanging)
|
||||
return;
|
||||
_whiteIntencityChanging = true;
|
||||
_illuminatorService.SetIntensity(white: value);
|
||||
_whiteIntencityChanging = false;
|
||||
}
|
||||
partial void OnUv365IntencityChanged(double value)
|
||||
{
|
||||
if (_uv365IntencityChanging)
|
||||
return;
|
||||
_uv365IntencityChanging = true;
|
||||
_illuminatorService.SetIntensity(uv365: value);
|
||||
_uv365IntencityChanging = false;
|
||||
}
|
||||
partial void OnUv254IntencityChanged(double value)
|
||||
{
|
||||
if (_uv254IntencityChanging)
|
||||
return;
|
||||
_uv254IntencityChanging = true;
|
||||
_illuminatorService.SetIntensity(uv254: value);
|
||||
_uv254IntencityChanging = false;
|
||||
}
|
||||
|
||||
partial void OnEnabledChanged(bool value)
|
||||
{
|
||||
if (value)
|
||||
_illuminatorService.TurnOn();
|
||||
else
|
||||
_illuminatorService.TurnOff();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user