Пример #1
0
 public override void Load()
 {
     try
     {
         IsEnabled           = true;
         PositionScaleFactor = 0.1;
         _lastTimeStamp      = 0;
         _velocityVec        = new Vector3D(0, 0, 0);
         _positionVec        = new Vector3D(0, 0, 0);
         RawPosition         = _positionVec;
         _device             = SensorDevices.GetFirstAvailable(FilterEnum.FindUSB);
         _keepCallbackAlive  = new ThreeSpaceInterop.DataCallbackDelegate(dataCallbackFunc);
         // keepCallbackAlive is to prevent crash from garbage collection not being able to track into the unmanged code of ThreeSpace_API.dll
         ThreeSpaceInterop.SetNewDataCallBack(_device.DeviceId, _keepCallbackAlive);
         StreamCommandSlots slots = new StreamCommandSlots(StreamCommand.TSS_NULL);
         slots.Slot0 = StreamCommand.TSS_GET_TARED_ORIENTATION_AS_QUATERNION;
         slots.Slot1 = StreamCommand.TSS_GET_CORRECTED_ACCELEROMETER_VECTOR;
         ThreeSpaceInterop.SetStreamingTiming(_device.DeviceId, 0, 0xffffffff, 0, ref _device.TimeStamp);
         ThreeSpaceInterop.SetStreamingSlots(_device.DeviceId, ref slots, ref _device.TimeStamp);
         ThreeSpaceInterop.StartStreaming(_device.DeviceId, ref _device.TimeStamp);
         Calibrate();
     }
     catch (Exception exc)
     {
         IsEnabled = false;
     }
 }
Пример #2
0
 public override void Load()
 {
     try
     {
         IsEnabled = true;
         PositionScaleFactor = 0.1;
         _lastTimeStamp = 0;
         _velocityVec = new Vector3D(0, 0, 0);
         _positionVec = new Vector3D(0, 0, 0);
         RawPosition = _positionVec;
         _device = SensorDevices.GetFirstAvailable(FilterEnum.FindUSB);
         _keepCallbackAlive = new ThreeSpaceInterop.DataCallbackDelegate(dataCallbackFunc);
         // keepCallbackAlive is to prevent crash from garbage collection not being able to track into the unmanged code of ThreeSpace_API.dll
         ThreeSpaceInterop.SetNewDataCallBack(_device.DeviceId, _keepCallbackAlive);
         StreamCommandSlots slots = new StreamCommandSlots(StreamCommand.TSS_NULL);
         slots.Slot0 = StreamCommand.TSS_GET_TARED_ORIENTATION_AS_QUATERNION;
         slots.Slot1 = StreamCommand.TSS_GET_CORRECTED_ACCELEROMETER_VECTOR;
         ThreeSpaceInterop.SetStreamingTiming(_device.DeviceId, 0, 0xffffffff, 0, ref _device.TimeStamp);
         ThreeSpaceInterop.SetStreamingSlots(_device.DeviceId, ref slots, ref _device.TimeStamp);
         ThreeSpaceInterop.StartStreaming(_device.DeviceId, ref _device.TimeStamp);
         Calibrate();
     }
     catch (Exception exc)
     {
         IsEnabled = false;
     }
 }