summaryrefslogtreecommitdiffstats
path: root/Kod/display/ClientServerApp
diff options
context:
space:
mode:
Diffstat (limited to 'Kod/display/ClientServerApp')
-rw-r--r--Kod/display/ClientServerApp/Client/Client.cpp151
-rw-r--r--Kod/display/ClientServerApp/Client/Client.vcproj188
-rw-r--r--Kod/display/ClientServerApp/Client/Client.vcxproj165
-rw-r--r--Kod/display/ClientServerApp/ClientServerApp.sln53
-rw-r--r--Kod/display/ClientServerApp/ClientServerApp.suobin0 -> 25088 bytes
-rw-r--r--Kod/display/ClientServerApp/Common/ComConduit.cpp151
-rw-r--r--Kod/display/ClientServerApp/Common/ComConduit.h59
-rw-r--r--Kod/display/ClientServerApp/Common/Common.vcproj203
-rw-r--r--Kod/display/ClientServerApp/Common/Common.vcxproj139
-rw-r--r--Kod/display/ClientServerApp/Common/Conduit.cpp529
-rw-r--r--Kod/display/ClientServerApp/Common/Conduit.h145
-rw-r--r--Kod/display/ClientServerApp/Common/ReadABuffer.cpp36
-rw-r--r--Kod/display/ClientServerApp/Common/ReadABuffer.h20
-rw-r--r--Kod/display/ClientServerApp/Common/WriteABuffer.cpp67
-rw-r--r--Kod/display/ClientServerApp/Common/WriteABuffer.h22
-rw-r--r--Kod/display/ClientServerApp/Common/ipclink.h80
-rw-r--r--Kod/display/ClientServerApp/Release/Client.exebin0 -> 10240 bytes
-rw-r--r--Kod/display/ClientServerApp/Release/Server.exebin0 -> 13312 bytes
-rw-r--r--Kod/display/ClientServerApp/Release/matlabclient.mexw32bin0 -> 12800 bytes
-rw-r--r--Kod/display/ClientServerApp/Release/matlabclient.mexw64bin0 -> 14848 bytes
-rw-r--r--Kod/display/ClientServerApp/Release/startServer.bat15
-rw-r--r--Kod/display/ClientServerApp/Server/Server.cpp418
-rw-r--r--Kod/display/ClientServerApp/Server/Server.vcproj189
-rw-r--r--Kod/display/ClientServerApp/Server/Server.vcxproj167
-rw-r--r--Kod/display/ClientServerApp/matlabClient/matlabClient.cpp400
-rw-r--r--Kod/display/ClientServerApp/matlabClient/matlabClient.vcproj178
-rw-r--r--Kod/display/ClientServerApp/matlabClient/matlabClient.vcxproj158
-rw-r--r--Kod/display/ClientServerApp/matlabClient/stdafx.cpp8
-rw-r--r--Kod/display/ClientServerApp/matlabClient/stdafx.h15
-rw-r--r--Kod/display/ClientServerApp/matlabClient/targetver.h13
-rw-r--r--Kod/display/ClientServerApp/matlabMake.bat16
31 files changed, 3585 insertions, 0 deletions
diff --git a/Kod/display/ClientServerApp/Client/Client.cpp b/Kod/display/ClientServerApp/Client/Client.cpp
new file mode 100644
index 0000000..efd08fe
--- /dev/null
+++ b/Kod/display/ClientServerApp/Client/Client.cpp
@@ -0,0 +1,151 @@
+//============================================================================
+// Name : Client.cpp
+// Author : Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+// Modified : Emil Larsson, lime@isy.liu.se, 2012-01-13
+//
+// Description : The client requests data to be sent by the server.
+//
+//============================================================================
+
+#include <stdio.h>
+#include <string>
+#include "ComConduit.h"
+
+//
+// Show the command-line usage
+//
+void Usage(char* argv[]) {
+
+ printf("\nUsage: %s <options>\n\n",argv[0]);
+ printf(" -S=<message> Send message, ex -S=\"hello world\".\n");
+ printf(" -X Shutdown server.\n");
+ printf("\n\n");
+}
+
+
+
+
+
+//
+// Module main function
+//
+int main(int argc, char* argv[]) {
+
+ // Conduit object
+ ComConduit Link;
+ // Key
+ KeyType key[KEY_LEN] = COM_KEY;
+ // Work variables
+ wchar_t data[COMSTR_LEN];
+ bool doShutdown;
+ FlagType ret;
+ int i,j;
+ char c,*ptr;
+ WaitResult wr;
+
+ // Initialize data
+ data[0] = '\0';
+ doShutdown = false;
+
+ //
+ // Parse the command-line.
+ //
+ for (i=1; i<argc; i++) {
+ ptr = argv[i];
+
+ while(*ptr == '-') // Step forward
+ ptr++;
+ c = *ptr; // Get option
+ ptr++;
+ if(*ptr == '=') // Step forward
+ ptr++;
+
+ switch(c) {
+
+ case 'S':
+ case 's':
+ // Read message
+ j = 0;
+ do {
+ // add 1 to avoid the "null" character
+// data[j] = (*ptr)+1;
+ data[j] = (*ptr);
+ ptr++;
+ j++;
+ } while(j<COMSTR_LEN && *ptr != '\0');
+ if(j >= COMSTR_LEN) {
+ fprintf(stderr,"\nToo long message.\n");
+ return EXIT_FAIL;
+ }
+ data[j] = '\0';
+ break;
+
+ case 'X':
+ case 'x':
+ // Shutdown
+ doShutdown = true;
+ break;
+ }
+ }
+
+ // Check valid args
+ if(!doShutdown && data[0] == '\0') {
+ Usage(argv);
+ return EXIT_FAIL;
+ }
+
+ //
+ // Start client
+ //
+ if(!Link.StartClient(key)) {
+ fprintf(stderr,"StartClient() failed.\n");
+ return EXIT_FAIL;
+ }
+
+ ret = EXIT_OK;
+ if(doShutdown) {
+ // Tell server to shutdown
+ if(!Link.CauseShutdown()) {
+ fprintf(stderr,"\nCauseShutdown() failed.\n");
+ ret = EXIT_FAIL;
+ }
+ }
+ else {
+ do {
+ // Check if server is ready
+ wr = Link.WaitForEvent(COM_READY,0);
+ if(wr != WAIT_OK) {
+ fprintf(stderr,"Server is not ready.\n");
+ ret = EXIT_FAIL;
+ break;
+ }
+
+ // Set data in shm
+ if(!Link.SetData(data)) {
+ fprintf(stderr,"SetData() failed.\n");
+ ret = EXIT_FAIL;
+ break;
+ }
+
+ // Request that the server send the data
+ if(!Link.CauseEvent(COM_REQUEST)) {
+ fprintf(stderr,"CauseEvent() failed.\n");
+ ret = EXIT_FAIL;
+ break;
+ }
+ } while(false);
+ }
+
+ //
+ // Shutdown
+ //
+ if(!Link.Shutdown()) {
+ fprintf(stderr,"Shutdown() failed.\n");
+ ret = EXIT_FAIL;
+ }
+ if(ret == EXIT_OK)
+ fprintf(stdout, "\nClean exit.\n");
+
+ return ret;
+}
+
diff --git a/Kod/display/ClientServerApp/Client/Client.vcproj b/Kod/display/ClientServerApp/Client/Client.vcproj
new file mode 100644
index 0000000..dce2a22
--- /dev/null
+++ b/Kod/display/ClientServerApp/Client/Client.vcproj
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Client"
+ ProjectGUID="{3941DB40-83AA-41FD-A225-29B47EEFD704}"
+ RootNamespace="Client"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;C:\Users\Emil\Documents\Visual Studio 2008\Projects\ClientServerApp\Common&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Client.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Kod/display/ClientServerApp/Client/Client.vcxproj b/Kod/display/ClientServerApp/Client/Client.vcxproj
new file mode 100644
index 0000000..7847220
--- /dev/null
+++ b/Kod/display/ClientServerApp/Client/Client.vcxproj
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{3941DB40-83AA-41FD-A225-29B47EEFD704}</ProjectGuid>
+ <RootNamespace>Client</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>"..\Common";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>"..\Common";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="Client.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Common\Common.vcxproj">
+ <Project>{8c1e78f5-0564-498a-958d-37a997bbfe49}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/ClientServerApp.sln b/Kod/display/ClientServerApp/ClientServerApp.sln
new file mode 100644
index 0000000..f23f502
--- /dev/null
+++ b/Kod/display/ClientServerApp/ClientServerApp.sln
@@ -0,0 +1,53 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "Server\Server.vcxproj", "{7B05F65E-9D5F-49CE-9339-959759F4E98C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "Client\Client.vcxproj", "{3941DB40-83AA-41FD-A225-29B47EEFD704}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Common\Common.vcxproj", "{8C1E78F5-0564-498A-958D-37A997BBFE49}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "matlabClient", "matlabClient\matlabClient.vcxproj", "{3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Debug|Win32.Build.0 = Debug|Win32
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Debug|x64.ActiveCfg = Debug|Win32
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Release|Win32.ActiveCfg = Release|Win32
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Release|Win32.Build.0 = Release|Win32
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Release|x64.ActiveCfg = Release|x64
+ {7B05F65E-9D5F-49CE-9339-959759F4E98C}.Release|x64.Build.0 = Release|x64
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Debug|Win32.Build.0 = Debug|Win32
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Debug|x64.ActiveCfg = Debug|x64
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Debug|x64.Build.0 = Debug|x64
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Release|Win32.ActiveCfg = Release|Win32
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Release|Win32.Build.0 = Release|Win32
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Release|x64.ActiveCfg = Release|x64
+ {3941DB40-83AA-41FD-A225-29B47EEFD704}.Release|x64.Build.0 = Release|x64
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Debug|Win32.Build.0 = Debug|Win32
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Debug|x64.ActiveCfg = Debug|Win32
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Release|Win32.ActiveCfg = Release|Win32
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Release|Win32.Build.0 = Release|Win32
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Release|x64.ActiveCfg = Release|x64
+ {8C1E78F5-0564-498A-958D-37A997BBFE49}.Release|x64.Build.0 = Release|x64
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Debug|Win32.Build.0 = Debug|Win32
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Debug|x64.ActiveCfg = Debug|Win32
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Release|Win32.ActiveCfg = Release|Win32
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Release|Win32.Build.0 = Release|Win32
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Release|x64.ActiveCfg = Release|x64
+ {3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Kod/display/ClientServerApp/ClientServerApp.suo b/Kod/display/ClientServerApp/ClientServerApp.suo
new file mode 100644
index 0000000..3de3b49
--- /dev/null
+++ b/Kod/display/ClientServerApp/ClientServerApp.suo
Binary files differ
diff --git a/Kod/display/ClientServerApp/Common/ComConduit.cpp b/Kod/display/ClientServerApp/Common/ComConduit.cpp
new file mode 100644
index 0000000..1bb952f
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/ComConduit.cpp
@@ -0,0 +1,151 @@
+/*
+ * ComConduit.cpp
+ *
+ * Definition of the ComConduit class
+ *
+ * Author: Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+ * Modified: Emil Larsson, lime@isy.liu.se, 2012-01-13
+ */
+
+#include "ComConduit.h"
+#include <string.h>
+//#include "mex.h"
+
+// Constructor
+ComConduit::ComConduit() {
+
+ ptrData = NULL;
+}
+
+// Destructor
+ComConduit::~ComConduit() {
+
+ // Issue shutdown function
+ Shutdown();
+}
+
+// Detach and remove shared memory segment
+bool ComConduit::Shutdown() {
+
+ if(Conduit::Shutdown()) {
+ ptrData = NULL;
+ return true;
+ }
+ else
+ return false;
+}
+
+// Server initialization
+bool ComConduit::StartServer(KeyType* key) {
+
+ if(!Conduit::StartServer(key))
+ return false;
+
+ ptrData = (COMdata*)ptrShm;
+ ptrData->Common.Flag = NULL_FLAG;
+ ptrData->Common.DoShutdown = false;
+ ptrData->string[0] = '\0';
+
+ return true;
+}
+
+// Client initialization
+bool ComConduit::StartClient(KeyType* key) {
+
+ if(!Conduit::StartClient(key))
+ return false;
+
+ ptrData = (COMdata*)ptrShm;
+
+ return true;
+}
+
+// Get shared data size
+int ComConduit::GetDataSize() const {
+
+ return sizeof(COMdata);
+}
+
+// Get pointer to common shared data
+CommonData* ComConduit::GetCommonData() const {
+
+ if(ptrData == NULL)
+ return(NULL);
+ else
+ return(&ptrData->Common);
+}
+
+// Get number of events
+int ComConduit::GetNumEvents() const {
+
+ return COM_NEVENTS;
+}
+
+// Set the data
+bool ComConduit::SetData(const wchar_t* data) {
+
+ int ii;
+
+ if(ptrData == NULL)
+ return false;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ // Copy string
+// wcscpy_s(ptrData->string,COMSTR_LEN, data);
+
+ /* Copy the wchar_t-string manual */
+ for (ii=0; ii<data[1]+EXTRA_LEN; ii++)
+ {
+ ptrData->string[ii] = data[ii];
+ // printf("\nptrData->string[%d]: %d \n", ii, ptrData->string[ii]);
+ }
+ /* Stop with a "null" char */
+ ptrData->string[ii] = '\0';
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ return true;
+}
+
+// Get the data
+bool ComConduit::GetData(wchar_t* data) {
+
+ int ii;
+
+ if(ptrData == NULL)
+ return false;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ // Copy string
+// wcscpy_s(data,COMSTR_LEN,ptrData->string);
+// strcpy((char*) data, ptrData->string);
+
+ //printf("\tComConduit:GetData: %d\n",ptrData->string[1]);
+
+ /* Copy the wchar_t-string manual */
+ for (ii=0; ii<ptrData->string[1]+EXTRA_LEN; ii++)
+ {
+ data[ii] = ptrData->string[ii];
+ //printf("\nGetData:data[%d]: %d \n", ii, data[ii]);
+ }
+ /* Stop with a "null" char */
+ data[ii] = (wchar_t) '\0';
+ //printf("\nGetData:data[%d]: %d \n", ii, data[ii]);
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ return true;
+}
+
+
+
diff --git a/Kod/display/ClientServerApp/Common/ComConduit.h b/Kod/display/ClientServerApp/Common/ComConduit.h
new file mode 100644
index 0000000..3948355
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/ComConduit.h
@@ -0,0 +1,59 @@
+/*
+ * ComConduit.h
+ *
+ * Declaration of the ComConduit class
+ *
+ * Author: Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+ * Modified: Emil Larsson, lime@isy.liu.se, 2012-01-13
+ */
+
+#ifndef COMCONDUIT_H_
+#define COMCONDUIT_H_
+
+// Include conduit base class
+#include "Conduit.h"
+// Include ipc interface
+#include "ipclink.h"
+
+#include <stdio.h>
+//
+// The ComConduit class
+//
+class ComConduit : public Conduit {
+
+public:
+
+ // Construct & Destruct
+ ComConduit();
+ virtual ~ComConduit();
+
+ // Server initialization
+ bool StartServer(KeyType* key);
+ // Client initialization
+ bool StartClient(KeyType* key);
+ // Detach and remove shared memory segment
+ bool Shutdown();
+
+ // Get shared data size
+ int GetDataSize() const;
+ // Get number of events
+ int GetNumEvents() const;
+ // Get pointer to common shared data
+ CommonData* GetCommonData() const;
+
+ // Write data
+ bool SetData(const wchar_t* data);
+
+ // Data read
+ bool GetData(wchar_t* data);
+
+private:
+
+ // Pointer to shared data
+ COMdata* ptrData;
+
+};
+
+
+
+#endif /* COMCONDUIT_H_ */
diff --git a/Kod/display/ClientServerApp/Common/Common.vcproj b/Kod/display/ClientServerApp/Common/Common.vcproj
new file mode 100644
index 0000000..b5be92d
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/Common.vcproj
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Common"
+ ProjectGUID="{8C1E78F5-0564-498A-958D-37A997BBFE49}"
+ RootNamespace="Common"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\ComConduit.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Conduit.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ReadABuffer.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\WriteABuffer.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\ComConduit.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Conduit.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ipclink.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ReadABuffer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\WriteABuffer.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Kod/display/ClientServerApp/Common/Common.vcxproj b/Kod/display/ClientServerApp/Common/Common.vcxproj
new file mode 100644
index 0000000..be80a98
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/Common.vcxproj
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{8C1E78F5-0564-498A-958D-37A997BBFE49}</ProjectGuid>
+ <RootNamespace>Common</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="ComConduit.cpp" />
+ <ClCompile Include="Conduit.cpp" />
+ <ClCompile Include="ReadABuffer.cpp" />
+ <ClCompile Include="WriteABuffer.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="ComConduit.h" />
+ <ClInclude Include="Conduit.h" />
+ <ClInclude Include="ipclink.h" />
+ <ClInclude Include="ReadABuffer.h" />
+ <ClInclude Include="WriteABuffer.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/Common/Conduit.cpp b/Kod/display/ClientServerApp/Common/Conduit.cpp
new file mode 100644
index 0000000..1d827f4
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/Conduit.cpp
@@ -0,0 +1,529 @@
+/*
+ * Conduit.cpp
+ *
+ * Definition of the Conduit class
+ *
+ * Author: Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+ * Modified: Emil Larsson, lime@isy.liu.se, 2012-01-13
+ */
+
+#include <stdio.h>
+#include "Conduit.h"
+#include <tchar.h>
+
+// Constructor
+Conduit::Conduit() {
+
+ ptrShm = NULL;
+ isServer = false;
+ iNumSems = 0;
+
+ hMapObject = NULL;
+ for(int i=0; i<MAX_NUM_SEM; i++)
+ hSemaphore[i] = NULL;
+}
+
+// Destructor
+Conduit::~Conduit() {
+
+ // Issue shutdown function
+ Shutdown();
+}
+
+// Detach and/or remove shared memory segment
+bool Conduit::Shutdown() {
+
+ bool ret = true;
+ int i;
+
+ if(hMapObject != NULL) {
+ // Detach shared memory segment
+ if(!UnmapViewOfFile(ptrShm))
+ ret = false;
+
+ if(isServer) {
+ // Remove shared memory segment
+ if(CloseHandle(hMapObject) == FALSE)
+ ret = false;
+
+ // Destroy semaphores
+ for(i=0; i<iNumSems; i++) {
+ if(CloseHandle(hSemaphore[i]) == FALSE)
+ ret = false;
+ }
+ }
+ hMapObject = NULL;
+ }
+
+ ptrShm = NULL;
+ isServer = false;
+
+ return ret;
+}
+
+// Server initialization
+bool Conduit::StartServer(KeyType* key) {
+
+ int i;
+ bool ret = true;
+
+ if(ptrShm != NULL)
+ return false;
+
+ // Calculate number of semaphores
+ iNumSems = NumberOfSemaphores();
+
+ if(iNumSems > MAX_NUM_SEM)
+ return false;
+
+
+ // WIN32 IPC: Shared memory based on file mapping.
+
+ char strKey[KEY_LEN+2];
+ SECURITY_ATTRIBUTES attr;
+
+ // Fill struct with security attributes
+ attr.nLength = sizeof(SECURITY_ATTRIBUTES);
+ attr.lpSecurityDescriptor = NULL;
+ attr.bInheritHandle = FALSE;
+
+ // Convert integer array 'key' to char array 'strKey'
+ for(i=0; i<KEY_LEN; i++)
+ strKey[i+1] = key[i]+48;
+ strKey[0] = 'A';
+ strKey[KEY_LEN+1] = '\0';
+
+
+ // Create shared memory segment
+ hMapObject = CreateFileMapping(INVALID_HANDLE_VALUE, // Use paging file
+ &attr, // Security attr.
+ PAGE_READWRITE, // Read/write access
+ 0, // Size: high 32-bits
+ GetDataSize(), // Size: low 32-bits
+ strKey); // Name of map object
+
+ if(hMapObject == NULL)
+ return false;
+
+ // Attach to shared memory segment
+ ptrShm = MapViewOfFile(hMapObject, // Object to map view of
+ FILE_MAP_WRITE, // Read/write access
+ 0, // High offset: map from
+ 0, // Low offset: beginning
+ 0); // Default: map entire file
+ if(ptrShm == NULL) {
+ CloseHandle(hMapObject);
+ return false;
+ }
+
+ // Create semaphore for mutual exclusion [initial value 1]
+ strKey[0]++;
+ hSemaphore[0] = CreateSemaphore(&attr, // Security attributes
+ 1, // Initial count
+ 1, // Maximum count
+ strKey); // Named semaphore
+ if(hSemaphore[0] == NULL)
+ ret = false;
+
+ // Create semaphores for event tracking [initial value 0]
+ for(i=1; i<iNumSems; i++) {
+ strKey[0]++;
+ hSemaphore[i] = CreateSemaphore(&attr, // Security attributes
+ 0, // Initial count
+ 1, // Maximum count
+ strKey); // Named semaphore
+ if(hSemaphore[i] == NULL)
+ ret = false;
+ }
+
+ // Making absolutely sure that the semaphores are initialized correctly
+ Signal(0);
+ for(i=1; i<iNumSems; i++)
+ Wait(i,0);
+
+
+
+ if(ret) {
+ isServer = true;
+ return true;
+ }
+ else {
+ isServer = true;
+ Shutdown();
+ isServer = false;
+ return false;
+ }
+}
+
+// Client initialization
+bool Conduit::StartClient(KeyType* key) {
+
+ int i;
+
+ if(ptrShm != NULL)
+ return false;
+
+ // Calculate number of semaphores
+ iNumSems = NumberOfSemaphores();
+
+
+ // WIN32 IPC: Shared memory based on file mapping.
+
+ char strKey[KEY_LEN+2];
+
+ // Convert integer array 'key' to char array 'strKey'
+ for(i=0; i<KEY_LEN; i++)
+ strKey[i+1] = key[i]+48;
+ strKey[0] = 'A';
+ strKey[KEY_LEN+1] = '\0';
+
+ // Locate shared memory segment
+ hMapObject = OpenFileMapping(FILE_MAP_WRITE, // Read/write acces
+ FALSE, // Handle not inheritable
+ strKey); // Name of map object
+ if(hMapObject == NULL)
+ return false;
+
+ // Attach to shared memory segment
+ ptrShm = MapViewOfFile(hMapObject, // Object to map view of
+ FILE_MAP_WRITE, // Read/write access
+ 0, // High offset: map from
+ 0, // Low offset: beginning
+ 0); // Default: map entire file
+ if(ptrShm == NULL)
+ return false;
+
+ // Locate semaphore for mutual exclusion
+ strKey[0]++;
+ hSemaphore[0] = OpenSemaphore(SEMAPHORE_MODIFY_STATE |
+ STANDARD_RIGHTS_ALL, // Desired access
+ FALSE, // No inheritance
+ strKey); // Sempahore name
+ if(hSemaphore[0] == NULL)
+ return false;
+
+ // Locate semaphores for event tracking
+ for(i=1; i<iNumSems; i++) {
+ strKey[0]++;
+ hSemaphore[i] = OpenSemaphore(SEMAPHORE_MODIFY_STATE |
+ STANDARD_RIGHTS_ALL, // Desired access
+ FALSE, // No inheritance
+ strKey); // Sempahore name
+ if(hSemaphore[i] == NULL)
+ return false;
+ }
+
+
+ isServer = false;
+ return true;
+}
+
+// Wait-operation on a semaphore
+bool Conduit::Wait(int index) {
+
+
+ if(hSemaphore[index] == NULL)
+ return false;
+
+ if(WaitForSingleObject(hSemaphore[index],INFINITE) != WAIT_OBJECT_0)
+ return false;
+
+ return true;
+
+
+}
+
+// Wait-operation with timeout [ms] on a semaphore
+bool Conduit::Wait(int index, int timeout) {
+
+
+ if(hSemaphore[index] == NULL)
+ return false;
+
+ if(WaitForSingleObject(hSemaphore[index],timeout) != WAIT_OBJECT_0)
+ return false;
+
+ return true;
+}
+
+// Signal-operation on semaphore
+bool Conduit::Signal(int index) {
+
+ if(hSemaphore[index] == NULL)
+ return false;
+
+ if(ReleaseSemaphore(hSemaphore[index],1,NULL) == FALSE) {
+ if(GetLastError() == ERROR_TOO_MANY_POSTS)
+ // Already unlocked
+ return true;
+ else
+ // Error
+ return false;
+ }
+
+ return true;
+}
+
+// Request lock on resource
+bool Conduit::RequestLock() {
+
+ return Wait(0);
+}
+
+// Release lock on resource
+bool Conduit::ReleaseLock() {
+
+ return Signal(0);
+}
+
+// Indicate change of flag
+bool Conduit::IndicateChangedFlag() {
+
+ return Signal(1);
+}
+
+// Wait for change of flag
+bool Conduit::WaitForChangedFlag() {
+
+ return Wait(1);
+}
+
+// Wait for change with timeout of flag
+bool Conduit::WaitForChangedFlag(int timeout) {
+
+ return Wait(1,timeout);
+}
+
+// Wait for a flag
+WaitResult Conduit::WaitForFlag(FlagType flag) {
+
+ bool ret,sflag;
+ WaitResult wr;
+ FlagType currentFlag;
+
+ do {
+ if(FlagEqual(flag,currentFlag))
+ return WAIT_OK;
+
+ // Perform wait
+ ret = WaitForChangedFlag();
+
+ wr = WAIT_OK;
+ if(!ret || !GetShutdownFlag(sflag))
+ wr = WAIT_FAIL;
+ if(sflag)
+ wr = WAIT_CLOSE;
+
+ } while(wr == WAIT_OK);
+
+ return wr;
+}
+
+// Wait for a flag with timeout
+WaitResult Conduit::WaitForFlag(FlagType flag, int timeout) {
+
+ bool ret,sflag;
+ WaitResult wr;
+ FlagType currentFlag;
+
+ do {
+ if(FlagEqual(flag,currentFlag))
+ return WAIT_OK;
+
+ // Perform wait
+ ret = WaitForChangedFlag(timeout);
+
+ wr = WAIT_OK;
+ if(!ret || !GetShutdownFlag(sflag))
+ wr = WAIT_FAIL;
+ if(sflag)
+ wr = WAIT_CLOSE;
+
+ } while(wr == WAIT_OK);
+
+ return wr;
+}
+
+// Get flag but also check if equal to given parameter. Equal means
+// that any of the bits set to one in flag matches a bit set to one in
+// the current flag, i.e. if an and-operation gives a positive result.
+bool Conduit::FlagEqual(FlagType flag, FlagType& current) {
+
+ return(GetFlag(current) &&
+ ((flag == NULL_FLAG && current == NULL_FLAG) ||
+ ((current & flag) > 0)));
+}
+
+// Wait for an event (reserve associated semaphore)
+WaitResult Conduit::WaitForEvent(int index) {
+
+ bool ret,flag;
+
+ if(!ValidIndex(index))
+ return WAIT_FAIL;
+
+ // Perform wait
+ ret = Wait(index + FIRST_EVENT_SEM);
+
+ if(!ret || !GetShutdownFlag(flag))
+ return WAIT_FAIL;
+ if(flag)
+ return WAIT_CLOSE;
+
+ return WAIT_OK;
+}
+
+// Wait for an event with timeout
+WaitResult Conduit::WaitForEvent(int index, int timeout) {
+
+ bool ret,flag;
+
+ if(!ValidIndex(index))
+ return WAIT_FAIL;
+
+ // Perform wait
+ ret = Wait(index + FIRST_EVENT_SEM,timeout);
+
+ if(!ret || !GetShutdownFlag(flag))
+ return WAIT_FAIL;
+ if(flag)
+ return WAIT_CLOSE;
+
+ return WAIT_OK;
+}
+
+// Cause an event (release associated sempahore)
+bool Conduit::CauseEvent(int index) {
+
+ if(!ValidIndex(index))
+ return false;
+ else
+ return Signal(index + FIRST_EVENT_SEM);
+}
+
+// Cause shutdown event
+bool Conduit::CauseShutdown() {
+
+ int i;
+
+ // Indicate shutdown
+ if(!SetShutdownFlag(true))
+ return false;
+
+ // Release all semaphores but the mutex
+ for(i=1; i<iNumSems; i++) {
+ if(!Signal(i))
+ return false;
+ }
+ return true;
+}
+
+// Get state flag
+bool Conduit::GetFlag(FlagType& flag) {
+
+ bool ret = true;
+ CommonData *ptr;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ if((ptr = GetCommonData()) != NULL)
+ flag = ptr->Flag;
+ else
+ ret = false;
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ return ret;
+}
+
+// Set state flag
+bool Conduit::SetFlag(FlagType flag) {
+
+ bool ret = true;
+ CommonData *ptr;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ if((ptr = GetCommonData()) != NULL)
+ ptr->Flag = flag;
+ else
+ ret = false;
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ // Indicate change
+ if(!IndicateChangedFlag())
+ return false;
+
+ return ret;
+}
+
+// Get shutdown boolean
+bool Conduit::GetShutdownFlag(bool& flag) {
+
+ bool ret = true;
+ CommonData *ptr;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ if((ptr = GetCommonData()) != NULL)
+ flag = ptr->DoShutdown;
+ else
+ ret = false;
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ return ret;
+}
+
+// Set shutdown boolean
+bool Conduit::SetShutdownFlag(bool flag) {
+
+ bool ret = true;
+ CommonData *ptr;
+
+ // Request lock
+ if(!RequestLock())
+ return false;
+
+ if((ptr = GetCommonData()) != NULL)
+ ptr->DoShutdown = flag;
+ else
+ ret = false;
+
+ // Release lock
+ if(!ReleaseLock())
+ return false;
+
+ return ret;
+}
+
+// Check validity of semaphore index
+bool Conduit::ValidIndex(int index) {
+
+ if(index < 0 || index > (iNumSems - FIRST_EVENT_SEM))
+ return false;
+
+ return true;
+}
+
+// Calculate number of semaphores
+int Conduit::NumberOfSemaphores() {
+
+ return(FIRST_EVENT_SEM + GetNumEvents());
+}
+
+
+
diff --git a/Kod/display/ClientServerApp/Common/Conduit.h b/Kod/display/ClientServerApp/Common/Conduit.h
new file mode 100644
index 0000000..012d3f6
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/Conduit.h
@@ -0,0 +1,145 @@
+/*
+ * Conduit.h
+ *
+ * Declaration of the Conduit class
+ *
+ * Author: Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+ * Modified: Emil Larsson, lime@isy.liu.se, 2012-01-13
+ */
+
+#ifndef CONDUIT_H_
+#define CONDUIT_H_
+
+#include "ipclink.h"
+#include <windows.h>
+
+// Segment key length
+#define KEY_LEN 4
+// Data type of segment key
+typedef unsigned short int KeyType;
+
+// Maximum number of semaphores
+#define MAX_NUM_SEM 10
+
+// First semaphore for event tracking
+// Semaphore 0 : mutual exclusion
+// Semaphore 1 : change of data
+#define FIRST_EVENT_SEM 2
+
+
+#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
+// union semun is defined by including <sys/sem.h>
+#else
+// according to X/OPEN we have to define it ourselves
+union semun {
+ int val; // value for SETVAL
+ struct semid_ds *buf; // buffer for IPC_STAT, IPC_SET
+ wchar_t *array; // array for GETALL, SETALL
+ // Linux specific part:
+ struct seminfo *__buf; // buffer for IPC_INFO
+};
+#endif
+
+
+//
+// The Conduit class
+//
+class Conduit {
+
+public:
+
+ // Construct & Destruct
+ Conduit();
+ virtual ~Conduit();
+
+ // Server initialization
+ bool StartServer(KeyType* key);
+ // Client initialization
+ bool StartClient(KeyType* key);
+ // Detach and remove shared memory segment
+ bool Shutdown();
+
+ // Request lock on shared data
+ bool RequestLock();
+ // Release lock on shared data
+ bool ReleaseLock();
+
+ // Wait for a flag
+ WaitResult WaitForFlag(FlagType flag);
+ // Wait for a flag with timeout
+ WaitResult WaitForFlag(FlagType flag, int timeout);
+
+ // Wait for an event
+ WaitResult WaitForEvent(int index);
+ // Wait for an event with timeout [ms]
+ WaitResult WaitForEvent(int index, int timeout);
+ // Cause an event
+ bool CauseEvent(int index);
+ // Cause shutdown event
+ bool CauseShutdown();
+
+ // Get state flag
+ bool GetFlag(FlagType& flag);
+ // Set state flag
+ bool SetFlag(FlagType flag);
+
+ // Get shutdown boolean
+ bool GetShutdownFlag(bool& flag);
+ // Set shutdown boolean
+ bool SetShutdownFlag(bool flag);
+
+ //
+ // Pure virtual functions
+ //
+ // Get shared data size
+ virtual int GetDataSize() const = 0;
+ // Get number of events
+ virtual int GetNumEvents() const = 0;
+ // Get pointer to common shared data
+ virtual CommonData* GetCommonData() const = 0;
+
+protected:
+
+ // Pointer to shared memory segment
+ void* ptrShm;
+
+private:
+
+ // Wait-operation on a semaphore
+ bool Wait(int index);
+ // Wait-operation with timeout [ms] on a semaphore
+ bool Wait(int index, int timeout);
+ // Signal-operation on semaphore
+ bool Signal(int index);
+
+ // Indicate change of flag
+ bool IndicateChangedFlag();
+ // Wait for change of flag
+ bool WaitForChangedFlag();
+ // Wait for change with timeout of flag
+ bool WaitForChangedFlag(int timeout);
+ // Get and compare flag
+ bool FlagEqual(FlagType flag, FlagType& current);
+
+ // Check validity of semaphore index
+ bool ValidIndex(int index);
+ // Calculate number of semaphores
+ int NumberOfSemaphores();
+
+ // State flag
+ bool isServer;
+ // Number of semaphores
+ int iNumSems;
+
+ // WIN32 IPC: Shared memory based on file mapping.
+
+ // Shared memory segment handle
+ HANDLE hMapObject;
+ // Semaphore handle
+ HANDLE hSemaphore[MAX_NUM_SEM];
+
+};
+
+
+
+#endif /* CONDUIT_H_ */
diff --git a/Kod/display/ClientServerApp/Common/ReadABuffer.cpp b/Kod/display/ClientServerApp/Common/ReadABuffer.cpp
new file mode 100644
index 0000000..97bd9b5
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/ReadABuffer.cpp
@@ -0,0 +1,36 @@
+#include "ReadABuffer.h"
+
+BOOL ReadABuffer(unsigned char * lpBuf, DWORD dwToWrite, HANDLE hComm)
+{
+ OVERLAPPED osWrite = {0};
+ DWORD dwWritten;
+ BOOL fRes;
+
+ // Create this writes OVERLAPPED structure hEvent.
+ osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (osWrite.hEvent == NULL)
+ // Error creating overlapped event handle.
+ return FALSE;
+
+ // Issue write.
+ if (!ReadFile(hComm, lpBuf, dwToWrite, &dwWritten, &osWrite)) {
+ if (GetLastError() != ERROR_IO_PENDING) {
+ // WriteFile failed, but it isn't delayed. Report error and abort.
+ fRes = FALSE;
+ }
+ else {
+ // Write is pending.
+ if (!GetOverlappedResult(hComm, &osWrite, &dwWritten, TRUE))
+ fRes = FALSE;
+ else
+ // Write operation completed successfully.
+ fRes = TRUE;
+ }
+ }
+ else
+ // WriteFile completed immediately.
+ fRes = TRUE;
+
+ CloseHandle(osWrite.hEvent);
+ return fRes;
+} \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/Common/ReadABuffer.h b/Kod/display/ClientServerApp/Common/ReadABuffer.h
new file mode 100644
index 0000000..56cf400
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/ReadABuffer.h
@@ -0,0 +1,20 @@
+#ifndef READABUFFER_H
+#define READABUFFER_H
+
+#include <windows.h>
+#include "ipclink.h"
+
+
+BOOL ReadABuffer(unsigned char * lpBuf, DWORD dwToWrite, HANDLE hComm);
+
+
+
+
+
+
+
+
+
+
+
+#endif \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/Common/WriteABuffer.cpp b/Kod/display/ClientServerApp/Common/WriteABuffer.cpp
new file mode 100644
index 0000000..41ecf52
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/WriteABuffer.cpp
@@ -0,0 +1,67 @@
+
+
+#include "WriteABuffer.h"
+
+
+BOOL WriteABuffer(wchar_t* lpBuf, HANDLE hComm)
+{
+ OVERLAPPED osWrite = {0};
+ DWORD dwWritten;
+ BOOL fRes;
+
+ unsigned char printBuf[COMSTR_LEN];
+ unsigned char* ptrPrintBuf;
+ ptrPrintBuf = &printBuf[0];
+
+ int lenBuf = (int) lpBuf[1];
+ int ii;
+
+// printf("\tInteger: %d\n",lenBuf);
+
+// printf("\tLength of lpBuf: %d\n",wcslen(lpBuf));
+
+ for (ii=0; ii<lenBuf+EXTRA_LEN; ii++)
+ {
+ printBuf[ii] = (unsigned char) lpBuf[ii];
+// printf("\nWriteABuffer, variable printBuf[%d]: %d \n", ii, printBuf[ii]);
+ }
+ printBuf[ii] ='\0';
+// printf("\nWriteABuffer, variable printBuf[%d]: %d \n", ii, printBuf[ii]);
+
+
+
+
+
+
+ // Create this writes OVERLAPPED structure hEvent.
+ osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (osWrite.hEvent == NULL)
+ // Error creating overlapped event handle.
+ return FALSE;
+
+ // Issue write.
+// printf("\tNum to write: %i\n",dwToWrite);
+// if (!WriteFile(hComm, lpBuf, dwToWrite, &dwWritten, &osWrite)) {
+ if (!WriteFile(hComm, ptrPrintBuf, lenBuf+3, &dwWritten, &osWrite)) {
+ if (GetLastError() != ERROR_IO_PENDING) {
+ // WriteFile failed, but it isn't delayed. Report error and abort.
+ fRes = FALSE;
+ }
+ else {
+ // Write is pending.
+ if (!GetOverlappedResult(hComm, &osWrite, &dwWritten, TRUE))
+ fRes = FALSE;
+ else
+ // Write operation completed successfully.
+ fRes = TRUE;
+ }
+ }
+ else
+ // WriteFile completed immediately.
+ fRes = TRUE;
+
+ CloseHandle(osWrite.hEvent);
+ return fRes;
+}
+
+
diff --git a/Kod/display/ClientServerApp/Common/WriteABuffer.h b/Kod/display/ClientServerApp/Common/WriteABuffer.h
new file mode 100644
index 0000000..d34b7f7
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/WriteABuffer.h
@@ -0,0 +1,22 @@
+#ifndef WRITEABUFFER_H
+#define WRITEABUFFER_H
+
+#include <windows.h>
+#include <stdio.h>
+#include "ipclink.h"
+
+BOOL WriteABuffer(wchar_t * lpBuf, HANDLE hComm);
+
+BOOL ReadABuffer(wchar_t * lpBuf, DWORD dwToWrite, HANDLE hComm);
+
+
+
+
+
+
+
+
+
+
+
+#endif \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/Common/ipclink.h b/Kod/display/ClientServerApp/Common/ipclink.h
new file mode 100644
index 0000000..d62429e
--- /dev/null
+++ b/Kod/display/ClientServerApp/Common/ipclink.h
@@ -0,0 +1,80 @@
+/*
+ * ipclink.h
+ *
+ * Interface for the shared memory communication
+ *
+ * Author: Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+ * Modified: Emil Larsson, lime@isy.liu.se, 2012-01-13
+ */
+
+#ifndef IPCLINK_H_
+#define IPCLINK_H_
+
+// Include files for sleep-functions
+#include <windows.h>
+
+//
+// Shared data description
+//
+
+// Keys
+#define COM_KEY {3,1,4,6}
+
+// Define what is returned from wait operations
+typedef unsigned int WaitResult;
+#define WAIT_OK 0
+#define WAIT_FAIL 1
+#define WAIT_CLOSE 2
+
+// Definition of flags
+typedef unsigned int FlagType;
+#define NULL_FLAG 0
+
+// Exit flags
+#define EXIT_OK 0
+#define EXIT_FAIL 1
+
+//
+// COMMON DATA
+//
+typedef struct structCommonData {
+ FlagType Flag; // State flag
+ bool DoShutdown; // Shutdown flag
+} CommonData;
+
+//
+// Length of <DC1>, len, and bcc
+// see manual for "smallprotocol package".
+//
+#define EXTRA_LEN 3
+
+
+//
+// COM CONDUIT
+//
+// Maximum string length
+//#define COMSTR_LEN 512
+// EXTRA_LEN is included
+#define COMSTR_LEN 131
+
+
+
+// Shared memory structure
+typedef struct {
+ CommonData Common; // Common data
+ wchar_t string[COMSTR_LEN]; // Data string
+} COMdata;
+
+// Flags
+//#define COM_FLAG 0x01 // Example flag
+// Events
+#define COM_NEVENTS 2 // Number of events
+#define COM_READY 0 // Ready
+#define COM_REQUEST 1 // Request
+
+// Define sleep function
+#define msleep(t) Sleep(t)
+
+
+
+#endif /* IPCLINK_H_ */
diff --git a/Kod/display/ClientServerApp/Release/Client.exe b/Kod/display/ClientServerApp/Release/Client.exe
new file mode 100644
index 0000000..217d968
--- /dev/null
+++ b/Kod/display/ClientServerApp/Release/Client.exe
Binary files differ
diff --git a/Kod/display/ClientServerApp/Release/Server.exe b/Kod/display/ClientServerApp/Release/Server.exe
new file mode 100644
index 0000000..4974f18
--- /dev/null
+++ b/Kod/display/ClientServerApp/Release/Server.exe
Binary files differ
diff --git a/Kod/display/ClientServerApp/Release/matlabclient.mexw32 b/Kod/display/ClientServerApp/Release/matlabclient.mexw32
new file mode 100644
index 0000000..d309fef
--- /dev/null
+++ b/Kod/display/ClientServerApp/Release/matlabclient.mexw32
Binary files differ
diff --git a/Kod/display/ClientServerApp/Release/matlabclient.mexw64 b/Kod/display/ClientServerApp/Release/matlabclient.mexw64
new file mode 100644
index 0000000..e25873e
--- /dev/null
+++ b/Kod/display/ClientServerApp/Release/matlabclient.mexw64
Binary files differ
diff --git a/Kod/display/ClientServerApp/Release/startServer.bat b/Kod/display/ClientServerApp/Release/startServer.bat
new file mode 100644
index 0000000..2bcc5b9
--- /dev/null
+++ b/Kod/display/ClientServerApp/Release/startServer.bat
@@ -0,0 +1,15 @@
+@echo off
+rem
+rem Script to start modules
+rem
+
+rem
+rem 2007-09-04
+rem Erik Hellström, hellstrom@isy.liu.se.
+rem
+
+rem |
+rem | Start server
+rem |
+start "SERVER" cmd /C Server.exe -Pcom3
+
diff --git a/Kod/display/ClientServerApp/Server/Server.cpp b/Kod/display/ClientServerApp/Server/Server.cpp
new file mode 100644
index 0000000..7a7dc23
--- /dev/null
+++ b/Kod/display/ClientServerApp/Server/Server.cpp
@@ -0,0 +1,418 @@
+//============================================================================
+// Name : Server.cpp
+// Author : Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+// Modified : Emil Larsson, lime@isy.liu.se, 2012-01-13
+//
+// Description : The server sends data on request from the client. Will
+// loop until an error occurs or the client requests shutdown.
+//
+//============================================================================
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include "ComConduit.h"
+#include "WriteABuffer.h"
+#include "ReadABuffer.h"
+
+//
+// Show the command-line usage
+//
+void Usage(char* argv[]) {
+
+ printf("\nUsage: %s <optiona>\n\n",argv[0]);
+ printf(" -P=<port> Selects the COM port, ex: -Pcom1.\n");
+ printf("\n\n");
+}
+
+
+//
+// Module main function
+//
+int main(int argc, char* argv[]) {
+
+
+ // Conduit object
+ ComConduit Link;
+ // Key
+ KeyType key[KEY_LEN] = COM_KEY;
+ // Work variables
+ int i;
+ char c,*ptr;
+ wchar_t data[COMSTR_LEN];
+ wchar_t* ptrData = &data[0];
+
+ // Data that will be saved to the buffer
+ wchar_t dataFromLCD[COMSTR_LEN];
+ wchar_t* ptrDataFromLCD = &dataFromLCD[0];
+
+ FlagType ret;
+ unsigned char portnum;
+ char port[] = "COM1";
+ // LPCWSTR port[] = "COM1";
+ int counter=1;
+
+
+ DCB dcb;
+ COMMTIMEOUTS CommTimeouts;
+ HANDLE hCom;
+
+ WaitResult wr;
+
+ // Initialize data
+ portnum = '0';
+
+ //
+ // Parse the command-line.
+ //
+ for (i=1; i<argc; i++) {
+ ptr = argv[i];
+
+ while(*ptr == '-') // Step forward
+ ptr++;
+ c = *ptr; // Get option
+ ptr++;
+ if(*ptr == '=') // Step forward
+ ptr++;
+
+ switch(c) {
+
+ case 'P':
+ case 'p':
+ // Port selection
+ if(sscanf_s(ptr,"com%c",&portnum) == 1)
+ break;
+ if(sscanf_s(ptr,"COM%c",&portnum) == 1)
+ break;
+ Usage(argv);
+ return EXIT_FAIL;
+ }
+ }
+
+ // Check valid args
+ if(portnum == '0') {
+ Usage(argv);
+ return EXIT_FAIL;
+ }
+ port[3] = portnum;
+
+ // TESTKOD
+ printf("\nPort: %s\n", port);
+
+ // TESTKOD
+ // printf("\nPort: %s\n", port);
+
+ // Open COM port
+ hCom = CreateFile(port, // the port
+ GENERIC_READ | GENERIC_WRITE, // access rights
+ 0, // exclusive access
+ 0, // handle can no be inherited
+ OPEN_EXISTING, // creation disposition
+ 0, // not overlapped i/o
+ 0); // no template file
+ if(hCom == INVALID_HANDLE_VALUE) {
+ fprintf(stderr,"\nCan't open com port.\n");
+ return EXIT_FAIL;
+ }
+ //
+ // Configure port
+ //
+ // Get the current Device Control Block (DCB)
+ if(!GetCommState(hCom, &dcb)) {
+ fprintf(stderr,"\nCan't get com port settings.\n");
+ fprintf(stderr,"GetCommState failed with error %d.\n", GetLastError());
+ return EXIT_FAIL;
+ }
+ if(!GetCommTimeouts(hCom, &CommTimeouts)) {
+ fprintf(stderr,"\nCan't get com port time-out settings.\n");
+ fprintf(stderr,"GetCommTimeouts failed with error %d.\n", GetLastError());
+ return EXIT_FAIL;
+ }
+
+ // Print out Baud Rate
+// printf("\nBaud rate: %u\n", dcb.BaudRate);
+
+ // Fill in DCB
+ dcb.DCBlength = sizeof(DCB); // Length of dcb struct
+ // dcb.BaudRate = CBR_9600; // set the baud rate to 9600 bps
+ dcb.BaudRate = CBR_115200; // set the baud rate to 115200 bps
+ dcb.fBinary = TRUE; // binary mode
+ dcb.fParity = FALSE; // No parity check
+ dcb.fOutxCtsFlow = FALSE; // No CTS output flow control
+ dcb.fOutxDsrFlow = FALSE; // No DSR output flow control
+ dcb.fDtrControl = DTR_CONTROL_ENABLE; // DTR flow control type
+ dcb.fDsrSensitivity = FALSE; // DSR sensitivity
+ dcb.fTXContinueOnXoff = TRUE; // XOFF continues Tx
+ dcb.fOutX = FALSE; // No XON/XOFF out flow control
+ dcb.fInX = FALSE; // No XON/XOFF in flow control
+ dcb.fErrorChar = FALSE; // Disable error replacement
+ dcb.fNull = FALSE; // Disable null stripping
+ dcb.fRtsControl = RTS_CONTROL_ENABLE; // RTS flow control
+ dcb.fAbortOnError = FALSE; // Do not abort reads/writes on error
+ dcb.XonLim = 256; // max. bytes allowed in the queue
+ dcb.XoffLim = 256; // max. bytes in before XOFF
+ dcb.ByteSize = 8; // Number of bits/byte, 4-8
+ dcb.Parity = NOPARITY; // 0-4=no,odd,even,mark,space
+ dcb.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2
+ // Set DCB
+ if(!SetCommState(hCom, &dcb)) {
+ fprintf(stderr,"\nCan't configure com port.\n");
+ fprintf(stderr,"SetCommState failed with error %d.\n", GetLastError());
+ return EXIT_FAIL;
+ }
+
+ // Print out Baud Rate
+ printf("\nBaud rate: %u\n", dcb.BaudRate);
+
+
+
+ // Fill in CommTimeouts
+ CommTimeouts.ReadIntervalTimeout = 0;
+ CommTimeouts.ReadTotalTimeoutMultiplier = 0;
+ CommTimeouts.ReadTotalTimeoutConstant = 50;
+ CommTimeouts.WriteTotalTimeoutMultiplier = 0;
+ CommTimeouts.WriteTotalTimeoutConstant = 0;
+ // Set CommTimeouts
+ if(!SetCommTimeouts(hCom, &CommTimeouts)) {
+ fprintf(stderr,"\nCan't configure com port.\n");
+ fprintf(stderr,"SetCommTimeouts failed with error %d.\n", GetLastError());
+ return EXIT_FAIL;
+ }
+
+ // Start server
+ if(!Link.StartServer(key)) {
+ fprintf(stderr,"StartServer() failed.");
+ return EXIT_FAIL;
+ }
+
+
+ // Show that startup is done.
+ printf("\nStartup done.\n");
+
+ ret = EXIT_OK;
+ while(true) {
+ // Indicate that we are ready
+ if(!Link.CauseEvent(COM_READY)) {
+ fprintf(stderr,"CauseEvent() failed.\n");
+ ret = EXIT_FAIL;
+ break;
+ }
+
+ //
+ // Wait for data send request (from client)
+ //
+
+ wr = Link.WaitForEvent(COM_REQUEST);
+ // printf("\nTestar Skriva ut!\n");
+ if(wr != WAIT_OK) {
+ // Check if there was an error
+ // or if shutdown is requested
+
+ // Exit
+ if(wr == WAIT_CLOSE)
+ printf("\nShutdown requested.\n");
+ else {
+ fprintf(stderr,"\nLink error.\n");
+ ret = EXIT_FAIL;
+ }
+ break;
+ }
+
+ //printf("\nSend requested.\n");
+ //putchar('.'); fflush(stdout);
+
+ //
+ // Read data
+ //
+ // Get data
+
+ if(!Link.GetData(data)) {
+ fprintf(stderr,"GetData() failed.\n");
+ return EXIT_FAIL;
+ }
+
+ //
+ //
+ // For print out data in the consol
+ //
+ //
+ wchar_t consoleData[COMSTR_LEN];
+ wcscpy_s(&consoleData[0],COMSTR_LEN,&data[0]);
+
+
+
+ //printf("\tLength of printData: %d\n",wcslen(consoleData));
+ //
+ // Send data
+ //
+ // Output data
+ //printf("\tString: %ls\n",data);
+ // WriteABuffer(data,strlen(data),hCom);
+
+ //wchar_t test[] = {17,12,27,90,76,117,0,32,0,84,101,115,116,0,19,'\0'};
+ //wchar_t test[] = {17,3,27,68,76,191,'\0'};
+ // wchar_t* pa = &test[0];
+
+
+ int ii;
+
+ printf("After %d iteration(s), Content in Shared memory (before data \nis written to LCD buffer): \n",counter);
+ printf("[");
+ for (ii=0; ii < ptrData[1]+2; ii++)
+ {
+// ReadABuffer(ptr_readChar,1,hCom);
+ printf("%d, ", ptrData[ii]);
+// printf("After %d iteration(s), Content in Shared memory: %d, ",counter, dataFromLCD[ii]);
+ }
+ printf("%d]", ptrData[ii]);
+ printf("\n\n");
+
+
+ WriteABuffer(ptrData,hCom);
+
+ //printf("\tPrint Test String: %ls\n",test);
+ //printf("\tLength of data: %d\n",wcslen(test));
+
+
+
+ //
+ //
+ // Check if correct string was sent to the display
+ // If output is 0x06, data package was sent correct
+ //
+ const int DC1 = 17;
+ const int DC2 = 18;
+ int DC;
+ DC = (int) ptrData[0];
+
+ int readBufLen;
+ int printSHM = 1;
+
+// printf("Buffer nr: %d, \t<ACK>: %d\n",counter, DC);
+// printf("Buffer nr: %d, \t<ACK>: %d\n",counter, ptrData[1]);
+
+
+
+ unsigned char readChar[COMSTR_LEN];
+ unsigned char* ptr_readChar = &readChar[0];
+
+ int jj = 0;
+ if (DC == DC1){
+ readBufLen = 1;
+ ReadABuffer(ptr_readChar,readBufLen,hCom);
+ dataFromLCD[0] = 0;
+ dataFromLCD[1] = readBufLen;
+ dataFromLCD[2] = (wchar_t) ptr_readChar[0];
+ jj = 3;
+ }
+ else if (DC == DC2){
+ ReadABuffer(ptr_readChar,3,hCom);
+
+ dataFromLCD[2] = (wchar_t) ptr_readChar[0];
+ dataFromLCD[3] = (wchar_t) ptr_readChar[1];
+ dataFromLCD[4] = (wchar_t) ptr_readChar[2];
+ readBufLen = (int) ptr_readChar[2];
+
+ for (jj=0; jj < readBufLen+2; jj++){
+ ReadABuffer(ptr_readChar,1,hCom);
+ dataFromLCD[5+jj] = (wchar_t) ptr_readChar[0];
+ }
+ jj = jj+5;
+ dataFromLCD[0] = 0;
+ dataFromLCD[1] = readBufLen+4;
+ }
+ else{
+ printf("Data in Shared memory will not be written to the LCD buffer \nbecause the data package is not correct!!! \n\n");
+ printSHM = 0;
+ };
+
+ /* Stop with a "null" char */
+ dataFromLCD[jj] = (wchar_t) '\0';
+
+// unsigned char readChar;
+// unsigned char* ptr_readChar = &readChar;
+// ReadABuffer(ptr_readChar,20,hCom);
+
+
+ if (printSHM == 1){
+// printf("After %d iteration(s), Content in Shared memory (after LCD \nbuffer is written to the Shared memory): \n",counter);
+ printf("After %d iteration(s), Content in Shared memory (after LCD buffer is written):\n[",counter);
+ for (ii=2; ii < dataFromLCD[1]+1; ii++)
+ {
+ // ReadABuffer(ptr_readChar,1,hCom);
+ printf("%d, ", dataFromLCD[ii]);
+ // printf("After %d iteration(s), Content in Shared memory: %d, ",counter, dataFromLCD[ii]);
+ }
+ printf("%d]", dataFromLCD[ii]);
+ printf("\n\n");
+ }
+
+// ReadABuffer(ptr_readChar,10,hCom);
+
+// printf("\nSend buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[0]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[1]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[2]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[3]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[4]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[5]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[6]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[7]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[8]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n",counter, ptr_readChar[9]);
+// printf("Send buffer nr: %d, \t<ACK>: %d\n\n",counter, ptr_readChar[10]);
+
+ counter++;
+
+// int ii;
+// for (ii=0; ii < 10; ii++)
+// {
+//
+// // copy each element
+// dataFromLCD[ii] = (wchar_t) ptr_readChar[ii];
+//
+// }
+// /* Stop with a "null" char */
+// dataFromLCD[ii] = (wchar_t) '\0';
+
+
+ // Set data in shm
+ if(!Link.SetData(dataFromLCD)) {
+ fprintf(stderr,"SetData() failed.\n");
+ return EXIT_FAIL;
+ }
+
+
+ // printf("\t\n");
+ }
+
+
+
+
+ //
+ // Shutdown
+ //
+
+ // Close COM port
+ if(CloseHandle(hCom) == 0) {
+ fprintf(stderr,"\nCan't close com-port.\n");
+ ret = EXIT_FAIL;
+ }
+
+ // Tell eventual clients to shutdown
+ if(!Link.CauseShutdown()) {
+ fprintf(stderr,"\nCauseShutdown() failed.\n");
+ ret = EXIT_FAIL;
+ }
+ // Wait for clients to shutdown
+ msleep(500);
+ // Shutdown server
+ if(!Link.Shutdown()) {
+ fprintf(stderr,"Shutdown() failed.\n");
+ ret = EXIT_FAIL;
+ }
+ // Exit
+ if(ret == EXIT_OK)
+ fprintf(stdout, "\nClean exit.\n");
+
+ return ret;
+} \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/Server/Server.vcproj b/Kod/display/ClientServerApp/Server/Server.vcproj
new file mode 100644
index 0000000..2444780
--- /dev/null
+++ b/Kod/display/ClientServerApp/Server/Server.vcproj
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Server"
+ ProjectGUID="{7B05F65E-9D5F-49CE-9339-959759F4E98C}"
+ RootNamespace="Server"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;C:\Users\Emil\Documents\Visual Studio 2008\Projects\ClientServerApp\Common&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories=""
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\Server.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Kod/display/ClientServerApp/Server/Server.vcxproj b/Kod/display/ClientServerApp/Server/Server.vcxproj
new file mode 100644
index 0000000..2d8c7c2
--- /dev/null
+++ b/Kod/display/ClientServerApp/Server/Server.vcxproj
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{7B05F65E-9D5F-49CE-9339-959759F4E98C}</ProjectGuid>
+ <RootNamespace>Server</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>"..\Common";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>"..\Common";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="Server.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Common\Common.vcxproj">
+ <Project>{8c1e78f5-0564-498a-958d-37a997bbfe49}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/matlabClient/matlabClient.cpp b/Kod/display/ClientServerApp/matlabClient/matlabClient.cpp
new file mode 100644
index 0000000..8f811b9
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/matlabClient.cpp
@@ -0,0 +1,400 @@
+//============================================================================
+// Name : matlabClient.cpp
+// Author : Erik Hellström, hellstrom@isy.liu.se, 2008-12-14
+// Modified : Emil Larsson, lime@isy.liu.se, 2012-01-13
+// Modified : Emil Larsson, lime@isy.liu.se, 2012-09-04
+// Data from LCD is written to the shared memory. By request, the
+// data is copied to a local Matlab variable.
+//
+// Description : The client requests data to be sent by the server.
+//
+//============================================================================
+
+
+#include <stdio.h>
+#include <string>
+#include "ComConduit.h"
+//#ifdef _CHAR16T
+//#define CHAR16_T
+//#endif
+#include "mex.h"
+
+int send_communication(bool doShutdown,wchar_t* input_string,int buflen,int flag){
+ // Conduit object
+ ComConduit Link;
+ // Key
+ KeyType key[KEY_LEN] = COM_KEY;
+ // Work variables
+ wchar_t data[COMSTR_LEN];
+ wchar_t dataFromLCD[COMSTR_LEN];
+ WaitResult wr;
+
+ int retval, ii;
+
+
+ // Initialize data
+ retval = 0;
+ data[0] = '\0';
+
+ // strcpy((char*) data,input_string);
+ // wcscpy_s(&data[0],COMSTR_LEN, input_string);
+
+ /* Copy data from input_string to data */
+ for (ii=0; ii<input_string[1]+3; ii++)
+ {
+ data[ii] = input_string[ii];
+ // mexPrintf("\ndata[%d]: %d \n", ii, *((unsigned char*) &data[ii]));
+ }
+
+ /* Stop with a "null" char */
+ data[ii] = '\0';
+
+
+
+ /* Start client */
+ if(!Link.StartClient(key)) {
+ mexPrintf("StartClient() failed.\n");
+ retval = 1;
+ return retval;
+ }
+
+ if(doShutdown) {
+ mexPrintf("Shutdown requested!!.\n");
+ // Request shutdown
+ if(!Link.CauseShutdown()) {
+ mexPrintf("\nCauseShutdown() failed.\n");
+ retval = 1;
+ return retval;
+ }
+ }
+ else if (flag == 2){
+
+ /* Get data from shared memory */
+ if(!Link.GetData(dataFromLCD)) {
+ mexPrintf("GetData() failed.\n");
+ retval = 1;
+ }
+
+ /* Length of Buffer */
+ int lenBuf = (int) dataFromLCD[1];
+
+ for (ii=0; ii < lenBuf+3; ii++){
+ /* Copy data from temporary string */
+ input_string[ii] = dataFromLCD[ii];
+ // mexPrintf("\ndataFromLCD[%d]: %d \n", ii, input_string[ii]);
+
+ };
+ }
+ else {
+ do {
+ // Check if server is ready
+ wr = Link.WaitForEvent(COM_READY,0);
+ if(wr != WAIT_OK) {
+ mexPrintf("Server is not ready. Start the server application.\n");
+ retval = 2;
+ break;
+ }
+
+ // Set data in shm
+ if(!Link.SetData(data)) {
+ mexPrintf("SetData() failed.\n");
+ retval = 1;
+ break;
+ }
+
+
+ // Request that the server send the data
+ if(!Link.CauseEvent(COM_REQUEST)) {
+ mexPrintf("CauseEvent() failed.\n");
+ retval = 1;
+ break;
+ }
+ } while(false);
+ }
+
+ //
+ // Shutdown
+ //
+ if(!Link.Shutdown()) {
+ mexPrintf("Shutdown() failed.\n");
+ retval = 1;
+ }
+ return retval;
+}
+
+
+void mexFunction( int nlhs,mxArray* plhs[],int nrhs, const mxArray* prhs[] )
+{
+ /* Version */
+ const double ver = 1.00;
+ const char date[] = "9 November 2012";
+
+ /* Initialize data */
+ bool doShutdown;
+ int retval;
+ mwSize ii, nx, mx, n;
+ doShutdown = false;
+ retval = 0;
+
+ wchar_t x_short_w[COMSTR_LEN];
+
+ /* checksum */
+ unsigned char bcc=0;
+
+ /* pointer to input string */
+// double dummy;
+ double *prtData;
+
+ /* Save in Shared memory */
+ int saveInSHM = 1;
+
+ /* Input flag: 1 = send to display, 2 = receive from display, 3 = shutdown */
+ int flag = 10;
+ if (nrhs > 0){
+ flag = (int)*mxGetPr(prhs[0]);
+ };
+
+ plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
+ // ptr_out = mxGetPr(plhs[1]);
+
+ //if( (nrhs < 4) && (nrhs > 0)){
+ // flag = (int)*mxGetPr(prhs[0]);
+ //};
+
+
+
+ if(flag==3){
+ /* If no error, call send_communication */
+ doShutdown = true;
+ }
+
+ /* Do some checks of input arguments */
+ if (nrhs > 0){
+ if (!mxIsDouble(prhs[0])) {
+ mexPrintf("\nThe first input argument is not a double.\n");
+ retval = 1;
+ }
+ else if (flag==4) {
+ mexPrintf("\nMatlab Client\n");
+ mexPrintf("=============\n");
+ mexPrintf("Version: %4.2f.\n", ver);
+ mexPrintf("Date: %s.\n", date);
+ retval = 4;
+ }
+ else if (!(mxGetN(prhs[0]) == 1) || !(mxGetM(prhs[0]) == 1)) {
+ mexPrintf("\nThe first input argument is not a scalar.\n");
+ retval = 1;
+ }
+ else if (!(flag == 1 || flag == 2 || flag == 3)) {
+ mexPrintf("\nWrong numerical value of the first argument.\n");
+ retval = 1;
+ }
+ else if (flag == 1 && nrhs < 2) {
+ mexPrintf("\nTo few input arguments.\n");
+ retval = 1;
+ }
+ }
+ else{
+ mexPrintf("\nTo few input arguments\n");
+ retval = 1;
+ }
+
+ if (nrhs > 1){
+ if (!(flag == 1) || !mxIsDouble(prhs[1])) {
+ mexPrintf("\nFirst and second argument mismatch.\n");
+ flag = 1;
+ retval = 1;
+ }
+ // if (!mxIsDouble(prhs[1])) {
+ // retval = 1;
+ // mexPrintf("The second argument is not a double vector.\n");
+ // }
+ }
+
+ if (nrhs > 2){
+ mexPrintf("\nTo many input arguments\n");
+ retval = 1;
+ }
+
+
+ /* Save output argument */
+ if ((retval == 1) || (retval == 4)){
+ plhs[0] = mxCreateDoubleMatrix(1,1, mxREAL);
+ *(mxGetPr(plhs[0])) = retval;
+ }
+
+
+
+ if ((nrhs > 0) && (retval == 0)){
+ /* Get the length of the input string. */
+ // buflen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
+
+ // mexPrintf("\nbuflen: %d \n", buflen);
+
+
+ /* Allocate memory for input and output strings. */
+ // input_buf=(char *) mxCalloc(buflen, sizeof(char));
+ // external_buf=(wchar_t *) mxCalloc(buflen+1, sizeof(wchar_t));
+
+ /* Copy the string data from prhs[0] into a C string
+ * input_buf. */
+ // status = mxGetString(prhs[0], input_buf, buflen);
+
+ // if (status != 0)
+ // mexWarnMsgTxt("Not enough space. String will be truncated.");
+
+
+ // unsigned char *start_of_pr;
+ // size_t bytes_to_copy;
+
+
+ /* get the length of the input vector and pointer to data*/
+ if (nrhs > 1) {
+ nx = mxGetN(prhs[1]);
+ mx = mxGetM(prhs[1]);
+ prtData = mxGetPr(prhs[1]);
+ }
+ else {
+ nx = 1;
+ mx = 1;
+ prtData = mxGetPr(prhs[0]);
+ }
+
+
+ /* check if the argument is a row or col vector */
+ if (nx > mx)
+ n = nx;
+ else
+ n = mx;
+
+
+ /* Check length of buffer */
+ if ((n > COMSTR_LEN) && (retval == 0) && (nrhs > 1)){
+ mexPrintf("\nToo long data package.\n");
+ retval = 1;
+ }
+ else if ((n < 4) && (retval == 0) && (nrhs > 1)) {
+ mexPrintf("\nToo short data package.\n");
+ retval = 1;
+ }
+
+ /* Check length of data package */
+ if ((int) prtData[1] != n-3 && (nrhs > 1)) {
+ mexPrintf("\nIncorrect data package.\n");
+ retval = 1;
+ }
+ /* Check if the package starts with DC1 or DC2 */
+ else if (((int) prtData[0] != 17) && ((int) prtData[0] != 18) && (nrhs > 1)) {
+ mexPrintf("\nIncorrect data package.\n");
+// mexPrintf("\nIncorrect data package. %d\n", (int) prtData[0]);
+ retval = 1;
+ }
+
+ /* Copy the double input vector to a wchar_t-string */
+ unsigned short int x_short[COMSTR_LEN];
+ ii = 0;
+ for (ii=0; ii < n; ii++)
+ {
+ x_short[ii] = (unsigned short int) prtData[ii];
+
+ /* Calculate checksum bcc */
+ if (ii < n-1)
+ bcc = bcc + x_short[ii];
+
+ /* Check if the element is too large */
+ if((x_short[ii] > 255) && (retval == 0)) {
+ mexPrintf("Vector element %d is larger then 255.\n", ii+1);
+ retval = 1;
+ break;
+ }
+
+ /* Copy each element */
+ x_short_w[ii] = (wchar_t) x_short[ii];
+ // mexPrintf("\nx_short[%d]: %d \n", ii, x_short[ii]);
+
+ }
+ /* Stop with a "null" char */
+ x_short_w[ii] = (wchar_t) '\0';
+
+ /* Compare the checksum bcc with the last element */
+ if ((x_short[n-1] != bcc) && (retval == 0) && (nrhs > 1)) {
+ mexPrintf("\nIncorrect data package.\n");
+ // mexPrintf("\nChecksum %d mismatch. \n", x_short[n-1]);
+ //printf("\nChecksum %d mismatch. \n", x_short[n-1]);
+ retval = 1;
+ }
+
+ /* If no error, call send_communication */
+ if (retval == 0){
+ retval = send_communication(doShutdown,x_short_w,n,flag);
+ }
+
+ /* Save output argument */
+ plhs[0] = mxCreateDoubleMatrix(1,1, mxREAL);
+ *(mxGetPr(plhs[0])) = retval;
+
+ /* Receive data from shared memory */
+ if (flag == 2){
+
+ /* Length of Buffer */
+ int lenBuf = (int) x_short_w[1];
+
+ //mexPrintf("\nHere: lenBuf %d: \n", lenBuf);
+
+ /* Save in Shared memory */
+ // int saveInSHM = 1;
+
+ if ((x_short_w[1] == 1) && (x_short_w[2])){
+ saveInSHM = 1;
+ }
+ else if ((x_short_w[1] == 1) && (x_short_w[2] == 21)){
+ saveInSHM = 1;
+ }
+ else {
+ /* calculate checksum */
+ bcc = 0;
+ for (ii=3; ii < (mwSize) x_short_w[4]+5; ii++){
+
+ /* Calculate checksum bcc */
+ bcc = bcc + x_short_w[ii];
+ }
+// mexPrintf("\nHere: Checksum bcc %d: \n", bcc);
+
+ /* Compare the checksum bcc with the last element */
+ if (x_short_w[ii] != bcc){
+// mexPrintf("\nHere: Checksum %d mismatch. \n", x_short_w[lenBuf+1]);
+ retval = 1;
+
+ saveInSHM = 0;
+ }
+ else {
+ saveInSHM = 1;
+ }
+ }
+
+
+
+ if (saveInSHM == 1){
+
+ /* Save output argument */
+ double *ptr_out;
+ plhs[1] = mxCreateDoubleMatrix(1,lenBuf,mxREAL);
+ ptr_out = mxGetPr(plhs[1]);
+
+ for (ii=2; ii < (mwSize) lenBuf+2; ii++){
+ ptr_out[ii-2] = (double) x_short_w[ii];
+ // mexPrintf("\nx_short_w[%d]: %f \n", ii, ptr_out[ii-1]);
+ }
+ }
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
diff --git a/Kod/display/ClientServerApp/matlabClient/matlabClient.vcproj b/Kod/display/ClientServerApp/matlabClient/matlabClient.vcproj
new file mode 100644
index 0000000..336b1f0
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/matlabClient.vcproj
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="matlabClient"
+ ProjectGUID="{3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}"
+ RootNamespace="matlabClient"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;C:\Program Files (x86)\MATLAB\R2009b\extern\include&quot;;&quot;C:\Users\Emil\Documents\Visual Studio 2008\Projects\ClientServerApp\Common&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\matlabClient.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Kod/display/ClientServerApp/matlabClient/matlabClient.vcxproj b/Kod/display/ClientServerApp/matlabClient/matlabClient.vcxproj
new file mode 100644
index 0000000..715e944
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/matlabClient.vcxproj
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{3094F281-B0A8-4B46-B1CC-A4B8B5CC596A}</ProjectGuid>
+ <RootNamespace>matlabClient</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>NotSet</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>C:\Program Files %28x86%29\MATLAB\R2011b\extern\include;C:\stuff\svn\TFYY51\Code\Display\ClientServerApp\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>C:\Program Files %28x86%29\MATLAB\R2011b\extern\include;C:\stuff\svn\TFYY51\Code\Display\ClientServerApp\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>C:\Program Files %28x86%29\MATLAB\R2011b\extern\include;..\Common</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>C:\Program Files %28x86%29\MATLAB\R2011b\extern\include;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>C:\Program Files\MATLAB\R2011b\extern\include;..\Common</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalLibraryDirectories>C:\Program Files %28x86%29\MATLAB\R2011b\extern\include;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="matlabClient.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Common\Common.vcxproj">
+ <Project>{8c1e78f5-0564-498a-958d-37a997bbfe49}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Kod/display/ClientServerApp/matlabClient/stdafx.cpp b/Kod/display/ClientServerApp/matlabClient/stdafx.cpp
new file mode 100644
index 0000000..1d98a62
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// matlabClient.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/Kod/display/ClientServerApp/matlabClient/stdafx.h b/Kod/display/ClientServerApp/matlabClient/stdafx.h
new file mode 100644
index 0000000..47a0d02
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/Kod/display/ClientServerApp/matlabClient/targetver.h b/Kod/display/ClientServerApp/matlabClient/targetver.h
new file mode 100644
index 0000000..a38195a
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabClient/targetver.h
@@ -0,0 +1,13 @@
+#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
diff --git a/Kod/display/ClientServerApp/matlabMake.bat b/Kod/display/ClientServerApp/matlabMake.bat
new file mode 100644
index 0000000..3ee0c82
--- /dev/null
+++ b/Kod/display/ClientServerApp/matlabMake.bat
@@ -0,0 +1,16 @@
+rem
+rem Run to make the mex-file
+rem
+
+rem
+rem Run first mex -setup for x86 architecture, i.e., in
+rem directory: "C:\Program Files (x86)\MATLAB\R2011b\bin"
+rem
+
+rem C:\PROGRA~2\MATLAB\R2011b\bin\mex matlabClient\Debug\matlabclient.obj Common\Release\Conduit.obj Common\Release\ComConduit.obj Common\Release\WriteABuffer.obj -outdir Release\
+
+C:\PROGRA~1\MATLAB\R2011b\bin\mex matlabClient\Release\matlabclient.obj Common\Release\Conduit.obj Common\Release\ComConduit.obj Common\Release\WriteABuffer.obj -outdir Release\
+
+
+rem
+rem move matlabClient\matlabclient.mexw32 Release \ No newline at end of file