Armband.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Threading;
  4. namespace SketchAssistantWPF
  5. {
  6. internal class Armband
  7. {
  8. [StructLayout(LayoutKind.Sequential)]
  9. public class BodyActuator
  10. {
  11. enum BodyActuator_Type
  12. {
  13. BODYACTUATOR_TYPE_NONE,
  14. BODYACTUATOR_TYPE_EAI,
  15. BODYACTUATOR_TYPE_PIEZO,
  16. BODYACTUATOR_TYPE_ERM,
  17. BODYACTUATOR_TYPE_EMS
  18. };
  19. bool valid;
  20. ushort actuatorCount;
  21. BodyActuator_Type type;
  22. ArduinoHub arduinoHub;
  23. EAIHub eaiHub;
  24. }
  25. [StructLayout(LayoutKind.Sequential)]
  26. public class EAIHub
  27. {
  28. bool valid;
  29. pthread_mutex_t mutex; //TODO fix this
  30. Thread thread;
  31. Actuator* actuators; //TODO
  32. uint tactorType;
  33. uint modulation;
  34. int deviceID;
  35. }
  36. [StructLayout(LayoutKind.Sequential)]
  37. public class ArduinoHub
  38. {
  39. enum ArduinoHub_Type
  40. {
  41. ARDUINOHUB_TYPE_PIEZO = 'P',
  42. ARDUINOHUB_TYPE_ERM = 'E',
  43. ARDUINOHUB_TYPE_EMS = 'M'
  44. }
  45. bool valid;
  46. pthread_mutex_t mutex; //TODO fix this
  47. Thread thread;
  48. ArduinoHub_Type arduinoType;
  49. Serial* serial;
  50. Actuator* actuators;
  51. }
  52. [DllImport("BodyActuator.dll", EntryPoint = "BodyActuator_actuate")]
  53. static extern void pushForward(ref BodyActuator self, byte tactor, double intensity, ulong duration);
  54. internal void pushForward()
  55. {
  56. Console.WriteLine("FORWARD_PUSH");
  57. }
  58. internal void pushBackward()
  59. {
  60. Console.WriteLine("BACKWARD_PUSH");
  61. }
  62. }
  63. }