Browse Source

implemented ArmbandInterface

Dennymany 5 years ago
parent
commit
17b9e59ba2

+ 5 - 2
SketchAssistant/SketchAssistant.sln

@@ -1,9 +1,12 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Blend for Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Blend for Visual Studio 15
+VisualStudioVersion = 15.0.28307.421
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SketchAssistantWPF", "SketchAssistantWPF\SketchAssistantWPF.csproj", "{EE53AE79-2AA0-4F43-9638-1789B189D5C3}"
+	ProjectSection(ProjectDependencies) = postProject
+		{9ED853D5-40BD-40EB-9F8F-228EE11319A1} = {9ED853D5-40BD-40EB-9F8F-228EE11319A1}
+	EndProjectSection
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhiteTests", "WhiteTests\WhiteTests.csproj", "{EB09C624-91F2-465F-825B-559BF7A7D5CB}"
 EndProject

+ 41 - 7
SketchAssistant/StaticLib1/ArmbandInterface.cpp

@@ -1,8 +1,9 @@
 #include "stdafx.h"
 extern "C" {
-#include "MotorHeader/ArduinoHub.h"
+#include "MotorHeader/BodyActuator.h"
 }
 #include <ctime>
+#include <stdio.h>
 
 
 namespace StaticLib1
@@ -10,23 +11,56 @@ namespace StaticLib1
 	class UnitTest1
 	{
 
-		ArduinoHub* armband;
+		BodyActuator* armband;
+		char *port = new char[5] {'C', 'O', 'M', '5', '\0'};
+
+		HINSTANCE lib;
+		typedef void (__cdecl *InitFunctionType)(BodyActuator*, BodyActuator_Type, char*, int);
+		InitFunctionType initFunctionHandle;
+		typedef void(__cdecl *StartFunctionType)(BodyActuator*, uint8_t, float);
+		StartFunctionType startFunctionHandle;
+		typedef void(__cdecl *StopFunctionType)(BodyActuator*, uint8_t);
+		StopFunctionType stopFunctionHandle;
 
 	public : 
 
+
+
 		int main() {
+			lib = LoadLibrary(TEXT("BodyActuator.dll"));
+			if (lib == NULL) {
+				printf("ERROR: library could not be loaded");
+				return 0;
+			}
+			initFunctionHandle = (InitFunctionType)GetProcAddress(lib, "BodyActuator_init");
+			if (initFunctionHandle == NULL) {
+				printf("ERROR: init function could not be retrieved");
+				return 1;
+			}
+			startFunctionHandle = (StartFunctionType)GetProcAddress(lib, "BodyActuator_startActuation");
+			if (startFunctionHandle == NULL) {
+				printf("ERROR: start function could not be retrieved");
+				return 2;
+			}
+			stopFunctionHandle = (StopFunctionType)GetProcAddress(lib, "BodyActuator_stopActuation");
+			if (stopFunctionHandle == NULL) {
+				printf("ERROR: stop function could not be retrieved");
+				return 3;
+			}
+			//strcpy(port, "COM5");
 			setupMotors();
-			startVibrate(1, 1.0);
+			startVibrate(0, 1.0);
 		}
 
 		void setupMotors() {
-			ArduinoHub_init(armband, "4", (ArduinoHub_Type) 'P');
+			(initFunctionHandle) (armband, BODYACTUATOR_TYPE_EAI, port, 8);
+			printf("armband initialized");
 		}
 		void startVibrate(uint8_t tactor, float intensity) {
-			ArduinoHub_startVibration(armband, tactor, intensity);
+			(startFunctionHandle) (armband, tactor, intensity);
 		}
-		void nstopVibration(uint8_t tactor) {
-			ArduinoHub_stopVibration(armband, tactor);
+		void stopVibration(uint8_t tactor) {
+			(stopFunctionHandle) (armband, tactor);
 		}
 	};
 }

+ 135 - 0
SketchAssistant/StaticLib1/Motorheader/BodyActuator.h

@@ -0,0 +1,135 @@
+/*
+
+ *  BodyActuator.h
+
+ *
+
+ *  Copyright (C)
+
+ *  Honda Research Institute Europe GmbH
+
+ *  Carl-Legien-Str. 30
+
+ *  63073 Offenbach/Main
+
+ *  Germany
+
+ *
+
+ *  UNPUBLISHED PROPRIETARY MATERIAL.
+
+ *  ALL RIGHTS RESERVED.
+
+ *
+
+ */
+
+#pragma once
+
+#include <stdbool.h>
+
+#include "ArduinoHub.h"
+
+#include "EAIHub.h"
+
+typedef enum
+
+{
+
+    BODYACTUATOR_TYPE_NONE,
+
+    BODYACTUATOR_TYPE_EAI,
+
+    BODYACTUATOR_TYPE_PIEZO,
+
+    BODYACTUATOR_TYPE_ERM,
+
+    BODYACTUATOR_TYPE_EMS
+
+} BodyActuator_Type;
+
+extern char* BodyActuator_Type_Names[5];
+
+typedef struct BodyActuator
+
+{
+
+    bool valid;
+
+    uint8_t actuatorCount;
+
+    BodyActuator_Type type;
+
+    ArduinoHub* arduinoHub;
+
+    EAIHub* eaiHub;
+
+} BodyActuator;
+
+BodyActuator* BodyActuator_new();
+
+void BodyActuator_init(BodyActuator* self, BodyActuator_Type type, char* port, uint8_t actuatorCount);
+
+void BodyActuator_clear(BodyActuator* self);
+
+void BodyActuator_delete(BodyActuator* self);
+
+/**
+
+ * Starts actuation for a specified duration. The command is non-blocking.
+
+ * @intensity:
+
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+
+ *      An intensity range can be set with BodyActuator_setIntensityRange().
+
+ * @duration:
+
+ *      Duration of the vibration in milliseconds.
+
+ */
+
+void BodyActuator_actuate(BodyActuator* self, uint8_t tactor, double intensity, uint64_t duration);
+
+/**
+
+ * Starts continuous actuation. The command is non-blocking.
+
+ * @intensity:
+
+ *      Intensity covering the whole spectrum of the actuator if no range is set.
+
+ *      An intensity range can be set with ArduinoActuator_setIntensityRange().
+
+ */
+
+void BodyActuator_startActuation(BodyActuator* self, uint8_t tactor, double intensity);
+
+/**
+
+ * Stops continuous vibration.
+
+ */
+
+void BodyActuator_stopActuation(BodyActuator* self, uint8_t tactor);
+
+/**
+
+* Sets the frequency of the vibration of an actuator.
+
+*/
+
+void BodyActuator_setFrequency(BodyActuator* self, uint8_t tactor, uint16_t frequency);
+
+/**
+
+ * Set the intensity range. The default range is the actuators whole intensity [0, 1].
+
+ * Modifying this setting cuts-out intensity values under min and above max.
+
+ * E.g., for the range [0.2, 1.0] the intensity 0.5 maps to a device intensity of 0.6.
+
+ */
+
+void BodyActuator_setIntensityRange(BodyActuator* self, uint8_t tactor, double minIntensity, double maxIntensity);

+ 1 - 1
SketchAssistant/StaticLib1/Motorheader/Serial.h

@@ -15,7 +15,7 @@
 #pragma once
 #include <stdbool.h>
 #include <stdint.h>
-//#include <windows.h>
+#include <windows.h>
 
 typedef struct Serial
 {

+ 2 - 1
SketchAssistant/StaticLib1/StaticLib1.vcxproj

@@ -151,6 +151,7 @@
   <ItemGroup>
     <ClInclude Include="Motorheader\Actuator.h" />
     <ClInclude Include="Motorheader\ArduinoHub.h" />
+    <ClInclude Include="Motorheader\BodyActuator.h" />
     <ClInclude Include="Motorheader\EAIHub.h" />
     <ClInclude Include="Motorheader\Serial.h" />
     <ClInclude Include="stdafx.h" />
@@ -178,7 +179,7 @@
   </ImportGroup>
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
-      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+      <ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
     </PropertyGroup>
     <Error Condition="!Exists('..\packages\pthreads.redist.2.9.1.4\build\native\pthreads.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pthreads.redist.2.9.1.4\build\native\pthreads.redist.targets'))" />
     <Error Condition="!Exists('..\packages\pthreads.2.9.1.4\build\native\pthreads.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pthreads.2.9.1.4\build\native\pthreads.targets'))" />

+ 3 - 0
SketchAssistant/StaticLib1/StaticLib1.vcxproj.filters

@@ -33,6 +33,9 @@
     <ClInclude Include="Motorheader\Serial.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Motorheader\BodyActuator.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">