Пример #1
0
        private void Reader_DataReceived(object sender, EndpointDataEventArgs e)
        {
            InterruptType type       = (InterruptType)e.Buffer[0];
            LCTFState     state      = (LCTFState)e.Buffer[1];
            int           wavelength = Convert.ToInt32(BitConverter.ToSingle(e.Buffer, 4));

            Task.Run(() =>
            {
                // _logger.Debug(m => m($"{interrupt.Type}"));
                switch (type)
                {
                case InterruptType.Error:
                    var onError = this.OnError;
                    onError?.Invoke(state, wavelength);
                    break;

                case InterruptType.TuningDone:
                    var onTuningDone = this.OnTuningDone;
                    onTuningDone?.Invoke(wavelength);
                    break;

                case InterruptType.CalibrationDone:
                    var onCalibrationDone = this.OnCalibrationDone;
                    onCalibrationDone?.Invoke();
                    break;

                case InterruptType.StateChanged:
                    var onStateChanged = this.OnStateChanged;
                    onStateChanged?.Invoke(state, wavelength);
                    break;

                case InterruptType.Busy:
                    var onBusy = this.OnBusy;
                    onBusy?.Invoke(state, wavelength);
                    break;

                default:
                    break;
                }
            });
        }
Пример #2
0
 private void LCTFDevice_OnStateChanged(LCTFState status, int tunedWavelength)
 {
     this.CurrentState = status;
 }