iocommander input and virtual input

This commit is contained in:
meelstorm
2025-07-21 12:07:33 +02:00
parent cd70088d9a
commit e761b24c95
21 changed files with 418 additions and 21 deletions

View File

@@ -12,28 +12,32 @@ namespace VisionBuilder.UI.IOCommander.Modules;
public class IOCommanderModule:IVisionBuilderModule
{
private readonly IOCommanderSettings _settings;
private readonly IIOCommanderFactory _factory;
private readonly IIOCommanderDebugViewService _debugViewService;
private IOCommander? _ioCommander;
public IOCommanderModule(IOCommanderSettings settings, IIOCommanderDebugViewService debugViewService)
private IIOCommander? _ioCommander;
public IOCommanderModule(IOCommanderSettings settings, IIOCommanderFactory factory, IIOCommanderDebugViewService debugViewService)
{
_settings = settings;
_factory = factory;
_debugViewService = debugViewService;
}
public void InitializeModule()
{
if (!_settings.EmulationMode)
{
_ioCommander = new IOCommander(_settings.Port);
_ioCommander.OnPinChanged += OnPinChanged;
}
_ioCommander = _factory.Create();
_ioCommander.OnPinChanged += OnPinChanged;
if(_settings.ShowDebugView)_debugViewService.ShowDebugView();
if (_settings.ShowDebugView)_debugViewService.ShowDebugView();
}
ConcurrentDictionary<int, bool> _pinStates = new ConcurrentDictionary<int, bool>();
public event Action<int, bool>? OnPinChangedEvent
{
add => _ioCommander!.OnPinChanged += value;
remove => _ioCommander!.OnPinChanged -= value;
}
private void OnPinChanged(int arg1, bool arg2)
{
_pinStates.TryAdd(arg1, arg2);