LocalArmbandInterface.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Runtime.InteropServices;
  7. namespace SketchAssistantWPF
  8. {
  9. /// <summary>
  10. /// interface providing access to the vibrotactile armband
  11. /// accessing the BodyActuator.dll C library via the StaticLibMotors.dll c++ library
  12. /// </summary>
  13. public static class LocalArmbandInterface
  14. {
  15. /// <summary>
  16. /// initializes the armband (and binds the C dll)
  17. /// must be called before calling any other of the methods of this class
  18. /// explicitly allocates memory and therefore must only be called once and must be followed by a call to DestroyArmband eventually
  19. /// </summary>
  20. /// <returns>an integer purely for debugging purposes, -1 means no unexpected behaviour occured and the initialization was successful</returns>
  21. [DllImport (@"../Debug/StaticLibMotors.dll", EntryPoint = "?setupArmband@ArmbandInterface@@QAAHXZ",
  22. CallingConvention = CallingConvention.Cdecl)]
  23. public static extern int SetupArmband();
  24. /// <summary>
  25. /// destroys the armband instance created by SetupArmband (thus freeing its allocated memory)
  26. /// </summary>
  27. /// <returns></returns>
  28. [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?destroyArmband@ArmbandInterface@@QAAHXZ",
  29. CallingConvention = CallingConvention.Cdecl)]
  30. public static extern int DestroyArmband();
  31. /// <summary>
  32. /// starts actuation of the specified tactor (motor) at the specified intensity (until it is stopped)
  33. /// </summary>
  34. /// <param name="motorNumber">integer from 0 to 7 specifying the number of the tactor to actuate</param>
  35. /// <param name="intensity">intensity, ranging from 0.0 to 1.0 by default</param>
  36. [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?startVibrate@ArmbandInterface@@QAAXHM@Z",
  37. CallingConvention = CallingConvention.Cdecl)]
  38. public static extern void StartVibrate(int motorNumber, double intensity);
  39. /// <summary>
  40. /// stop actuation of the specified tactor (motor)
  41. /// </summary>
  42. /// <param name="motorNumber">integer from 0 to 7 specifying the number of the tactor to stop</param>
  43. [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?stopVibrate@ArmbandInterface@@QAAXH@Z",
  44. CallingConvention = CallingConvention.Cdecl)]
  45. public static extern void StopVibration(int motorNumber);
  46. /// <summary>
  47. /// starts actuation of the specified tactor (motor) at the specified intensity for a specified amount of time
  48. /// </summary>
  49. /// <param name="tactor">integer from 0 to 7 specifying the number of the tactor to actuate</param>
  50. /// <param name="intensity">intensity, ranging from 0.0 to 1.0 by default</param>
  51. /// <param name="duration">number of millisecons to actuate the tactor for</param>
  52. [DllImport(@"../Debug/StaticLibMotors.dll", EntryPoint = "?actuate100@ArmbandInterface@@QAAXHNH@Z",
  53. CallingConvention = CallingConvention.Cdecl)]
  54. public static extern void Actuate(int tactor, double intensity, int duration);
  55. }
  56. }