public IObservable <TResult> Generate() { var source = Observable.Create <ONIManagedFrame <TData> >(async observer => { var cd = await ONIContextManager.ReserveOpenContextAsync(DeviceAddress.HardwareSlot); var in_table = cd.Context.DeviceTable.TryGetValue((uint)DeviceAddress.Address, out var device); if (!in_table || device.ID != (int)ID) { throw new WorkflowException("Selected device address is invalid."); } EventHandler <FrameReceivedEventArgs> frame_received = (sender, e) => { if (e.Frame.DeviceAddress == DeviceAddress.Address) { ONIManagedFrame <TData> frame = new ONIManagedFrame <TData>(e.Frame); observer.OnNext(frame); } }; cd.Context.FrameReceived += frame_received; return(Disposable.Create(() => { cd.Context.FrameReceived -= frame_received; cd.Dispose(); })); }); ulong frameOffset = FrameClockOffset; return(Process(source, frameOffset)); }
public RawDataFrame(ONIManagedFrame <ushort> frame, ulong frameOffset) : base(frame, frameOffset) { var data = new ArraySegment <ushort>(frame.Sample, 4, frame.Sample.Length - 4); Data = Mat.FromArray(data.ToArray(), frame.Sample.Length - 4, 1, Depth.U16, 1); }
public HeadstagePortControlFrame(ONIManagedFrame <ushort> frame, ulong frameOffset) : base(frame, frameOffset) { Lock = (frame.Sample[4] & 0x0001) == 1; Pass = (frame.Sample[4] & 0x0002) == 2; Code = (frame.Sample[4] & 0x0004) == 4 ? (frame.Sample[4] & 0xFF00) >> 8 : 0; Message = CodeToString(Code); }
public LoadTestingDataFrame(ONIManagedFrame<ushort> frame, ulong frameOffset) : base(frame, frameOffset) { Delta = ((ulong)frame.Sample[4] << 48) | ((ulong)frame.Sample[5] << 32) | ((ulong)frame.Sample[6] << 16) | ((ulong)frame.Sample[7] << 0); var data = new ushort[frame.Sample.Length - 8]; Array.Copy(frame.Sample, 8, data, 0, data.Length); Payload = Mat.FromArray(data, data.Length, 1, Depth.U16, 1); }
public BNO055DataFrame(ONIManagedFrame <ushort> frame, ulong frameOffset) : base(frame, frameOffset) { ushort[] sample = frame.Sample; // Convert data packet (output format is hard coded right now) Euler = GetEuler(sample, 4); Quaternion = GetQuat(sample, 7); LinearAcceleration = GetAcceleration(sample, 11); GravityVector = GetAcceleration(sample, 14); Temperature = (byte)(sample[17] & 0x00FF); // 1°C = 1 LSB Calibration = (byte)((sample[17] & 0xFF00) >> 8); // Full calibration byte SystemCalibrated = (sample[17] & 0x0300) > 0; // 3 = calibrated, 0 = not calibrated AccelerometerCalibrated = (sample[17] & 0x0C00) > 0; GyroscopeCalibrated = (sample[17] & 0x3000) > 0; MagnitometerCalibrated = (sample[17] & 0xC000) > 0; }