iocommander input and virtual input
This commit is contained in:
@@ -14,22 +14,54 @@ public class IOCommanderCameraModule: IVisionBuilderModule
|
||||
private readonly IOCommanderCameraSettings _cameraSettings;
|
||||
private readonly IRecognitionControl _recognitionControl;
|
||||
private readonly MainWindowVM _mainWindowVm;
|
||||
private readonly SingleCameraVM _cameraVm;
|
||||
|
||||
public IOCommanderCameraModule(IOCommanderModule mainModule, IOCommanderSettings settings, IOCommanderCameraSettings cameraSettings, IRecognitionControl recognitionControl, MainWindowVM mainWindowVm)
|
||||
public IOCommanderCameraModule(IOCommanderModule mainModule, IOCommanderSettings settings, IOCommanderCameraSettings cameraSettings, IRecognitionControl recognitionControl, MainWindowVM mainWindowVm, SingleCameraVM cameraVm)
|
||||
{
|
||||
_mainModule = mainModule;
|
||||
_settings = settings;
|
||||
_cameraSettings = cameraSettings;
|
||||
_recognitionControl = recognitionControl;
|
||||
_mainWindowVm = mainWindowVm;
|
||||
_cameraVm = cameraVm;
|
||||
|
||||
_recognitionControl.ImageProcessed += _recognitionControl_ImageProcessed;
|
||||
_recognitionControl.SessionStarted += _recognitionControl_SessionStarted;
|
||||
_recognitionControl.SessionEnded += _recognitionControl_SessionEnded;
|
||||
mainModule.OnPinChangedEvent += MainModule_OnPinChangedEvent;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ProcessCommand(EGPIOCommand command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case EGPIOCommand.Start:
|
||||
if(_cameraVm.StartCommand.CanExecute(null))
|
||||
{
|
||||
_cameraVm.StartCommand.Execute(null);
|
||||
}
|
||||
break;
|
||||
case EGPIOCommand.Stop:
|
||||
if(_cameraVm.StopCommand.CanExecute(null))
|
||||
{
|
||||
_cameraVm.StopCommand.Execute(null);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(command), command, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void MainModule_OnPinChangedEvent(int arg1, bool arg2)
|
||||
{
|
||||
var @event = _cameraSettings.GPIOCommands.FirstOrDefault(x => x.Pin == arg1 && x.OnHigh == arg2);
|
||||
if (@event != null)
|
||||
{
|
||||
ProcessCommand(@event.Command);
|
||||
}
|
||||
}
|
||||
|
||||
private void EmitEvent(EProcessingEvent @event)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user