public async Task Invoke(DataModel model, PipelineDelegate <DataModel> next) { if (model.NetworkTask != null && Math.Abs(model.NetworkTask.Frequency - model.RadioModel.Frequency) < 0.001) { OnDataAvailable?.Invoke(this, new DataEventArgs <NetworkTaskData>(model.NetworkTask)); } await next.Invoke(model); }
private MediaRecorder(IJSRuntime jsRuntime, JsObjectRef jsObjectRef, IMediaStream stream, MediaRecorderOptions options) : base(jsRuntime, jsObjectRef) { AddNativeEventListenerForObjectRef("dataavailable", (s, e) => OnDataAvailable?.Invoke(s, e), BlobEvent.Create); AddNativeEventListenerForObjectRef("error", (s, e) => OnError?.Invoke(s, e), DOMException.Create); AddNativeEventListener("pause", (s, e) => OnPause?.Invoke(s, e)); AddNativeEventListener("resume", (s, e) => OnResume?.Invoke(s, e)); AddNativeEventListener("start", (s, e) => OnStart?.Invoke(s, e)); AddNativeEventListener("stop", (s, e) => OnStop?.Invoke(s, e)); }
private void PerformContinuousReads() { while (IsRunning) { var sensorData = RetrieveSensorData(); if (!IsRunning) { continue; } OnDataAvailable?.Invoke(this, sensorData); Thread.Sleep(200); } }
public Microphone(WaveFormat format, IWaveIn waveIn) { _audioListener = waveIn; _audioListener.WaveFormat = format; _audioListener.DataAvailable += (obj, args) => { var bytes = new byte[args.BytesRecorded]; Array.Copy(args.Buffer, bytes, args.BytesRecorded); OnDataAvailable?.Invoke(this, new ByteDataEventArgs { Data = bytes }); }; }
/// <summary> /// Performs the continuous reads of the sensor. /// This method represents the body of the worker. /// </summary> private void PerformContinuousReads() { while (_isRunning) { try { // Start to comunicate with sensor // Inform sensor that must finish last execution and put it's state in idle DataPin.PinMode = GpioPinDriveMode.Output; // Send request to trasmission from board to sensor DataPin.Write(GpioPinValue.Low); _systemTiming.SleepMicroseconds(5000); DataPin.Write(GpioPinValue.High); _systemTiming.SleepMicroseconds(30); DataPin.Write(GpioPinValue.Low); // Acquire measure var sensorData = RetrieveSensorData(); if (sensorData != null) { OnDataAvailable?.Invoke(this, sensorData); } DataPin.PinMode = GpioPinDriveMode.Output; DataPin.Write(GpioPinValue.High); } catch (Exception ex) { ex.Error(nameof(TemperatureSensorAM2302), ex.Message); } // Waiting for sensor init Thread.Sleep(ReadInterval); } }