ArmbandInterface.h 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include "stdafx.h"
  3. extern "C" {
  4. #include "MotorHeader/BodyActuator.h"
  5. }
  6. #include <time.h>
  7. #include <stdio.h>
  8. #define DllExport extern "C" __declspec( dllexport )
  9. /*
  10. This is the header file of a static class acting as a interface for the BodActuator dll, which is plain C code and can't be called directly from C# (managed) code.
  11. Therefore this class will encapsulate all memory management necessary to instantiate and use an Object of the BodyActuator type, aswell as provide all modyfying methods to external callers.
  12. Basically, this class acts as a single static BodyActuator instance towards outside callers, and can be used from within managed (specifically C#) code.
  13. (side note: the use of the terms 'function' and 'method' might be a bit messy here...)
  14. */
  15. DllExport int setupArmband();
  16. DllExport void startVibrate(int tactor, float intensity);
  17. DllExport void stopVibrate(int tactor);
  18. DllExport void actuate100(int tactor, double intensity, int duration);
  19. DllExport void actuate66(int tactor, int duration);
  20. DllExport void actuate33(int tactor, int duration);
  21. DllExport void deleteArmband();
  22. class ArmbandInterface
  23. {
  24. public:
  25. /*
  26. public initialization method for external calls, loading the BodyActuator dll and linking its methods to the previously defined function
  27. handles, aswell as creating and initializing the single static BodyActuator object afterwards (allocates memory to that pointer without
  28. releasing it, as the pointer is still needed outside of this method -> mus be freed later)
  29. return value may be used for debugging purposes and holds no other purpose
  30. */
  31. __declspec(dllexport) int __cdecl setupArmband();
  32. /*
  33. resets the instance of BodyActuator to a clean state
  34. */
  35. __declspec(dllexport) void __cdecl clearArmband();
  36. /*
  37. destructor method destroying the instance of BodyActuator and freeing the memory held by the instance pointer
  38. */
  39. __declspec(dllexport) void __cdecl deleteArmband();
  40. /*
  41. start vibrating the specified tactor (number from 0 to 7) at the specified intensity until it is stopped (explicitly or implicitly)
  42. provides access to the DLLs BodyActuator_startActuation method and handles type conversion to C types required by the DLL which are not available in C#
  43. */
  44. __declspec(dllexport) void __cdecl startVibrate(int tactor, double intensity);
  45. /*
  46. explicitly stop actuating the specified tactor (number from 0 to 7)
  47. provides access to the DLLs BodyActuator_stopActuation method and handles type conversion to C types required by the DLL which are not available in C#
  48. */
  49. __declspec(dllexport) void __cdecl stopVibrate(int tactor);
  50. /*
  51. make the specified tactor (number from 0 to 7) actuate at intensity 1.0 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
  52. provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
  53. */
  54. __declspec(dllexport) void __cdecl actuate100(int tactor, double intensity, int duration);
  55. /*
  56. make the specified tactor (number from 0 to 7) actuate at intensity 0.66 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
  57. provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
  58. */
  59. __declspec(dllexport) void __cdecl actuate66(int tactor, int duration);
  60. /*
  61. make the specified tactor (number from 0 to 7) actuate at intensity 0.33 (default: between 0.0 and 1.0, but range may be set using the setIntensityRange function) for the specified duration (number of milliseconds) ,or until it is stopped
  62. provides access to the DLLs BodyActuator_actuate method and handles type conversion to C types required by the DLL which are not available in C#
  63. */
  64. __declspec(dllexport) void __cdecl actuate33(int tactor, int duration);
  65. /*
  66. sets the frequency of the specified tactor to a new value (unit unknown, possibly Hz...)
  67. */
  68. __declspec(dllexport) void __cdecl setFrequency(int tactor, int frequency);
  69. /*
  70. sets a new intensity range for a single actuator to make different actuators react differently even when receiving an actuation command with the same intensity (e.g. to to compensate differing tactile sensitivity on different parts of the human body)
  71. */
  72. __declspec(dllexport) void __cdecl setIntensityRange(int tactor, double minIntensity, double maxIntensity);
  73. //private:
  74. /*
  75. internal method to initialize the BodyActuator object (and handle the memory allocation involved)
  76. */
  77. int setupMotors();
  78. };