internal void HandleEvent(libmyo.EventType type, DateTime timestamp, IntPtr evt) { bool outputEmgData = false; switch (type) { case libmyo.EventType.Connected: if (Connected != null) { Connected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Disconnected: if (Disconnected != null) { Disconnected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.ArmSynced: if (ArmSynced != null) { Arm arm = (Arm)libmyo.event_get_arm(evt); XDirection xDirection = (XDirection)libmyo.event_get_x_direction(evt); ArmSynced(this, new ArmSyncedEventArgs(this, timestamp, arm, xDirection)); } break; case libmyo.EventType.ArmUnsynced: if (ArmUnsynced != null) { ArmUnsynced(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Orientation: if (AccelerometerData != null) { float x = libmyo.event_get_accelerometer(evt, 0); float y = libmyo.event_get_accelerometer(evt, 1); float z = libmyo.event_get_accelerometer(evt, 2); var accelerometer = new Vector3(x, y, z); AccelerometerData(this, new AccelerometerDataEventArgs(this, timestamp, accelerometer)); } if (GyroscopeData != null) { float x = libmyo.event_get_gyroscope(evt, 0); float y = libmyo.event_get_gyroscope(evt, 1); float z = libmyo.event_get_gyroscope(evt, 2); var gyroscope = new Vector3(x, y, z); GyroscopeData(this, new GyroscopeDataEventArgs(this, timestamp, gyroscope)); } if (OrientationData != null) { float x = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.X); float y = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Y); float z = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Z); float w = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.W); var orientation = new Quaternion(x, y, z, w); OrientationData(this, new OrientationDataEventArgs(this, timestamp, orientation)); } break; case libmyo.EventType.Pose: if (PoseChange != null) { var pose = (Pose)libmyo.event_get_pose(evt); PoseChange(this, new PoseEventArgs(this, timestamp, pose)); } break; case libmyo.EventType.Rssi: if (Rssi != null) { var rssi = libmyo.event_get_rssi(evt); Rssi(this, new RssiEventArgs(this, timestamp, rssi)); } break; case libmyo.EventType.Emg: outputEmgData = true; SetEmgData(evt, timestamp); break; case libmyo.EventType.Unlocked: if (Unlocked != null) { Unlocked(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Locked: if (Locked != null) { Locked(this, new MyoEventArgs(this, timestamp)); } break; } if (!outputEmgData && streamEmg) { SetEmgData(evt, timestamp); } }
internal void HandleEvent(libmyo.EventType type, DateTime timestamp, IntPtr evt) { switch (type) { case libmyo.EventType.Connected: if (Connected != null) { Connected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Disconnected: if (Disconnected != null) { Disconnected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Orientation: if (AccelerometerData != null) { float x = libmyo.event_get_accelerometer(evt, 0); float y = libmyo.event_get_accelerometer(evt, 1); float z = libmyo.event_get_accelerometer(evt, 2); var accelerometer = new Vector3(x, y, z); AccelerometerData(this, new AccelerometerDataEventArgs(this, timestamp, accelerometer)); } if (GyroscopeData != null) { float x = libmyo.event_get_gyroscope(evt, 0); float y = libmyo.event_get_gyroscope(evt, 1); float z = libmyo.event_get_gyroscope(evt, 2); var gyroscope = new Vector3(x, y, z); GyroscopeData(this, new GyroscopeDataEventArgs(this, timestamp, gyroscope)); } if (OrientationData != null) { float x = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.X); float y = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Y); float z = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Z); float w = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.W); var orientation = new Quaternion(x, y, z, w); OrientationData(this, new OrientationDataEventArgs(this, timestamp, orientation)); } break; case libmyo.EventType.Pose: if (PoseChange != null) { var pose = (Pose)libmyo.event_get_pose(evt); PoseChange(this, new PoseEventArgs(this, timestamp, pose)); } break; case libmyo.EventType.Rssi: if (Rssi != null) { var rssi = libmyo.event_get_rssi(evt); Rssi(this, new RssiEventArgs(this, timestamp, rssi)); } break; } }
internal void HandleEvent(libmyo.EventType type, DateTime timestamp, IntPtr evt) { switch (type) { case libmyo.EventType.Connected: if (Connected != null) { Connected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Disconnected: if (Disconnected != null) { Disconnected(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.ArmSynced: if (ArmSynced != null) { Arm arm = (Arm)libmyo.event_get_arm(evt); XDirection xDirection = (XDirection)libmyo.event_get_x_direction(evt); ArmSynced(this, new ArmSyncedEventArgs(this, timestamp, arm, xDirection)); } break; case libmyo.EventType.ArmUnsynced: if (ArmUnsynced != null) { ArmUnsynced(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Orientation: if (AccelerometerData != null) { float x = libmyo.event_get_accelerometer(evt, 0); float y = libmyo.event_get_accelerometer(evt, 1); float z = libmyo.event_get_accelerometer(evt, 2); var accelerometer = new Vector3(x, y, z); AccelerometerData(this, new AccelerometerDataEventArgs(this, timestamp, accelerometer)); } if (GyroscopeData != null) { float x = libmyo.event_get_gyroscope(evt, 0); float y = libmyo.event_get_gyroscope(evt, 1); float z = libmyo.event_get_gyroscope(evt, 2); var gyroscope = new Vector3(x, y, z); GyroscopeData(this, new GyroscopeDataEventArgs(this, timestamp, gyroscope)); } if (OrientationData != null) { float x = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.X); float y = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Y); float z = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.Z); float w = libmyo.event_get_orientation(evt, libmyo.OrientationIndex.W); var orientation = new Quaternion(x, y, z, w); OrientationData(this, new OrientationDataEventArgs(this, timestamp, orientation)); } break; case libmyo.EventType.Pose: if (PoseChange != null) { var pose = (Pose)libmyo.event_get_pose(evt); PoseChange(this, new PoseEventArgs(this, timestamp, pose)); } break; case libmyo.EventType.Rssi: if (Rssi != null) { var rssi = libmyo.event_get_rssi(evt); Rssi(this, new RssiEventArgs(this, timestamp, rssi)); } break; case libmyo.EventType.Unlocked: if (Unlocked != null) { Unlocked(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Locked: if (Locked != null) { Locked(this, new MyoEventArgs(this, timestamp)); } break; case libmyo.EventType.Emg: Dictionary<int, sbyte> emgData = new Dictionary<int, sbyte>(); for(int i = 0; i < 8;i++) { emgData[i] = libmyo.event_get_emg(evt, (uint)i); } if (Emg != null) { Emg(this, new EmgEventArgs(this, timestamp, emgData)); } break; } }
public static extern Result training_collect_data(IntPtr dataset, PoseType pose, libmyo.TrainingCollectStatus callback, IntPtr userData, IntPtr error);