Browse Source

testing pInvoke

Rumei 5 years ago
parent
commit
1f1e0efe2d

+ 52 - 2
SketchAssistant/SketchAssistantWPF/Armband.cs

@@ -1,12 +1,62 @@
 using System;
 using System.Runtime.InteropServices;
+using System.Threading;
 
 namespace SketchAssistantWPF
 {
     internal class Armband
     {
-        //[DllImport("BodyActuator.dll")]
-        //static extern void pushForward(BodyActuator* self, uint8_t tactor, double intensity, uint64_t duration);
+        [StructLayout(LayoutKind.Sequential)]
+        public class BodyActuator
+        {
+            enum BodyActuator_Type
+            {
+                BODYACTUATOR_TYPE_NONE,
+                BODYACTUATOR_TYPE_EAI,
+                BODYACTUATOR_TYPE_PIEZO,
+                BODYACTUATOR_TYPE_ERM,
+                BODYACTUATOR_TYPE_EMS
+            };
+            bool valid;
+            ushort actuatorCount;
+            BodyActuator_Type type;
+            ArduinoHub arduinoHub;
+            EAIHub eaiHub;
+        }
+
+
+        [StructLayout(LayoutKind.Sequential)]
+        public class EAIHub
+        {
+            bool valid;
+            pthread_mutex_t mutex; //TODO fix this
+            Thread thread;
+            Actuator* actuators; //TODO
+            uint tactorType;
+            uint modulation;
+            int deviceID;
+        }
+
+        [StructLayout(LayoutKind.Sequential)]
+        public class ArduinoHub
+        {
+            enum ArduinoHub_Type
+            { 
+                ARDUINOHUB_TYPE_PIEZO = 'P',
+                ARDUINOHUB_TYPE_ERM = 'E',
+                ARDUINOHUB_TYPE_EMS = 'M'
+            }
+            bool valid;
+            pthread_mutex_t mutex; //TODO fix this
+            Thread thread;
+            ArduinoHub_Type arduinoType;
+            Serial* serial;
+            Actuator* actuators;
+        }
+        
+        [DllImport("BodyActuator.dll", EntryPoint = "BodyActuator_actuate")]
+        static extern void pushForward(ref BodyActuator self, byte tactor, double intensity, ulong duration);
+
         internal void pushForward()
         {
             Console.WriteLine("FORWARD_PUSH");

+ 30 - 2
SketchAssistant/SketchAssistantWPF/SketchAssistantWPF.csproj

@@ -164,11 +164,39 @@
     </BootstrapperPackage>
   </ItemGroup>
   <ItemGroup>
+    <Content Include="DLLs\ArduinoHub.h">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="BodyActuator.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\BodyActuator.h">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\EAIHub.h">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\eai_common.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\eai_serial.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\eai_winbluetooth.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\eai_winusb.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\TActionManager.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="DLLs\TactorInterface.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
     <Content Include="NPTrackingTools.dll">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="TActionManager.dll" />
-    <Content Include="TactorInterface.dll" />
   </ItemGroup>
   <ItemGroup>
     <WCFMetadata Include="Connected Services\" />