using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace MotorTest { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); IntPtr actuator = EAIWrapper.BodyActuator_new(); Console.WriteLine(actuator.ToString()); EAIWrapper.BodyActuator_init(actuator, ActuatorType.EAI, "COM5" , 16); EAIWrapper.BodyActuator_startActuation(actuator, 0 , (float)0.3); System.Threading.Thread.Sleep(1000); EAIWrapper.BodyActuator_stopActuation(actuator, 0); } } class EAIWrapper { [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr BodyActuator_new(); [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void BodyActuator_init(IntPtr self, ActuatorType type, [MarshalAs(UnmanagedType.LPStr)]string port, int actuatorCount); [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void BodyActuator_startActuation(IntPtr self, int tactor, float intensity); [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void BodyActuator_actuate(IntPtr self, int tactor, float intensity, int duration); [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void BodyActuator_stopActuation(IntPtr self, int tactor); [DllImport("BodyActuator.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void BodyActuator_setFrequency(IntPtr self, int tactor, int frequency); } enum ActuatorType { NONE = 0, EAI, PIEZO, ERM, EMS } }