浏览代码

tried some stuff, now StaticLibMotors wont compile because of linkage errors, but at least it tries to link at all...

Vincenz Mechler 5 年之前
父节点
当前提交
e33b329217

+ 2 - 2
SketchAssistant/SketchAssistant.sln

@@ -1,6 +1,6 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Blend for Visual Studio 15
+# 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}"
@@ -53,7 +53,7 @@ Global
 		{EB09C624-91F2-465F-825B-559BF7A7D5CB}.Release|x64.Build.0 = Release|Any CPU
 		{EB09C624-91F2-465F-825B-559BF7A7D5CB}.Release|x86.ActiveCfg = Release|Any CPU
 		{EB09C624-91F2-465F-825B-559BF7A7D5CB}.Release|x86.Build.0 = Release|Any CPU
-		{9ED853D5-40BD-40EB-9F8F-228EE11319A1}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{9ED853D5-40BD-40EB-9F8F-228EE11319A1}.Debug|Any CPU.ActiveCfg = Debug|x64
 		{9ED853D5-40BD-40EB-9F8F-228EE11319A1}.Debug|x64.ActiveCfg = Debug|x64
 		{9ED853D5-40BD-40EB-9F8F-228EE11319A1}.Debug|x64.Build.0 = Debug|x64
 		{9ED853D5-40BD-40EB-9F8F-228EE11319A1}.Debug|x86.ActiveCfg = Debug|Win32

+ 7 - 0
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -111,6 +111,9 @@ namespace SketchAssistantWPF
 
         public MVP_Model(MVP_Presenter presenter)
         {
+            //TODO remove
+            LocalArmbandInterface.setupArmband();
+
             programPresenter = presenter;
             historyOfActions = new ActionHistory();
             //redrawAss = new RedrawAssistant();
@@ -356,6 +359,8 @@ namespace SketchAssistantWPF
                 currentLine.Clear();
                 currentLine.Add(currentCursorPosition);
             }
+            //TODO remove
+            LocalArmbandInterface.startVibrate(0, 1);
         }
 
         /// <summary>
@@ -384,6 +389,8 @@ namespace SketchAssistantWPF
                 currentLine.Clear();
             }
             UpdateUI();
+            //TODO remove
+            LocalArmbandInterface.stopVibration(0);
         }
 
         /// <summary>

+ 26 - 8
SketchAssistant/SketchAssistantWPF/SketchAssistantWPF.csproj

@@ -17,6 +17,7 @@
     <Deterministic>true</Deterministic>
     <NuGetPackageImportStamp>
     </NuGetPackageImportStamp>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Disk</InstallFrom>
@@ -29,7 +30,6 @@
     <MapFileExtensions>true</MapFileExtensions>
     <ApplicationRevision>0</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
@@ -75,6 +75,7 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="ActionHistory.cs" />
+    <Compile Include="LocalArmbandInterface.cs" />
     <Compile Include="CustomCanvas.cs" />
     <Compile Include="DebugData.cs" />
     <Compile Include="FileImporter.cs" />
@@ -139,13 +140,30 @@
     </BootstrapperPackage>
   </ItemGroup>
   <ItemGroup>
-    <Content Include="BodyActuator.dll" />
-    <Content Include="eai_common.dll" />
-    <Content Include="eai_serial.dll" />
-    <Content Include="eai_winbluetooth.dll" />
-    <Content Include="eai_winusb.dll" />
-    <Content Include="TActionManager.dll" />
-    <Content Include="TactorInterface.dll" />
+    <Content Include="BodyActuator.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="eai_common.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="eai_serial.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="eai_winbluetooth.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="eai_winusb.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="StaticLibMotors.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="TActionManager.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="TactorInterface.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 14 - 31
SketchAssistant/StaticLib1/ArmbandInterface.cpp

@@ -4,29 +4,11 @@ extern "C" {
 }
 #include <ctime>
 #include <stdio.h>
+#include "ArmbandInterface.h"
 
 
-namespace StaticLib1
-{		
-	class UnitTest1
-	{
-
-		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() {
+extern "C" {
+		__declspec(dllexport) int __cdecl ArmbandInterface::setupArmband() {
 			lib = LoadLibrary(TEXT("BodyActuator.dll"));
 			if (lib == NULL) {
 				printf("ERROR: library could not be loaded");
@@ -50,17 +32,18 @@ namespace StaticLib1
 			//strcpy(port, "COM5");
 			setupMotors();
 			startVibrate(0, 1.0);
+			return -1;
 		}
-
-		void setupMotors() {
-			(initFunctionHandle) (armband, BODYACTUATOR_TYPE_EAI, port, 8);
-			printf("armband initialized");
+		__declspec(dllexport) void __cdecl ArmbandInterface::startVibrate(int tactor, float intensity) {
+			(startFunctionHandle)(armband, (uint8_t)tactor, intensity);
 		}
-		void startVibrate(uint8_t tactor, float intensity) {
-			(startFunctionHandle) (armband, tactor, intensity);
+		__declspec(dllexport) void __cdecl ArmbandInterface::stopVibrate(int tactor) {
+			(stopFunctionHandle)(armband, (uint8_t)tactor);
 		}
-		void stopVibration(uint8_t tactor) {
-			(stopFunctionHandle) (armband, tactor);
+	}
+
+ void ArmbandInterface::setupMotors() {
+			(initFunctionHandle) (armband, BODYACTUATOR_TYPE_EAI, new char[5]{ 'C', 'O', 'M', '5', '\0' }, 8);
+			printf("armband initialized");
 		}
-	};
-}
+ 

+ 5 - 3
SketchAssistant/StaticLib1/StaticLib1.vcxproj

@@ -28,7 +28,7 @@
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolset>v141</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
@@ -41,7 +41,7 @@
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolset>v141</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
@@ -96,6 +96,7 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -149,6 +150,7 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="ArmbandInterface.h" />
     <ClInclude Include="Motorheader\Actuator.h" />
     <ClInclude Include="Motorheader\ArduinoHub.h" />
     <ClInclude Include="Motorheader\BodyActuator.h" />
@@ -179,7 +181,7 @@
   </ImportGroup>
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
-      <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>
+      <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>
     </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

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