Example #1
0
        public override StepResult ExecuteStep(object parameters)
        {
            // Fusion parameters
            var param = parameters as Parameters;

            // add custom plugin log
            InfinityService.Log.Info($"Fusion Parameter 1 : Serial Com Port = {param?.ComPortNumber}");

            _tokenSource          = new CancellationTokenSource();
            _taskCompletionSource = new TaskCompletionSource <StepResult>();

            // Serial port
            _serialClient = new SerialClient(param?.ComPortNumber);
            _serialClient.OpenCom();
            _serialClient.SerialDataReceived += SerialDataReceived;

            Application.Current.Dispatcher.Invoke(() =>
            {
                // Display Fusion parameters
                _viewModel.SerialPortNumber = param?.ComPortNumber;

                _viewModel.KeyboardData       = "Keyboard ---";
                _viewModel.SerialDataReceived = "Serial Data ---";
            });

            _taskCompletionSource.Task.Wait(_tokenSource.Token);
            return(_taskCompletionSource.Task.Result);
        }