diff --git a/ACT/LibMC.xml b/ACT/LibMC.xml index ac20f26d..a3c0f058 100644 --- a/ACT/LibMC.xml +++ b/ACT/LibMC.xml @@ -244,7 +244,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -271,19 +315,46 @@ - + + + + + + + + + + + + + + + + + + - - + + + - - + + + - + + + + + + + + + @@ -318,17 +389,12 @@ - + - + + - - - - - - - + diff --git a/ACT/LibMCData.xml b/ACT/LibMCData.xml index 3972474e..43d010f9 100644 --- a/ACT/LibMCData.xml +++ b/ACT/LibMCData.xml @@ -231,10 +231,51 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -259,8 +300,18 @@ + - + + + + + + + + + + @@ -314,10 +365,6 @@ - - - - @@ -394,10 +441,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -412,6 +499,10 @@ + + + + @@ -419,12 +510,51 @@ + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -440,7 +570,7 @@ - + diff --git a/ACT/LibMCDriverEnv.xml b/ACT/LibMCDriverEnv.xml index 0ec32a83..68e2835e 100644 --- a/ACT/LibMCDriverEnv.xml +++ b/ACT/LibMCDriverEnv.xml @@ -60,14 +60,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + @@ -77,6 +144,7 @@ + diff --git a/ACT/LibMCEnv.xml b/ACT/LibMCEnv.xml index f4abe3c7..be848d4d 100644 --- a/ACT/LibMCEnv.xml +++ b/ACT/LibMCEnv.xml @@ -65,14 +65,26 @@ + + + + + + + + + + + - + + @@ -93,6 +105,17 @@ + + + + + + + + + + + @@ -101,7 +124,15 @@ - + + + + + + + + + @@ -109,8 +140,8 @@ - - + + @@ -121,10 +152,61 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -152,6 +234,11 @@ + + + + + @@ -172,6 +259,11 @@ + + + + + @@ -213,6 +305,12 @@ + + + + + + @@ -233,6 +331,11 @@ + + + + + @@ -253,7 +356,7 @@ - + @@ -277,27 +380,14 @@ - - - - - - + + + - - - - - - - - - - @@ -330,6 +420,11 @@ + + + + + @@ -355,6 +450,11 @@ + + + + + @@ -386,6 +486,12 @@ + + + + + + @@ -410,6 +516,12 @@ + + + + + + diff --git a/ACT/act.exe b/ACT/act.exe index 7a1d9a6a..ae2b8f1e 100644 Binary files a/ACT/act.exe and b/ACT/act.exe differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 70fe7907..07a8fcb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ project(LibMC) add_subdirectory(Drivers) add_subdirectory(Plugins) -set (CMAKE_CXX_STANDARD 11) +set (CMAKE_CXX_STANDARD 14) # The location of autogenerated interfaces set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Framework/InterfacesCore) @@ -59,6 +59,10 @@ file(GLOB LIBMC_SRC_API ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/API/*.cpp ) +file(GLOB LIBMC_SRC_UI + ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/UI/*.cpp +) + file(GLOB LIBMC_SRC_LIBMC ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/LibMC/*.cpp ${CMAKE_CURRENT_AUTOGENERATED_DIR}/libmc_interfaceexception.cpp @@ -91,6 +95,7 @@ file(GLOB LIBMC_SRC_DEP_CROSSGUID source_group("core" FILES ${LIBMC_SRC_CORE}) source_group("common" FILES ${LIBMC_SRC_COMMON}) source_group("api" FILES ${LIBMC_SRC_API}) +source_group("ui" FILES ${LIBMC_SRC_UI}) source_group("libmc" FILES ${LIBMC_SRC_LIBMC}) source_group("libmcenv" FILES ${LIBMC_SRC_LIBMCENV}) source_group("libmcdriverenv" FILES ${LIBMC_SRC_LIBMCDRIVERENV}) @@ -104,6 +109,7 @@ set(LIBMC_SRC ${LIBMC_SRC_CORE} ${LIBMC_SRC_COMMON} ${LIBMC_SRC_API} + ${LIBMC_SRC_UI} ${LIBMC_SRC_LIBMC} ${LIBMC_SRC_LIBMCENV} ${LIBMC_SRC_LIBMCDRIVERENV} @@ -123,12 +129,15 @@ set_target_properties(libmc PROPERTIES VISIBILITY_INLINES_HIDDEN ON) # This makes sure symbols are exported target_compile_options(libmc PRIVATE "-D__LIBMC_EXPORTS") +target_compile_options(libmc PRIVATE "-D__GITHASH=${GLOBALGITHASH}") target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_HEADERS_CORE_DIR}) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_HEADERS_DEV_DIR}) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation) +target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/API) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/Core) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/Common) +target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/UI) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/LibMC) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/LibMCEnv) target_include_directories(libmc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/LibMCDriverEnv) @@ -188,10 +197,15 @@ set_target_properties(libmcdata PROPERTIES VISIBILITY_INLINES_HIDDEN ON) if(WIN32) target_link_libraries(libmcdata ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/SQLite/sqlite3.lib) +elseif(UNIX AND NOT APPLE) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Libraries/SQLite) +target_link_libraries(libmcdata SQLite3) endif() # This makes sure symbols are exported target_compile_options(libmcdata PRIVATE "-D__LIBMCDATA_EXPORTS") +target_compile_options(libmcdata PRIVATE "-D__GITHASH=${GLOBALGITHASH}") + target_include_directories(libmcdata PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) target_include_directories(libmcdata PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/SQLite) target_include_directories(libmcdata PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries) diff --git a/Client/src/App.vue b/Client/src/App.vue index ed847e46..985d184e 100644 --- a/Client/src/App.vue +++ b/Client/src/App.vue @@ -1,924 +1,280 @@ - - - - - - - - - - {{ item.text }} - - - - - - - {{ child.icon }} - - - - {{ child.text }} - - - - - - - - {{ item.icon }} - - - - {{ item.text }} - - - - - - - - - - - - - {{ uiButtonCaptionCheck (UI.textApplicationName) }} - - - - - - - - mdi-factory{{ uiButtonCaptionCheck ("Builds") }} - - - mdi-speedometer{{ uiButtonCaptionCheck ("Status") }} - - - mdi-message-text{{ uiButtonCaptionCheck ("Logs") }} - - - mdi-settings{{ uiButtonCaptionCheck ("Settings") }} - - - - - - - - - - - - - - - - {{ UI.textApplicationName }} - - - - - - - - - - mdi-loginLogin - - - - - - - - - - - - - - - - Home - - - - - - - - - - - - - - Builds - - - - - - Drag your build file here to begin or click to browse - - - Uploading {{ fileCount }} files... - - - - - - - - - - - - - - - - - - - - Machine Status - - - - - - - - - - Subsystems - - - - - - - - {{ instance.description }} - - - - - - - - - - - - - - - - - - - - - - {{ Data.instanceMap[this.UI.activeSubPage].description }}: {{ UI.activePageStatus }} - - - - - - - mdi-refresh - Draw Graph - - - - - - - - - - - - - - - Settings - - - - - - - - - - - - - - - Logs - - - - - - - - - - - - - Could not retrieve machine logs! - - - - - - - - - - mdi-download - Download - - - mdi-refresh - Reload - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - © {{ UI.textCopyRight }} - - - + + + + + + + + + {{ item.caption }} + + + + + + + {{ child.icon }} + + + + {{ child.text }} + + + + + + + + {{ item.icon }} + + + + {{ item.caption }} + + + + + + + + + + + {{ uiButtonCaptionCheck(AppDefinition.TextApplicationName) }} + + + + + + + {{ toolbaritem.icon }}{{ uiButtonCaptionCheck(toolbaritem.caption) }} + + + + + + + + + + + + + + + + + {{ AppDefinition.TextApplicationName }} + + + + + + + + + + + mdi-loginLogin + + + + + + + + + + + + + Fatal error + + + Could not connect to server. Please try again later! + + + + + mdi-refreshReload page + + + + + + + + + + + + + © {{ AppDefinition.TextCopyRight }} + + - - + API: { + baseURL: "/api" + }, + AppDefinition: { + TextApplicationName: "", + TextCopyRight: "", + MainPage: "", + PageDefinitions: {}, + ToolbarItems: [], + MenuItems: [] + }, + AppState: { + currentStatus: "initial", // one of "initial" / "login" / "ready" / "error" + currentError: "", + showDrawer: true, + activePage: "", + globalTimer: "", + + uiLoginUser: "", + uiLoginPassword: "" + } + }) +}; + \ No newline at end of file +} + diff --git a/Client/src/plugins/vuetify.js b/Client/src/plugins/vuetify.js index ec46adba..e13aae32 100644 --- a/Client/src/plugins/vuetify.js +++ b/Client/src/plugins/vuetify.js @@ -1,7 +1,9 @@ import Vue from 'vue'; import Vuetify from 'vuetify/lib'; +//import colors from 'vuetify/lib/util/colors' Vue.use(Vuetify); export default new Vuetify({ + }); diff --git a/Drivers/CMakeLists.txt b/Drivers/CMakeLists.txt index 49a6a956..d72db5aa 100644 --- a/Drivers/CMakeLists.txt +++ b/Drivers/CMakeLists.txt @@ -19,4 +19,5 @@ project("AMCDrivers") add_subdirectory(ScanLab) add_subdirectory(Marlin) +add_subdirectory(Camera) diff --git a/Drivers/Camera/ACT/LibMCDriver_Camera.xml b/Drivers/Camera/ACT/LibMCDriver_Camera.xml new file mode 100644 index 00000000..0ca3f36e --- /dev/null +++ b/Drivers/Camera/ACT/LibMCDriver_Camera.xml @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Drivers/Camera/ACT/generateInterfaces.bat b/Drivers/Camera/ACT/generateInterfaces.bat new file mode 100644 index 00000000..48594f6f --- /dev/null +++ b/Drivers/Camera/ACT/generateInterfaces.bat @@ -0,0 +1,3 @@ +..\..\..\ACT\act.exe LibMCDriver_Camera.xml -bindings ..\Headers -interfaces ..\Interfaces -suppresssubcomponents -suppresslicense -suppressstub -suppressexamples + +pause \ No newline at end of file diff --git a/Drivers/Camera/CMakeLists.txt b/Drivers/Camera/CMakeLists.txt new file mode 100644 index 00000000..57df25bd --- /dev/null +++ b/Drivers/Camera/CMakeLists.txt @@ -0,0 +1,126 @@ +#[[++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +]] + + +cmake_minimum_required(VERSION 3.5) + +########################################################################################## +### Change the next line for making a new driver +########################################################################################## + +set (DRIVERPROJECT Camera) + +########################################################################################## +### generic CMake boilerplate code +########################################################################################## + +project(LibMCDriver_${DRIVERPROJECT}) + +string(TOLOWER ${DRIVERPROJECT} DRIVERSUFFIX) +string(TOUPPER ${DRIVERPROJECT} DRIVERSUFFIX_UPPER) + +set (DRIVERNAME libmcdriver_${DRIVERSUFFIX}) + +set (EXPORTFLAG __LIBMCDRIVER_${DRIVERSUFFIX_UPPER}_EXPORTS) + +set (CMAKE_CXX_STANDARD 14) + +# The location of autogenerated interfaces +set(CMAKE_CURRENT_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Framework/HeadersDev/CppDynamic) +set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Framework/InterfacesDev) +set(CMAKE_CURRENT_OUTPUT_DIR ${PROJECT_BINARY_DIR}/../../Output) + +file(STRINGS ${PROJECT_BINARY_DIR}/../../githash.txt GLOBALGITHASH) +message(STATUS "Global git hash: \"${GLOBALGITHASH}\"") + + +file(GLOB LIBMCDRIVER_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/serial/*.cc +) + +add_library(${DRIVERNAME} SHARED ${LIBMCDRIVER_SRC}) +# Do not prefix the binary's name with "lib" on Unix systems: +set_target_properties(${DRIVERNAME} PROPERTIES PREFIX "" IMPORT_PREFIX "" ) +# The following two properties are crucial to reduce the number of undesirably exported symbols +set_target_properties(${DRIVERNAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) +set_target_properties(${DRIVERNAME} PROPERTIES VISIBILITY_INLINES_HIDDEN ON) +# This makes sure symbols are exported +target_compile_options(${DRIVERNAME} PRIVATE "-D${EXPORTFLAG}") +target_compile_options(${DRIVERNAME} PRIVATE "-D__LIBMCDRIVER_EXPORTS") +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_HEADER_DIR}) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) + +set_target_properties(${DRIVERNAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_OUTPUT_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + VS_DEBUGGER_COMMAND "${CMAKE_CURRENT_OUTPUT_DIR}/amc_server.exe" + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + OUTPUT_NAME "${GLOBALGITHASH}_driver_${DRIVERSUFFIX}" +) + + +########################################################################################## +### Copy driver header files +########################################################################################## + +file (GLOB headerfiles LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}/Headers/CppDynamic/*.h*") +foreach(headerfile ${headerfiles}) + + get_filename_component(headerfilename ${headerfile} NAME) + + add_custom_command( + TARGET ${DRIVERNAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "copying ${headerfile}...") + + add_custom_command( + TARGET ${DRIVERNAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${headerfile} + ${CMAKE_CURRENT_BINARY_DIR}/../../DevPackage/Framework/HeadersDriver/CppDynamic/${headerfilename}) + + +endforeach() + + +########################################################################################## +### Add custom code below +########################################################################################## + + + + diff --git a/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_abi.hpp b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_abi.hpp new file mode 100644 index 00000000..305af7ff --- /dev/null +++ b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_abi.hpp @@ -0,0 +1,361 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_HEADER_CPP +#define __LIBMCDRIVER_CAMERA_HEADER_CPP + +#ifdef __LIBMCDRIVER_CAMERA_EXPORTS +#ifdef _WIN32 +#define LIBMCDRIVER_CAMERA_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBMCDRIVER_CAMERA_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBMCDRIVER_CAMERA_EXPORTS +#define LIBMCDRIVER_CAMERA_DECLSPEC +#endif // __LIBMCDRIVER_CAMERA_EXPORTS + +#include "libmcdriver_camera_types.hpp" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getname(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameBufferSize, LibMCDriver_Camera_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_gettype(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nTypeBufferSize, LibMCDriver_Camera_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getversion(LibMCDriver_Camera_Driver pDriver, LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro, const LibMCDriver_Camera_uint32 nBuildBufferSize, LibMCDriver_Camera_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getheaderinformation(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameSpaceBufferSize, LibMCDriver_Camera_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_Camera_uint32 nBaseNameBufferSize, LibMCDriver_Camera_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_movenext(LibMCDriver_Camera_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_moveprevious(LibMCDriver_Camera_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_getcurrent(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_clone(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Iterator * pOutIterator); + +/** +* Returns the number of resources the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_count(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for PNGImage +**************************************************************************************************************************/ + +/** +* Returns width of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pWidth - width of the image in pixels. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getwidth(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pWidth); + +/** +* Returns height of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pHeight - height of the image in pixels. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getheight(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pHeight); + +/** +* Returns pixel format of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pPixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getpixelformat(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera::eImagePixelFormat * pPixelformat); + +/** +* Returns raw data of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nPNGDataBufferSize - Number of elements in buffer +* @param[out] pPNGDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPNGDataBuffer - uint8 buffer of Binary data of PNG image captured. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getrawdata(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer); + +/** +* Saves PNG Image on Disk. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nFileNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFileNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFileNameBuffer - buffer of Filename to save PNG to., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_savetofile(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint32 nFileNameBufferSize, LibMCDriver_Camera_uint32* pFileNameNeededChars, char * pFileNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_Camera +**************************************************************************************************************************/ + +/** +* Captures an image from the camera and returns a PNG image. +* +* @param[in] pDriver_Camera - Driver_Camera instance. +* @param[out] pPNGImage - Instance of the PNG Image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_camera_capturepngimage(LibMCDriver_Camera_Driver_Camera pDriver_Camera, LibMCDriver_Camera_PNGImage * pPNGImage); + +/************************************************************************************************************************* + Class definition for RaspiCameraDevice +**************************************************************************************************************************/ + +/** +* Returns path to the camera device. +* +* @param[in] pRaspiCameraDevice - RaspiCameraDevice instance. +* @param[in] nDeviceStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pDeviceStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDeviceStringBuffer - buffer of Path to camera device., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_raspicameradevice_getdevicestring(LibMCDriver_Camera_RaspiCameraDevice pRaspiCameraDevice, const LibMCDriver_Camera_uint32 nDeviceStringBufferSize, LibMCDriver_Camera_uint32* pDeviceStringNeededChars, char * pDeviceStringBuffer); + +/************************************************************************************************************************* + Class definition for RaspiCameraDeviceIterator +**************************************************************************************************************************/ + +/** +* Returns the camera device the iterator points at. +* +* @param[in] pRaspiCameraDeviceIterator - RaspiCameraDeviceIterator instance. +* @param[out] pCurrentInstance - returns the camera device instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_raspicameradeviceiterator_getcameradevice(LibMCDriver_Camera_RaspiCameraDeviceIterator pRaspiCameraDeviceIterator, LibMCDriver_Camera_RaspiCameraDevice * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Driver_RaspiCamera +**************************************************************************************************************************/ + +/** +* Looks for cameras on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[out] pDeviceIterator - Iterator Instance through all found devices. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_querydevices(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, LibMCDriver_Camera_RaspiCameraDeviceIterator * pDeviceIterator); + +/** +* Initialize the camera on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[in] pDeviceString - Path to camera device. +* @param[in] nWidth - Width of Image in Pixels. +* @param[in] nHeight - Height of Image in Pixels. +* @param[in] ePixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_initialize(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, const char * pDeviceString, LibMCDriver_Camera_uint32 nWidth, LibMCDriver_Camera_uint32 nHeight, LibMCDriver_Camera::eImagePixelFormat ePixelformat); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getversion(LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getlasterror(LibMCDriver_Camera_Base pInstance, const LibMCDriver_Camera_uint32 nErrorMessageBufferSize, LibMCDriver_Camera_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_releaseinstance(LibMCDriver_Camera_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_acquireinstance(LibMCDriver_Camera_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_injectcomponent(const char * pNameSpace, LibMCDriver_Camera_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getsymbollookupmethod(LibMCDriver_Camera_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_Camera_Driver * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBMCDRIVER_CAMERA_HEADER_CPP + diff --git a/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.h b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.h new file mode 100644 index 00000000..88b2ef10 --- /dev/null +++ b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.h @@ -0,0 +1,378 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_DYNAMICHEADER_CPPTYPES +#define __LIBMCDRIVER_CAMERA_DYNAMICHEADER_CPPTYPES + +#include "libmcdriver_camera_types.hpp" + +#include "libmcdriverenv_types.hpp" + + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_GetNamePtr) (LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameBufferSize, LibMCDriver_Camera_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_GetTypePtr) (LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nTypeBufferSize, LibMCDriver_Camera_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_GetVersionPtr) (LibMCDriver_Camera_Driver pDriver, LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro, const LibMCDriver_Camera_uint32 nBuildBufferSize, LibMCDriver_Camera_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_GetHeaderInformationPtr) (LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameSpaceBufferSize, LibMCDriver_Camera_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_Camera_uint32 nBaseNameBufferSize, LibMCDriver_Camera_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraIterator_MoveNextPtr) (LibMCDriver_Camera_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraIterator_MovePreviousPtr) (LibMCDriver_Camera_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraIterator_GetCurrentPtr) (LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraIterator_ClonePtr) (LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Iterator * pOutIterator); + +/** +* Returns the number of resources the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraIterator_CountPtr) (LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for PNGImage +**************************************************************************************************************************/ + +/** +* Returns width of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pWidth - width of the image in pixels. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraPNGImage_GetWidthPtr) (LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pWidth); + +/** +* Returns height of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pHeight - height of the image in pixels. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraPNGImage_GetHeightPtr) (LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pHeight); + +/** +* Returns pixel format of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pPixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraPNGImage_GetPixelFormatPtr) (LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera::eImagePixelFormat * pPixelformat); + +/** +* Returns raw data of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nPNGDataBufferSize - Number of elements in buffer +* @param[out] pPNGDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPNGDataBuffer - uint8 buffer of Binary data of PNG image captured. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraPNGImage_GetRawDataPtr) (LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer); + +/** +* Saves PNG Image on Disk. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nFileNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFileNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFileNameBuffer - buffer of Filename to save PNG to., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraPNGImage_SaveToFilePtr) (LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint32 nFileNameBufferSize, LibMCDriver_Camera_uint32* pFileNameNeededChars, char * pFileNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_Camera +**************************************************************************************************************************/ + +/** +* Captures an image from the camera and returns a PNG image. +* +* @param[in] pDriver_Camera - Driver_Camera instance. +* @param[out] pPNGImage - Instance of the PNG Image. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_Camera_CapturePNGImagePtr) (LibMCDriver_Camera_Driver_Camera pDriver_Camera, LibMCDriver_Camera_PNGImage * pPNGImage); + +/************************************************************************************************************************* + Class definition for RaspiCameraDevice +**************************************************************************************************************************/ + +/** +* Returns path to the camera device. +* +* @param[in] pRaspiCameraDevice - RaspiCameraDevice instance. +* @param[in] nDeviceStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pDeviceStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDeviceStringBuffer - buffer of Path to camera device., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraRaspiCameraDevice_GetDeviceStringPtr) (LibMCDriver_Camera_RaspiCameraDevice pRaspiCameraDevice, const LibMCDriver_Camera_uint32 nDeviceStringBufferSize, LibMCDriver_Camera_uint32* pDeviceStringNeededChars, char * pDeviceStringBuffer); + +/************************************************************************************************************************* + Class definition for RaspiCameraDeviceIterator +**************************************************************************************************************************/ + +/** +* Returns the camera device the iterator points at. +* +* @param[in] pRaspiCameraDeviceIterator - RaspiCameraDeviceIterator instance. +* @param[out] pCurrentInstance - returns the camera device instance. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraRaspiCameraDeviceIterator_GetCameraDevicePtr) (LibMCDriver_Camera_RaspiCameraDeviceIterator pRaspiCameraDeviceIterator, LibMCDriver_Camera_RaspiCameraDevice * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Driver_RaspiCamera +**************************************************************************************************************************/ + +/** +* Looks for cameras on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[out] pDeviceIterator - Iterator Instance through all found devices. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_RaspiCamera_QueryDevicesPtr) (LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, LibMCDriver_Camera_RaspiCameraDeviceIterator * pDeviceIterator); + +/** +* Initialize the camera on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[in] pDeviceString - Path to camera device. +* @param[in] nWidth - Width of Image in Pixels. +* @param[in] nHeight - Height of Image in Pixels. +* @param[in] ePixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraDriver_RaspiCamera_InitializePtr) (LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, const char * pDeviceString, LibMCDriver_Camera_uint32 nWidth, LibMCDriver_Camera_uint32 nHeight, LibMCDriver_Camera::eImagePixelFormat ePixelformat); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraGetVersionPtr) (LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraGetLastErrorPtr) (LibMCDriver_Camera_Base pInstance, const LibMCDriver_Camera_uint32 nErrorMessageBufferSize, LibMCDriver_Camera_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraReleaseInstancePtr) (LibMCDriver_Camera_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraAcquireInstancePtr) (LibMCDriver_Camera_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraInjectComponentPtr) (const char * pNameSpace, LibMCDriver_Camera_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraGetSymbolLookupMethodPtr) (LibMCDriver_Camera_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +typedef LibMCDriver_CameraResult (*PLibMCDriver_CameraCreateDriverPtr) (const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_Camera_Driver * pInstance); + +/************************************************************************************************************************* + Function Table Structure +**************************************************************************************************************************/ + +typedef struct { + void * m_LibraryHandle; + PLibMCDriver_CameraDriver_GetNamePtr m_Driver_GetName; + PLibMCDriver_CameraDriver_GetTypePtr m_Driver_GetType; + PLibMCDriver_CameraDriver_GetVersionPtr m_Driver_GetVersion; + PLibMCDriver_CameraDriver_GetHeaderInformationPtr m_Driver_GetHeaderInformation; + PLibMCDriver_CameraIterator_MoveNextPtr m_Iterator_MoveNext; + PLibMCDriver_CameraIterator_MovePreviousPtr m_Iterator_MovePrevious; + PLibMCDriver_CameraIterator_GetCurrentPtr m_Iterator_GetCurrent; + PLibMCDriver_CameraIterator_ClonePtr m_Iterator_Clone; + PLibMCDriver_CameraIterator_CountPtr m_Iterator_Count; + PLibMCDriver_CameraPNGImage_GetWidthPtr m_PNGImage_GetWidth; + PLibMCDriver_CameraPNGImage_GetHeightPtr m_PNGImage_GetHeight; + PLibMCDriver_CameraPNGImage_GetPixelFormatPtr m_PNGImage_GetPixelFormat; + PLibMCDriver_CameraPNGImage_GetRawDataPtr m_PNGImage_GetRawData; + PLibMCDriver_CameraPNGImage_SaveToFilePtr m_PNGImage_SaveToFile; + PLibMCDriver_CameraDriver_Camera_CapturePNGImagePtr m_Driver_Camera_CapturePNGImage; + PLibMCDriver_CameraRaspiCameraDevice_GetDeviceStringPtr m_RaspiCameraDevice_GetDeviceString; + PLibMCDriver_CameraRaspiCameraDeviceIterator_GetCameraDevicePtr m_RaspiCameraDeviceIterator_GetCameraDevice; + PLibMCDriver_CameraDriver_RaspiCamera_QueryDevicesPtr m_Driver_RaspiCamera_QueryDevices; + PLibMCDriver_CameraDriver_RaspiCamera_InitializePtr m_Driver_RaspiCamera_Initialize; + PLibMCDriver_CameraGetVersionPtr m_GetVersion; + PLibMCDriver_CameraGetLastErrorPtr m_GetLastError; + PLibMCDriver_CameraReleaseInstancePtr m_ReleaseInstance; + PLibMCDriver_CameraAcquireInstancePtr m_AcquireInstance; + PLibMCDriver_CameraInjectComponentPtr m_InjectComponent; + PLibMCDriver_CameraGetSymbolLookupMethodPtr m_GetSymbolLookupMethod; + PLibMCDriver_CameraCreateDriverPtr m_CreateDriver; +} sLibMCDriver_CameraDynamicWrapperTable; + +#endif // __LIBMCDRIVER_CAMERA_DYNAMICHEADER_CPPTYPES + diff --git a/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.hpp b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.hpp new file mode 100644 index 00000000..48af506e --- /dev/null +++ b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_dynamic.hpp @@ -0,0 +1,1342 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_CPPHEADER_DYNAMIC_CPP +#define __LIBMCDRIVER_CAMERA_CPPHEADER_DYNAMIC_CPP + +#include "libmcdriver_camera_types.hpp" +#include "libmcdriver_camera_dynamic.h" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef _WIN32 +#include +#else // _WIN32 +#include +#endif // _WIN32 +#include +#include +#include +#include + +namespace LibMCDriver_Camera { + +/************************************************************************************************************************* + Forward Declaration of all classes +**************************************************************************************************************************/ +class CWrapper; +class CBase; +class CDriver; +class CIterator; +class CPNGImage; +class CDriver_Camera; +class CRaspiCameraDevice; +class CRaspiCameraDeviceIterator; +class CDriver_RaspiCamera; + +/************************************************************************************************************************* + Declaration of deprecated class types +**************************************************************************************************************************/ +typedef CWrapper CLibMCDriver_CameraWrapper; +typedef CBase CLibMCDriver_CameraBase; +typedef CDriver CLibMCDriver_CameraDriver; +typedef CIterator CLibMCDriver_CameraIterator; +typedef CPNGImage CLibMCDriver_CameraPNGImage; +typedef CDriver_Camera CLibMCDriver_CameraDriver_Camera; +typedef CRaspiCameraDevice CLibMCDriver_CameraRaspiCameraDevice; +typedef CRaspiCameraDeviceIterator CLibMCDriver_CameraRaspiCameraDeviceIterator; +typedef CDriver_RaspiCamera CLibMCDriver_CameraDriver_RaspiCamera; + +/************************************************************************************************************************* + Declaration of shared pointer types +**************************************************************************************************************************/ +typedef std::shared_ptr PWrapper; +typedef std::shared_ptr PBase; +typedef std::shared_ptr PDriver; +typedef std::shared_ptr PIterator; +typedef std::shared_ptr PPNGImage; +typedef std::shared_ptr PDriver_Camera; +typedef std::shared_ptr PRaspiCameraDevice; +typedef std::shared_ptr PRaspiCameraDeviceIterator; +typedef std::shared_ptr PDriver_RaspiCamera; + +/************************************************************************************************************************* + Declaration of deprecated shared pointer types +**************************************************************************************************************************/ +typedef PWrapper PLibMCDriver_CameraWrapper; +typedef PBase PLibMCDriver_CameraBase; +typedef PDriver PLibMCDriver_CameraDriver; +typedef PIterator PLibMCDriver_CameraIterator; +typedef PPNGImage PLibMCDriver_CameraPNGImage; +typedef PDriver_Camera PLibMCDriver_CameraDriver_Camera; +typedef PRaspiCameraDevice PLibMCDriver_CameraRaspiCameraDevice; +typedef PRaspiCameraDeviceIterator PLibMCDriver_CameraRaspiCameraDeviceIterator; +typedef PDriver_RaspiCamera PLibMCDriver_CameraDriver_RaspiCamera; + + +/************************************************************************************************************************* + classParam Definition +**************************************************************************************************************************/ + +template class classParam { +private: + const T* m_ptr; + +public: + classParam(const T* ptr) + : m_ptr (ptr) + { + } + + classParam(std::shared_ptr sharedPtr) + : m_ptr (sharedPtr.get()) + { + } + + LibMCDriver_CameraHandle GetHandle() + { + if (m_ptr != nullptr) + return m_ptr->handle(); + return nullptr; + } +}; + +/************************************************************************************************************************* + Class ELibMCDriver_CameraException +**************************************************************************************************************************/ +class ELibMCDriver_CameraException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibMCDriver_CameraResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibMCDriver_CameraException(LibMCDriver_CameraResult errorCode, const std::string & sErrorMessage) + : m_errorMessage("LibMCDriver_Camera Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") + { + m_errorCode = errorCode; + } + + /** + * Returns error code + */ + LibMCDriver_CameraResult getErrorCode() const noexcept + { + return m_errorCode; + } + + /** + * Returns error message + */ + const char* what() const noexcept + { + return m_errorMessage.c_str(); + } + +}; + +/************************************************************************************************************************* + Class CInputVector +**************************************************************************************************************************/ +template +class CInputVector { +private: + + const T* m_data; + size_t m_size; + +public: + + CInputVector( const std::vector& vec) + : m_data( vec.data() ), m_size( vec.size() ) + { + } + + CInputVector( const T* in_data, size_t in_size) + : m_data( in_data ), m_size(in_size ) + { + } + + const T* data() const + { + return m_data; + } + + size_t size() const + { + return m_size; + } + +}; + +// declare deprecated class name +template +using CLibMCDriver_CameraInputVector = CInputVector; + +/************************************************************************************************************************* + Class CWrapper +**************************************************************************************************************************/ +class CWrapper { +public: + + CWrapper(void* pSymbolLookupMethod) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod)); + + CheckError(nullptr, checkBinaryVersion()); + } + + CWrapper(const std::string &sFileName) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str())); + + CheckError(nullptr, checkBinaryVersion()); + } + + static PWrapper loadLibrary(const std::string &sFileName) + { + return std::make_shared(sFileName); + } + + static PWrapper loadLibraryFromSymbolLookupMethod(void* pSymbolLookupMethod) + { + return std::make_shared(pSymbolLookupMethod); + } + + ~CWrapper() + { + releaseWrapperTable(&m_WrapperTable); + } + + inline void CheckError(CBase * pBaseClass, LibMCDriver_CameraResult nResult); + + inline void GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro); + inline bool GetLastError(classParam pInstance, std::string & sErrorMessage); + inline void ReleaseInstance(classParam pInstance); + inline void AcquireInstance(classParam pInstance); + inline void InjectComponent(const std::string & sNameSpace, const LibMCDriver_Camera_pvoid pSymbolAddressMethod); + inline LibMCDriver_Camera_pvoid GetSymbolLookupMethod(); + inline PDriver CreateDriver(const std::string & sName, const std::string & sType, classParam pDriverEnvironment); + +private: + sLibMCDriver_CameraDynamicWrapperTable m_WrapperTable; + // Injected Components + LibMCDriverEnv::PWrapper m_pLibMCDriverEnvWrapper; + + + LibMCDriver_CameraResult checkBinaryVersion() + { + LibMCDriver_Camera_uint32 nMajor, nMinor, nMicro; + GetVersion(nMajor, nMinor, nMicro); + if ( (nMajor != LIBMCDRIVER_CAMERA_VERSION_MAJOR) || (nMinor < LIBMCDRIVER_CAMERA_VERSION_MINOR) ) { + return LIBMCDRIVER_CAMERA_ERROR_INCOMPATIBLEBINARYVERSION; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + LibMCDriver_CameraResult initWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable); + LibMCDriver_CameraResult releaseWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable); + LibMCDriver_CameraResult loadWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName); + LibMCDriver_CameraResult loadWrapperTableFromSymbolLookupMethod(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod); + + friend class CBase; + friend class CDriver; + friend class CIterator; + friend class CPNGImage; + friend class CDriver_Camera; + friend class CRaspiCameraDevice; + friend class CRaspiCameraDeviceIterator; + friend class CDriver_RaspiCamera; + +}; + + +/************************************************************************************************************************* + Class CBase +**************************************************************************************************************************/ +class CBase { +public: + +protected: + /* Wrapper Object that created the class. */ + CWrapper * m_pWrapper; + /* Handle to Instance in library*/ + LibMCDriver_CameraHandle m_pHandle; + + /* Checks for an Error code and raises Exceptions */ + void CheckError(LibMCDriver_CameraResult nResult) + { + if (m_pWrapper != nullptr) + m_pWrapper->CheckError(this, nResult); + } +public: + /** + * CBase::CBase - Constructor for Base class. + */ + CBase(CWrapper * pWrapper, LibMCDriver_CameraHandle pHandle) + : m_pWrapper(pWrapper), m_pHandle(pHandle) + { + } + + /** + * CBase::~CBase - Destructor for Base class. + */ + virtual ~CBase() + { + if (m_pWrapper != nullptr) + m_pWrapper->ReleaseInstance(this); + m_pWrapper = nullptr; + } + + /** + * CBase::handle - Returns handle to instance. + */ + LibMCDriver_CameraHandle handle() const + { + return m_pHandle; + } + + /** + * CBase::wrapper - Returns wrapper instance. + */ + CWrapper * wrapper() const + { + return m_pWrapper; + } + + friend class CWrapper; +}; + +/************************************************************************************************************************* + Class CDriver +**************************************************************************************************************************/ +class CDriver : public CBase { +public: + + /** + * CDriver::CDriver - Constructor for Driver class. + */ + CDriver(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetName(); + inline std::string GetType(); + inline void GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro, std::string & sBuild); + inline void GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName); +}; + +/************************************************************************************************************************* + Class CIterator +**************************************************************************************************************************/ +class CIterator : public CBase { +public: + + /** + * CIterator::CIterator - Constructor for Iterator class. + */ + CIterator(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline PBase GetCurrent(); + inline PIterator Clone(); + inline LibMCDriver_Camera_uint64 Count(); +}; + +/************************************************************************************************************************* + Class CPNGImage +**************************************************************************************************************************/ +class CPNGImage : public CBase { +public: + + /** + * CPNGImage::CPNGImage - Constructor for PNGImage class. + */ + CPNGImage(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline LibMCDriver_Camera_uint64 GetWidth(); + inline LibMCDriver_Camera_uint64 GetHeight(); + inline eImagePixelFormat GetPixelFormat(); + inline void GetRawData(std::vector & PNGDataBuffer); + inline std::string SaveToFile(); +}; + +/************************************************************************************************************************* + Class CDriver_Camera +**************************************************************************************************************************/ +class CDriver_Camera : public CDriver { +public: + + /** + * CDriver_Camera::CDriver_Camera - Constructor for Driver_Camera class. + */ + CDriver_Camera(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CDriver(pWrapper, pHandle) + { + } + + inline PPNGImage CapturePNGImage(); +}; + +/************************************************************************************************************************* + Class CRaspiCameraDevice +**************************************************************************************************************************/ +class CRaspiCameraDevice : public CBase { +public: + + /** + * CRaspiCameraDevice::CRaspiCameraDevice - Constructor for RaspiCameraDevice class. + */ + CRaspiCameraDevice(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetDeviceString(); +}; + +/************************************************************************************************************************* + Class CRaspiCameraDeviceIterator +**************************************************************************************************************************/ +class CRaspiCameraDeviceIterator : public CIterator { +public: + + /** + * CRaspiCameraDeviceIterator::CRaspiCameraDeviceIterator - Constructor for RaspiCameraDeviceIterator class. + */ + CRaspiCameraDeviceIterator(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CIterator(pWrapper, pHandle) + { + } + + inline PRaspiCameraDevice GetCameraDevice(); +}; + +/************************************************************************************************************************* + Class CDriver_RaspiCamera +**************************************************************************************************************************/ +class CDriver_RaspiCamera : public CDriver_Camera { +public: + + /** + * CDriver_RaspiCamera::CDriver_RaspiCamera - Constructor for Driver_RaspiCamera class. + */ + CDriver_RaspiCamera(CWrapper* pWrapper, LibMCDriver_CameraHandle pHandle) + : CDriver_Camera(pWrapper, pHandle) + { + } + + inline PRaspiCameraDeviceIterator QueryDevices(); + inline void Initialize(const std::string & sDeviceString, const LibMCDriver_Camera_uint32 nWidth, const LibMCDriver_Camera_uint32 nHeight, const eImagePixelFormat ePixelformat); +}; + + /** + * CWrapper::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + inline void CWrapper::GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro) + { + CheckError(nullptr,m_WrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro)); + } + + /** + * CWrapper::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + inline bool CWrapper::GetLastError(classParam pInstance, std::string & sErrorMessage) + { + LibMCDriver_CameraHandle hInstance = pInstance.GetHandle(); + LibMCDriver_Camera_uint32 bytesNeededErrorMessage = 0; + LibMCDriver_Camera_uint32 bytesWrittenErrorMessage = 0; + bool resultHasError = 0; + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, 0, &bytesNeededErrorMessage, nullptr, &resultHasError)); + std::vector bufferErrorMessage(bytesNeededErrorMessage); + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], &resultHasError)); + sErrorMessage = std::string(&bufferErrorMessage[0]); + + return resultHasError; + } + + /** + * CWrapper::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::ReleaseInstance(classParam pInstance) + { + LibMCDriver_CameraHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_ReleaseInstance(hInstance)); + } + + /** + * CWrapper::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::AcquireInstance(classParam pInstance) + { + LibMCDriver_CameraHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_AcquireInstance(hInstance)); + } + + /** + * CWrapper::InjectComponent - Injects an imported component for usage within this component + * @param[in] sNameSpace - NameSpace of the injected component + * @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component + */ + inline void CWrapper::InjectComponent(const std::string & sNameSpace, const LibMCDriver_Camera_pvoid pSymbolAddressMethod) + { + CheckError(nullptr,m_WrapperTable.m_InjectComponent(sNameSpace.c_str(), pSymbolAddressMethod)); + + bool bNameSpaceFound = false; + if (sNameSpace == "LibMCDriverEnv") { + if (m_pLibMCDriverEnvWrapper != nullptr) { + throw ELibMCDriver_CameraException(LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY, "Library with namespace " + sNameSpace + " is already registered."); + } + m_pLibMCDriverEnvWrapper = LibMCDriverEnv::CWrapper::loadLibraryFromSymbolLookupMethod(pSymbolAddressMethod); + bNameSpaceFound = true; + } + if (!bNameSpaceFound) + throw ELibMCDriver_CameraException(LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY, "Unknown namespace " + sNameSpace); + } + + /** + * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod + * @return Address of the SymbolAddressMethod + */ + inline LibMCDriver_Camera_pvoid CWrapper::GetSymbolLookupMethod() + { + LibMCDriver_Camera_pvoid resultSymbolLookupMethod = 0; + CheckError(nullptr,m_WrapperTable.m_GetSymbolLookupMethod(&resultSymbolLookupMethod)); + + return resultSymbolLookupMethod; + } + + /** + * CWrapper::CreateDriver - Creates a driver instance with a specific name. + * @param[in] sName - Name of driver to be created. + * @param[in] sType - Type of driver to be created. + * @param[in] pDriverEnvironment - Environment of this driver. + * @return New Driver instance + */ + inline PDriver CWrapper::CreateDriver(const std::string & sName, const std::string & sType, classParam pDriverEnvironment) + { + LibMCDriverEnvHandle hDriverEnvironment = pDriverEnvironment.GetHandle(); + LibMCDriver_CameraHandle hInstance = nullptr; + CheckError(nullptr,m_WrapperTable.m_CreateDriver(sName.c_str(), sType.c_str(), hDriverEnvironment, &hInstance)); + + if (!hInstance) { + CheckError(nullptr,LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(this, hInstance); + } + + inline void CWrapper::CheckError(CBase * pBaseClass, LibMCDriver_CameraResult nResult) + { + if (nResult != 0) { + std::string sErrorMessage; + if (pBaseClass != nullptr) { + GetLastError(pBaseClass, sErrorMessage); + } + throw ELibMCDriver_CameraException(nResult, sErrorMessage); + } + } + + + inline LibMCDriver_CameraResult CWrapper::initWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + + pWrapperTable->m_LibraryHandle = nullptr; + pWrapperTable->m_Driver_GetName = nullptr; + pWrapperTable->m_Driver_GetType = nullptr; + pWrapperTable->m_Driver_GetVersion = nullptr; + pWrapperTable->m_Driver_GetHeaderInformation = nullptr; + pWrapperTable->m_Iterator_MoveNext = nullptr; + pWrapperTable->m_Iterator_MovePrevious = nullptr; + pWrapperTable->m_Iterator_GetCurrent = nullptr; + pWrapperTable->m_Iterator_Clone = nullptr; + pWrapperTable->m_Iterator_Count = nullptr; + pWrapperTable->m_PNGImage_GetWidth = nullptr; + pWrapperTable->m_PNGImage_GetHeight = nullptr; + pWrapperTable->m_PNGImage_GetPixelFormat = nullptr; + pWrapperTable->m_PNGImage_GetRawData = nullptr; + pWrapperTable->m_PNGImage_SaveToFile = nullptr; + pWrapperTable->m_Driver_Camera_CapturePNGImage = nullptr; + pWrapperTable->m_RaspiCameraDevice_GetDeviceString = nullptr; + pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice = nullptr; + pWrapperTable->m_Driver_RaspiCamera_QueryDevices = nullptr; + pWrapperTable->m_Driver_RaspiCamera_Initialize = nullptr; + pWrapperTable->m_GetVersion = nullptr; + pWrapperTable->m_GetLastError = nullptr; + pWrapperTable->m_ReleaseInstance = nullptr; + pWrapperTable->m_AcquireInstance = nullptr; + pWrapperTable->m_InjectComponent = nullptr; + pWrapperTable->m_GetSymbolLookupMethod = nullptr; + pWrapperTable->m_CreateDriver = nullptr; + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + + inline LibMCDriver_CameraResult CWrapper::releaseWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + + if (pWrapperTable->m_LibraryHandle != nullptr) { + #ifdef _WIN32 + HMODULE hModule = (HMODULE) pWrapperTable->m_LibraryHandle; + FreeLibrary(hModule); + #else // _WIN32 + dlclose(pWrapperTable->m_LibraryHandle); + #endif // _WIN32 + return initWrapperTable(pWrapperTable); + } + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + + inline LibMCDriver_CameraResult CWrapper::loadWrapperTable(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + if (pLibraryFileName == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + + #ifdef _WIN32 + // Convert filename to UTF16-string + int nLength = (int)strlen(pLibraryFileName); + int nBufferSize = nLength * 2 + 2; + std::vector wsLibraryFileName(nBufferSize); + int nResult = MultiByteToWideChar(CP_UTF8, 0, pLibraryFileName, nLength, &wsLibraryFileName[0], nBufferSize); + if (nResult == 0) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY; + + HMODULE hLibrary = LoadLibraryW(wsLibraryFileName.data()); + if (hLibrary == 0) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY; + #else // _WIN32 + void* hLibrary = dlopen(pLibraryFileName, RTLD_LAZY); + if (hLibrary == 0) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY; + dlerror(); + #endif // _WIN32 + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetName = (PLibMCDriver_CameraDriver_GetNamePtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_getname"); + #else // _WIN32 + pWrapperTable->m_Driver_GetName = (PLibMCDriver_CameraDriver_GetNamePtr) dlsym(hLibrary, "libmcdriver_camera_driver_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetName == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetType = (PLibMCDriver_CameraDriver_GetTypePtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_gettype"); + #else // _WIN32 + pWrapperTable->m_Driver_GetType = (PLibMCDriver_CameraDriver_GetTypePtr) dlsym(hLibrary, "libmcdriver_camera_driver_gettype"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetType == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetVersion = (PLibMCDriver_CameraDriver_GetVersionPtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_getversion"); + #else // _WIN32 + pWrapperTable->m_Driver_GetVersion = (PLibMCDriver_CameraDriver_GetVersionPtr) dlsym(hLibrary, "libmcdriver_camera_driver_getversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetVersion == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetHeaderInformation = (PLibMCDriver_CameraDriver_GetHeaderInformationPtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_getheaderinformation"); + #else // _WIN32 + pWrapperTable->m_Driver_GetHeaderInformation = (PLibMCDriver_CameraDriver_GetHeaderInformationPtr) dlsym(hLibrary, "libmcdriver_camera_driver_getheaderinformation"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetHeaderInformation == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_MoveNext = (PLibMCDriver_CameraIterator_MoveNextPtr) GetProcAddress(hLibrary, "libmcdriver_camera_iterator_movenext"); + #else // _WIN32 + pWrapperTable->m_Iterator_MoveNext = (PLibMCDriver_CameraIterator_MoveNextPtr) dlsym(hLibrary, "libmcdriver_camera_iterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_MoveNext == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_MovePrevious = (PLibMCDriver_CameraIterator_MovePreviousPtr) GetProcAddress(hLibrary, "libmcdriver_camera_iterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_Iterator_MovePrevious = (PLibMCDriver_CameraIterator_MovePreviousPtr) dlsym(hLibrary, "libmcdriver_camera_iterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_MovePrevious == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_GetCurrent = (PLibMCDriver_CameraIterator_GetCurrentPtr) GetProcAddress(hLibrary, "libmcdriver_camera_iterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_Iterator_GetCurrent = (PLibMCDriver_CameraIterator_GetCurrentPtr) dlsym(hLibrary, "libmcdriver_camera_iterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_GetCurrent == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_Clone = (PLibMCDriver_CameraIterator_ClonePtr) GetProcAddress(hLibrary, "libmcdriver_camera_iterator_clone"); + #else // _WIN32 + pWrapperTable->m_Iterator_Clone = (PLibMCDriver_CameraIterator_ClonePtr) dlsym(hLibrary, "libmcdriver_camera_iterator_clone"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_Clone == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_Count = (PLibMCDriver_CameraIterator_CountPtr) GetProcAddress(hLibrary, "libmcdriver_camera_iterator_count"); + #else // _WIN32 + pWrapperTable->m_Iterator_Count = (PLibMCDriver_CameraIterator_CountPtr) dlsym(hLibrary, "libmcdriver_camera_iterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_Count == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PNGImage_GetWidth = (PLibMCDriver_CameraPNGImage_GetWidthPtr) GetProcAddress(hLibrary, "libmcdriver_camera_pngimage_getwidth"); + #else // _WIN32 + pWrapperTable->m_PNGImage_GetWidth = (PLibMCDriver_CameraPNGImage_GetWidthPtr) dlsym(hLibrary, "libmcdriver_camera_pngimage_getwidth"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PNGImage_GetWidth == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PNGImage_GetHeight = (PLibMCDriver_CameraPNGImage_GetHeightPtr) GetProcAddress(hLibrary, "libmcdriver_camera_pngimage_getheight"); + #else // _WIN32 + pWrapperTable->m_PNGImage_GetHeight = (PLibMCDriver_CameraPNGImage_GetHeightPtr) dlsym(hLibrary, "libmcdriver_camera_pngimage_getheight"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PNGImage_GetHeight == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PNGImage_GetPixelFormat = (PLibMCDriver_CameraPNGImage_GetPixelFormatPtr) GetProcAddress(hLibrary, "libmcdriver_camera_pngimage_getpixelformat"); + #else // _WIN32 + pWrapperTable->m_PNGImage_GetPixelFormat = (PLibMCDriver_CameraPNGImage_GetPixelFormatPtr) dlsym(hLibrary, "libmcdriver_camera_pngimage_getpixelformat"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PNGImage_GetPixelFormat == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PNGImage_GetRawData = (PLibMCDriver_CameraPNGImage_GetRawDataPtr) GetProcAddress(hLibrary, "libmcdriver_camera_pngimage_getrawdata"); + #else // _WIN32 + pWrapperTable->m_PNGImage_GetRawData = (PLibMCDriver_CameraPNGImage_GetRawDataPtr) dlsym(hLibrary, "libmcdriver_camera_pngimage_getrawdata"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PNGImage_GetRawData == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PNGImage_SaveToFile = (PLibMCDriver_CameraPNGImage_SaveToFilePtr) GetProcAddress(hLibrary, "libmcdriver_camera_pngimage_savetofile"); + #else // _WIN32 + pWrapperTable->m_PNGImage_SaveToFile = (PLibMCDriver_CameraPNGImage_SaveToFilePtr) dlsym(hLibrary, "libmcdriver_camera_pngimage_savetofile"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PNGImage_SaveToFile == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Camera_CapturePNGImage = (PLibMCDriver_CameraDriver_Camera_CapturePNGImagePtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_camera_capturepngimage"); + #else // _WIN32 + pWrapperTable->m_Driver_Camera_CapturePNGImage = (PLibMCDriver_CameraDriver_Camera_CapturePNGImagePtr) dlsym(hLibrary, "libmcdriver_camera_driver_camera_capturepngimage"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Camera_CapturePNGImage == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_RaspiCameraDevice_GetDeviceString = (PLibMCDriver_CameraRaspiCameraDevice_GetDeviceStringPtr) GetProcAddress(hLibrary, "libmcdriver_camera_raspicameradevice_getdevicestring"); + #else // _WIN32 + pWrapperTable->m_RaspiCameraDevice_GetDeviceString = (PLibMCDriver_CameraRaspiCameraDevice_GetDeviceStringPtr) dlsym(hLibrary, "libmcdriver_camera_raspicameradevice_getdevicestring"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_RaspiCameraDevice_GetDeviceString == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice = (PLibMCDriver_CameraRaspiCameraDeviceIterator_GetCameraDevicePtr) GetProcAddress(hLibrary, "libmcdriver_camera_raspicameradeviceiterator_getcameradevice"); + #else // _WIN32 + pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice = (PLibMCDriver_CameraRaspiCameraDeviceIterator_GetCameraDevicePtr) dlsym(hLibrary, "libmcdriver_camera_raspicameradeviceiterator_getcameradevice"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_RaspiCamera_QueryDevices = (PLibMCDriver_CameraDriver_RaspiCamera_QueryDevicesPtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_raspicamera_querydevices"); + #else // _WIN32 + pWrapperTable->m_Driver_RaspiCamera_QueryDevices = (PLibMCDriver_CameraDriver_RaspiCamera_QueryDevicesPtr) dlsym(hLibrary, "libmcdriver_camera_driver_raspicamera_querydevices"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_RaspiCamera_QueryDevices == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_RaspiCamera_Initialize = (PLibMCDriver_CameraDriver_RaspiCamera_InitializePtr) GetProcAddress(hLibrary, "libmcdriver_camera_driver_raspicamera_initialize"); + #else // _WIN32 + pWrapperTable->m_Driver_RaspiCamera_Initialize = (PLibMCDriver_CameraDriver_RaspiCamera_InitializePtr) dlsym(hLibrary, "libmcdriver_camera_driver_raspicamera_initialize"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_RaspiCamera_Initialize == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetVersion = (PLibMCDriver_CameraGetVersionPtr) GetProcAddress(hLibrary, "libmcdriver_camera_getversion"); + #else // _WIN32 + pWrapperTable->m_GetVersion = (PLibMCDriver_CameraGetVersionPtr) dlsym(hLibrary, "libmcdriver_camera_getversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetVersion == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetLastError = (PLibMCDriver_CameraGetLastErrorPtr) GetProcAddress(hLibrary, "libmcdriver_camera_getlasterror"); + #else // _WIN32 + pWrapperTable->m_GetLastError = (PLibMCDriver_CameraGetLastErrorPtr) dlsym(hLibrary, "libmcdriver_camera_getlasterror"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetLastError == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibMCDriver_CameraReleaseInstancePtr) GetProcAddress(hLibrary, "libmcdriver_camera_releaseinstance"); + #else // _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibMCDriver_CameraReleaseInstancePtr) dlsym(hLibrary, "libmcdriver_camera_releaseinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_ReleaseInstance == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_AcquireInstance = (PLibMCDriver_CameraAcquireInstancePtr) GetProcAddress(hLibrary, "libmcdriver_camera_acquireinstance"); + #else // _WIN32 + pWrapperTable->m_AcquireInstance = (PLibMCDriver_CameraAcquireInstancePtr) dlsym(hLibrary, "libmcdriver_camera_acquireinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_AcquireInstance == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_InjectComponent = (PLibMCDriver_CameraInjectComponentPtr) GetProcAddress(hLibrary, "libmcdriver_camera_injectcomponent"); + #else // _WIN32 + pWrapperTable->m_InjectComponent = (PLibMCDriver_CameraInjectComponentPtr) dlsym(hLibrary, "libmcdriver_camera_injectcomponent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_InjectComponent == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibMCDriver_CameraGetSymbolLookupMethodPtr) GetProcAddress(hLibrary, "libmcdriver_camera_getsymbollookupmethod"); + #else // _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibMCDriver_CameraGetSymbolLookupMethodPtr) dlsym(hLibrary, "libmcdriver_camera_getsymbollookupmethod"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetSymbolLookupMethod == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_CreateDriver = (PLibMCDriver_CameraCreateDriverPtr) GetProcAddress(hLibrary, "libmcdriver_camera_createdriver"); + #else // _WIN32 + pWrapperTable->m_CreateDriver = (PLibMCDriver_CameraCreateDriverPtr) dlsym(hLibrary, "libmcdriver_camera_createdriver"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_CreateDriver == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + pWrapperTable->m_LibraryHandle = hLibrary; + return LIBMCDRIVER_CAMERA_SUCCESS; + } + + inline LibMCDriver_CameraResult CWrapper::loadWrapperTableFromSymbolLookupMethod(sLibMCDriver_CameraDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod) +{ + if (pWrapperTable == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + if (pSymbolLookupMethod == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + + typedef LibMCDriver_CameraResult(*SymbolLookupType)(const char*, void**); + + SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod; + + LibMCDriver_CameraResult eLookupError = LIBMCDRIVER_CAMERA_SUCCESS; + eLookupError = (*pLookup)("libmcdriver_camera_driver_getname", (void**)&(pWrapperTable->m_Driver_GetName)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetName == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_gettype", (void**)&(pWrapperTable->m_Driver_GetType)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetType == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_getversion", (void**)&(pWrapperTable->m_Driver_GetVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetVersion == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_getheaderinformation", (void**)&(pWrapperTable->m_Driver_GetHeaderInformation)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetHeaderInformation == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_iterator_movenext", (void**)&(pWrapperTable->m_Iterator_MoveNext)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_MoveNext == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_iterator_moveprevious", (void**)&(pWrapperTable->m_Iterator_MovePrevious)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_MovePrevious == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_iterator_getcurrent", (void**)&(pWrapperTable->m_Iterator_GetCurrent)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_GetCurrent == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_iterator_clone", (void**)&(pWrapperTable->m_Iterator_Clone)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_Clone == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_iterator_count", (void**)&(pWrapperTable->m_Iterator_Count)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_Count == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_pngimage_getwidth", (void**)&(pWrapperTable->m_PNGImage_GetWidth)); + if ( (eLookupError != 0) || (pWrapperTable->m_PNGImage_GetWidth == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_pngimage_getheight", (void**)&(pWrapperTable->m_PNGImage_GetHeight)); + if ( (eLookupError != 0) || (pWrapperTable->m_PNGImage_GetHeight == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_pngimage_getpixelformat", (void**)&(pWrapperTable->m_PNGImage_GetPixelFormat)); + if ( (eLookupError != 0) || (pWrapperTable->m_PNGImage_GetPixelFormat == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_pngimage_getrawdata", (void**)&(pWrapperTable->m_PNGImage_GetRawData)); + if ( (eLookupError != 0) || (pWrapperTable->m_PNGImage_GetRawData == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_pngimage_savetofile", (void**)&(pWrapperTable->m_PNGImage_SaveToFile)); + if ( (eLookupError != 0) || (pWrapperTable->m_PNGImage_SaveToFile == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_camera_capturepngimage", (void**)&(pWrapperTable->m_Driver_Camera_CapturePNGImage)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Camera_CapturePNGImage == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_raspicameradevice_getdevicestring", (void**)&(pWrapperTable->m_RaspiCameraDevice_GetDeviceString)); + if ( (eLookupError != 0) || (pWrapperTable->m_RaspiCameraDevice_GetDeviceString == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_raspicameradeviceiterator_getcameradevice", (void**)&(pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice)); + if ( (eLookupError != 0) || (pWrapperTable->m_RaspiCameraDeviceIterator_GetCameraDevice == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_raspicamera_querydevices", (void**)&(pWrapperTable->m_Driver_RaspiCamera_QueryDevices)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_RaspiCamera_QueryDevices == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_driver_raspicamera_initialize", (void**)&(pWrapperTable->m_Driver_RaspiCamera_Initialize)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_RaspiCamera_Initialize == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_getversion", (void**)&(pWrapperTable->m_GetVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetVersion == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_getlasterror", (void**)&(pWrapperTable->m_GetLastError)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetLastError == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_releaseinstance", (void**)&(pWrapperTable->m_ReleaseInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_ReleaseInstance == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_acquireinstance", (void**)&(pWrapperTable->m_AcquireInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_AcquireInstance == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_injectcomponent", (void**)&(pWrapperTable->m_InjectComponent)); + if ( (eLookupError != 0) || (pWrapperTable->m_InjectComponent == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_getsymbollookupmethod", (void**)&(pWrapperTable->m_GetSymbolLookupMethod)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetSymbolLookupMethod == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_camera_createdriver", (void**)&(pWrapperTable->m_CreateDriver)); + if ( (eLookupError != 0) || (pWrapperTable->m_CreateDriver == nullptr) ) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + + return LIBMCDRIVER_CAMERA_SUCCESS; +} + + + + /** + * Method definitions for class CBase + */ + + /** + * Method definitions for class CDriver + */ + + /** + * CDriver::GetName - returns the name identifier of the driver + * @return Name of the driver. + */ + std::string CDriver::GetName() + { + LibMCDriver_Camera_uint32 bytesNeededName = 0; + LibMCDriver_Camera_uint32 bytesWrittenName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetName(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetName(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CDriver::GetType - returns the type identifier of the driver + * @return Type of the driver. + */ + std::string CDriver::GetType() + { + LibMCDriver_Camera_uint32 bytesNeededType = 0; + LibMCDriver_Camera_uint32 bytesWrittenType = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetType(m_pHandle, 0, &bytesNeededType, nullptr)); + std::vector bufferType(bytesNeededType); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetType(m_pHandle, bytesNeededType, &bytesWrittenType, &bufferType[0])); + + return std::string(&bufferType[0]); + } + + /** + * CDriver::GetVersion - returns the version identifiers of the driver + * @param[out] nMajor - Major version. + * @param[out] nMinor - Minor version. + * @param[out] nMicro - Micro version. + * @param[out] sBuild - Build identifier. + */ + void CDriver::GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro, std::string & sBuild) + { + LibMCDriver_Camera_uint32 bytesNeededBuild = 0; + LibMCDriver_Camera_uint32 bytesWrittenBuild = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetVersion(m_pHandle, &nMajor, &nMinor, &nMicro, 0, &bytesNeededBuild, nullptr)); + std::vector bufferBuild(bytesNeededBuild); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetVersion(m_pHandle, &nMajor, &nMinor, &nMicro, bytesNeededBuild, &bytesWrittenBuild, &bufferBuild[0])); + sBuild = std::string(&bufferBuild[0]); + } + + /** + * CDriver::GetHeaderInformation - returns the header information + * @param[out] sNameSpace - NameSpace of the driver. + * @param[out] sBaseName - BaseName of the driver. + */ + void CDriver::GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName) + { + LibMCDriver_Camera_uint32 bytesNeededNameSpace = 0; + LibMCDriver_Camera_uint32 bytesWrittenNameSpace = 0; + LibMCDriver_Camera_uint32 bytesNeededBaseName = 0; + LibMCDriver_Camera_uint32 bytesWrittenBaseName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetHeaderInformation(m_pHandle, 0, &bytesNeededNameSpace, nullptr, 0, &bytesNeededBaseName, nullptr)); + std::vector bufferNameSpace(bytesNeededNameSpace); + std::vector bufferBaseName(bytesNeededBaseName); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetHeaderInformation(m_pHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0], bytesNeededBaseName, &bytesWrittenBaseName, &bufferBaseName[0])); + sNameSpace = std::string(&bufferNameSpace[0]); + sBaseName = std::string(&bufferBaseName[0]); + } + + /** + * Method definitions for class CIterator + */ + + /** + * CIterator::MoveNext - Iterates to the next resource in the list. + * @return Iterates to the next resource in the list. + */ + bool CIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_MoveNext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CIterator::MovePrevious - Iterates to the previous resource in the list. + * @return Iterates to the previous resource in the list. + */ + bool CIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_MovePrevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CIterator::GetCurrent - Returns the resource the iterator points at. + * @return returns the resource instance. + */ + PBase CIterator::GetCurrent() + { + LibMCDriver_CameraHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_GetCurrent(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * CIterator::Clone - Creates a new resource iterator with the same resource list. + * @return returns the cloned Iterator instance + */ + PIterator CIterator::Clone() + { + LibMCDriver_CameraHandle hOutIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_Clone(m_pHandle, &hOutIterator)); + + if (!hOutIterator) { + CheckError(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hOutIterator); + } + + /** + * CIterator::Count - Returns the number of resources the iterator captures. + * @return returns the number of resources the iterator captures. + */ + LibMCDriver_Camera_uint64 CIterator::Count() + { + LibMCDriver_Camera_uint64 resultCount = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_Count(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * Method definitions for class CPNGImage + */ + + /** + * CPNGImage::GetWidth - Returns width of the image. + * @return width of the image in pixels. + */ + LibMCDriver_Camera_uint64 CPNGImage::GetWidth() + { + LibMCDriver_Camera_uint64 resultWidth = 0; + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_GetWidth(m_pHandle, &resultWidth)); + + return resultWidth; + } + + /** + * CPNGImage::GetHeight - Returns height of the image. + * @return height of the image in pixels. + */ + LibMCDriver_Camera_uint64 CPNGImage::GetHeight() + { + LibMCDriver_Camera_uint64 resultHeight = 0; + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_GetHeight(m_pHandle, &resultHeight)); + + return resultHeight; + } + + /** + * CPNGImage::GetPixelFormat - Returns pixel format of the image. + * @return Pixel format of the image. + */ + eImagePixelFormat CPNGImage::GetPixelFormat() + { + eImagePixelFormat resultPixelformat = (eImagePixelFormat) 0; + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_GetPixelFormat(m_pHandle, &resultPixelformat)); + + return resultPixelformat; + } + + /** + * CPNGImage::GetRawData - Returns raw data of the image. + * @param[out] PNGDataBuffer - Binary data of PNG image captured. + */ + void CPNGImage::GetRawData(std::vector & PNGDataBuffer) + { + LibMCDriver_Camera_uint64 elementsNeededPNGData = 0; + LibMCDriver_Camera_uint64 elementsWrittenPNGData = 0; + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_GetRawData(m_pHandle, 0, &elementsNeededPNGData, nullptr)); + PNGDataBuffer.resize((size_t) elementsNeededPNGData); + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_GetRawData(m_pHandle, elementsNeededPNGData, &elementsWrittenPNGData, PNGDataBuffer.data())); + } + + /** + * CPNGImage::SaveToFile - Saves PNG Image on Disk. + * @return Filename to save PNG to. + */ + std::string CPNGImage::SaveToFile() + { + LibMCDriver_Camera_uint32 bytesNeededFileName = 0; + LibMCDriver_Camera_uint32 bytesWrittenFileName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_SaveToFile(m_pHandle, 0, &bytesNeededFileName, nullptr)); + std::vector bufferFileName(bytesNeededFileName); + CheckError(m_pWrapper->m_WrapperTable.m_PNGImage_SaveToFile(m_pHandle, bytesNeededFileName, &bytesWrittenFileName, &bufferFileName[0])); + + return std::string(&bufferFileName[0]); + } + + /** + * Method definitions for class CDriver_Camera + */ + + /** + * CDriver_Camera::CapturePNGImage - Captures an image from the camera and returns a PNG image. + * @return Instance of the PNG Image. + */ + PPNGImage CDriver_Camera::CapturePNGImage() + { + LibMCDriver_CameraHandle hPNGImage = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Camera_CapturePNGImage(m_pHandle, &hPNGImage)); + + if (!hPNGImage) { + CheckError(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hPNGImage); + } + + /** + * Method definitions for class CRaspiCameraDevice + */ + + /** + * CRaspiCameraDevice::GetDeviceString - Returns path to the camera device. + * @return Path to camera device. + */ + std::string CRaspiCameraDevice::GetDeviceString() + { + LibMCDriver_Camera_uint32 bytesNeededDeviceString = 0; + LibMCDriver_Camera_uint32 bytesWrittenDeviceString = 0; + CheckError(m_pWrapper->m_WrapperTable.m_RaspiCameraDevice_GetDeviceString(m_pHandle, 0, &bytesNeededDeviceString, nullptr)); + std::vector bufferDeviceString(bytesNeededDeviceString); + CheckError(m_pWrapper->m_WrapperTable.m_RaspiCameraDevice_GetDeviceString(m_pHandle, bytesNeededDeviceString, &bytesWrittenDeviceString, &bufferDeviceString[0])); + + return std::string(&bufferDeviceString[0]); + } + + /** + * Method definitions for class CRaspiCameraDeviceIterator + */ + + /** + * CRaspiCameraDeviceIterator::GetCameraDevice - Returns the camera device the iterator points at. + * @return returns the camera device instance. + */ + PRaspiCameraDevice CRaspiCameraDeviceIterator::GetCameraDevice() + { + LibMCDriver_CameraHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_RaspiCameraDeviceIterator_GetCameraDevice(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * Method definitions for class CDriver_RaspiCamera + */ + + /** + * CDriver_RaspiCamera::QueryDevices - Looks for cameras on the Raspberry PI. + * @return Iterator Instance through all found devices. + */ + PRaspiCameraDeviceIterator CDriver_RaspiCamera::QueryDevices() + { + LibMCDriver_CameraHandle hDeviceIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_RaspiCamera_QueryDevices(m_pHandle, &hDeviceIterator)); + + if (!hDeviceIterator) { + CheckError(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hDeviceIterator); + } + + /** + * CDriver_RaspiCamera::Initialize - Initialize the camera on the Raspberry PI. + * @param[in] sDeviceString - Path to camera device. + * @param[in] nWidth - Width of Image in Pixels. + * @param[in] nHeight - Height of Image in Pixels. + * @param[in] ePixelformat - Pixel format of the image. + */ + void CDriver_RaspiCamera::Initialize(const std::string & sDeviceString, const LibMCDriver_Camera_uint32 nWidth, const LibMCDriver_Camera_uint32 nHeight, const eImagePixelFormat ePixelformat) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_RaspiCamera_Initialize(m_pHandle, sDeviceString.c_str(), nWidth, nHeight, ePixelformat)); + } + +} // namespace LibMCDriver_Camera + +#endif // __LIBMCDRIVER_CAMERA_CPPHEADER_DYNAMIC_CPP + diff --git a/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_types.hpp b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_types.hpp new file mode 100644 index 00000000..7897cf0a --- /dev/null +++ b/Drivers/Camera/Headers/CppDynamic/libmcdriver_camera_types.hpp @@ -0,0 +1,163 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP +#define __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +typedef unsigned char LibMCDriver_Camera_uint8; +typedef unsigned short LibMCDriver_Camera_uint16 ; +typedef unsigned int LibMCDriver_Camera_uint32; +typedef unsigned long long LibMCDriver_Camera_uint64; +typedef char LibMCDriver_Camera_int8; +typedef short LibMCDriver_Camera_int16; +typedef int LibMCDriver_Camera_int32; +typedef long long LibMCDriver_Camera_int64; + +#else // LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibMCDriver_Camera_uint8; +typedef uint16_t LibMCDriver_Camera_uint16; +typedef uint32_t LibMCDriver_Camera_uint32; +typedef uint64_t LibMCDriver_Camera_uint64; +typedef int8_t LibMCDriver_Camera_int8; +typedef int16_t LibMCDriver_Camera_int16; +typedef int32_t LibMCDriver_Camera_int32; +typedef int64_t LibMCDriver_Camera_int64 ; + +#endif // LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +typedef float LibMCDriver_Camera_single; +typedef double LibMCDriver_Camera_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibMCDriver_Camera_int32 LibMCDriver_CameraResult; +typedef void * LibMCDriver_CameraHandle; +typedef void * LibMCDriver_Camera_pvoid; + +/************************************************************************************************************************* + Version for LibMCDriver_Camera +**************************************************************************************************************************/ + +#define LIBMCDRIVER_CAMERA_VERSION_MAJOR 1 +#define LIBMCDRIVER_CAMERA_VERSION_MINOR 0 +#define LIBMCDRIVER_CAMERA_VERSION_MICRO 0 +#define LIBMCDRIVER_CAMERA_VERSION_PRERELEASEINFO "" +#define LIBMCDRIVER_CAMERA_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibMCDriver_Camera +**************************************************************************************************************************/ + +#define LIBMCDRIVER_CAMERA_SUCCESS 0 +#define LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED 1 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM 2 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST 3 +#define LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL 4 +#define LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION 5 +#define LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBMCDRIVER_CAMERA_ERROR_INCOMPATIBLEBINARYVERSION 8 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDSTATENAME 9 +#define LIBMCDRIVER_CAMERA_ERROR_DRIVERERROR 1000 +#define LIBMCDRIVER_CAMERA_ERROR_ITERATORERROR 1001 + +/************************************************************************************************************************* + Error strings for LibMCDriver_Camera +**************************************************************************************************************************/ + +inline const char * LIBMCDRIVER_CAMERA_GETERRORSTRING (LibMCDriver_CameraResult nErrorCode) { + switch (nErrorCode) { + case LIBMCDRIVER_CAMERA_SUCCESS: return "no error"; + case LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBMCDRIVER_CAMERA_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDSTATENAME: return "invalid state name"; + case LIBMCDRIVER_CAMERA_ERROR_DRIVERERROR: return "a driver error occured"; + case LIBMCDRIVER_CAMERA_ERROR_ITERATORERROR: return "iterator does not point at valid object."; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Base; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Iterator; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_PNGImage; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver_Camera; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_RaspiCameraDevice; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_RaspiCameraDeviceIterator; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver_RaspiCamera; + +namespace LibMCDriver_Camera { + + /************************************************************************************************************************* + Declaration of enums + **************************************************************************************************************************/ + + enum class eImagePixelFormat : LibMCDriver_Camera_int32 { + Unknown = 0, + RGB32 = 1, + Grayscale32 = 2 + }; + +} // namespace LibMCDriver_Camera; + +// define legacy C-names for enums, structs and function types +typedef LibMCDriver_Camera::eImagePixelFormat eLibMCDriver_CameraImagePixelFormat; + +#endif // __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP diff --git a/Drivers/Camera/Implementation/libmcdriver_camera.cpp b/Drivers/Camera/Implementation/libmcdriver_camera.cpp new file mode 100644 index 00000000..0bb6fb8d --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera.cpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ implementation file in order to allow easy +development of MC Driver Camera. It needs to be generated only once. + +Interface version: 1.0.0 + +*/ + +#include "libmcdriver_camera_abi.hpp" +#include "libmcdriver_camera_interfaces.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" +#include "libmcdriver_camera_driver_raspicamera.hpp" + +using namespace LibMCDriver_Camera; +using namespace LibMCDriver_Camera::Impl; + +// Injected Components +LibMCDriverEnv::PWrapper CWrapper::sPLibMCDriverEnvWrapper; + +void CWrapper::GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro) +{ + nMajor = LIBMCDRIVER_CAMERA_VERSION_MAJOR; + nMinor = LIBMCDRIVER_CAMERA_VERSION_MINOR; + nMicro = LIBMCDRIVER_CAMERA_VERSION_MICRO; +} + +bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) +{ + if (pInstance) { + return pInstance->GetLastErrorMessage (sErrorMessage); + } else { + return false; + } +} + +void CWrapper::ReleaseInstance(IBase* pInstance) +{ + IBase::ReleaseBaseClassInterface(pInstance); +} + +void CWrapper::AcquireInstance(IBase* pInstance) +{ + IBase::AcquireBaseClassInterface(pInstance); +} + +IDriver * CWrapper::CreateDriver(const std::string & sName, const std::string & sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment) +{ + if (sType == "raspi-camera-1.0") { + + return new CDriver_RaspiCamera(sName, sType, pDriverEnvironment); + + } + + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_DRIVERERROR); +} + + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_base.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_base.cpp new file mode 100644 index 00000000..6daac49a --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_base.cpp @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CBase + +*/ + +#include "libmcdriver_camera_base.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CBase +**************************************************************************************************************************/ + +bool CBase::GetLastErrorMessage(std::string & sErrorMessage) +{ + if (m_pLastError.get() != nullptr) { + sErrorMessage = *m_pLastError; + return true; + } else { + sErrorMessage = ""; + return false; + } +} + +void CBase::ClearErrorMessages() +{ + m_pLastError.reset(); +} + +void CBase::RegisterErrorMessage(const std::string & sErrorMessage) +{ + if (m_pLastError.get() == nullptr) { + m_pLastError.reset(new std::string()); + } + *m_pLastError = sErrorMessage; +} + +void CBase::IncRefCount() +{ + ++m_nReferenceCount; +} + +bool CBase::DecRefCount() +{ + m_nReferenceCount--; + if (!m_nReferenceCount) { + delete this; + return true; + } + return false; +} + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_base.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_base.hpp new file mode 100644 index 00000000..36ce7d02 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_base.hpp @@ -0,0 +1,97 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CBase + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_BASE +#define __LIBMCDRIVER_CAMERA_BASE + +#include "libmcdriver_camera_interfaces.hpp" +#include +#include +#include + + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CBase +**************************************************************************************************************************/ + +class CBase : public virtual IBase { +private: + + std::unique_ptr m_pLastError; + uint32_t m_nReferenceCount = 1; + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + bool GetLastErrorMessage(std::string & sErrorMessage) override; + + void ClearErrorMessages() override; + + void RegisterErrorMessage(const std::string & sErrorMessage) override; + + void IncRefCount() override; + + bool DecRefCount() override; + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#endif // __LIBMCDRIVER_CAMERA_BASE diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver.cpp new file mode 100644 index 00000000..c780f389 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver.cpp @@ -0,0 +1,77 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CDriver + +*/ + +#include "libmcdriver_camera_driver.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CDriver +**************************************************************************************************************************/ +CDriver::CDriver() +{ + +} + + +CDriver::CDriver(const std::string& sName, const std::string& sType) + : m_sName(sName), m_sType(sType) +{ +} + +std::string CDriver::GetName() +{ + return m_sName; +} + +std::string CDriver::GetType() +{ + return m_sType; +} + +void CDriver::GetVersion(LibMCDriver_Camera_uint32& nMajor, LibMCDriver_Camera_uint32& nMinor, LibMCDriver_Camera_uint32& nMicro, std::string& sBuild) +{ + +} + + +void CDriver::GetHeaderInformation(std::string& sNameSpace, std::string& sBaseName) +{ + sNameSpace = "LibMCDriver_Camera"; + sBaseName = "libmcdriver_camera"; +} + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver.hpp new file mode 100644 index 00000000..13587f41 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver.hpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CDriver + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_DRIVER +#define __LIBMCDRIVER_CAMERA_DRIVER + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDriver +**************************************************************************************************************************/ + +class CDriver : public virtual IDriver, public virtual CBase { +private: + + +protected: + std::string m_sName; + std::string m_sType; + +public: + CDriver(); + + CDriver(const std::string& sName, const std::string& sType); + + std::string GetName() override; + + std::string GetType() override; + + void GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro, std::string & sBuild) override; + + void GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName) override; + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_DRIVER diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.cpp new file mode 100644 index 00000000..4ad64f35 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.cpp @@ -0,0 +1,52 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CDriver_Camera + +*/ + +#include "libmcdriver_camera_driver_camera.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CDriver_Camera +**************************************************************************************************************************/ + +CDriver_Camera::CDriver_Camera(const std::string& sName, const std::string& sType) + : CDriver (sName, sType) +{ + +} + + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.hpp new file mode 100644 index 00000000..3ab88d88 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver_camera.hpp @@ -0,0 +1,79 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CDriver_Camera + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_DRIVER_CAMERA +#define __LIBMCDRIVER_CAMERA_DRIVER_CAMERA + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_driver.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDriver_Camera +**************************************************************************************************************************/ + +class CDriver_Camera : public virtual IDriver_Camera, public virtual CDriver { +private: + + +protected: + + +public: + + CDriver_Camera (const std::string& sName, const std::string& sType); + + virtual IPNGImage* CapturePNGImage() = 0; + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_DRIVER_CAMERA diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.cpp new file mode 100644 index 00000000..0ad293a5 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.cpp @@ -0,0 +1,87 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CDriver_RaspiCamera + +*/ + +#include "libmcdriver_camera_driver_raspicamera.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" +#include "libmcdriver_camera_raspicameradeviceiterator.hpp" +#include "libmcdriver_camera_pngimage.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CDriver_RaspiCamera +**************************************************************************************************************************/ + +CDriver_RaspiCamera::CDriver_RaspiCamera(const std::string& sName, const std::string& sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment) + : CDriver_Camera (sName, sType), m_pDriverEnvironment (pDriverEnvironment) +{ + if (pDriverEnvironment.get() == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + +} + + +IRaspiCameraDeviceIterator* CDriver_RaspiCamera::QueryDevices() +{ + auto pIterator = std::make_unique (); + pIterator->addDevice("/dev/raspicamera0"); + + return pIterator.release(); +} + +void CDriver_RaspiCamera::Initialize(const std::string & sDeviceString, const LibMCDriver_Camera_uint32 nWidth, const LibMCDriver_Camera_uint32 nHeight, const LibMCDriver_Camera::eImagePixelFormat ePixelformat) +{ + // Successful + +} + +IPNGImage* CDriver_RaspiCamera::CapturePNGImage() +{ + auto pImage = std::make_unique(400, 300, eImagePixelFormat::RGB32); + + std::vector & pData = pImage->getBinaryData(); + + pData.push_back('t'); + pData.push_back('e'); + pData.push_back('s'); + pData.push_back('t'); + pData.push_back('1'); + pData.push_back('2'); + pData.push_back('3'); + + return pImage.release(); +} + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.hpp new file mode 100644 index 00000000..0f430200 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_driver_raspicamera.hpp @@ -0,0 +1,83 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CDriver_RaspiCamera + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_DRIVER_RASPICAMERA +#define __LIBMCDRIVER_CAMERA_DRIVER_RASPICAMERA + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_driver_camera.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDriver_RaspiCamera +**************************************************************************************************************************/ + +class CDriver_RaspiCamera : public virtual IDriver_RaspiCamera, public virtual CDriver_Camera { +private: + + +protected: + LibMCDriverEnv::PDriverEnvironment m_pDriverEnvironment; + +public: + + CDriver_RaspiCamera(const std::string& sName, const std::string& sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment); + + IRaspiCameraDeviceIterator* QueryDevices() override; + + void Initialize(const std::string & sDeviceString, const LibMCDriver_Camera_uint32 nWidth, const LibMCDriver_Camera_uint32 nHeight, const LibMCDriver_Camera::eImagePixelFormat ePixelformat) override; + + IPNGImage* CapturePNGImage() override; + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_DRIVER_RASPICAMERA diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_iterator.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_iterator.cpp new file mode 100644 index 00000000..424addc7 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_iterator.cpp @@ -0,0 +1,70 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CIterator + +*/ + +#include "libmcdriver_camera_iterator.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CIterator +**************************************************************************************************************************/ + +bool CIterator::MoveNext() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + +bool CIterator::MovePrevious() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + +IBase * CIterator::GetCurrent() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + +IIterator * CIterator::Clone() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + +LibMCDriver_Camera_uint64 CIterator::Count() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_iterator.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_iterator.hpp new file mode 100644 index 00000000..895df169 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_iterator.hpp @@ -0,0 +1,83 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CIterator + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_ITERATOR +#define __LIBMCDRIVER_CAMERA_ITERATOR + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CIterator +**************************************************************************************************************************/ + +class CIterator : public virtual IIterator, public virtual CBase { +private: + +protected: + +public: + + virtual bool MoveNext() = 0; + + virtual bool MovePrevious() = 0; + + virtual IBase * GetCurrent() = 0; + + virtual IIterator * Clone() = 0; + + virtual LibMCDriver_Camera_uint64 Count() = 0; + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_ITERATOR diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.cpp new file mode 100644 index 00000000..9ad0627e --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.cpp @@ -0,0 +1,102 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CPNGImage + +*/ + +#include "libmcdriver_camera_pngimage.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CPNGImage +**************************************************************************************************************************/ +CPNGImage::CPNGImage(uint32_t nWidth, uint32_t nHeight, eImagePixelFormat ePixelFormat) + : m_nWidth (nWidth), m_nHeight (nHeight), m_ePixelFormat (ePixelFormat) +{ + if ((nWidth == 0) || (nHeight == 0) || (ePixelFormat == eImagePixelFormat::Unknown)) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + + +} + + +LibMCDriver_Camera_uint64 CPNGImage::GetWidth() +{ + return m_nWidth; +} + +LibMCDriver_Camera_uint64 CPNGImage::GetHeight() +{ + return m_nHeight; +} + +LibMCDriver_Camera::eImagePixelFormat CPNGImage::GetPixelFormat() +{ + return m_ePixelFormat; +} + +void CPNGImage::GetRawData(LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer) +{ + + size_t nSize = m_BinaryData.size(); + if (pPNGDataNeededCount != nullptr) + *pPNGDataNeededCount = nSize; + + if (pPNGDataBuffer != nullptr) { + if (nPNGDataBufferSize < nSize) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + + if (nSize > 0) { + const uint8_t* pSrc = m_BinaryData.data(); + uint8_t* pDst = pPNGDataBuffer; + + for (size_t nIndex = 0; nIndex < nSize; nIndex++) { + *pDst = *pSrc; + pSrc++; + pDst++; + } + } + } +} + +std::string CPNGImage::SaveToFile() +{ + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED); +} + +std::vector & CPNGImage::getBinaryData() +{ + return m_BinaryData; +} diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.hpp new file mode 100644 index 00000000..0c9d27d7 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_pngimage.hpp @@ -0,0 +1,94 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CPNGImage + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_PNGIMAGE +#define __LIBMCDRIVER_CAMERA_PNGIMAGE + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CPNGImage +**************************************************************************************************************************/ + +class CPNGImage : public virtual IPNGImage, public virtual CBase { +private: + + +protected: + + uint32_t m_nWidth; + uint32_t m_nHeight; + eImagePixelFormat m_ePixelFormat; + + std::vector m_BinaryData; + +public: + + CPNGImage(uint32_t nWidth, uint32_t nHeight, eImagePixelFormat ePixelFormat); + + LibMCDriver_Camera_uint64 GetWidth() override; + + LibMCDriver_Camera_uint64 GetHeight() override; + + LibMCDriver_Camera::eImagePixelFormat GetPixelFormat() override; + + void GetRawData(LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer) override; + + std::string SaveToFile() override; + + std::vector & getBinaryData (); + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_PNGIMAGE diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.cpp new file mode 100644 index 00000000..b4266244 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.cpp @@ -0,0 +1,58 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CRaspiCameraDevice + +*/ + +#include "libmcdriver_camera_raspicameradevice.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CRaspiCameraDevice +**************************************************************************************************************************/ + +CRaspiCameraDevice::CRaspiCameraDevice(const std::string& sDeviceString) + : m_sDeviceString (sDeviceString) +{ + if (sDeviceString.empty()) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); +} + + +std::string CRaspiCameraDevice::GetDeviceString() +{ + return m_sDeviceString; +} + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.hpp new file mode 100644 index 00000000..30cabeb1 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradevice.hpp @@ -0,0 +1,80 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CRaspiCameraDevice + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_RASPICAMERADEVICE +#define __LIBMCDRIVER_CAMERA_RASPICAMERADEVICE + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CRaspiCameraDevice +**************************************************************************************************************************/ + +class CRaspiCameraDevice : public virtual IRaspiCameraDevice, public virtual CBase { +private: + + + +protected: + std::string m_sDeviceString; + +public: + + CRaspiCameraDevice (const std::string & sDeviceString); + + std::string GetDeviceString() override; + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_RASPICAMERADEVICE diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.cpp b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.cpp new file mode 100644 index 00000000..0e591410 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.cpp @@ -0,0 +1,108 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CRaspiCameraDeviceIterator + +*/ + +#include "libmcdriver_camera_raspicameradeviceiterator.hpp" +#include "libmcdriver_camera_raspicameradevice.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCDriver_Camera::Impl; + +/************************************************************************************************************************* + Class definition of CRaspiCameraDeviceIterator +**************************************************************************************************************************/ + +CRaspiCameraDeviceIterator::CRaspiCameraDeviceIterator() + : CIterator(), m_nCurrentIndex (-1) +{ + +} + +bool CRaspiCameraDeviceIterator::MoveNext() +{ + if ((m_nCurrentIndex + 1) < (int64_t) m_DeviceStrings.size()) { + m_nCurrentIndex++; + return true; + } + + return false; +} + +bool CRaspiCameraDeviceIterator::MovePrevious() +{ + if (m_nCurrentIndex > 0) { + m_nCurrentIndex--; + return true; + } + + return false; +} + +IBase* CRaspiCameraDeviceIterator::GetCurrent() +{ + return (IBase*)GetCameraDevice(); +} + +IRaspiCameraDevice* CRaspiCameraDeviceIterator::GetCameraDevice() +{ + if ((m_nCurrentIndex >= 0) && (m_nCurrentIndex < (int64_t)m_DeviceStrings.size())) { + return new CRaspiCameraDevice(m_DeviceStrings [m_nCurrentIndex]); + } + + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_ITERATORERROR); +} + +IIterator* CRaspiCameraDeviceIterator::Clone() +{ + std::unique_ptr pNewIterator(new CRaspiCameraDeviceIterator()); + pNewIterator->m_DeviceStrings = m_DeviceStrings; + + return pNewIterator.release(); +} + +LibMCDriver_Camera_uint64 CRaspiCameraDeviceIterator::Count() +{ + return m_DeviceStrings.size(); +} + +void CRaspiCameraDeviceIterator::addDevice(const std::string& sDeviceString) +{ + if (sDeviceString.empty()) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + + m_DeviceStrings.push_back(sDeviceString); +} + + diff --git a/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.hpp b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.hpp new file mode 100644 index 00000000..fbbe8b35 --- /dev/null +++ b/Drivers/Camera/Implementation/libmcdriver_camera_raspicameradeviceiterator.hpp @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CRaspiCameraDeviceIterator + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_RASPICAMERADEVICEITERATOR +#define __LIBMCDRIVER_CAMERA_RASPICAMERADEVICEITERATOR + +#include "libmcdriver_camera_interfaces.hpp" + +// Parent classes +#include "libmcdriver_camera_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibMCDriver_Camera { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CRaspiCameraDeviceIterator +**************************************************************************************************************************/ + +class CRaspiCameraDeviceIterator : public virtual IRaspiCameraDeviceIterator, public virtual CIterator { +private: + +protected: + + std::vector m_DeviceStrings; + int64_t m_nCurrentIndex; + +public: + + CRaspiCameraDeviceIterator(); + + virtual bool MoveNext() override; + + virtual bool MovePrevious() override; + + virtual IBase* GetCurrent() override; + + virtual IIterator* Clone() override; + + virtual LibMCDriver_Camera_uint64 Count() override; + + IRaspiCameraDevice * GetCameraDevice() override; + + void addDevice (const std::string & sDeviceString); + +}; + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCDRIVER_CAMERA_RASPICAMERADEVICEITERATOR diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_abi.hpp b/Drivers/Camera/Interfaces/libmcdriver_camera_abi.hpp new file mode 100644 index 00000000..305af7ff --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_abi.hpp @@ -0,0 +1,361 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_HEADER_CPP +#define __LIBMCDRIVER_CAMERA_HEADER_CPP + +#ifdef __LIBMCDRIVER_CAMERA_EXPORTS +#ifdef _WIN32 +#define LIBMCDRIVER_CAMERA_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBMCDRIVER_CAMERA_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBMCDRIVER_CAMERA_EXPORTS +#define LIBMCDRIVER_CAMERA_DECLSPEC +#endif // __LIBMCDRIVER_CAMERA_EXPORTS + +#include "libmcdriver_camera_types.hpp" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getname(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameBufferSize, LibMCDriver_Camera_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_gettype(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nTypeBufferSize, LibMCDriver_Camera_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getversion(LibMCDriver_Camera_Driver pDriver, LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro, const LibMCDriver_Camera_uint32 nBuildBufferSize, LibMCDriver_Camera_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_getheaderinformation(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameSpaceBufferSize, LibMCDriver_Camera_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_Camera_uint32 nBaseNameBufferSize, LibMCDriver_Camera_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_movenext(LibMCDriver_Camera_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_moveprevious(LibMCDriver_Camera_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_getcurrent(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_clone(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Iterator * pOutIterator); + +/** +* Returns the number of resources the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_iterator_count(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for PNGImage +**************************************************************************************************************************/ + +/** +* Returns width of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pWidth - width of the image in pixels. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getwidth(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pWidth); + +/** +* Returns height of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pHeight - height of the image in pixels. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getheight(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pHeight); + +/** +* Returns pixel format of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[out] pPixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getpixelformat(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera::eImagePixelFormat * pPixelformat); + +/** +* Returns raw data of the image. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nPNGDataBufferSize - Number of elements in buffer +* @param[out] pPNGDataNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPNGDataBuffer - uint8 buffer of Binary data of PNG image captured. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_getrawdata(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer); + +/** +* Saves PNG Image on Disk. +* +* @param[in] pPNGImage - PNGImage instance. +* @param[in] nFileNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFileNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFileNameBuffer - buffer of Filename to save PNG to., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_pngimage_savetofile(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint32 nFileNameBufferSize, LibMCDriver_Camera_uint32* pFileNameNeededChars, char * pFileNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_Camera +**************************************************************************************************************************/ + +/** +* Captures an image from the camera and returns a PNG image. +* +* @param[in] pDriver_Camera - Driver_Camera instance. +* @param[out] pPNGImage - Instance of the PNG Image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_camera_capturepngimage(LibMCDriver_Camera_Driver_Camera pDriver_Camera, LibMCDriver_Camera_PNGImage * pPNGImage); + +/************************************************************************************************************************* + Class definition for RaspiCameraDevice +**************************************************************************************************************************/ + +/** +* Returns path to the camera device. +* +* @param[in] pRaspiCameraDevice - RaspiCameraDevice instance. +* @param[in] nDeviceStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pDeviceStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pDeviceStringBuffer - buffer of Path to camera device., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_raspicameradevice_getdevicestring(LibMCDriver_Camera_RaspiCameraDevice pRaspiCameraDevice, const LibMCDriver_Camera_uint32 nDeviceStringBufferSize, LibMCDriver_Camera_uint32* pDeviceStringNeededChars, char * pDeviceStringBuffer); + +/************************************************************************************************************************* + Class definition for RaspiCameraDeviceIterator +**************************************************************************************************************************/ + +/** +* Returns the camera device the iterator points at. +* +* @param[in] pRaspiCameraDeviceIterator - RaspiCameraDeviceIterator instance. +* @param[out] pCurrentInstance - returns the camera device instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_raspicameradeviceiterator_getcameradevice(LibMCDriver_Camera_RaspiCameraDeviceIterator pRaspiCameraDeviceIterator, LibMCDriver_Camera_RaspiCameraDevice * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Driver_RaspiCamera +**************************************************************************************************************************/ + +/** +* Looks for cameras on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[out] pDeviceIterator - Iterator Instance through all found devices. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_querydevices(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, LibMCDriver_Camera_RaspiCameraDeviceIterator * pDeviceIterator); + +/** +* Initialize the camera on the Raspberry PI. +* +* @param[in] pDriver_RaspiCamera - Driver_RaspiCamera instance. +* @param[in] pDeviceString - Path to camera device. +* @param[in] nWidth - Width of Image in Pixels. +* @param[in] nHeight - Height of Image in Pixels. +* @param[in] ePixelformat - Pixel format of the image. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_initialize(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, const char * pDeviceString, LibMCDriver_Camera_uint32 nWidth, LibMCDriver_Camera_uint32 nHeight, LibMCDriver_Camera::eImagePixelFormat ePixelformat); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getversion(LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getlasterror(LibMCDriver_Camera_Base pInstance, const LibMCDriver_Camera_uint32 nErrorMessageBufferSize, LibMCDriver_Camera_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_releaseinstance(LibMCDriver_Camera_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_acquireinstance(LibMCDriver_Camera_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_injectcomponent(const char * pNameSpace, LibMCDriver_Camera_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_getsymbollookupmethod(LibMCDriver_Camera_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_CAMERA_DECLSPEC LibMCDriver_CameraResult libmcdriver_camera_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_Camera_Driver * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBMCDRIVER_CAMERA_HEADER_CPP + diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.cpp b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.cpp new file mode 100644 index 00000000..5d4eefec --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.cpp @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Implementation file with the basic internal + exception type in order to allow an easy use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + + +#include + +#include "libmcdriver_camera_interfaceexception.hpp" + +/************************************************************************************************************************* + Class ELibMCDriver_CameraInterfaceException +**************************************************************************************************************************/ +ELibMCDriver_CameraInterfaceException::ELibMCDriver_CameraInterfaceException(LibMCDriver_CameraResult errorCode) + : m_errorMessage(LIBMCDRIVER_CAMERA_GETERRORSTRING (errorCode)) +{ + m_errorCode = errorCode; +} + +ELibMCDriver_CameraInterfaceException::ELibMCDriver_CameraInterfaceException(LibMCDriver_CameraResult errorCode, std::string errorMessage) + : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") +{ + m_errorCode = errorCode; +} + +LibMCDriver_CameraResult ELibMCDriver_CameraInterfaceException::getErrorCode () +{ + return m_errorCode; +} + +const char * ELibMCDriver_CameraInterfaceException::what () const noexcept +{ + return m_errorMessage.c_str(); +} + diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.hpp b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.hpp new file mode 100644 index 00000000..93eaf3b0 --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaceexception.hpp @@ -0,0 +1,83 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Header file with the basic internal + exception type in order to allow an easy use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_INTERFACEEXCEPTION_HEADER +#define __LIBMCDRIVER_CAMERA_INTERFACEEXCEPTION_HEADER + +#include +#include +#include "libmcdriver_camera_types.hpp" + +/************************************************************************************************************************* + Class ELibMCDriver_CameraInterfaceException +**************************************************************************************************************************/ + + +class ELibMCDriver_CameraInterfaceException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibMCDriver_CameraResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibMCDriver_CameraInterfaceException(LibMCDriver_CameraResult errorCode); + + /** + * Custom Exception Constructor. + */ + ELibMCDriver_CameraInterfaceException(LibMCDriver_CameraResult errorCode, std::string errorMessage); + + /** + * Returns error code + */ + LibMCDriver_CameraResult getErrorCode(); + /** + * Returns error message + */ + const char* what() const noexcept override; +}; + +#endif // __LIBMCDRIVER_CAMERA_INTERFACEEXCEPTION_HEADER diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_interfaces.hpp b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaces.hpp new file mode 100644 index 00000000..42060547 --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_interfaces.hpp @@ -0,0 +1,519 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ header file in order to allow easy +development of MC Driver Camera. The implementer of MC Driver Camera needs to +derive concrete classes from the abstract classes in this header. + +Interface version: 1.0.0 + +*/ + + +#ifndef __LIBMCDRIVER_CAMERA_CPPINTERFACES +#define __LIBMCDRIVER_CAMERA_CPPINTERFACES + +#include +#include + +#include "libmcdriver_camera_types.hpp" + + +#include "libmcdriverenv_dynamic.hpp" + +namespace LibMCDriver_Camera { +namespace Impl { + +/** + Forward declarations of class interfaces +*/ +class IBase; +class IDriver; +class IIterator; +class IPNGImage; +class IDriver_Camera; +class IRaspiCameraDevice; +class IRaspiCameraDeviceIterator; +class IDriver_RaspiCamera; + + + +/************************************************************************************************************************* + Parameter Cache definitions +**************************************************************************************************************************/ + +class ParameterCache { + public: + virtual ~ParameterCache() {} +}; + +template class ParameterCache_1 : public ParameterCache { + private: + T1 m_param1; + public: + ParameterCache_1 (const T1 & param1) + : m_param1 (param1) + { + } + + void retrieveData (T1 & param1) + { + param1 = m_param1; + } +}; + +template class ParameterCache_2 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + public: + ParameterCache_2 (const T1 & param1, const T2 & param2) + : m_param1 (param1), m_param2 (param2) + { + } + + void retrieveData (T1 & param1, T2 & param2) + { + param1 = m_param1; + param2 = m_param2; + } +}; + +template class ParameterCache_3 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + public: + ParameterCache_3 (const T1 & param1, const T2 & param2, const T3 & param3) + : m_param1 (param1), m_param2 (param2), m_param3 (param3) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + } +}; + +template class ParameterCache_4 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + T4 m_param4; + public: + ParameterCache_4 (const T1 & param1, const T2 & param2, const T3 & param3, const T4 & param4) + : m_param1 (param1), m_param2 (param2), m_param3 (param3), m_param4 (param4) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3, T4 & param4) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + param4 = m_param4; + } +}; + + +/************************************************************************************************************************* + Class interface for Base +**************************************************************************************************************************/ + +class IBase { +private: + std::unique_ptr m_ParameterCache; +public: + /** + * IBase::~IBase - virtual destructor of IBase + */ + virtual ~IBase() {}; + + /** + * IBase::ReleaseBaseClassInterface - Releases ownership of a base class interface. Deletes the reference, if necessary. + * @param[in] pIBase - The base class instance to release + */ + static void ReleaseBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->DecRefCount(); + } + }; + + /** + * IBase::AcquireBaseClassInterface - Acquires shared ownership of a base class interface. + * @param[in] pIBase - The base class instance to acquire + */ + static void AcquireBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->IncRefCount(); + } + }; + + + /** + * IBase::GetLastErrorMessage - Returns the last error registered of this class instance + * @param[out] sErrorMessage - Message of the last error registered + * @return Has an error been registered already + */ + virtual bool GetLastErrorMessage(std::string & sErrorMessage) = 0; + + /** + * IBase::ClearErrorMessages - Clears all registered messages of this class instance + */ + virtual void ClearErrorMessages() = 0; + + /** + * IBase::RegisterErrorMessage - Registers an error message with this class instance + * @param[in] sErrorMessage - Error message to register + */ + virtual void RegisterErrorMessage(const std::string & sErrorMessage) = 0; + + /** + * IBase::IncRefCount - Increases the reference count of a class instance + */ + virtual void IncRefCount() = 0; + + /** + * IBase::DecRefCount - Decreases the reference count of a class instance and free releases it, if the last reference has been removed + * @return Has the object been released + */ + virtual bool DecRefCount() = 0; + + /** + * IBase::_setCache - set parameter cache of object + */ + void _setCache(ParameterCache * pCache) + { + m_ParameterCache.reset(pCache); + } + + /** + * IBase::_getCache - returns parameter cache of object + */ + ParameterCache* _getCache() + { + return m_ParameterCache.get(); + } + +}; + + +/** + Definition of a shared pointer class for IBase +*/ +template +class IBaseSharedPtr : public std::shared_ptr +{ +public: + explicit IBaseSharedPtr(T* t = nullptr) + : std::shared_ptr(t, IBase::ReleaseBaseClassInterface) + { + t->IncRefCount(); + } + + // Reset function, as it also needs to properly set the deleter. + void reset(T* t = nullptr) + { + std::shared_ptr::reset(t, IBase::ReleaseBaseClassInterface); + } + + // Get-function that increases the Base class's reference count + T* getCoOwningPtr() + { + T* t = this->get(); + t->IncRefCount(); + return t; + } +}; + + +typedef IBaseSharedPtr PIBase; + + +/************************************************************************************************************************* + Class interface for Driver +**************************************************************************************************************************/ + +class IDriver : public virtual IBase { +public: + /** + * IDriver::GetName - returns the name identifier of the driver + * @return Name of the driver. + */ + virtual std::string GetName() = 0; + + /** + * IDriver::GetType - returns the type identifier of the driver + * @return Type of the driver. + */ + virtual std::string GetType() = 0; + + /** + * IDriver::GetVersion - returns the version identifiers of the driver + * @param[out] nMajor - Major version. + * @param[out] nMinor - Minor version. + * @param[out] nMicro - Micro version. + * @param[out] sBuild - Build identifier. + */ + virtual void GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro, std::string & sBuild) = 0; + + /** + * IDriver::GetHeaderInformation - returns the header information + * @param[out] sNameSpace - NameSpace of the driver. + * @param[out] sBaseName - BaseName of the driver. + */ + virtual void GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName) = 0; + +}; + +typedef IBaseSharedPtr PIDriver; + + +/************************************************************************************************************************* + Class interface for Iterator +**************************************************************************************************************************/ + +class IIterator : public virtual IBase { +public: + /** + * IIterator::MoveNext - Iterates to the next resource in the list. + * @return Iterates to the next resource in the list. + */ + virtual bool MoveNext() = 0; + + /** + * IIterator::MovePrevious - Iterates to the previous resource in the list. + * @return Iterates to the previous resource in the list. + */ + virtual bool MovePrevious() = 0; + + /** + * IIterator::GetCurrent - Returns the resource the iterator points at. + * @return returns the resource instance. + */ + virtual IBase * GetCurrent() = 0; + + /** + * IIterator::Clone - Creates a new resource iterator with the same resource list. + * @return returns the cloned Iterator instance + */ + virtual IIterator * Clone() = 0; + + /** + * IIterator::Count - Returns the number of resources the iterator captures. + * @return returns the number of resources the iterator captures. + */ + virtual LibMCDriver_Camera_uint64 Count() = 0; + +}; + +typedef IBaseSharedPtr PIIterator; + + +/************************************************************************************************************************* + Class interface for PNGImage +**************************************************************************************************************************/ + +class IPNGImage : public virtual IBase { +public: + /** + * IPNGImage::GetWidth - Returns width of the image. + * @return width of the image in pixels. + */ + virtual LibMCDriver_Camera_uint64 GetWidth() = 0; + + /** + * IPNGImage::GetHeight - Returns height of the image. + * @return height of the image in pixels. + */ + virtual LibMCDriver_Camera_uint64 GetHeight() = 0; + + /** + * IPNGImage::GetPixelFormat - Returns pixel format of the image. + * @return Pixel format of the image. + */ + virtual LibMCDriver_Camera::eImagePixelFormat GetPixelFormat() = 0; + + /** + * IPNGImage::GetRawData - Returns raw data of the image. + * @param[in] nPNGDataBufferSize - Number of elements in buffer + * @param[out] pPNGDataNeededCount - will be filled with the count of the written structs, or needed buffer size. + * @param[out] pPNGDataBuffer - uint8 buffer of Binary data of PNG image captured. + */ + virtual void GetRawData(LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer) = 0; + + /** + * IPNGImage::SaveToFile - Saves PNG Image on Disk. + * @return Filename to save PNG to. + */ + virtual std::string SaveToFile() = 0; + +}; + +typedef IBaseSharedPtr PIPNGImage; + + +/************************************************************************************************************************* + Class interface for Driver_Camera +**************************************************************************************************************************/ + +class IDriver_Camera : public virtual IDriver { +public: + /** + * IDriver_Camera::CapturePNGImage - Captures an image from the camera and returns a PNG image. + * @return Instance of the PNG Image. + */ + virtual IPNGImage * CapturePNGImage() = 0; + +}; + +typedef IBaseSharedPtr PIDriver_Camera; + + +/************************************************************************************************************************* + Class interface for RaspiCameraDevice +**************************************************************************************************************************/ + +class IRaspiCameraDevice : public virtual IBase { +public: + /** + * IRaspiCameraDevice::GetDeviceString - Returns path to the camera device. + * @return Path to camera device. + */ + virtual std::string GetDeviceString() = 0; + +}; + +typedef IBaseSharedPtr PIRaspiCameraDevice; + + +/************************************************************************************************************************* + Class interface for RaspiCameraDeviceIterator +**************************************************************************************************************************/ + +class IRaspiCameraDeviceIterator : public virtual IIterator { +public: + /** + * IRaspiCameraDeviceIterator::GetCameraDevice - Returns the camera device the iterator points at. + * @return returns the camera device instance. + */ + virtual IRaspiCameraDevice * GetCameraDevice() = 0; + +}; + +typedef IBaseSharedPtr PIRaspiCameraDeviceIterator; + + +/************************************************************************************************************************* + Class interface for Driver_RaspiCamera +**************************************************************************************************************************/ + +class IDriver_RaspiCamera : public virtual IDriver_Camera { +public: + /** + * IDriver_RaspiCamera::QueryDevices - Looks for cameras on the Raspberry PI. + * @return Iterator Instance through all found devices. + */ + virtual IRaspiCameraDeviceIterator * QueryDevices() = 0; + + /** + * IDriver_RaspiCamera::Initialize - Initialize the camera on the Raspberry PI. + * @param[in] sDeviceString - Path to camera device. + * @param[in] nWidth - Width of Image in Pixels. + * @param[in] nHeight - Height of Image in Pixels. + * @param[in] ePixelformat - Pixel format of the image. + */ + virtual void Initialize(const std::string & sDeviceString, const LibMCDriver_Camera_uint32 nWidth, const LibMCDriver_Camera_uint32 nHeight, const LibMCDriver_Camera::eImagePixelFormat ePixelformat) = 0; + +}; + +typedef IBaseSharedPtr PIDriver_RaspiCamera; + + +/************************************************************************************************************************* + Global functions declarations +**************************************************************************************************************************/ +class CWrapper { +public: + // Injected Components + static LibMCDriverEnv::PWrapper sPLibMCDriverEnvWrapper; + + /** + * Ilibmcdriver_camera::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + static void GetVersion(LibMCDriver_Camera_uint32 & nMajor, LibMCDriver_Camera_uint32 & nMinor, LibMCDriver_Camera_uint32 & nMicro); + + /** + * Ilibmcdriver_camera::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + static bool GetLastError(IBase* pInstance, std::string & sErrorMessage); + + /** + * Ilibmcdriver_camera::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void ReleaseInstance(IBase* pInstance); + + /** + * Ilibmcdriver_camera::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void AcquireInstance(IBase* pInstance); + + /** + * Ilibmcdriver_camera::CreateDriver - Creates a driver instance with a specific name. + * @param[in] sName - Name of driver to be created. + * @param[in] sType - Type of driver to be created. + * @param[in] pDriverEnvironment - Environment of this driver. + * @return New Driver instance + */ + static IDriver * CreateDriver(const std::string & sName, const std::string & sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment); + +}; + +LibMCDriver_CameraResult LibMCDriver_Camera_GetProcAddress (const char * pProcName, void ** ppProcAddress); + +} // namespace Impl +} // namespace LibMCDriver_Camera + +#endif // __LIBMCDRIVER_CAMERA_CPPINTERFACES diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_interfacewrapper.cpp b/Drivers/Camera/Interfaces/libmcdriver_camera_interfacewrapper.cpp new file mode 100644 index 00000000..2d10d4a3 --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_interfacewrapper.cpp @@ -0,0 +1,1047 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ implementation file in order to allow easy +development of MC Driver Camera. The functions in this file need to be implemented. It needs to be generated only once. + +Interface version: 1.0.0 + +*/ + +#include "libmcdriver_camera_abi.hpp" +#include "libmcdriver_camera_interfaces.hpp" +#include "libmcdriver_camera_interfaceexception.hpp" + +#include + +using namespace LibMCDriver_Camera::Impl; + +LibMCDriver_CameraResult handleLibMCDriver_CameraException(IBase * pIBaseClass, ELibMCDriver_CameraInterfaceException & Exception) +{ + LibMCDriver_CameraResult errorCode = Exception.getErrorCode(); + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibMCDriver_CameraResult handleStdException(IBase * pIBaseClass, std::exception & Exception) +{ + LibMCDriver_CameraResult errorCode = LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibMCDriver_CameraResult handleUnhandledException(IBase * pIBaseClass) +{ + LibMCDriver_CameraResult errorCode = LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage("Unhandled Exception"); + + return errorCode; +} + + + +/************************************************************************************************************************* + Class implementation for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for Driver +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_driver_getname(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameBufferSize, LibMCDriver_Camera_uint32* pNameNeededChars, char * pNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pNameBuffer) && !(pNameNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sName(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIDriver->GetName(); + + pIDriver->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIDriver->_setCache (nullptr); + } + + if (pNameNeededChars) + *pNameNeededChars = (LibMCDriver_Camera_uint32) (sName.size()+1); + if (pNameBuffer) { + if (sName.size() >= nNameBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iName = 0; iName < sName.size(); iName++) + pNameBuffer[iName] = sName[iName]; + pNameBuffer[sName.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_driver_gettype(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nTypeBufferSize, LibMCDriver_Camera_uint32* pTypeNeededChars, char * pTypeBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pTypeBuffer) && !(pTypeNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sType(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pTypeBuffer == nullptr); + if (isCacheCall) { + sType = pIDriver->GetType(); + + pIDriver->_setCache (new ParameterCache_1 (sType)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (sType); + pIDriver->_setCache (nullptr); + } + + if (pTypeNeededChars) + *pTypeNeededChars = (LibMCDriver_Camera_uint32) (sType.size()+1); + if (pTypeBuffer) { + if (sType.size() >= nTypeBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iType = 0; iType < sType.size(); iType++) + pTypeBuffer[iType] = sType[iType]; + pTypeBuffer[sType.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_driver_getversion(LibMCDriver_Camera_Driver pDriver, LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro, const LibMCDriver_Camera_uint32 nBuildBufferSize, LibMCDriver_Camera_uint32* pBuildNeededChars, char * pBuildBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if (!pMajor) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (!pMinor) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (!pMicro) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if ( (!pBuildBuffer) && !(pBuildNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sBuild(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pBuildBuffer == nullptr); + if (isCacheCall) { + pIDriver->GetVersion(*pMajor, *pMinor, *pMicro, sBuild); + + pIDriver->_setCache (new ParameterCache_4 (*pMajor, *pMinor, *pMicro, sBuild)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (*pMajor, *pMinor, *pMicro, sBuild); + pIDriver->_setCache (nullptr); + } + + if (pBuildNeededChars) + *pBuildNeededChars = (LibMCDriver_Camera_uint32) (sBuild.size()+1); + if (pBuildBuffer) { + if (sBuild.size() >= nBuildBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iBuild = 0; iBuild < sBuild.size(); iBuild++) + pBuildBuffer[iBuild] = sBuild[iBuild]; + pBuildBuffer[sBuild.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_driver_getheaderinformation(LibMCDriver_Camera_Driver pDriver, const LibMCDriver_Camera_uint32 nNameSpaceBufferSize, LibMCDriver_Camera_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_Camera_uint32 nBaseNameBufferSize, LibMCDriver_Camera_uint32* pBaseNameNeededChars, char * pBaseNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pNameSpaceBuffer) && !(pNameSpaceNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if ( (!pBaseNameBuffer) && !(pBaseNameNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sNameSpace(""); + std::string sBaseName(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameSpaceBuffer == nullptr) || (pBaseNameBuffer == nullptr); + if (isCacheCall) { + pIDriver->GetHeaderInformation(sNameSpace, sBaseName); + + pIDriver->_setCache (new ParameterCache_2 (sNameSpace, sBaseName)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (sNameSpace, sBaseName); + pIDriver->_setCache (nullptr); + } + + if (pNameSpaceNeededChars) + *pNameSpaceNeededChars = (LibMCDriver_Camera_uint32) (sNameSpace.size()+1); + if (pNameSpaceBuffer) { + if (sNameSpace.size() >= nNameSpaceBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iNameSpace = 0; iNameSpace < sNameSpace.size(); iNameSpace++) + pNameSpaceBuffer[iNameSpace] = sNameSpace[iNameSpace]; + pNameSpaceBuffer[sNameSpace.size()] = 0; + } + if (pBaseNameNeededChars) + *pBaseNameNeededChars = (LibMCDriver_Camera_uint32) (sBaseName.size()+1); + if (pBaseNameBuffer) { + if (sBaseName.size() >= nBaseNameBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iBaseName = 0; iBaseName < sBaseName.size(); iBaseName++) + pBaseNameBuffer[iBaseName] = sBaseName[iBaseName]; + pBaseNameBuffer[sBaseName.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Iterator +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_iterator_movenext(LibMCDriver_Camera_Iterator pIterator, bool * pHasNext) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pHasNext == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pHasNext = pIIterator->MoveNext(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_iterator_moveprevious(LibMCDriver_Camera_Iterator pIterator, bool * pHasPrevious) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pHasPrevious == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pHasPrevious = pIIterator->MovePrevious(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_iterator_getcurrent(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Base * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIIterator->GetCurrent(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_iterator_clone(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_Iterator * pOutIterator) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pOutIterator == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pBaseOutIterator(nullptr); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pBaseOutIterator = pIIterator->Clone(); + + *pOutIterator = (IBase*)(pBaseOutIterator); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_iterator_count(LibMCDriver_Camera_Iterator pIterator, LibMCDriver_Camera_uint64 * pCount) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pCount == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pCount = pIIterator->Count(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for PNGImage +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_pngimage_getwidth(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pWidth) +{ + IBase* pIBaseClass = (IBase *)pPNGImage; + + try { + if (pWidth == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IPNGImage* pIPNGImage = dynamic_cast(pIBaseClass); + if (!pIPNGImage) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pWidth = pIPNGImage->GetWidth(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_pngimage_getheight(LibMCDriver_Camera_PNGImage pPNGImage, LibMCDriver_Camera_uint64 * pHeight) +{ + IBase* pIBaseClass = (IBase *)pPNGImage; + + try { + if (pHeight == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IPNGImage* pIPNGImage = dynamic_cast(pIBaseClass); + if (!pIPNGImage) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pHeight = pIPNGImage->GetHeight(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_pngimage_getpixelformat(LibMCDriver_Camera_PNGImage pPNGImage, eLibMCDriver_CameraImagePixelFormat * pPixelformat) +{ + IBase* pIBaseClass = (IBase *)pPNGImage; + + try { + if (pPixelformat == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IPNGImage* pIPNGImage = dynamic_cast(pIBaseClass); + if (!pIPNGImage) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + *pPixelformat = pIPNGImage->GetPixelFormat(); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_pngimage_getrawdata(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint64 nPNGDataBufferSize, LibMCDriver_Camera_uint64* pPNGDataNeededCount, LibMCDriver_Camera_uint8 * pPNGDataBuffer) +{ + IBase* pIBaseClass = (IBase *)pPNGImage; + + try { + if ((!pPNGDataBuffer) && !(pPNGDataNeededCount)) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IPNGImage* pIPNGImage = dynamic_cast(pIBaseClass); + if (!pIPNGImage) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pIPNGImage->GetRawData(nPNGDataBufferSize, pPNGDataNeededCount, pPNGDataBuffer); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_pngimage_savetofile(LibMCDriver_Camera_PNGImage pPNGImage, const LibMCDriver_Camera_uint32 nFileNameBufferSize, LibMCDriver_Camera_uint32* pFileNameNeededChars, char * pFileNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pPNGImage; + + try { + if ( (!pFileNameBuffer) && !(pFileNameNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sFileName(""); + IPNGImage* pIPNGImage = dynamic_cast(pIBaseClass); + if (!pIPNGImage) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pFileNameBuffer == nullptr); + if (isCacheCall) { + sFileName = pIPNGImage->SaveToFile(); + + pIPNGImage->_setCache (new ParameterCache_1 (sFileName)); + } + else { + auto cache = dynamic_cast*> (pIPNGImage->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (sFileName); + pIPNGImage->_setCache (nullptr); + } + + if (pFileNameNeededChars) + *pFileNameNeededChars = (LibMCDriver_Camera_uint32) (sFileName.size()+1); + if (pFileNameBuffer) { + if (sFileName.size() >= nFileNameBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iFileName = 0; iFileName < sFileName.size(); iFileName++) + pFileNameBuffer[iFileName] = sFileName[iFileName]; + pFileNameBuffer[sFileName.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Driver_Camera +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_driver_camera_capturepngimage(LibMCDriver_Camera_Driver_Camera pDriver_Camera, LibMCDriver_Camera_PNGImage * pPNGImage) +{ + IBase* pIBaseClass = (IBase *)pDriver_Camera; + + try { + if (pPNGImage == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pBasePNGImage(nullptr); + IDriver_Camera* pIDriver_Camera = dynamic_cast(pIBaseClass); + if (!pIDriver_Camera) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pBasePNGImage = pIDriver_Camera->CapturePNGImage(); + + *pPNGImage = (IBase*)(pBasePNGImage); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for RaspiCameraDevice +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_raspicameradevice_getdevicestring(LibMCDriver_Camera_RaspiCameraDevice pRaspiCameraDevice, const LibMCDriver_Camera_uint32 nDeviceStringBufferSize, LibMCDriver_Camera_uint32* pDeviceStringNeededChars, char * pDeviceStringBuffer) +{ + IBase* pIBaseClass = (IBase *)pRaspiCameraDevice; + + try { + if ( (!pDeviceStringBuffer) && !(pDeviceStringNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sDeviceString(""); + IRaspiCameraDevice* pIRaspiCameraDevice = dynamic_cast(pIBaseClass); + if (!pIRaspiCameraDevice) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + bool isCacheCall = (pDeviceStringBuffer == nullptr); + if (isCacheCall) { + sDeviceString = pIRaspiCameraDevice->GetDeviceString(); + + pIRaspiCameraDevice->_setCache (new ParameterCache_1 (sDeviceString)); + } + else { + auto cache = dynamic_cast*> (pIRaspiCameraDevice->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + cache->retrieveData (sDeviceString); + pIRaspiCameraDevice->_setCache (nullptr); + } + + if (pDeviceStringNeededChars) + *pDeviceStringNeededChars = (LibMCDriver_Camera_uint32) (sDeviceString.size()+1); + if (pDeviceStringBuffer) { + if (sDeviceString.size() >= nDeviceStringBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iDeviceString = 0; iDeviceString < sDeviceString.size(); iDeviceString++) + pDeviceStringBuffer[iDeviceString] = sDeviceString[iDeviceString]; + pDeviceStringBuffer[sDeviceString.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for RaspiCameraDeviceIterator +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_raspicameradeviceiterator_getcameradevice(LibMCDriver_Camera_RaspiCameraDeviceIterator pRaspiCameraDeviceIterator, LibMCDriver_Camera_RaspiCameraDevice * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pRaspiCameraDeviceIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IRaspiCameraDeviceIterator* pIRaspiCameraDeviceIterator = dynamic_cast(pIBaseClass); + if (!pIRaspiCameraDeviceIterator) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIRaspiCameraDeviceIterator->GetCameraDevice(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Driver_RaspiCamera +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_querydevices(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, LibMCDriver_Camera_RaspiCameraDeviceIterator * pDeviceIterator) +{ + IBase* pIBaseClass = (IBase *)pDriver_RaspiCamera; + + try { + if (pDeviceIterator == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pBaseDeviceIterator(nullptr); + IDriver_RaspiCamera* pIDriver_RaspiCamera = dynamic_cast(pIBaseClass); + if (!pIDriver_RaspiCamera) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pBaseDeviceIterator = pIDriver_RaspiCamera->QueryDevices(); + + *pDeviceIterator = (IBase*)(pBaseDeviceIterator); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_driver_raspicamera_initialize(LibMCDriver_Camera_Driver_RaspiCamera pDriver_RaspiCamera, const char * pDeviceString, LibMCDriver_Camera_uint32 nWidth, LibMCDriver_Camera_uint32 nHeight, eLibMCDriver_CameraImagePixelFormat ePixelformat) +{ + IBase* pIBaseClass = (IBase *)pDriver_RaspiCamera; + + try { + if (pDeviceString == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sDeviceString(pDeviceString); + IDriver_RaspiCamera* pIDriver_RaspiCamera = dynamic_cast(pIBaseClass); + if (!pIDriver_RaspiCamera) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + pIDriver_RaspiCamera->Initialize(sDeviceString, nWidth, nHeight, ePixelformat); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + + +/************************************************************************************************************************* + Function table lookup implementation +**************************************************************************************************************************/ + +LibMCDriver_CameraResult LibMCDriver_Camera::Impl::LibMCDriver_Camera_GetProcAddress (const char * pProcName, void ** ppProcAddress) +{ + if (pProcName == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + if (ppProcAddress == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM; + *ppProcAddress = nullptr; + std::string sProcName (pProcName); + + if (sProcName == "libmcdriver_camera_driver_getname") + *ppProcAddress = (void*) &libmcdriver_camera_driver_getname; + if (sProcName == "libmcdriver_camera_driver_gettype") + *ppProcAddress = (void*) &libmcdriver_camera_driver_gettype; + if (sProcName == "libmcdriver_camera_driver_getversion") + *ppProcAddress = (void*) &libmcdriver_camera_driver_getversion; + if (sProcName == "libmcdriver_camera_driver_getheaderinformation") + *ppProcAddress = (void*) &libmcdriver_camera_driver_getheaderinformation; + if (sProcName == "libmcdriver_camera_iterator_movenext") + *ppProcAddress = (void*) &libmcdriver_camera_iterator_movenext; + if (sProcName == "libmcdriver_camera_iterator_moveprevious") + *ppProcAddress = (void*) &libmcdriver_camera_iterator_moveprevious; + if (sProcName == "libmcdriver_camera_iterator_getcurrent") + *ppProcAddress = (void*) &libmcdriver_camera_iterator_getcurrent; + if (sProcName == "libmcdriver_camera_iterator_clone") + *ppProcAddress = (void*) &libmcdriver_camera_iterator_clone; + if (sProcName == "libmcdriver_camera_iterator_count") + *ppProcAddress = (void*) &libmcdriver_camera_iterator_count; + if (sProcName == "libmcdriver_camera_pngimage_getwidth") + *ppProcAddress = (void*) &libmcdriver_camera_pngimage_getwidth; + if (sProcName == "libmcdriver_camera_pngimage_getheight") + *ppProcAddress = (void*) &libmcdriver_camera_pngimage_getheight; + if (sProcName == "libmcdriver_camera_pngimage_getpixelformat") + *ppProcAddress = (void*) &libmcdriver_camera_pngimage_getpixelformat; + if (sProcName == "libmcdriver_camera_pngimage_getrawdata") + *ppProcAddress = (void*) &libmcdriver_camera_pngimage_getrawdata; + if (sProcName == "libmcdriver_camera_pngimage_savetofile") + *ppProcAddress = (void*) &libmcdriver_camera_pngimage_savetofile; + if (sProcName == "libmcdriver_camera_driver_camera_capturepngimage") + *ppProcAddress = (void*) &libmcdriver_camera_driver_camera_capturepngimage; + if (sProcName == "libmcdriver_camera_raspicameradevice_getdevicestring") + *ppProcAddress = (void*) &libmcdriver_camera_raspicameradevice_getdevicestring; + if (sProcName == "libmcdriver_camera_raspicameradeviceiterator_getcameradevice") + *ppProcAddress = (void*) &libmcdriver_camera_raspicameradeviceiterator_getcameradevice; + if (sProcName == "libmcdriver_camera_driver_raspicamera_querydevices") + *ppProcAddress = (void*) &libmcdriver_camera_driver_raspicamera_querydevices; + if (sProcName == "libmcdriver_camera_driver_raspicamera_initialize") + *ppProcAddress = (void*) &libmcdriver_camera_driver_raspicamera_initialize; + if (sProcName == "libmcdriver_camera_getversion") + *ppProcAddress = (void*) &libmcdriver_camera_getversion; + if (sProcName == "libmcdriver_camera_getlasterror") + *ppProcAddress = (void*) &libmcdriver_camera_getlasterror; + if (sProcName == "libmcdriver_camera_releaseinstance") + *ppProcAddress = (void*) &libmcdriver_camera_releaseinstance; + if (sProcName == "libmcdriver_camera_acquireinstance") + *ppProcAddress = (void*) &libmcdriver_camera_acquireinstance; + if (sProcName == "libmcdriver_camera_injectcomponent") + *ppProcAddress = (void*) &libmcdriver_camera_injectcomponent; + if (sProcName == "libmcdriver_camera_getsymbollookupmethod") + *ppProcAddress = (void*) &libmcdriver_camera_getsymbollookupmethod; + if (sProcName == "libmcdriver_camera_createdriver") + *ppProcAddress = (void*) &libmcdriver_camera_createdriver; + + if (*ppProcAddress == nullptr) + return LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT; + return LIBMCDRIVER_CAMERA_SUCCESS; +} + +/************************************************************************************************************************* + Global functions implementation +**************************************************************************************************************************/ +LibMCDriver_CameraResult libmcdriver_camera_getversion(LibMCDriver_Camera_uint32 * pMajor, LibMCDriver_Camera_uint32 * pMinor, LibMCDriver_Camera_uint32 * pMicro) +{ + IBase* pIBaseClass = nullptr; + + try { + if (!pMajor) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (!pMinor) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (!pMicro) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + CWrapper::GetVersion(*pMajor, *pMinor, *pMicro); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_getlasterror(LibMCDriver_Camera_Base pInstance, const LibMCDriver_Camera_uint32 nErrorMessageBufferSize, LibMCDriver_Camera_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError) +{ + IBase* pIBaseClass = nullptr; + + try { + if ( (!pErrorMessageBuffer) && !(pErrorMessageNeededChars) ) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (pHasError == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + std::string sErrorMessage(""); + *pHasError = CWrapper::GetLastError(pIInstance, sErrorMessage); + + if (pErrorMessageNeededChars) + *pErrorMessageNeededChars = (LibMCDriver_Camera_uint32) (sErrorMessage.size()+1); + if (pErrorMessageBuffer) { + if (sErrorMessage.size() >= nErrorMessageBufferSize) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL); + for (size_t iErrorMessage = 0; iErrorMessage < sErrorMessage.size(); iErrorMessage++) + pErrorMessageBuffer[iErrorMessage] = sErrorMessage[iErrorMessage]; + pErrorMessageBuffer[sErrorMessage.size()] = 0; + } + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_releaseinstance(LibMCDriver_Camera_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + CWrapper::ReleaseInstance(pIInstance); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_acquireinstance(LibMCDriver_Camera_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + CWrapper::AcquireInstance(pIInstance); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_injectcomponent(const char * pNameSpace, LibMCDriver_Camera_pvoid pSymbolAddressMethod) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pNameSpace == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sNameSpace(pNameSpace); + + bool bNameSpaceFound = false; + + if (sNameSpace == "LibMCDriverEnv") { + if (CWrapper::sPLibMCDriverEnvWrapper.get() != nullptr) { + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY); + } + CWrapper::sPLibMCDriverEnvWrapper = LibMCDriverEnv::CWrapper::loadLibraryFromSymbolLookupMethod(pSymbolAddressMethod); + bNameSpaceFound = true; + } + + if (!bNameSpaceFound) + throw ELibMCDriver_CameraInterfaceException(LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY); + + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_getsymbollookupmethod(LibMCDriver_Camera_pvoid * pSymbolLookupMethod) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pSymbolLookupMethod == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + *pSymbolLookupMethod = (void*)&LibMCDriver_Camera::Impl::LibMCDriver_Camera_GetProcAddress; + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_CameraResult libmcdriver_camera_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_Camera_Driver * pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pName == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (pType == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + if (pInstance == nullptr) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM); + std::string sName(pName); + std::string sType(pType); + LibMCDriverEnv::PDriverEnvironment pIDriverEnvironment = std::make_shared(CWrapper::sPLibMCDriverEnvWrapper.get(), pDriverEnvironment); + CWrapper::sPLibMCDriverEnvWrapper->AcquireInstance(pIDriverEnvironment.get()); + if (!pIDriverEnvironment) + throw ELibMCDriver_CameraInterfaceException (LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST); + + IBase* pBaseInstance(nullptr); + pBaseInstance = CWrapper::CreateDriver(sName, sType, pIDriverEnvironment); + + *pInstance = (IBase*)(pBaseInstance); + return LIBMCDRIVER_CAMERA_SUCCESS; + } + catch (ELibMCDriver_CameraInterfaceException & Exception) { + return handleLibMCDriver_CameraException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + diff --git a/Drivers/Camera/Interfaces/libmcdriver_camera_types.hpp b/Drivers/Camera/Interfaces/libmcdriver_camera_types.hpp new file mode 100644 index 00000000..7897cf0a --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_camera_types.hpp @@ -0,0 +1,163 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of MC Driver Camera + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP +#define __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +typedef unsigned char LibMCDriver_Camera_uint8; +typedef unsigned short LibMCDriver_Camera_uint16 ; +typedef unsigned int LibMCDriver_Camera_uint32; +typedef unsigned long long LibMCDriver_Camera_uint64; +typedef char LibMCDriver_Camera_int8; +typedef short LibMCDriver_Camera_int16; +typedef int LibMCDriver_Camera_int32; +typedef long long LibMCDriver_Camera_int64; + +#else // LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibMCDriver_Camera_uint8; +typedef uint16_t LibMCDriver_Camera_uint16; +typedef uint32_t LibMCDriver_Camera_uint32; +typedef uint64_t LibMCDriver_Camera_uint64; +typedef int8_t LibMCDriver_Camera_int8; +typedef int16_t LibMCDriver_Camera_int16; +typedef int32_t LibMCDriver_Camera_int32; +typedef int64_t LibMCDriver_Camera_int64 ; + +#endif // LIBMCDRIVER_CAMERA_USELEGACYINTEGERTYPES + +typedef float LibMCDriver_Camera_single; +typedef double LibMCDriver_Camera_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibMCDriver_Camera_int32 LibMCDriver_CameraResult; +typedef void * LibMCDriver_CameraHandle; +typedef void * LibMCDriver_Camera_pvoid; + +/************************************************************************************************************************* + Version for LibMCDriver_Camera +**************************************************************************************************************************/ + +#define LIBMCDRIVER_CAMERA_VERSION_MAJOR 1 +#define LIBMCDRIVER_CAMERA_VERSION_MINOR 0 +#define LIBMCDRIVER_CAMERA_VERSION_MICRO 0 +#define LIBMCDRIVER_CAMERA_VERSION_PRERELEASEINFO "" +#define LIBMCDRIVER_CAMERA_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibMCDriver_Camera +**************************************************************************************************************************/ + +#define LIBMCDRIVER_CAMERA_SUCCESS 0 +#define LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED 1 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM 2 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST 3 +#define LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL 4 +#define LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION 5 +#define LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBMCDRIVER_CAMERA_ERROR_INCOMPATIBLEBINARYVERSION 8 +#define LIBMCDRIVER_CAMERA_ERROR_INVALIDSTATENAME 9 +#define LIBMCDRIVER_CAMERA_ERROR_DRIVERERROR 1000 +#define LIBMCDRIVER_CAMERA_ERROR_ITERATORERROR 1001 + +/************************************************************************************************************************* + Error strings for LibMCDriver_Camera +**************************************************************************************************************************/ + +inline const char * LIBMCDRIVER_CAMERA_GETERRORSTRING (LibMCDriver_CameraResult nErrorCode) { + switch (nErrorCode) { + case LIBMCDRIVER_CAMERA_SUCCESS: return "no error"; + case LIBMCDRIVER_CAMERA_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBMCDRIVER_CAMERA_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBMCDRIVER_CAMERA_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBMCDRIVER_CAMERA_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBMCDRIVER_CAMERA_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBMCDRIVER_CAMERA_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + case LIBMCDRIVER_CAMERA_ERROR_INVALIDSTATENAME: return "invalid state name"; + case LIBMCDRIVER_CAMERA_ERROR_DRIVERERROR: return "a driver error occured"; + case LIBMCDRIVER_CAMERA_ERROR_ITERATORERROR: return "iterator does not point at valid object."; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Base; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Iterator; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_PNGImage; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver_Camera; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_RaspiCameraDevice; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_RaspiCameraDeviceIterator; +typedef LibMCDriver_CameraHandle LibMCDriver_Camera_Driver_RaspiCamera; + +namespace LibMCDriver_Camera { + + /************************************************************************************************************************* + Declaration of enums + **************************************************************************************************************************/ + + enum class eImagePixelFormat : LibMCDriver_Camera_int32 { + Unknown = 0, + RGB32 = 1, + Grayscale32 = 2 + }; + +} // namespace LibMCDriver_Camera; + +// define legacy C-names for enums, structs and function types +typedef LibMCDriver_Camera::eImagePixelFormat eLibMCDriver_CameraImagePixelFormat; + +#endif // __LIBMCDRIVER_CAMERA_TYPES_HEADER_CPP diff --git a/Drivers/Camera/Interfaces/libmcdriver_interfacewrapper.cpp b/Drivers/Camera/Interfaces/libmcdriver_interfacewrapper.cpp new file mode 100644 index 00000000..602d8170 --- /dev/null +++ b/Drivers/Camera/Interfaces/libmcdriver_interfacewrapper.cpp @@ -0,0 +1,89 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + +#include "libmcdriver_abi.hpp" +#include "libmcdriver_camera_abi.hpp" + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_driver_getname(LibMCDriver_Driver pDriver, const LibMCDriver_uint32 nNameBufferSize, LibMCDriver_uint32* pNameNeededChars, char * pNameBuffer) +{ + return libmcdriver_camera_driver_getname (pDriver, nNameBufferSize, pNameNeededChars, pNameBuffer); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_driver_gettype(LibMCDriver_Driver pDriver, const LibMCDriver_uint32 nTypeBufferSize, LibMCDriver_uint32* pTypeNeededChars, char * pTypeBuffer) +{ + return libmcdriver_camera_driver_gettype(pDriver, nTypeBufferSize, pTypeNeededChars, pTypeBuffer); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_driver_getversion(LibMCDriver_Driver pDriver, LibMCDriver_uint32 * pMajor, LibMCDriver_uint32 * pMinor, LibMCDriver_uint32 * pMicro, const LibMCDriver_uint32 nBuildBufferSize, LibMCDriver_uint32* pBuildNeededChars, char * pBuildBuffer) +{ + return libmcdriver_camera_driver_getversion(pDriver, pMajor, pMinor, pMicro, nBuildBufferSize, pBuildNeededChars, pBuildBuffer); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_driver_getheaderinformation(LibMCDriver_Driver pDriver, const LibMCDriver_uint32 nNameSpaceBufferSize, LibMCDriver_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_uint32 nBaseNameBufferSize, LibMCDriver_uint32* pBaseNameNeededChars, char * pBaseNameBuffer) +{ + return libmcdriver_camera_driver_getheaderinformation(pDriver, nNameSpaceBufferSize, pNameSpaceNeededChars, pNameSpaceBuffer, nNameSpaceBufferSize, pBaseNameNeededChars, pBaseNameBuffer); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_getversion(LibMCDriver_uint32 * pMajor, LibMCDriver_uint32 * pMinor, LibMCDriver_uint32 * pMicro) +{ + return libmcdriver_camera_getversion(pMajor, pMinor, pMicro); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_getlasterror(LibMCDriver_Base pInstance, const LibMCDriver_uint32 nErrorMessageBufferSize, LibMCDriver_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError) +{ + return libmcdriver_camera_getlasterror(pInstance, nErrorMessageBufferSize, pErrorMessageNeededChars, pErrorMessageBuffer, pHasError); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_releaseinstance(LibMCDriver_Base pInstance) +{ + return libmcdriver_camera_releaseinstance(pInstance); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_acquireinstance(LibMCDriver_Base pInstance) +{ + return libmcdriver_camera_acquireinstance(pInstance); +} + + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_injectcomponent(const char * pNameSpace, LibMCDriver_pvoid pSymbolAddressMethod) +{ + return libmcdriver_camera_injectcomponent(pNameSpace, pSymbolAddressMethod); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_Driver * pInstance) +{ + return libmcdriver_camera_createdriver(pName, pType, pDriverEnvironment, pInstance); +} + +LIBMCDRIVER_DECLSPEC LibMCDriverResult libmcdriver_getsymbollookupmethod(LibMCDriver_pvoid* pSymbolLookupMethod) +{ + return libmcdriver_camera_getsymbollookupmethod(pSymbolLookupMethod); +} diff --git a/Drivers/Marlin/ACT/LibMCDriver_Marlin.xml b/Drivers/Marlin/ACT/LibMCDriver_Marlin.xml index e20b700b..dbaa5391 100644 --- a/Drivers/Marlin/ACT/LibMCDriver_Marlin.xml +++ b/Drivers/Marlin/ACT/LibMCDriver_Marlin.xml @@ -108,6 +108,8 @@ Custom implementation + + @@ -117,6 +119,28 @@ Custom implementation + + + + + + + + + + + + + + + + + + + + + + @@ -132,10 +156,25 @@ Custom implementation - - + + + + + + + + + + + + + + + + + @@ -147,21 +186,37 @@ Custom implementation - + + + + + - + - + - + + + + + + + + + + + + + diff --git a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_abi.hpp b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_abi.hpp index 4a922d34..c008d1ce 100644 --- a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_abi.hpp +++ b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_abi.hpp @@ -125,9 +125,11 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_g * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] pCOMPort - Device Port to connect to * @param[in] nBaudrate - Baudrate to use +* @param[in] dStatusUpdateInterval - Timer interval [ms] for updating status +* @param[in] nConnectTimeout - Timeout [ms] for connecting printer * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate, LibMCDriver_Marlin_double dStatusUpdateInterval, LibMCDriver_Marlin_uint32 nConnectTimeout); /** * Disconnects from the Marlin board. @@ -146,6 +148,48 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m */ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setabsolutepositioning(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool bAbsolute); +/** +* Sets heated bed target temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dTemperatureInDegreeCelcius - Bed target temperature. +* @param[in] bWaitForTemp - If true, waits for the target bed temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Sets target temperature of the given extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of extruder. +* @param[in] dTemperatureInDegreeCelcius - Extruder target temperature. +* @param[in] bWaitForTemp - If true, waits for the target extruder temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setextrudertargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Turns on one of the fans and set its speed. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nFanID - ID of fan. +* @param[in] nSpeed - Fan speed [0..255]. 0=0%!.(MISSING).255=100%! +(MISSING)* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setfanspeed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nFanID, LibMCDriver_Marlin_uint32 nSpeed); + +/** +* Sets PID parameters. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dP - New value for P parameter. +* @param[in] dI - New value for I parameter. +* @param[in] dD - New value for D parameter. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dP, LibMCDriver_Marlin_double dI, LibMCDriver_Marlin_double dD); + /** * Polls a new state from the firmware. * @@ -177,15 +221,45 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_gettargetposition(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pX, LibMCDriver_Marlin_double * pY, LibMCDriver_Marlin_double * pZ); /** -* Returns the current temperature of an extruder. +* Returns the target extruder position. * * @param[in] pDriver_Marlin - Driver_Marlin instance. -* @param[in] nExtruderID - ID of Extruder +* @param[out] pE - E Value in mm +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertargetposition(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pE); + +/** +* Returns the current and the target bed temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pTargetTemperature - Target Temperature in degree celsius. * @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getheatedbedtemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current and the target temperature of an extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of Extruder * @param[out] pTargetTemperature - Target Temperature in degree celsius. +* @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current PID values. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pP - Current P value. +* @param[out] pI - Current I value. +* @param[out] pD - Current D value. * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pCurrentTemperature, LibMCDriver_Marlin_double * pTargetTemperature); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pP, LibMCDriver_Marlin_double * pI, LibMCDriver_Marlin_double * pD); /** * Returns if the movement buffer can receive another movement command.. @@ -205,17 +279,26 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m */ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ismoving(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); +/** +* Returns if the printer is homed +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pValue - True if printer is homed. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ishomed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); + /** * Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm -* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_moveto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); /** * Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. @@ -223,11 +306,39 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dZ - Z Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefastto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); + +/** +* Start Homing of printer. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_starthoming(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin); /************************************************************************************************************************* Global functions diff --git a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.h b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.h index 12fccd97..a4094385 100644 --- a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.h +++ b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.h @@ -112,9 +112,11 @@ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_GetHeaderInformatio * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] pCOMPort - Device Port to connect to * @param[in] nBaudrate - Baudrate to use +* @param[in] dStatusUpdateInterval - Timer interval [ms] for updating status +* @param[in] nConnectTimeout - Timeout [ms] for connecting printer * @return error code or 0 (success) */ -typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_ConnectPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate); +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_ConnectPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate, LibMCDriver_Marlin_double dStatusUpdateInterval, LibMCDriver_Marlin_uint32 nConnectTimeout); /** * Disconnects from the Marlin board. @@ -133,6 +135,48 @@ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_DisconnectPt */ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_SetAbsolutePositioningPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool bAbsolute); +/** +* Sets heated bed target temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dTemperatureInDegreeCelcius - Bed target temperature. +* @param[in] bWaitForTemp - If true, waits for the target bed temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_SetHeatedBedTargetTemperaturePtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Sets target temperature of the given extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of extruder. +* @param[in] dTemperatureInDegreeCelcius - Extruder target temperature. +* @param[in] bWaitForTemp - If true, waits for the target extruder temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_SetExtruderTargetTemperaturePtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Turns on one of the fans and set its speed. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nFanID - ID of fan. +* @param[in] nSpeed - Fan speed [0..255]. 0=0%!.(MISSING).255=100%! +(MISSING)* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_SetFanSpeedPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nFanID, LibMCDriver_Marlin_uint32 nSpeed); + +/** +* Sets PID parameters. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dP - New value for P parameter. +* @param[in] dI - New value for I parameter. +* @param[in] dD - New value for D parameter. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_SetPidParametersPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dP, LibMCDriver_Marlin_double dI, LibMCDriver_Marlin_double dD); + /** * Polls a new state from the firmware. * @@ -164,15 +208,45 @@ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetCurrentPo typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetTargetPositionPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pX, LibMCDriver_Marlin_double * pY, LibMCDriver_Marlin_double * pZ); /** -* Returns the current temperature of an extruder. +* Returns the target extruder position. * * @param[in] pDriver_Marlin - Driver_Marlin instance. -* @param[in] nExtruderID - ID of Extruder +* @param[out] pE - E Value in mm +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetExtruderTargetPositionPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pE); + +/** +* Returns the current and the target bed temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pTargetTemperature - Target Temperature in degree celsius. * @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetHeatedBedTemperaturePtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current and the target temperature of an extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of Extruder * @param[out] pTargetTemperature - Target Temperature in degree celsius. +* @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetExtruderTemperaturePtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current PID values. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pP - Current P value. +* @param[out] pI - Current I value. +* @param[out] pD - Current D value. * @return error code or 0 (success) */ -typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetExtruderTemperaturePtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pCurrentTemperature, LibMCDriver_Marlin_double * pTargetTemperature); +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_GetPidParametersPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pP, LibMCDriver_Marlin_double * pI, LibMCDriver_Marlin_double * pD); /** * Returns if the movement buffer can receive another movement command.. @@ -192,17 +266,26 @@ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_CanExecuteMo */ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_IsMovingPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); +/** +* Returns if the printer is homed +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pValue - True if printer is homed. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_IsHomedPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); + /** * Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm -* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveToPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveToXYPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); /** * Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. @@ -210,11 +293,39 @@ typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveToPtr) ( * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveFastToXYPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveToZPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dZ - Z Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveFastToPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_MoveFastToZPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); + +/** +* Start Homing of printer. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @return error code or 0 (success) +*/ +typedef LibMCDriver_MarlinResult (*PLibMCDriver_MarlinDriver_Marlin_StartHomingPtr) (LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin); /************************************************************************************************************************* Global functions @@ -299,14 +410,25 @@ typedef struct { PLibMCDriver_MarlinDriver_Marlin_ConnectPtr m_Driver_Marlin_Connect; PLibMCDriver_MarlinDriver_Marlin_DisconnectPtr m_Driver_Marlin_Disconnect; PLibMCDriver_MarlinDriver_Marlin_SetAbsolutePositioningPtr m_Driver_Marlin_SetAbsolutePositioning; + PLibMCDriver_MarlinDriver_Marlin_SetHeatedBedTargetTemperaturePtr m_Driver_Marlin_SetHeatedBedTargetTemperature; + PLibMCDriver_MarlinDriver_Marlin_SetExtruderTargetTemperaturePtr m_Driver_Marlin_SetExtruderTargetTemperature; + PLibMCDriver_MarlinDriver_Marlin_SetFanSpeedPtr m_Driver_Marlin_SetFanSpeed; + PLibMCDriver_MarlinDriver_Marlin_SetPidParametersPtr m_Driver_Marlin_SetPidParameters; PLibMCDriver_MarlinDriver_Marlin_UpdateStatePtr m_Driver_Marlin_UpdateState; PLibMCDriver_MarlinDriver_Marlin_GetCurrentPositionPtr m_Driver_Marlin_GetCurrentPosition; PLibMCDriver_MarlinDriver_Marlin_GetTargetPositionPtr m_Driver_Marlin_GetTargetPosition; + PLibMCDriver_MarlinDriver_Marlin_GetExtruderTargetPositionPtr m_Driver_Marlin_GetExtruderTargetPosition; + PLibMCDriver_MarlinDriver_Marlin_GetHeatedBedTemperaturePtr m_Driver_Marlin_GetHeatedBedTemperature; PLibMCDriver_MarlinDriver_Marlin_GetExtruderTemperaturePtr m_Driver_Marlin_GetExtruderTemperature; + PLibMCDriver_MarlinDriver_Marlin_GetPidParametersPtr m_Driver_Marlin_GetPidParameters; PLibMCDriver_MarlinDriver_Marlin_CanExecuteMovementPtr m_Driver_Marlin_CanExecuteMovement; PLibMCDriver_MarlinDriver_Marlin_IsMovingPtr m_Driver_Marlin_IsMoving; - PLibMCDriver_MarlinDriver_Marlin_MoveToPtr m_Driver_Marlin_MoveTo; - PLibMCDriver_MarlinDriver_Marlin_MoveFastToPtr m_Driver_Marlin_MoveFastTo; + PLibMCDriver_MarlinDriver_Marlin_IsHomedPtr m_Driver_Marlin_IsHomed; + PLibMCDriver_MarlinDriver_Marlin_MoveToXYPtr m_Driver_Marlin_MoveToXY; + PLibMCDriver_MarlinDriver_Marlin_MoveFastToXYPtr m_Driver_Marlin_MoveFastToXY; + PLibMCDriver_MarlinDriver_Marlin_MoveToZPtr m_Driver_Marlin_MoveToZ; + PLibMCDriver_MarlinDriver_Marlin_MoveFastToZPtr m_Driver_Marlin_MoveFastToZ; + PLibMCDriver_MarlinDriver_Marlin_StartHomingPtr m_Driver_Marlin_StartHoming; PLibMCDriver_MarlinGetVersionPtr m_GetVersion; PLibMCDriver_MarlinGetLastErrorPtr m_GetLastError; PLibMCDriver_MarlinReleaseInstancePtr m_ReleaseInstance; diff --git a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.hpp b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.hpp index e0005ab9..f910e228 100644 --- a/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.hpp +++ b/Drivers/Marlin/Headers/CppDynamic/libmcdriver_marlin_dynamic.hpp @@ -360,17 +360,28 @@ class CDriver_Marlin : public CDriver { { } - inline void Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate); + inline void Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate, const LibMCDriver_Marlin_double dStatusUpdateInterval, const LibMCDriver_Marlin_uint32 nConnectTimeout); inline void Disconnect(); inline void SetAbsolutePositioning(const bool bAbsolute); + inline void SetHeatedBedTargetTemperature(const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp); + inline void SetExtruderTargetTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp); + inline void SetFanSpeed(const LibMCDriver_Marlin_uint32 nFanID, const LibMCDriver_Marlin_uint32 nSpeed); + inline void SetPidParameters(const LibMCDriver_Marlin_double dP, const LibMCDriver_Marlin_double dI, const LibMCDriver_Marlin_double dD); inline void UpdateState(); inline void GetCurrentPosition(LibMCDriver_Marlin_double & dX, LibMCDriver_Marlin_double & dY, LibMCDriver_Marlin_double & dZ); inline void GetTargetPosition(LibMCDriver_Marlin_double & dX, LibMCDriver_Marlin_double & dY, LibMCDriver_Marlin_double & dZ); - inline void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dCurrentTemperature, LibMCDriver_Marlin_double & dTargetTemperature); + inline void GetExtruderTargetPosition(LibMCDriver_Marlin_double & dE); + inline void GetHeatedBedTemperature(LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature); + inline void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature); + inline void GetPidParameters(LibMCDriver_Marlin_double & dP, LibMCDriver_Marlin_double & dI, LibMCDriver_Marlin_double & dD); inline bool CanExecuteMovement(); inline bool IsMoving(); - inline void MoveTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed); - inline void MoveFastTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed); + inline bool IsHomed(); + inline void MoveToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed); + inline void MoveFastToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dSpeed); + inline void MoveToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed); + inline void MoveFastToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed); + inline void StartHoming(); }; /** @@ -501,14 +512,25 @@ class CDriver_Marlin : public CDriver { pWrapperTable->m_Driver_Marlin_Connect = nullptr; pWrapperTable->m_Driver_Marlin_Disconnect = nullptr; pWrapperTable->m_Driver_Marlin_SetAbsolutePositioning = nullptr; + pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature = nullptr; + pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature = nullptr; + pWrapperTable->m_Driver_Marlin_SetFanSpeed = nullptr; + pWrapperTable->m_Driver_Marlin_SetPidParameters = nullptr; pWrapperTable->m_Driver_Marlin_UpdateState = nullptr; pWrapperTable->m_Driver_Marlin_GetCurrentPosition = nullptr; pWrapperTable->m_Driver_Marlin_GetTargetPosition = nullptr; + pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition = nullptr; + pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature = nullptr; pWrapperTable->m_Driver_Marlin_GetExtruderTemperature = nullptr; + pWrapperTable->m_Driver_Marlin_GetPidParameters = nullptr; pWrapperTable->m_Driver_Marlin_CanExecuteMovement = nullptr; pWrapperTable->m_Driver_Marlin_IsMoving = nullptr; - pWrapperTable->m_Driver_Marlin_MoveTo = nullptr; - pWrapperTable->m_Driver_Marlin_MoveFastTo = nullptr; + pWrapperTable->m_Driver_Marlin_IsHomed = nullptr; + pWrapperTable->m_Driver_Marlin_MoveToXY = nullptr; + pWrapperTable->m_Driver_Marlin_MoveFastToXY = nullptr; + pWrapperTable->m_Driver_Marlin_MoveToZ = nullptr; + pWrapperTable->m_Driver_Marlin_MoveFastToZ = nullptr; + pWrapperTable->m_Driver_Marlin_StartHoming = nullptr; pWrapperTable->m_GetVersion = nullptr; pWrapperTable->m_GetLastError = nullptr; pWrapperTable->m_ReleaseInstance = nullptr; @@ -627,6 +649,42 @@ class CDriver_Marlin : public CDriver { if (pWrapperTable->m_Driver_Marlin_SetAbsolutePositioning == nullptr) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature = (PLibMCDriver_MarlinDriver_Marlin_SetHeatedBedTargetTemperaturePtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature = (PLibMCDriver_MarlinDriver_Marlin_SetHeatedBedTargetTemperaturePtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature = (PLibMCDriver_MarlinDriver_Marlin_SetExtruderTargetTemperaturePtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_setextrudertargettemperature"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature = (PLibMCDriver_MarlinDriver_Marlin_SetExtruderTargetTemperaturePtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_setextrudertargettemperature"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_SetFanSpeed = (PLibMCDriver_MarlinDriver_Marlin_SetFanSpeedPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_setfanspeed"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_SetFanSpeed = (PLibMCDriver_MarlinDriver_Marlin_SetFanSpeedPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_setfanspeed"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_SetFanSpeed == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_SetPidParameters = (PLibMCDriver_MarlinDriver_Marlin_SetPidParametersPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_setpidparameters"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_SetPidParameters = (PLibMCDriver_MarlinDriver_Marlin_SetPidParametersPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_setpidparameters"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_SetPidParameters == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Driver_Marlin_UpdateState = (PLibMCDriver_MarlinDriver_Marlin_UpdateStatePtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_updatestate"); #else // _WIN32 @@ -654,6 +712,24 @@ class CDriver_Marlin : public CDriver { if (pWrapperTable->m_Driver_Marlin_GetTargetPosition == nullptr) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition = (PLibMCDriver_MarlinDriver_Marlin_GetExtruderTargetPositionPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_getextrudertargetposition"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition = (PLibMCDriver_MarlinDriver_Marlin_GetExtruderTargetPositionPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_getextrudertargetposition"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature = (PLibMCDriver_MarlinDriver_Marlin_GetHeatedBedTemperaturePtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_getheatedbedtemperature"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature = (PLibMCDriver_MarlinDriver_Marlin_GetHeatedBedTemperaturePtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_getheatedbedtemperature"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Driver_Marlin_GetExtruderTemperature = (PLibMCDriver_MarlinDriver_Marlin_GetExtruderTemperaturePtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_getextrudertemperature"); #else // _WIN32 @@ -663,6 +739,15 @@ class CDriver_Marlin : public CDriver { if (pWrapperTable->m_Driver_Marlin_GetExtruderTemperature == nullptr) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_GetPidParameters = (PLibMCDriver_MarlinDriver_Marlin_GetPidParametersPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_getpidparameters"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_GetPidParameters = (PLibMCDriver_MarlinDriver_Marlin_GetPidParametersPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_getpidparameters"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_GetPidParameters == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Driver_Marlin_CanExecuteMovement = (PLibMCDriver_MarlinDriver_Marlin_CanExecuteMovementPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_canexecutemovement"); #else // _WIN32 @@ -682,21 +767,57 @@ class CDriver_Marlin : public CDriver { return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 - pWrapperTable->m_Driver_Marlin_MoveTo = (PLibMCDriver_MarlinDriver_Marlin_MoveToPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_moveto"); + pWrapperTable->m_Driver_Marlin_IsHomed = (PLibMCDriver_MarlinDriver_Marlin_IsHomedPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_ishomed"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_IsHomed = (PLibMCDriver_MarlinDriver_Marlin_IsHomedPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_ishomed"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_IsHomed == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_MoveToXY = (PLibMCDriver_MarlinDriver_Marlin_MoveToXYPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_movetoxy"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_MoveToXY = (PLibMCDriver_MarlinDriver_Marlin_MoveToXYPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_movetoxy"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_MoveToXY == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_MoveFastToXY = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToXYPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_movefasttoxy"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_MoveFastToXY = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToXYPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_movefasttoxy"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_MoveFastToXY == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_MoveToZ = (PLibMCDriver_MarlinDriver_Marlin_MoveToZPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_movetoz"); + #else // _WIN32 + pWrapperTable->m_Driver_Marlin_MoveToZ = (PLibMCDriver_MarlinDriver_Marlin_MoveToZPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_movetoz"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_Marlin_MoveToZ == nullptr) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_Marlin_MoveFastToZ = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToZPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_movefasttoz"); #else // _WIN32 - pWrapperTable->m_Driver_Marlin_MoveTo = (PLibMCDriver_MarlinDriver_Marlin_MoveToPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_moveto"); + pWrapperTable->m_Driver_Marlin_MoveFastToZ = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToZPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_movefasttoz"); dlerror(); #endif // _WIN32 - if (pWrapperTable->m_Driver_Marlin_MoveTo == nullptr) + if (pWrapperTable->m_Driver_Marlin_MoveFastToZ == nullptr) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 - pWrapperTable->m_Driver_Marlin_MoveFastTo = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_movefastto"); + pWrapperTable->m_Driver_Marlin_StartHoming = (PLibMCDriver_MarlinDriver_Marlin_StartHomingPtr) GetProcAddress(hLibrary, "libmcdriver_marlin_driver_marlin_starthoming"); #else // _WIN32 - pWrapperTable->m_Driver_Marlin_MoveFastTo = (PLibMCDriver_MarlinDriver_Marlin_MoveFastToPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_movefastto"); + pWrapperTable->m_Driver_Marlin_StartHoming = (PLibMCDriver_MarlinDriver_Marlin_StartHomingPtr) dlsym(hLibrary, "libmcdriver_marlin_driver_marlin_starthoming"); dlerror(); #endif // _WIN32 - if (pWrapperTable->m_Driver_Marlin_MoveFastTo == nullptr) + if (pWrapperTable->m_Driver_Marlin_StartHoming == nullptr) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 @@ -806,6 +927,22 @@ class CDriver_Marlin : public CDriver { if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_SetAbsolutePositioning == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature", (void**)&(pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_SetHeatedBedTargetTemperature == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_setextrudertargettemperature", (void**)&(pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_SetExtruderTargetTemperature == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_setfanspeed", (void**)&(pWrapperTable->m_Driver_Marlin_SetFanSpeed)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_SetFanSpeed == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_setpidparameters", (void**)&(pWrapperTable->m_Driver_Marlin_SetPidParameters)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_SetPidParameters == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_updatestate", (void**)&(pWrapperTable->m_Driver_Marlin_UpdateState)); if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_UpdateState == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -818,10 +955,22 @@ class CDriver_Marlin : public CDriver { if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_GetTargetPosition == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_getextrudertargetposition", (void**)&(pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_GetExtruderTargetPosition == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_getheatedbedtemperature", (void**)&(pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_GetHeatedBedTemperature == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_getextrudertemperature", (void**)&(pWrapperTable->m_Driver_Marlin_GetExtruderTemperature)); if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_GetExtruderTemperature == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_getpidparameters", (void**)&(pWrapperTable->m_Driver_Marlin_GetPidParameters)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_GetPidParameters == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_canexecutemovement", (void**)&(pWrapperTable->m_Driver_Marlin_CanExecuteMovement)); if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_CanExecuteMovement == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -830,12 +979,28 @@ class CDriver_Marlin : public CDriver { if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_IsMoving == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; - eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_moveto", (void**)&(pWrapperTable->m_Driver_Marlin_MoveTo)); - if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveTo == nullptr) ) + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_ishomed", (void**)&(pWrapperTable->m_Driver_Marlin_IsHomed)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_IsHomed == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_movetoxy", (void**)&(pWrapperTable->m_Driver_Marlin_MoveToXY)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveToXY == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; - eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_movefastto", (void**)&(pWrapperTable->m_Driver_Marlin_MoveFastTo)); - if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveFastTo == nullptr) ) + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_movefasttoxy", (void**)&(pWrapperTable->m_Driver_Marlin_MoveFastToXY)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveFastToXY == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_movetoz", (void**)&(pWrapperTable->m_Driver_Marlin_MoveToZ)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveToZ == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_movefasttoz", (void**)&(pWrapperTable->m_Driver_Marlin_MoveFastToZ)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_MoveFastToZ == nullptr) ) + return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_marlin_driver_marlin_starthoming", (void**)&(pWrapperTable->m_Driver_Marlin_StartHoming)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Marlin_StartHoming == nullptr) ) return LIBMCDRIVER_MARLIN_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libmcdriver_marlin_getversion", (void**)&(pWrapperTable->m_GetVersion)); @@ -953,10 +1118,12 @@ class CDriver_Marlin : public CDriver { * CDriver_Marlin::Connect - Creates and initializes a new Marlin Connector. * @param[in] sCOMPort - Device Port to connect to * @param[in] nBaudrate - Baudrate to use + * @param[in] dStatusUpdateInterval - Timer interval [ms] for updating status + * @param[in] nConnectTimeout - Timeout [ms] for connecting printer */ - void CDriver_Marlin::Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate) + void CDriver_Marlin::Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate, const LibMCDriver_Marlin_double dStatusUpdateInterval, const LibMCDriver_Marlin_uint32 nConnectTimeout) { - CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_Connect(m_pHandle, sCOMPort.c_str(), nBaudrate)); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_Connect(m_pHandle, sCOMPort.c_str(), nBaudrate, dStatusUpdateInterval, nConnectTimeout)); } /** @@ -976,6 +1143,48 @@ class CDriver_Marlin : public CDriver { CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_SetAbsolutePositioning(m_pHandle, bAbsolute)); } + /** + * CDriver_Marlin::SetHeatedBedTargetTemperature - Sets heated bed target temperature. + * @param[in] dTemperatureInDegreeCelcius - Bed target temperature. + * @param[in] bWaitForTemp - If true, waits for the target bed temperature to be reached before proceeding + */ + void CDriver_Marlin::SetHeatedBedTargetTemperature(const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_SetHeatedBedTargetTemperature(m_pHandle, dTemperatureInDegreeCelcius, bWaitForTemp)); + } + + /** + * CDriver_Marlin::SetExtruderTargetTemperature - Sets target temperature of the given extruder. + * @param[in] nExtruderID - ID of extruder. + * @param[in] dTemperatureInDegreeCelcius - Extruder target temperature. + * @param[in] bWaitForTemp - If true, waits for the target extruder temperature to be reached before proceeding + */ + void CDriver_Marlin::SetExtruderTargetTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_SetExtruderTargetTemperature(m_pHandle, nExtruderID, dTemperatureInDegreeCelcius, bWaitForTemp)); + } + + /** + * CDriver_Marlin::SetFanSpeed - Turns on one of the fans and set its speed. + * @param[in] nFanID - ID of fan. + * @param[in] nSpeed - Fan speed [0..255]. 0=0%!.(MISSING).255=100%! +(MISSING) */ + void CDriver_Marlin::SetFanSpeed(const LibMCDriver_Marlin_uint32 nFanID, const LibMCDriver_Marlin_uint32 nSpeed) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_SetFanSpeed(m_pHandle, nFanID, nSpeed)); + } + + /** + * CDriver_Marlin::SetPidParameters - Sets PID parameters. + * @param[in] dP - New value for P parameter. + * @param[in] dI - New value for I parameter. + * @param[in] dD - New value for D parameter. + */ + void CDriver_Marlin::SetPidParameters(const LibMCDriver_Marlin_double dP, const LibMCDriver_Marlin_double dI, const LibMCDriver_Marlin_double dD) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_SetPidParameters(m_pHandle, dP, dI, dD)); + } + /** * CDriver_Marlin::UpdateState - Polls a new state from the firmware. */ @@ -1007,14 +1216,44 @@ class CDriver_Marlin : public CDriver { } /** - * CDriver_Marlin::GetExtruderTemperature - Returns the current temperature of an extruder. - * @param[in] nExtruderID - ID of Extruder + * CDriver_Marlin::GetExtruderTargetPosition - Returns the target extruder position. + * @param[out] dE - E Value in mm + */ + void CDriver_Marlin::GetExtruderTargetPosition(LibMCDriver_Marlin_double & dE) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_GetExtruderTargetPosition(m_pHandle, &dE)); + } + + /** + * CDriver_Marlin::GetHeatedBedTemperature - Returns the current and the target bed temperature. + * @param[out] dTargetTemperature - Target Temperature in degree celsius. * @param[out] dCurrentTemperature - Current Temperature in degree celsius. + */ + void CDriver_Marlin::GetHeatedBedTemperature(LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_GetHeatedBedTemperature(m_pHandle, &dTargetTemperature, &dCurrentTemperature)); + } + + /** + * CDriver_Marlin::GetExtruderTemperature - Returns the current and the target temperature of an extruder. + * @param[in] nExtruderID - ID of Extruder * @param[out] dTargetTemperature - Target Temperature in degree celsius. + * @param[out] dCurrentTemperature - Current Temperature in degree celsius. */ - void CDriver_Marlin::GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dCurrentTemperature, LibMCDriver_Marlin_double & dTargetTemperature) + void CDriver_Marlin::GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature) { - CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_GetExtruderTemperature(m_pHandle, nExtruderID, &dCurrentTemperature, &dTargetTemperature)); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_GetExtruderTemperature(m_pHandle, nExtruderID, &dTargetTemperature, &dCurrentTemperature)); + } + + /** + * CDriver_Marlin::GetPidParameters - Returns the current PID values. + * @param[out] dP - Current P value. + * @param[out] dI - Current I value. + * @param[out] dD - Current D value. + */ + void CDriver_Marlin::GetPidParameters(LibMCDriver_Marlin_double & dP, LibMCDriver_Marlin_double & dI, LibMCDriver_Marlin_double & dD) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_GetPidParameters(m_pHandle, &dP, &dI, &dD)); } /** @@ -1042,27 +1281,67 @@ class CDriver_Marlin : public CDriver { } /** - * CDriver_Marlin::MoveTo - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * CDriver_Marlin::IsHomed - Returns if the printer is homed + * @return True if printer is homed. + */ + bool CDriver_Marlin::IsHomed() + { + bool resultValue = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_IsHomed(m_pHandle, &resultValue)); + + return resultValue; + } + + /** + * CDriver_Marlin::MoveToXY - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm - * @param[in] dZ - Z Value in mm + * @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s */ - void CDriver_Marlin::MoveTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) + void CDriver_Marlin::MoveToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) { - CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveTo(m_pHandle, dX, dY, dZ, dSpeed)); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveToXY(m_pHandle, dX, dY, dE, dSpeed)); } /** - * CDriver_Marlin::MoveFastTo - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * CDriver_Marlin::MoveFastToXY - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm + * @param[in] dSpeed - Movement speed in mm/s + */ + void CDriver_Marlin::MoveFastToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dSpeed) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveFastToXY(m_pHandle, dX, dY, dSpeed)); + } + + /** + * CDriver_Marlin::MoveToZ - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dZ - Z Value in mm + * @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s */ - void CDriver_Marlin::MoveFastTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) + void CDriver_Marlin::MoveToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveToZ(m_pHandle, dZ, dE, dSpeed)); + } + + /** + * CDriver_Marlin::MoveFastToZ - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * @param[in] dZ - Z Value in mm + * @param[in] dSpeed - Movement speed in mm/s + */ + void CDriver_Marlin::MoveFastToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) + { + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveFastToZ(m_pHandle, dZ, dSpeed)); + } + + /** + * CDriver_Marlin::StartHoming - Start Homing of printer. + */ + void CDriver_Marlin::StartHoming() { - CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_MoveFastTo(m_pHandle, dX, dY, dZ, dSpeed)); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_Marlin_StartHoming(m_pHandle)); } } // namespace LibMCDriver_Marlin diff --git a/Drivers/Marlin/Implementation/AMC_SerialController.hpp b/Drivers/Marlin/Implementation/AMC_SerialController.hpp index 13819d2d..1aeebb76 100644 --- a/Drivers/Marlin/Implementation/AMC_SerialController.hpp +++ b/Drivers/Marlin/Implementation/AMC_SerialController.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -34,8 +35,10 @@ namespace AMC { virtual void setPositioningAbolute() = 0; virtual void setPositioningRelative() = 0; - virtual void setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius) = 0; - virtual void setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius) = 0; + virtual void setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius, bool bWait) = 0; + virtual void setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius, bool bWait) = 0; + virtual void setFanSpeed(uint32_t nFanIndex, uint32_t nSpeed) = 0; + virtual void setPidParameters(double dP, double dI, double dD) = 0; virtual void queryTemperatureState (uint32_t nExtruderIndex) = 0; virtual void queryPositionState () = 0; @@ -45,14 +48,19 @@ namespace AMC { virtual void getTargetPosition (double & dX, double& dY, double& dZ) = 0; virtual void getCurrentPosition(double& dX, double& dY, double& dZ) = 0; - virtual void getExtruderPosition (double &dE) = 0; - + virtual void getExtruderTargetPosition (double &dE) = 0; + virtual void getPidParameters(double& dP, double& dI, double& dD) = 0; + virtual void startHoming() = 0; virtual void setLcdMsg(const std::string& sLcdMsg) = 0; - virtual void move(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) = 0; - virtual void moveFast(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) = 0; + virtual void moveXY(const double dX, const double dY, const double dE, const double dSpeedInMMperSecond) = 0; + virtual void moveFastXY(const double dX, const double dY, const double dSpeedInMMperSecond) = 0; + + virtual void moveZ(const double dZ, const double dE, const double dSpeedInMMperSecond) = 0; + virtual void moveFastZ(const double dZ, const double dSpeedInMMperSecond) = 0; + virtual bool isHomed() = 0; virtual bool isMoving() = 0; virtual bool canReceiveMovement () = 0; virtual void waitForMovement() = 0; diff --git a/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.cpp b/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.cpp index b3f937e5..f620fc15 100644 --- a/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.cpp +++ b/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.cpp @@ -30,23 +30,64 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "AMC_SerialController_Marlin.hpp" +#include #include +#ifdef __linux__ +#include +#endif + +#define MARLINDRIVER_MINSPEED 0.0001 + namespace AMC { - CSerialController_Marlin::CSerialController_Marlin(bool bDebug) - : m_sCOMPort ("COM1"), - m_nBaudRate (115200), - m_sAckSymbol ("ok"), - m_nLineNumber (1), - m_bDebug (bDebug), - m_sResendSymbol ("Resend:"), - m_nMinBufferSpace (3), m_nMaxBufferSpace (0), m_nCurrentBufferSpace (0) + CSerialController_Marlin::CSerialController_Marlin(bool bDebug, bool bDoQueryFirmwareInfo, bool bDisableHoming) + : m_sCOMPort("COM1"), + m_nBaudRate(115200), + m_nConnectTimeout(2000), + m_bDoQueryFirmwareInfo(bDoQueryFirmwareInfo), + m_bDisableHoming(bDisableHoming), + m_dStatusUpdateTimerInterval(100), + m_sAckSymbol("ok"), + m_nLineNumber(1), + m_bDebug(bDebug), + m_sResendSymbol("Resend:"), + m_nMinBufferSpace(3), + m_nMaxBufferSpace(0), + m_nCurrentBufferSpace(0), + m_bIsHomed(false), + m_iExtruderCount(0), + m_dCurrentBedTemp(0), + m_dTargetBedTemp(0), + m_dTargetPosX(0), + m_dTargetPosY(0), + m_dTargetPosZ(0), + m_dTargetPosE(0), + m_dCurrentPosX(0), + m_dCurrentPosY(0), + m_dCurrentPosZ(0), + m_dAxisStepsPerUnitX(0), + m_dAxisStepsPerUnitY(0), + m_dAxisStepsPerUnitZ(0), + m_dAxisStepsPerUnitE(0), + m_dCurrentSpeedInMMperSecond(0), + m_dPidValueP(0), + m_dPidValueI(0), + m_dPidValueD(0) + { + // If we disabled homing, then we expect to be at the home position at creation + if (m_bDisableHoming) + m_bIsHomed = true; + } + void CSerialController_Marlin::setStatusUpdateTimerInterval(const double dStatusUpdateTimerInterval) + { + m_dStatusUpdateTimerInterval = dStatusUpdateTimerInterval; } - void CSerialController_Marlin::setCOMPort(const std::string& sCOMPort) + + void CSerialController_Marlin::setCOMPort(const std::string& sCOMPort) { m_sCOMPort = sCOMPort; } @@ -58,7 +99,7 @@ namespace AMC { return m_sCOMPort; } - + void CSerialController_Marlin::setBaudrate(const uint32_t nBaudrate) { if (m_pConnection.get() != nullptr) @@ -72,6 +113,19 @@ namespace AMC { return m_nBaudRate; } + void CSerialController_Marlin::setConnectTimeout(const uint32_t nConnectTimeout) + { + if (m_pConnection.get() != nullptr) + throw std::runtime_error("Serial Port already initialized"); + + m_nConnectTimeout = nConnectTimeout; + } + + uint32_t CSerialController_Marlin::getConnectTimeout() + { + return m_nConnectTimeout; + } + CSerialController_Marlin::~CSerialController_Marlin() { } @@ -81,25 +135,70 @@ namespace AMC { if (m_pConnection.get() != nullptr) throw std::runtime_error("Serial Port already initialized"); - m_pConnection.reset(new serial::Serial(m_sCOMPort, m_nBaudRate, serial::Timeout::simpleTimeout(1000))); + // set timeout >1000 => 2000 (default of m_nConnectTimeout) + // + // if printer is booting (echoing start+ Date+Memory... after switch on printer or plug in cable) and + // timeout would be 1000 the while loop below we be leaved "to early" (after timeout of 1sec) and + // the next command is sent, but printer can't respond to this command with OK, + // because he's not ready to receive commands => boot initialize hags up!! + // + // if printer is not booting (no echoing text... after software" reconnect) + // "start" will no be received, + // but timeout after 2000 will respond with an empty string and + // printer is ready to receive commands + m_pConnection.reset(new serial::Serial(m_sCOMPort, m_nBaudRate, serial::Timeout::simpleTimeout(m_nConnectTimeout))); if (!m_pConnection->isOpen()) { m_pConnection.reset(); throw std::runtime_error("Could not connect to serial port"); } - m_nLineNumber = 1; + // instead of waiting a fixed time wait until "start" or "" (after timeout) received from device?? + //std::this_thread::sleep_for(std::chrono::milliseconds(500)); + bool bAck = false; + while (!bAck) { + std::string sLineRead = m_pConnection->readline(); + if (m_bDebug) { + std::cout << "RETURN: " << sLineRead << std::endl; + } + + bAck = sLineRead.empty() || (sLineRead.find("start") != std::string::npos); + } + - sendCommand("M110 N1"); + // reset line number + std::stringstream sCommand; + sCommand << "M110 " << m_nLineNumber; + sendCommand(sCommand.str()); m_nCurrentBufferSpace = 0; + sendCommand("M400"); + sendCommand("G21"); // set mm units + sendCommand("M149 C"); // set temperature unit to Celsius + sendCommand("M113 S1"); // keep alive period 0-60 possible, no decimals! + setPositioningAbolute(); if (m_nCurrentBufferSpace > 0) { m_nMaxBufferSpace = m_nCurrentBufferSpace; } - sendCommand("G21"); + queryAxisStepsPerUnitStateAndPidValues(); + + m_iExtruderCount = 1; + + if (m_bDoQueryFirmwareInfo) + queryFirmwareInfo(); + + // add an element to list of extruder for every detected extruder + for (uint32_t i = 0; i < m_iExtruderCount; ++i) + { + m_dTargetExtruderTemp.push_back(0); + m_dCurrentExtruderTemp.push_back(0); + } + + checkIsHomed(); + } @@ -114,6 +213,35 @@ namespace AMC { initializeController(); } + + + void CSerialController_Marlin::checkIsHomed() + { + if (m_pConnection.get() == nullptr) + throw std::runtime_error("Serial Port not initialized"); + + if (!m_bDisableHoming) { + + // get endstops states + auto sStream = sendCommand("M119"); + auto sLine = sStream.str(); + std::transform(sLine.begin(), sLine.end(), sLine.begin(), ::tolower); + + auto nPosition = sLine.find("_min: open\n"); + + if (nPosition == std::string::npos) { + // no axis is open => all are TRIGGERED => homed + m_bIsHomed = true; + } + else { + // at least on end stop of an axis is "open" => not homed + m_bIsHomed = false; + } + + } + + } + uint32_t CSerialController_Marlin::calculateLineChecksum(const std::string& sCommand) { uint32_t nChecksum = 0; @@ -187,7 +315,6 @@ namespace AMC { bool bResend = (sLineRead.find(m_sResendSymbol) != std::string::npos); if (bResend) { // For now fail, because firmware was not in reset state... - // TODO: Find out how to reset firmware throw std::runtime_error("line number mismatch in firmware"); } @@ -200,18 +327,238 @@ namespace AMC { - void CSerialController_Marlin::setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius) + void CSerialController_Marlin::setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius, bool bWait) + { + if (bWait) { + // wait for the target bed temperature to be reached before proceeding + sendCommand("M190 S" + std::to_string(nTemperatureInDegreeCelcius)); + } + else { + // don't wait + sendCommand("M140 S" + std::to_string(nTemperatureInDegreeCelcius)); + } + } + + void CSerialController_Marlin::setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius, bool bWait) { + if ((nExtruderIndex >= 0) && (nExtruderIndex < m_iExtruderCount)) + { + if (bWait) { + // wait for the target extruder temperature to be reached before proceeding + sendCommand("M109 T" + std::to_string(nExtruderIndex) + " S" + std::to_string(nTemperatureInDegreeCelcius)); + } + else { + // don't wait + sendCommand("M104 T" + std::to_string(nExtruderIndex) + " S" + std::to_string(nTemperatureInDegreeCelcius)); + } + } } - void CSerialController_Marlin::setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius) + void CSerialController_Marlin::setPidParameters(double dP, double dI, double dD) { + sendCommand("M301 P" + std::to_string(dP) + " I" + std::to_string(dI) + " D" + std::to_string(dD)); + + m_dPidValueP = dP; + m_dPidValueI = dI; + m_dPidValueD = dD; } + void CSerialController_Marlin::setFanSpeed(uint32_t nFanIndex, uint32_t nSpeed) + { + if ((nFanIndex >= 0)) + { + if ((nSpeed > 0) && (nSpeed < 256)) { + // turn fan on + sendCommand("M106 P" + std::to_string(nFanIndex) + " S" + std::to_string(nSpeed)); + } + else { + // turn fan off + sendCommand("M107 P" + std::to_string(nFanIndex)); + } + } + } + void CSerialController_Marlin::queryTemperatureState(uint32_t nExtruderIndex) { - auto sStream = sendCommand("M105 T" + std::to_string (nExtruderIndex)); + if (nExtruderIndex < m_iExtruderCount) + { + auto sStream = sendCommand("M105 T" + std::to_string(nExtruderIndex)); + auto sLine = sStream.str(); + auto nPosition = sLine.find("T:"); + + if (nPosition == std::string::npos) + throw std::runtime_error("could not query extruder temperature state."); + + + // get extruder temperature + auto sExtruderTempPosString = sLine.substr(nPosition + 2); + + auto nCurrentExtruderTempPosition = sExtruderTempPosString.find('/'); + auto nTargetExtruderTempPosition = sExtruderTempPosString.find('B'); + + if (nCurrentExtruderTempPosition == std::string::npos) + throw std::runtime_error("could not find extruder current temperature position."); + if (nTargetExtruderTempPosition == std::string::npos) + throw std::runtime_error("could not find extruder target temperature position."); + + if (!(nCurrentExtruderTempPosition < nTargetExtruderTempPosition)) + throw std::runtime_error("invalid extruder temperature position order."); + + auto sCurrentExtTemp = sExtruderTempPosString.substr(0, nCurrentExtruderTempPosition); + auto sTargetExtTemp = sExtruderTempPosString.substr(nCurrentExtruderTempPosition + 1, nTargetExtruderTempPosition - (nCurrentExtruderTempPosition + 1)); + + m_dCurrentExtruderTemp[nExtruderIndex] = std::stod(sCurrentExtTemp); + m_dTargetExtruderTemp[nExtruderIndex] = std::stod(sTargetExtTemp); + + + // get bed temperature + auto sBedTempPosString = sExtruderTempPosString.substr(nTargetExtruderTempPosition + 2); + + auto nCurrentBedTempPosition = sBedTempPosString.find('/'); + auto nTargetBedTempPosition = sBedTempPosString.find('@'); + + if (nCurrentBedTempPosition == std::string::npos) + throw std::runtime_error("could not find bed current temperature position."); + if (nTargetBedTempPosition == std::string::npos) + throw std::runtime_error("could not find bed target temperature position."); + + if (!(nCurrentBedTempPosition < nTargetBedTempPosition)) + throw std::runtime_error("invalid bed temperature position order."); + + auto sCurrentBedTemp = sBedTempPosString.substr(0, nCurrentBedTempPosition); + auto sTargetBedTemp = sBedTempPosString.substr(nCurrentBedTempPosition + 1, nTargetBedTempPosition - (nCurrentBedTempPosition + 1)); + + m_dCurrentBedTemp = std::stod(sCurrentBedTemp); + m_dTargetBedTemp = std::stod(sTargetBedTemp); + } + } + + void CSerialController_Marlin::queryAxisStepsPerUnitStateAndPidValues() + { + auto sStream = sendCommand("M503 S0"); + auto sLine = sStream.str(); + + // get AXIS_STEPS_PER_UNIT + auto nPosition = sLine.find("M92"); + + if (nPosition == std::string::npos) + throw std::runtime_error("could not query axis_steps_per_unit state."); + + auto sTempString = sLine.substr(nPosition + 4); + nPosition = sTempString.find("\n"); + auto sAxisStepsPerUnitString = sTempString.substr(0, nPosition); + + auto nAxisStepsPerUnitXPosition = sAxisStepsPerUnitString.find("X"); + auto nAxisStepsPerUnitYPosition = sAxisStepsPerUnitString.find("Y"); + auto nAxisStepsPerUnitZPosition = sAxisStepsPerUnitString.find("Z"); + auto nAxisStepsPerUnitEPosition = sAxisStepsPerUnitString.find("E"); + + if (nAxisStepsPerUnitXPosition == std::string::npos) + throw std::runtime_error("could not find axis_steps_per_unit X position."); + if (nAxisStepsPerUnitYPosition == std::string::npos) + throw std::runtime_error("could not find axis_steps_per_unit Y position."); + if (nAxisStepsPerUnitZPosition == std::string::npos) + throw std::runtime_error("could not find axis_steps_per_unit Z position."); + if (nAxisStepsPerUnitEPosition == std::string::npos) + throw std::runtime_error("could not find axis_steps_per_unit E position."); + + if (!((nAxisStepsPerUnitXPosition < nAxisStepsPerUnitYPosition) && (nAxisStepsPerUnitYPosition < nAxisStepsPerUnitZPosition) && + (nAxisStepsPerUnitZPosition < nAxisStepsPerUnitEPosition))) + throw std::runtime_error("invalid axis_steps_per_unit position order."); + + auto sAxis_steps_per_unitXString = sAxisStepsPerUnitString.substr(nAxisStepsPerUnitXPosition + 1, nAxisStepsPerUnitYPosition - (nAxisStepsPerUnitXPosition + 1)); + auto sAxis_steps_per_unitYString = sAxisStepsPerUnitString.substr(nAxisStepsPerUnitYPosition + 1, nAxisStepsPerUnitZPosition - (nAxisStepsPerUnitYPosition + 1)); + auto sAxis_steps_per_unitZString = sAxisStepsPerUnitString.substr(nAxisStepsPerUnitZPosition + 1, nAxisStepsPerUnitEPosition - (nAxisStepsPerUnitZPosition + 1)); + auto sAxis_steps_per_unitEString = sAxisStepsPerUnitString.substr(nAxisStepsPerUnitEPosition + 1); + + m_dAxisStepsPerUnitX = std::stod(sAxis_steps_per_unitXString); + m_dAxisStepsPerUnitY = std::stod(sAxis_steps_per_unitYString); + m_dAxisStepsPerUnitZ = std::stod(sAxis_steps_per_unitZString); + m_dAxisStepsPerUnitE = std::stod(sAxis_steps_per_unitEString); + + // get PID values + nPosition = sLine.find("M301"); + + if (nPosition == std::string::npos) + throw std::runtime_error("could not query PID values."); + + sTempString = sLine.substr(nPosition + 5); + nPosition = sTempString.find("\n"); + auto sPidValuesString = sTempString.substr(0, nPosition); + + auto nPidValuePPosition = sPidValuesString.find("P"); + auto nPidValueIPosition = sPidValuesString.find("I"); + auto nPidValueDPosition = sPidValuesString.find("D"); + + if (nPidValuePPosition == std::string::npos) + throw std::runtime_error("could not find PID value P position."); + if (nPidValueIPosition == std::string::npos) + throw std::runtime_error("could not find PID value I position."); + if (nPidValueDPosition == std::string::npos) + throw std::runtime_error("could not find PID value D position."); + + if (!((nPidValuePPosition < nPidValueIPosition) && (nPidValueIPosition < nPidValueDPosition))) + throw std::runtime_error("invalid PID values position order."); + + auto sPidValuePString = sPidValuesString.substr(nPidValuePPosition + 1, nPidValueIPosition - (nPidValuePPosition + 1)); + auto sPidValueIString = sPidValuesString.substr(nPidValueIPosition + 1, nPidValueDPosition - (nPidValueIPosition + 1)); + auto sPidValueDString = sPidValuesString.substr(nPidValueDPosition + 1); + + m_dPidValueP = std::stod(sPidValuePString); + m_dPidValueI = std::stod(sPidValueIString); + m_dPidValueD = std::stod(sPidValueDString); + + } + + void CSerialController_Marlin::queryFirmwareInfo() + { + auto sStream = sendCommand("M115"); + auto sLine = sStream.str(); + + + const std::string sFirmwareName = "FIRMWARE_NAME:"; + const std::string sSourceCodeUrl = "SOURCE_CODE_URL:"; + const std::string sProtocolVersion = "PROTOCOL_VERSION:"; + const std::string sMachineType = "MACHINE_TYPE:"; + const std::string sExtruderCount = "EXTRUDER_COUNT:"; + const std::string sUuid = "UUID:"; + + auto nPosFirmwareName = sLine.find(sFirmwareName); + auto nPosSourceCodeUrl = sLine.find(sSourceCodeUrl); + auto nPosProtocolVersion = sLine.find(sProtocolVersion); + auto nPosMachineType = sLine.find(sMachineType); + auto nPosExtruderCount = sLine.find(sExtruderCount); + auto nPosUuid = sLine.find(sUuid); + auto nPosEol = sLine.find("\n"); + + if (nPosFirmwareName == std::string::npos) + throw std::runtime_error("could not query FIRMWARE_NAME in firmware info."); + if (nPosSourceCodeUrl == std::string::npos) + throw std::runtime_error("could not query SOURCE_CODE_URL in firmware info."); + if (nPosProtocolVersion == std::string::npos) + throw std::runtime_error("could not query PROTOCOL_VERSION in firmware info."); + if (nPosMachineType == std::string::npos) + throw std::runtime_error("could not query MACHINE_TYPE in firmware info."); + if (nPosExtruderCount == std::string::npos) + throw std::runtime_error("could not query EXTRUDER_COUNT in firmware info."); + if (nPosUuid == std::string::npos) + throw std::runtime_error("could not query UUID in firmware info."); + if (nPosEol == std::string::npos) + throw std::runtime_error("could not query EOL in firmware info."); + + if (!((nPosFirmwareName < nPosSourceCodeUrl) && (nPosSourceCodeUrl < nPosProtocolVersion) && + (nPosProtocolVersion < nPosMachineType) && (nPosMachineType < nPosExtruderCount) && + (nPosExtruderCount < nPosUuid) && (nPosUuid < nPosEol))) + throw std::runtime_error("invalid order of firmware info."); + + m_sFirmwareName = sLine.substr(sFirmwareName.length(), nPosSourceCodeUrl - sFirmwareName.length() - 1); + m_sSourceCodeUrl = sLine.substr(nPosSourceCodeUrl + sSourceCodeUrl.length(), nPosProtocolVersion - (nPosSourceCodeUrl + sSourceCodeUrl.length() + 1)); + m_sProtocolVersion = sLine.substr(nPosProtocolVersion + sProtocolVersion.length(), nPosMachineType - (nPosProtocolVersion + sProtocolVersion.length() + 1)); + m_sMachineType = sLine.substr(nPosMachineType + sMachineType.length(), nPosExtruderCount - (nPosMachineType + sMachineType.length() + 1)); + m_iExtruderCount = std::stoi(sLine.substr(nPosExtruderCount + sExtruderCount.length(), nPosUuid - (nPosExtruderCount + sExtruderCount.length() + 1))); + m_sUUID = sLine.substr(nPosUuid + sUuid.length(), nPosEol - (nPosUuid + sUuid.length())); + } void CSerialController_Marlin::queryPositionState() @@ -258,6 +605,8 @@ namespace AMC { auto nCurrentXPosition = sCurrentPosString.find("X:"); auto nCurrentYPosition = sCurrentPosString.find("Y:"); auto nCurrentZPosition = sCurrentPosString.find("Z:"); + auto nCurrentEolPosition = sCurrentPosString.find("\n"); + if (nCurrentXPosition == std::string::npos) throw std::runtime_error("could not find current X position."); @@ -271,26 +620,36 @@ namespace AMC { auto sCurrentXString = sCurrentPosString.substr(nCurrentXPosition + 2, nCurrentYPosition - (nCurrentXPosition + 2)); auto sCurrentYString = sCurrentPosString.substr(nCurrentYPosition + 2, nCurrentZPosition - (nCurrentYPosition + 2)); - auto sCurrentZString = sCurrentPosString.substr(nCurrentZPosition + 2); + auto sCurrentZString = sCurrentPosString.substr(nCurrentZPosition + 2, nCurrentEolPosition - (nCurrentZPosition + 2)); - m_dCurrentPosX = std::stod(sCurrentXString); - m_dCurrentPosY = std::stod(sCurrentYString); - m_dCurrentPosZ = std::stod(sCurrentZString); + m_dCurrentPosX = std::stod(sCurrentXString) / m_dAxisStepsPerUnitX;; + m_dCurrentPosY = std::stod(sCurrentYString) / m_dAxisStepsPerUnitY;; + m_dCurrentPosZ = std::stod(sCurrentZString) / m_dAxisStepsPerUnitZ;; } void CSerialController_Marlin::getHeatedBedTemperature(double& dTargetTemperature, double& dCurrentTemperature) { - + dTargetTemperature = m_dTargetBedTemp; + dCurrentTemperature = m_dCurrentBedTemp; } void CSerialController_Marlin::getExtruderTemperature(uint32_t nExtruderIndex, double& dTargetTemperature, double& dCurrentTemperature) { - dTargetTemperature = 0.0; - dCurrentTemperature = 0.0; + if (nExtruderIndex < m_iExtruderCount) { + dTargetTemperature = m_dTargetExtruderTemp[nExtruderIndex]; + dCurrentTemperature = m_dCurrentExtruderTemp[nExtruderIndex]; + } } + void CSerialController_Marlin::getPidParameters(double& dP, double& dI, double& dD) + { + dP = m_dPidValueP; + dI = m_dPidValueI; + dD = m_dPidValueD; + } + void CSerialController_Marlin::getTargetPosition(double& dX, double& dY, double& dZ) { dX = m_dTargetPosX; @@ -305,15 +664,18 @@ namespace AMC { dZ = m_dCurrentPosZ; } - void CSerialController_Marlin::getExtruderPosition(double& dE) + void CSerialController_Marlin::getExtruderTargetPosition(double& dE) { - dE = m_dCurrentPosE; + dE = m_dTargetPosE; } void CSerialController_Marlin::startHoming() { - sendCommand("G28"); + if (!m_bDisableHoming) { + sendCommand("G28"); + } sendCommand("M400"); + checkIsHomed(); } void CSerialController_Marlin::setLcdMsg(const std::string& sLcdMsg) @@ -332,32 +694,96 @@ namespace AMC { sendCommand("G91"); } - void CSerialController_Marlin::move(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) + void CSerialController_Marlin::moveToEx(bool bFastMove, + bool bInX, const double dX, + bool bInY, const double dY, + bool bInZ, const double dZ, + bool bInE, const double dE, + const double dSpeedInMMperSecond) { std::stringstream sCommand; - sCommand << "G1 X" << dX << " Y" << dY << " Z" << dZ << " F" << dSpeedInMMperSecond * 60.0; + + if (bFastMove) { + sCommand << "G0"; + } + else { + sCommand << "G1"; + } + + if (bInX) { + // X given => add X+value to command str + sCommand << " X" << dX; + } + if (bInY) { + // Y given => add Y+value to command str + sCommand << " Y" << dY; + } + if (bInZ) { + // Z given => add Z+value to command str + sCommand << " Z" << dZ; + } + if (bInE && !bFastMove) { + // E given => add E+value to command str + // TODO remove to activate Extrusion + //sCommand << " E" << dE; + } + if (dSpeedInMMperSecond > 0) { + if (fabs(m_dCurrentSpeedInMMperSecond - dSpeedInMMperSecond) > MARLINDRIVER_MINSPEED) { + m_dCurrentSpeedInMMperSecond = dSpeedInMMperSecond; + sCommand << " F" << (int)(dSpeedInMMperSecond * 60.0); + } + } sendCommand(sCommand.str()); - m_dTargetPosX = dX; - m_dTargetPosY = dY; - m_dTargetPosZ = dZ; + if (bInX) { + m_dTargetPosX = dX; + } + if (bInY) { + m_dTargetPosY = dY; + } + if (bInZ) { + m_dTargetPosZ = dZ; + } + if (bInE) { + m_dTargetPosE = dE; + } + } + + + void CSerialController_Marlin::moveXY(const double dX, const double dY, const double dE, const double dSpeedInMMperSecond) + { + bool dInE = false; + if (fabs(dE) > MARLINDRIVER_MINSPEED) { + dInE = true; + } + moveToEx(false, true, dX, true, dY, false, 0.0, dInE, dE, dSpeedInMMperSecond); } - void CSerialController_Marlin::moveFast(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) + void CSerialController_Marlin::moveFastXY(const double dX, const double dY, const double dSpeedInMMperSecond) { - std::stringstream sCommand; - sCommand << "G0 X" << dX << " Y" << dY << " Z" << dZ << " F" << dSpeedInMMperSecond * 60.0; + moveToEx(true, true, dX, true, dY, false, 0.0, false, 0.0, dSpeedInMMperSecond); + } - sendCommand(sCommand.str()); + void CSerialController_Marlin::moveZ(const double dZ, const double dE, const double dSpeedInMMperSecond) + { + bool dInE = false; + if (fabs(dE) > MARLINDRIVER_MINSPEED) { + dInE = true; + } + moveToEx(false, false, 0.0, false, 0.0, true, dZ, dInE, dE, dSpeedInMMperSecond); + } - m_dTargetPosX = dX; - m_dTargetPosY = dY; - m_dTargetPosZ = dZ; + void CSerialController_Marlin::moveFastZ(const double dZ, const double dSpeedInMMperSecond) + { + moveToEx(true, false, 0.0, false, 0.0, true, dZ, false, 0.0, dSpeedInMMperSecond); } void CSerialController_Marlin::waitForMovement() { sendCommand("M400"); + // Print time (M31) responses immediately with ok (+ADVANCED_OK) + print time + // not added to the planning buffer + //sendCommand("M31"); } bool CSerialController_Marlin::canReceiveMovement() @@ -370,5 +796,10 @@ namespace AMC { return (m_nCurrentBufferSpace != m_nMaxBufferSpace); } + bool CSerialController_Marlin::isHomed() + { + return (m_bIsHomed); + } + -} \ No newline at end of file +} diff --git a/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.hpp b/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.hpp index 3b9bcc3e..608a44f5 100644 --- a/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.hpp +++ b/Drivers/Marlin/Implementation/AMC_SerialController_Marlin.hpp @@ -12,13 +12,26 @@ namespace AMC { class CSerialController_Marlin : public CSerialController { private: - std::unique_ptr m_pConnection; std::string m_sCOMPort; uint32_t m_nBaudRate; + uint32_t m_nConnectTimeout; uint32_t m_nLineNumber; + double m_dStatusUpdateTimerInterval; bool m_bDebug; + bool m_bIsHomed; + bool m_bDoQueryFirmwareInfo; + bool m_bDisableHoming; + + double m_dAxisStepsPerUnitX; + double m_dAxisStepsPerUnitY; + double m_dAxisStepsPerUnitZ; + double m_dAxisStepsPerUnitE; + + double m_dPidValueP; + double m_dPidValueI; + double m_dPidValueD; double m_dTargetPosX; double m_dTargetPosY; @@ -28,7 +41,21 @@ namespace AMC { double m_dCurrentPosX; double m_dCurrentPosY; double m_dCurrentPosZ; - double m_dCurrentPosE; + double m_dCurrentSpeedInMMperSecond; + + // firmware info + std::string m_sFirmwareName; + std::string m_sSourceCodeUrl; + std::string m_sProtocolVersion; + std::string m_sMachineType; + uint32_t m_iExtruderCount; + std::string m_sUUID; + + + std::vector m_dCurrentExtruderTemp; + std::vector m_dTargetExtruderTemp; + double m_dCurrentBedTemp; + double m_dTargetBedTemp; std::string m_sAckSymbol; std::string m_sResendSymbol; @@ -37,15 +64,25 @@ namespace AMC { uint32_t m_nMaxBufferSpace; uint32_t m_nCurrentBufferSpace; + std::stringstream sendCommand(const std::string& sCommand); uint32_t calculateLineChecksum (const std::string& sCommand); + void checkIsHomed(); bool parseAckSymbol(const std::string& sLine, const uint32_t nLineNumber); - + void queryAxisStepsPerUnitStateAndPidValues(); + void queryFirmwareInfo(); + void moveToEx (bool bFastMove, bool bInX, const double dX, bool bInY, const double dY, bool bInZ, const double dZ, bool bInE, const double dE, const double dSpeedInMMperSecond); + public: - CSerialController_Marlin(bool bDebug); + CSerialController_Marlin(bool bDebug, bool bDoQueryFirmwareInfo, bool bDisableHoming); virtual ~CSerialController_Marlin(); - void setCOMPort(const std::string & sCOMPort); + void setStatusUpdateTimerInterval(const double dStatusUpdateTimerInterval); + + void setConnectTimeout(const uint32_t nConnectTimeout); + uint32_t getConnectTimeout(); + + void setCOMPort(const std::string& sCOMPort); std::string getCOMPort(); void setBaudrate(const uint32_t nBaudrate); @@ -58,8 +95,10 @@ namespace AMC { void setPositioningAbolute(); void setPositioningRelative(); - void setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius) override; - void setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius) override; + void setHeatedBedTargetTemperature(double nTemperatureInDegreeCelcius, bool bWait) override; + void setExtruderTargetTemperature(uint32_t nExtruderIndex, double nTemperatureInDegreeCelcius, bool bWait) override; + void setPidParameters(double dP, double dI, double dD) override; + void setFanSpeed(uint32_t nFanIndex, uint32_t nSpeed) override; void queryTemperatureState(uint32_t nExtruderIndex) override; void queryPositionState() override; @@ -69,14 +108,18 @@ namespace AMC { void getTargetPosition(double& dX, double& dY, double& dZ) override; void getCurrentPosition(double& dX, double& dY, double& dZ) override; - void getExtruderPosition(double& dE) override; + void getExtruderTargetPosition(double& dE) override; + void getPidParameters(double& dP, double& dI, double& dD) override; void startHoming() override; void setLcdMsg(const std::string& sLcdMsg) override; - void move(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) override; - void moveFast(const double dX, const double dY, const double dZ, const double dSpeedInMMperSecond) override; + void moveXY(const double dX, const double dY, const double dE, const double dSpeedInMMperSecond) override; + void moveFastXY(const double dX, const double dY, const double dSpeedInMMperSecond) override; + void moveZ(const double dZ, const double dE, const double dSpeedInMMperSecond) override; + void moveFastZ(const double dZ, const double dSpeedInMMperSecond) override; + bool isHomed() override; bool isMoving() override; bool canReceiveMovement() override; void waitForMovement() override; diff --git a/Drivers/Marlin/Implementation/libmcdriver_marlin.cpp b/Drivers/Marlin/Implementation/libmcdriver_marlin.cpp index fa004438..92d4f569 100644 --- a/Drivers/Marlin/Implementation/libmcdriver_marlin.cpp +++ b/Drivers/Marlin/Implementation/libmcdriver_marlin.cpp @@ -70,8 +70,22 @@ void CWrapper::AcquireInstance(IBase* pInstance) IDriver * CWrapper::CreateDriver(const std::string& sName, const std::string& sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment) { - if (sType == "marlin-2.0") - return new CDriver_Marlin(sName, sType); + + if (sType == "marlin-2.0") { + bool bDebug = false; + bool bDoFirmwareQuery = false; + bool bDisableHoming = true; + + return new CDriver_Marlin(sName, sType, bDoFirmwareQuery, bDisableHoming, bDebug); + } + + if (sType == "marlin-ender-2.0") { + bool bDebug = false; + bool bDoFirmwareQuery = true; + bool bDisableHoming = false; + + return new CDriver_Marlin(sName, sType, bDoFirmwareQuery, bDisableHoming, bDebug); + } throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_DRIVERERROR); diff --git a/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.cpp b/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.cpp index 742fa380..309ff7fd 100644 --- a/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.cpp +++ b/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.cpp @@ -40,20 +40,21 @@ using namespace LibMCDriver_Marlin::Impl; Class definition of CDriver_Marlin **************************************************************************************************************************/ -CDriver_Marlin::CDriver_Marlin(const std::string& sName, const std::string& sType) - : CDriver (sName, sType) +CDriver_Marlin::CDriver_Marlin(const std::string& sName, const std::string& sType, const bool doQueryFirmwareInfo, const bool bDisableHoming, const bool bDebug) + : CDriver (sName, sType), m_doQueryFirmwareInfo (doQueryFirmwareInfo), m_bDisableHoming (bDisableHoming), m_bDebug (bDebug) { - } -void CDriver_Marlin::Connect(const std::string& sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate) +void CDriver_Marlin::Connect(const std::string& sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate, const LibMCDriver_Marlin_double dStatusUpdateInterval, const LibMCDriver_Marlin_uint32 nConnectTimeout) { Disconnect (); - auto pSerialController = std::make_shared(false); + auto pSerialController = std::make_shared(m_bDebug, m_doQueryFirmwareInfo, m_bDisableHoming); pSerialController->setCOMPort(sCOMPort); pSerialController->setBaudrate(nBaudrate); + pSerialController->setConnectTimeout(nConnectTimeout); + pSerialController->setStatusUpdateTimerInterval(dStatusUpdateInterval); pSerialController->initializeController(); m_pSerialController = pSerialController; @@ -80,7 +81,27 @@ void CDriver_Marlin::SetAbsolutePositioning(const bool bAbsolute) } } -void CDriver_Marlin::UpdateState() +void CDriver_Marlin::SetHeatedBedTargetTemperature(const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) +{ + m_pSerialController->setHeatedBedTargetTemperature(dTemperatureInDegreeCelcius, bWaitForTemp); +} + +void CDriver_Marlin::SetExtruderTargetTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) +{ + m_pSerialController->setExtruderTargetTemperature(nExtruderID, dTemperatureInDegreeCelcius, bWaitForTemp); +} + +void CDriver_Marlin::SetFanSpeed(const LibMCDriver_Marlin_uint32 nFanID, const LibMCDriver_Marlin_uint32 nSpeed) +{ + m_pSerialController->setFanSpeed(nFanID, nSpeed); +} + +void CDriver_Marlin::SetPidParameters(const LibMCDriver_Marlin_double dP, const LibMCDriver_Marlin_double dI, const LibMCDriver_Marlin_double dD) +{ + m_pSerialController->setPidParameters(dP, dI, dD); +} + +void CDriver_Marlin::UpdateState() { if (m_pSerialController.get() == nullptr) throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_NOTCONNECTED); @@ -99,6 +120,26 @@ void CDriver_Marlin::GetTargetPosition(LibMCDriver_Marlin_double& dX, LibMCDrive m_pSerialController->getTargetPosition(dX, dY, dZ); } +void CDriver_Marlin::GetExtruderTargetPosition(LibMCDriver_Marlin_double& dE) +{ + m_pSerialController->getExtruderTargetPosition(dE); +} + +void CDriver_Marlin::GetHeatedBedTemperature(LibMCDriver_Marlin_double& dTargetTemperature, LibMCDriver_Marlin_double& dCurrentTemperature) +{ + m_pSerialController->getHeatedBedTemperature(dTargetTemperature, dCurrentTemperature); +} + +void CDriver_Marlin::GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double& dTargetTemperature, LibMCDriver_Marlin_double& dCurrentTemperature) +{ + m_pSerialController->getExtruderTemperature(nExtruderID, dTargetTemperature, dCurrentTemperature); +} + +void CDriver_Marlin::GetPidParameters(LibMCDriver_Marlin_double& dP, LibMCDriver_Marlin_double& dI, LibMCDriver_Marlin_double& dD) +{ + m_pSerialController->getPidParameters(dP, dI, dD); +} + bool CDriver_Marlin::CanExecuteMovement() { return m_pSerialController->canReceiveMovement(); @@ -109,17 +150,34 @@ bool CDriver_Marlin::IsMoving() return m_pSerialController->isMoving(); } -void CDriver_Marlin::MoveTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) +bool CDriver_Marlin::IsHomed() { - m_pSerialController->move(dX, dY, dZ, dSpeed); + return m_pSerialController->isHomed(); } -void CDriver_Marlin::MoveFastTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) +void CDriver_Marlin::MoveToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) { - m_pSerialController->moveFast(dX, dY, dZ, dSpeed); + m_pSerialController->moveXY(dX, dY, dE, dSpeed); } -void CDriver_Marlin::GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double& dCurrentTemperature, LibMCDriver_Marlin_double& dTargetTemperature) +void CDriver_Marlin::MoveFastToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dSpeed) { - m_pSerialController->getExtruderTemperature(nExtruderID, dTargetTemperature, dCurrentTemperature); -} \ No newline at end of file + m_pSerialController->moveFastXY(dX, dY, dSpeed); +} + +void CDriver_Marlin::MoveToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) +{ + m_pSerialController->moveZ(dZ, dE, dSpeed); +} + +void CDriver_Marlin::MoveFastToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) +{ + m_pSerialController->moveFastZ(dZ, dSpeed); +} + + + +void CDriver_Marlin::StartHoming() +{ + m_pSerialController->startHoming(); +} diff --git a/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.hpp b/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.hpp index 1d029407..68508d7c 100644 --- a/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.hpp +++ b/Drivers/Marlin/Implementation/libmcdriver_marlin_driver_marlin.hpp @@ -38,32 +38,59 @@ class CDriver_Marlin : public virtual IDriver_Marlin, public virtual CDriver { protected: AMC::PSerialController m_pSerialController; + bool m_doQueryFirmwareInfo; + bool m_bDisableHoming; + bool m_bDebug; public: - CDriver_Marlin(const std::string& sName, const std::string& sType); + CDriver_Marlin(const std::string& sName, const std::string& sType, const bool doQueryFirmwareInfo, const bool bDisableHoming, const bool bDebug); - void Connect(const std::string& sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate) override; + void Connect(const std::string& sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate, const LibMCDriver_Marlin_double dStatusUpdateInterval, const LibMCDriver_Marlin_uint32 nConnectTimeout) override; void Disconnect() override; void SetAbsolutePositioning(const bool bAbsolute) override; + void SetHeatedBedTargetTemperature(const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) override; + + void SetExtruderTargetTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) override; + + void SetFanSpeed(const LibMCDriver_Marlin_uint32 nFanID, const LibMCDriver_Marlin_uint32 dSpeed) override; + + void SetPidParameters(const LibMCDriver_Marlin_double dP, const LibMCDriver_Marlin_double dI, const LibMCDriver_Marlin_double dD) override; + void UpdateState() override; void GetCurrentPosition(LibMCDriver_Marlin_double& dX, LibMCDriver_Marlin_double& dY, LibMCDriver_Marlin_double& dZ) override; void GetTargetPosition(LibMCDriver_Marlin_double& dX, LibMCDriver_Marlin_double& dY, LibMCDriver_Marlin_double& dZ) override; + void GetExtruderTargetPosition(LibMCDriver_Marlin_double& dE) override; + + void GetHeatedBedTemperature(LibMCDriver_Marlin_double& dTargetTemperature, LibMCDriver_Marlin_double& dCurrentTemperature) override; + + void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double& dTargetTemperature, LibMCDriver_Marlin_double& dCurrentTemperature) override; + + void GetPidParameters(LibMCDriver_Marlin_double& dP, LibMCDriver_Marlin_double& dI, LibMCDriver_Marlin_double& dD) override; + bool CanExecuteMovement() override; bool IsMoving() override; - void MoveTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) override; + bool IsHomed() override; + + void MoveToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) override; + + void MoveFastToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dSpeed) override; + + void MoveToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) override; + + void MoveFastToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) override; + + void StartHoming() override; - void MoveFastTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) override; - void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double& dCurrentTemperature, LibMCDriver_Marlin_double& dTargetTemperature) override; }; diff --git a/Drivers/Marlin/Interfaces/libmcdriver_marlin_abi.hpp b/Drivers/Marlin/Interfaces/libmcdriver_marlin_abi.hpp index 4a922d34..c008d1ce 100644 --- a/Drivers/Marlin/Interfaces/libmcdriver_marlin_abi.hpp +++ b/Drivers/Marlin/Interfaces/libmcdriver_marlin_abi.hpp @@ -125,9 +125,11 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_g * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] pCOMPort - Device Port to connect to * @param[in] nBaudrate - Baudrate to use +* @param[in] dStatusUpdateInterval - Timer interval [ms] for updating status +* @param[in] nConnectTimeout - Timeout [ms] for connecting printer * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate, LibMCDriver_Marlin_double dStatusUpdateInterval, LibMCDriver_Marlin_uint32 nConnectTimeout); /** * Disconnects from the Marlin board. @@ -146,6 +148,48 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m */ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setabsolutepositioning(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool bAbsolute); +/** +* Sets heated bed target temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dTemperatureInDegreeCelcius - Bed target temperature. +* @param[in] bWaitForTemp - If true, waits for the target bed temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Sets target temperature of the given extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of extruder. +* @param[in] dTemperatureInDegreeCelcius - Extruder target temperature. +* @param[in] bWaitForTemp - If true, waits for the target extruder temperature to be reached before proceeding +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setextrudertargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp); + +/** +* Turns on one of the fans and set its speed. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nFanID - ID of fan. +* @param[in] nSpeed - Fan speed [0..255]. 0=0%!.(MISSING).255=100%! +(MISSING)* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setfanspeed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nFanID, LibMCDriver_Marlin_uint32 nSpeed); + +/** +* Sets PID parameters. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dP - New value for P parameter. +* @param[in] dI - New value for I parameter. +* @param[in] dD - New value for D parameter. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dP, LibMCDriver_Marlin_double dI, LibMCDriver_Marlin_double dD); + /** * Polls a new state from the firmware. * @@ -177,15 +221,45 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_gettargetposition(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pX, LibMCDriver_Marlin_double * pY, LibMCDriver_Marlin_double * pZ); /** -* Returns the current temperature of an extruder. +* Returns the target extruder position. * * @param[in] pDriver_Marlin - Driver_Marlin instance. -* @param[in] nExtruderID - ID of Extruder +* @param[out] pE - E Value in mm +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertargetposition(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pE); + +/** +* Returns the current and the target bed temperature. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pTargetTemperature - Target Temperature in degree celsius. * @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getheatedbedtemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current and the target temperature of an extruder. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] nExtruderID - ID of Extruder * @param[out] pTargetTemperature - Target Temperature in degree celsius. +* @param[out] pCurrentTemperature - Current Temperature in degree celsius. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature); + +/** +* Returns the current PID values. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pP - Current P value. +* @param[out] pI - Current I value. +* @param[out] pD - Current D value. * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pCurrentTemperature, LibMCDriver_Marlin_double * pTargetTemperature); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pP, LibMCDriver_Marlin_double * pI, LibMCDriver_Marlin_double * pD); /** * Returns if the movement buffer can receive another movement command.. @@ -205,17 +279,26 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m */ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ismoving(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); +/** +* Returns if the printer is homed +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[out] pValue - True if printer is homed. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ishomed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue); + /** * Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm -* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_moveto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); /** * Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. @@ -223,11 +306,39 @@ LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_m * @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @param[in] dZ - Z Value in mm +* @param[in] dE - E Value in mm +* @param[in] dSpeed - Movement speed in mm/s +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed); + +/** +* Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. * @param[in] dZ - Z Value in mm * @param[in] dSpeed - Movement speed in mm/s * @return error code or 0 (success) */ -LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefastto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed); + +/** +* Start Homing of printer. +* +* @param[in] pDriver_Marlin - Driver_Marlin instance. +* @return error code or 0 (success) +*/ +LIBMCDRIVER_MARLIN_DECLSPEC LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_starthoming(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin); /************************************************************************************************************************* Global functions diff --git a/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfaces.hpp b/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfaces.hpp index cf98f1fe..6195cbcf 100644 --- a/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfaces.hpp +++ b/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfaces.hpp @@ -308,8 +308,10 @@ class IDriver_Marlin : public virtual IDriver { * IDriver_Marlin::Connect - Creates and initializes a new Marlin Connector. * @param[in] sCOMPort - Device Port to connect to * @param[in] nBaudrate - Baudrate to use + * @param[in] dStatusUpdateInterval - Timer interval [ms] for updating status + * @param[in] nConnectTimeout - Timeout [ms] for connecting printer */ - virtual void Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate) = 0; + virtual void Connect(const std::string & sCOMPort, const LibMCDriver_Marlin_uint32 nBaudrate, const LibMCDriver_Marlin_double dStatusUpdateInterval, const LibMCDriver_Marlin_uint32 nConnectTimeout) = 0; /** * IDriver_Marlin::Disconnect - Disconnects from the Marlin board. @@ -322,6 +324,36 @@ class IDriver_Marlin : public virtual IDriver { */ virtual void SetAbsolutePositioning(const bool bAbsolute) = 0; + /** + * IDriver_Marlin::SetHeatedBedTargetTemperature - Sets heated bed target temperature. + * @param[in] dTemperatureInDegreeCelcius - Bed target temperature. + * @param[in] bWaitForTemp - If true, waits for the target bed temperature to be reached before proceeding + */ + virtual void SetHeatedBedTargetTemperature(const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) = 0; + + /** + * IDriver_Marlin::SetExtruderTargetTemperature - Sets target temperature of the given extruder. + * @param[in] nExtruderID - ID of extruder. + * @param[in] dTemperatureInDegreeCelcius - Extruder target temperature. + * @param[in] bWaitForTemp - If true, waits for the target extruder temperature to be reached before proceeding + */ + virtual void SetExtruderTargetTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, const LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, const bool bWaitForTemp) = 0; + + /** + * IDriver_Marlin::SetFanSpeed - Turns on one of the fans and set its speed. + * @param[in] nFanID - ID of fan. + * @param[in] nSpeed - Fan speed [0..255]. 0=0%...255=100% + */ + virtual void SetFanSpeed(const LibMCDriver_Marlin_uint32 nFanID, const LibMCDriver_Marlin_uint32 nSpeed) = 0; + + /** + * IDriver_Marlin::SetPidParameters - Sets PID parameters. + * @param[in] dP - New value for P parameter. + * @param[in] dI - New value for I parameter. + * @param[in] dD - New value for D parameter. + */ + virtual void SetPidParameters(const LibMCDriver_Marlin_double dP, const LibMCDriver_Marlin_double dI, const LibMCDriver_Marlin_double dD) = 0; + /** * IDriver_Marlin::UpdateState - Polls a new state from the firmware. */ @@ -344,12 +376,33 @@ class IDriver_Marlin : public virtual IDriver { virtual void GetTargetPosition(LibMCDriver_Marlin_double & dX, LibMCDriver_Marlin_double & dY, LibMCDriver_Marlin_double & dZ) = 0; /** - * IDriver_Marlin::GetExtruderTemperature - Returns the current temperature of an extruder. - * @param[in] nExtruderID - ID of Extruder + * IDriver_Marlin::GetExtruderTargetPosition - Returns the target extruder position. + * @param[out] dE - E Value in mm + */ + virtual void GetExtruderTargetPosition(LibMCDriver_Marlin_double & dE) = 0; + + /** + * IDriver_Marlin::GetHeatedBedTemperature - Returns the current and the target bed temperature. + * @param[out] dTargetTemperature - Target Temperature in degree celsius. * @param[out] dCurrentTemperature - Current Temperature in degree celsius. + */ + virtual void GetHeatedBedTemperature(LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature) = 0; + + /** + * IDriver_Marlin::GetExtruderTemperature - Returns the current and the target temperature of an extruder. + * @param[in] nExtruderID - ID of Extruder * @param[out] dTargetTemperature - Target Temperature in degree celsius. + * @param[out] dCurrentTemperature - Current Temperature in degree celsius. */ - virtual void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dCurrentTemperature, LibMCDriver_Marlin_double & dTargetTemperature) = 0; + virtual void GetExtruderTemperature(const LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double & dTargetTemperature, LibMCDriver_Marlin_double & dCurrentTemperature) = 0; + + /** + * IDriver_Marlin::GetPidParameters - Returns the current PID values. + * @param[out] dP - Current P value. + * @param[out] dI - Current I value. + * @param[out] dD - Current D value. + */ + virtual void GetPidParameters(LibMCDriver_Marlin_double & dP, LibMCDriver_Marlin_double & dI, LibMCDriver_Marlin_double & dD) = 0; /** * IDriver_Marlin::CanExecuteMovement - Returns if the movement buffer can receive another movement command.. @@ -364,22 +417,47 @@ class IDriver_Marlin : public virtual IDriver { virtual bool IsMoving() = 0; /** - * IDriver_Marlin::MoveTo - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * IDriver_Marlin::IsHomed - Returns if the printer is homed + * @return True if printer is homed. + */ + virtual bool IsHomed() = 0; + + /** + * IDriver_Marlin::MoveToXY - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm - * @param[in] dZ - Z Value in mm + * @param[in] dE - E Value in mm * @param[in] dSpeed - Movement speed in mm/s */ - virtual void MoveTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) = 0; + virtual void MoveToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) = 0; /** - * IDriver_Marlin::MoveFastTo - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * IDriver_Marlin::MoveFastToXY - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dX - X Value in mm * @param[in] dY - Y Value in mm + * @param[in] dSpeed - Movement speed in mm/s + */ + virtual void MoveFastToXY(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dSpeed) = 0; + + /** + * IDriver_Marlin::MoveToZ - Moves to/by a certain position by a linear move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. + * @param[in] dZ - Z Value in mm + * @param[in] dE - E Value in mm + * @param[in] dSpeed - Movement speed in mm/s + */ + virtual void MoveToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dE, const LibMCDriver_Marlin_double dSpeed) = 0; + + /** + * IDriver_Marlin::MoveFastToZ - Moves to/by a certain position by a fast move. Takes the relative/absolute mode into account. Fails if it cannot execute a movement. * @param[in] dZ - Z Value in mm * @param[in] dSpeed - Movement speed in mm/s */ - virtual void MoveFastTo(const LibMCDriver_Marlin_double dX, const LibMCDriver_Marlin_double dY, const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) = 0; + virtual void MoveFastToZ(const LibMCDriver_Marlin_double dZ, const LibMCDriver_Marlin_double dSpeed) = 0; + + /** + * IDriver_Marlin::StartHoming - Start Homing of printer. + */ + virtual void StartHoming() = 0; }; diff --git a/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfacewrapper.cpp b/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfacewrapper.cpp index 35195a56..8df5c462 100644 --- a/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfacewrapper.cpp +++ b/Drivers/Marlin/Interfaces/libmcdriver_marlin_interfacewrapper.cpp @@ -297,7 +297,7 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_getheaderinformation(LibMCDri /************************************************************************************************************************* Class implementation for Driver_Marlin **************************************************************************************************************************/ -LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate) +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, const char * pCOMPort, LibMCDriver_Marlin_uint32 nBaudrate, LibMCDriver_Marlin_double dStatusUpdateInterval, LibMCDriver_Marlin_uint32 nConnectTimeout) { IBase* pIBaseClass = (IBase *)pDriver_Marlin; @@ -309,7 +309,7 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_connect(LibMCDriver_Ma if (!pIDriver_Marlin) throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); - pIDriver_Marlin->Connect(sCOMPort, nBaudrate); + pIDriver_Marlin->Connect(sCOMPort, nBaudrate, dStatusUpdateInterval, nConnectTimeout); return LIBMCDRIVER_MARLIN_SUCCESS; } @@ -372,6 +372,102 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setabsolutepositioning } } +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->SetHeatedBedTargetTemperature(dTemperatureInDegreeCelcius, bWaitForTemp); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setextrudertargettemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double dTemperatureInDegreeCelcius, bool bWaitForTemp) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->SetExtruderTargetTemperature(nExtruderID, dTemperatureInDegreeCelcius, bWaitForTemp); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setfanspeed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nFanID, LibMCDriver_Marlin_uint32 nSpeed) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->SetFanSpeed(nFanID, nSpeed); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_setpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dP, LibMCDriver_Marlin_double dI, LibMCDriver_Marlin_double dD) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->SetPidParameters(dP, dI, dD); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_updatestate(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin) { IBase* pIBaseClass = (IBase *)pDriver_Marlin; @@ -456,20 +552,104 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_gettargetposition(LibM } } -LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pCurrentTemperature, LibMCDriver_Marlin_double * pTargetTemperature) +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertargetposition(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pE) { IBase* pIBaseClass = (IBase *)pDriver_Marlin; try { + if (!pE) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->GetExtruderTargetPosition(*pE); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getheatedbedtemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + if (!pTargetTemperature) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); if (!pCurrentTemperature) throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->GetHeatedBedTemperature(*pTargetTemperature, *pCurrentTemperature); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getextrudertemperature(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_uint32 nExtruderID, LibMCDriver_Marlin_double * pTargetTemperature, LibMCDriver_Marlin_double * pCurrentTemperature) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { if (!pTargetTemperature) throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + if (!pCurrentTemperature) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); if (!pIDriver_Marlin) throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); - pIDriver_Marlin->GetExtruderTemperature(nExtruderID, *pCurrentTemperature, *pTargetTemperature); + pIDriver_Marlin->GetExtruderTemperature(nExtruderID, *pTargetTemperature, *pCurrentTemperature); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_getpidparameters(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double * pP, LibMCDriver_Marlin_double * pI, LibMCDriver_Marlin_double * pD) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + if (!pP) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + if (!pI) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + if (!pD) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->GetPidParameters(*pP, *pI, *pD); return LIBMCDRIVER_MARLIN_SUCCESS; } @@ -536,7 +716,105 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ismoving(LibMCDriver_M } } -LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_moveto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed) +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_ishomed(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, bool * pValue) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + if (pValue == nullptr) + throw ELibMCDriver_MarlinInterfaceException (LIBMCDRIVER_MARLIN_ERROR_INVALIDPARAM); + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + *pValue = pIDriver_Marlin->IsHomed(); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->MoveToXY(dX, dY, dE, dSpeed); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoxy(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dSpeed) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->MoveFastToXY(dX, dY, dSpeed); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movetoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dE, LibMCDriver_Marlin_double dSpeed) +{ + IBase* pIBaseClass = (IBase *)pDriver_Marlin; + + try { + IDriver_Marlin* pIDriver_Marlin = dynamic_cast(pIBaseClass); + if (!pIDriver_Marlin) + throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); + + pIDriver_Marlin->MoveToZ(dZ, dE, dSpeed); + + return LIBMCDRIVER_MARLIN_SUCCESS; + } + catch (ELibMCDriver_MarlinInterfaceException & Exception) { + return handleLibMCDriver_MarlinException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefasttoz(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed) { IBase* pIBaseClass = (IBase *)pDriver_Marlin; @@ -545,7 +823,7 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_moveto(LibMCDriver_Mar if (!pIDriver_Marlin) throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); - pIDriver_Marlin->MoveTo(dX, dY, dZ, dSpeed); + pIDriver_Marlin->MoveFastToZ(dZ, dSpeed); return LIBMCDRIVER_MARLIN_SUCCESS; } @@ -560,7 +838,7 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_moveto(LibMCDriver_Mar } } -LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefastto(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin, LibMCDriver_Marlin_double dX, LibMCDriver_Marlin_double dY, LibMCDriver_Marlin_double dZ, LibMCDriver_Marlin_double dSpeed) +LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_starthoming(LibMCDriver_Marlin_Driver_Marlin pDriver_Marlin) { IBase* pIBaseClass = (IBase *)pDriver_Marlin; @@ -569,7 +847,7 @@ LibMCDriver_MarlinResult libmcdriver_marlin_driver_marlin_movefastto(LibMCDriver if (!pIDriver_Marlin) throw ELibMCDriver_MarlinInterfaceException(LIBMCDRIVER_MARLIN_ERROR_INVALIDCAST); - pIDriver_Marlin->MoveFastTo(dX, dY, dZ, dSpeed); + pIDriver_Marlin->StartHoming(); return LIBMCDRIVER_MARLIN_SUCCESS; } @@ -613,22 +891,44 @@ LibMCDriver_MarlinResult LibMCDriver_Marlin::Impl::LibMCDriver_Marlin_GetProcAdd *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_disconnect; if (sProcName == "libmcdriver_marlin_driver_marlin_setabsolutepositioning") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_setabsolutepositioning; + if (sProcName == "libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_setheatedbedtargettemperature; + if (sProcName == "libmcdriver_marlin_driver_marlin_setextrudertargettemperature") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_setextrudertargettemperature; + if (sProcName == "libmcdriver_marlin_driver_marlin_setfanspeed") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_setfanspeed; + if (sProcName == "libmcdriver_marlin_driver_marlin_setpidparameters") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_setpidparameters; if (sProcName == "libmcdriver_marlin_driver_marlin_updatestate") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_updatestate; if (sProcName == "libmcdriver_marlin_driver_marlin_getcurrentposition") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_getcurrentposition; if (sProcName == "libmcdriver_marlin_driver_marlin_gettargetposition") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_gettargetposition; + if (sProcName == "libmcdriver_marlin_driver_marlin_getextrudertargetposition") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_getextrudertargetposition; + if (sProcName == "libmcdriver_marlin_driver_marlin_getheatedbedtemperature") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_getheatedbedtemperature; if (sProcName == "libmcdriver_marlin_driver_marlin_getextrudertemperature") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_getextrudertemperature; + if (sProcName == "libmcdriver_marlin_driver_marlin_getpidparameters") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_getpidparameters; if (sProcName == "libmcdriver_marlin_driver_marlin_canexecutemovement") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_canexecutemovement; if (sProcName == "libmcdriver_marlin_driver_marlin_ismoving") *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_ismoving; - if (sProcName == "libmcdriver_marlin_driver_marlin_moveto") - *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_moveto; - if (sProcName == "libmcdriver_marlin_driver_marlin_movefastto") - *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_movefastto; + if (sProcName == "libmcdriver_marlin_driver_marlin_ishomed") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_ishomed; + if (sProcName == "libmcdriver_marlin_driver_marlin_movetoxy") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_movetoxy; + if (sProcName == "libmcdriver_marlin_driver_marlin_movefasttoxy") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_movefasttoxy; + if (sProcName == "libmcdriver_marlin_driver_marlin_movetoz") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_movetoz; + if (sProcName == "libmcdriver_marlin_driver_marlin_movefasttoz") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_movefasttoz; + if (sProcName == "libmcdriver_marlin_driver_marlin_starthoming") + *ppProcAddress = (void*) &libmcdriver_marlin_driver_marlin_starthoming; if (sProcName == "libmcdriver_marlin_getversion") *ppProcAddress = (void*) &libmcdriver_marlin_getversion; if (sProcName == "libmcdriver_marlin_getlasterror") diff --git a/Drivers/ScanLabOIE/ACT/LibMCDriver_ScanLabOIE.xml b/Drivers/ScanLabOIE/ACT/LibMCDriver_ScanLabOIE.xml new file mode 100644 index 00000000..25ce965d --- /dev/null +++ b/Drivers/ScanLabOIE/ACT/LibMCDriver_ScanLabOIE.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Drivers/ScanLabOIE/ACT/LibOIE.xml b/Drivers/ScanLabOIE/ACT/LibOIE.xml new file mode 100644 index 00000000..4f88cd46 --- /dev/null +++ b/Drivers/ScanLabOIE/ACT/LibOIE.xml @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Drivers/ScanLabOIE/ACT/generateInterfaces.bat b/Drivers/ScanLabOIE/ACT/generateInterfaces.bat new file mode 100644 index 00000000..bcbbf18f --- /dev/null +++ b/Drivers/ScanLabOIE/ACT/generateInterfaces.bat @@ -0,0 +1,4 @@ +..\..\..\ACT\act.exe LibMCDriver_ScanLabOIE.xml -bindings ..\Headers -interfaces ..\Interfaces -suppresssubcomponents -suppresslicense -suppressstub -suppressexamples +..\..\..\ACT\act.exe LIBOIE.xml -bindings ..\LibOIE\Headers -interfaces ..\LibOIE\Interfaces -suppresssubcomponents -suppresslicense -suppressstub -suppressexamples + +pause \ No newline at end of file diff --git a/Drivers/ScanLabOIE/CMakeLists.txt b/Drivers/ScanLabOIE/CMakeLists.txt new file mode 100644 index 00000000..f2d7f612 --- /dev/null +++ b/Drivers/ScanLabOIE/CMakeLists.txt @@ -0,0 +1,137 @@ +#[[++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +]] + + +cmake_minimum_required(VERSION 3.5) + +########################################################################################## +### Change the next line for making a new driver +########################################################################################## + +set (DRIVERPROJECT ScanLabOIE) + +########################################################################################## +### generic CMake boilerplate code +########################################################################################## + +project(LibMCDriver_${DRIVERPROJECT}) + +string(TOLOWER ${DRIVERPROJECT} DRIVERSUFFIX) +string(TOUPPER ${DRIVERPROJECT} DRIVERSUFFIX_UPPER) + +set (DRIVERNAME libmcdriver_${DRIVERSUFFIX}) + +set (EXPORTFLAG __LIBMCDRIVER_${DRIVERSUFFIX_UPPER}_EXPORTS) + +set (CMAKE_CXX_STANDARD 11) + +# The location of autogenerated interfaces +set(CMAKE_CURRENT_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Framework/HeadersDev/CppDynamic) +set(CMAKE_CURRENT_AUTOGENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../Framework/InterfacesDev) +set(CMAKE_CURRENT_OUTPUT_DIR ${PROJECT_BINARY_DIR}/../../Output) + +file(STRINGS ${PROJECT_BINARY_DIR}/../../githash.txt GLOBALGITHASH) +message(STATUS "Global git hash: \"${GLOBALGITHASH}\"") + + +file(GLOB LIBMCDRIVER_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/*.cpp +) + +add_library(${DRIVERNAME} SHARED ${LIBMCDRIVER_SRC}) +# Do not prefix the binary's name with "lib" on Unix systems: +set_target_properties(${DRIVERNAME} PROPERTIES PREFIX "" IMPORT_PREFIX "" ) +# The following two properties are crucial to reduce the number of undesirably exported symbols +set_target_properties(${DRIVERNAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) +set_target_properties(${DRIVERNAME} PROPERTIES VISIBILITY_INLINES_HIDDEN ON) +# This makes sure symbols are exported +target_compile_options(${DRIVERNAME} PRIVATE "-D${EXPORTFLAG}") +target_compile_options(${DRIVERNAME} PRIVATE "-D__LIBMCDRIVER_EXPORTS") +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_AUTOGENERATED_DIR}) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_HEADER_DIR}) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation) +target_include_directories(${DRIVERNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) + +set_target_properties(${DRIVERNAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_OUTPUT_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + VS_DEBUGGER_COMMAND "${CMAKE_CURRENT_OUTPUT_DIR}/amc_server.exe" + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_OUTPUT_DIR}" + OUTPUT_NAME "${GLOBALGITHASH}_driver_${DRIVERSUFFIX}" +) + + +########################################################################################## +### Copy driver header files +########################################################################################## + +file (GLOB headerfiles LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}/Headers/CppDynamic/*.h*") +foreach(headerfile ${headerfiles}) + + get_filename_component(headerfilename ${headerfile} NAME) + + add_custom_command( + TARGET ${DRIVERNAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "copying ${headerfile}...") + + add_custom_command( + TARGET ${DRIVERNAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${headerfile} + ${CMAKE_CURRENT_BINARY_DIR}/../../DevPackage/Framework/HeadersDriver/CppDynamic/${headerfilename}) + + +endforeach() + + +########################################################################################## +### Add custom code below +########################################################################################## + +file(GLOB LIBOIE_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/LibOIE/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces/liboie*.cpp +) + +add_library(liboie SHARED ${LIBOIE_SRC}) +# Do not prefix the binary's name with "lib" on Unix systems: +set_target_properties(liboie PROPERTIES PREFIX "" IMPORT_PREFIX "" ) +# The following two properties are crucial to reduce the number of undesirably exported symbols +set_target_properties(liboie PROPERTIES CXX_VISIBILITY_PRESET hidden) +set_target_properties(liboie PROPERTIES VISIBILITY_INLINES_HIDDEN ON) +# This makes sure symbols are exported +target_compile_options(liboie PRIVATE "-D__LIBOIE_EXPORTS") +target_include_directories(liboie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/LibOIE) +target_include_directories(liboie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) diff --git a/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_abi.hpp b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_abi.hpp new file mode 100644 index 00000000..925ccef8 --- /dev/null +++ b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_abi.hpp @@ -0,0 +1,197 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_HEADER_CPP +#define __LIBMCDRIVER_SCANLABOIE_HEADER_CPP + +#ifdef __LIBMCDRIVER_SCANLABOIE_EXPORTS +#ifdef _WIN32 +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBMCDRIVER_SCANLABOIE_EXPORTS +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC +#endif // __LIBMCDRIVER_SCANLABOIE_EXPORTS + +#include "libmcdriver_scanlaboie_types.hpp" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getname(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_gettype(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nTypeBufferSize, LibMCDriver_ScanLabOIE_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getversion(LibMCDriver_ScanLabOIE_Driver pDriver, LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro, const LibMCDriver_ScanLabOIE_uint32 nBuildBufferSize, LibMCDriver_ScanLabOIE_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getheaderinformation(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameSpaceBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_ScanLabOIE_uint32 nBaseNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_ScanLab_OIE +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getversion(LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getlasterror(LibMCDriver_ScanLabOIE_Base pInstance, const LibMCDriver_ScanLabOIE_uint32 nErrorMessageBufferSize, LibMCDriver_ScanLabOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_releaseinstance(LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_acquireinstance(LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_injectcomponent(const char * pNameSpace, LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getsymbollookupmethod(LibMCDriver_ScanLabOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_ScanLabOIE_Driver * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBMCDRIVER_SCANLABOIE_HEADER_CPP + diff --git a/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.h b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.h new file mode 100644 index 00000000..805f6f3c --- /dev/null +++ b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.h @@ -0,0 +1,199 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_DYNAMICHEADER_CPPTYPES +#define __LIBMCDRIVER_SCANLABOIE_DYNAMICHEADER_CPPTYPES + +#include "libmcdriver_scanlaboie_types.hpp" + +#include "libmcdriverenv_types.hpp" + + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEDriver_GetNamePtr) (LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEDriver_GetTypePtr) (LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nTypeBufferSize, LibMCDriver_ScanLabOIE_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEDriver_GetVersionPtr) (LibMCDriver_ScanLabOIE_Driver pDriver, LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro, const LibMCDriver_ScanLabOIE_uint32 nBuildBufferSize, LibMCDriver_ScanLabOIE_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEDriver_GetHeaderInformationPtr) (LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameSpaceBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_ScanLabOIE_uint32 nBaseNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_ScanLab_OIE +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEGetVersionPtr) (LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEGetLastErrorPtr) (LibMCDriver_ScanLabOIE_Base pInstance, const LibMCDriver_ScanLabOIE_uint32 nErrorMessageBufferSize, LibMCDriver_ScanLabOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEReleaseInstancePtr) (LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEAcquireInstancePtr) (LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEInjectComponentPtr) (const char * pNameSpace, LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIEGetSymbolLookupMethodPtr) (LibMCDriver_ScanLabOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +typedef LibMCDriver_ScanLabOIEResult (*PLibMCDriver_ScanLabOIECreateDriverPtr) (const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_ScanLabOIE_Driver * pInstance); + +/************************************************************************************************************************* + Function Table Structure +**************************************************************************************************************************/ + +typedef struct { + void * m_LibraryHandle; + PLibMCDriver_ScanLabOIEDriver_GetNamePtr m_Driver_GetName; + PLibMCDriver_ScanLabOIEDriver_GetTypePtr m_Driver_GetType; + PLibMCDriver_ScanLabOIEDriver_GetVersionPtr m_Driver_GetVersion; + PLibMCDriver_ScanLabOIEDriver_GetHeaderInformationPtr m_Driver_GetHeaderInformation; + PLibMCDriver_ScanLabOIEGetVersionPtr m_GetVersion; + PLibMCDriver_ScanLabOIEGetLastErrorPtr m_GetLastError; + PLibMCDriver_ScanLabOIEReleaseInstancePtr m_ReleaseInstance; + PLibMCDriver_ScanLabOIEAcquireInstancePtr m_AcquireInstance; + PLibMCDriver_ScanLabOIEInjectComponentPtr m_InjectComponent; + PLibMCDriver_ScanLabOIEGetSymbolLookupMethodPtr m_GetSymbolLookupMethod; + PLibMCDriver_ScanLabOIECreateDriverPtr m_CreateDriver; +} sLibMCDriver_ScanLabOIEDynamicWrapperTable; + +#endif // __LIBMCDRIVER_SCANLABOIE_DYNAMICHEADER_CPPTYPES + diff --git a/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.hpp b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.hpp new file mode 100644 index 00000000..a2e9ba82 --- /dev/null +++ b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_dynamic.hpp @@ -0,0 +1,790 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_CPPHEADER_DYNAMIC_CPP +#define __LIBMCDRIVER_SCANLABOIE_CPPHEADER_DYNAMIC_CPP + +#include "libmcdriver_scanlaboie_types.hpp" +#include "libmcdriver_scanlaboie_dynamic.h" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef _WIN32 +#include +#else // _WIN32 +#include +#endif // _WIN32 +#include +#include +#include +#include + +namespace LibMCDriver_ScanLabOIE { + +/************************************************************************************************************************* + Forward Declaration of all classes +**************************************************************************************************************************/ +class CWrapper; +class CBase; +class CDriver; +class CDriver_ScanLab_OIE; + +/************************************************************************************************************************* + Declaration of deprecated class types +**************************************************************************************************************************/ +typedef CWrapper CLibMCDriver_ScanLabOIEWrapper; +typedef CBase CLibMCDriver_ScanLabOIEBase; +typedef CDriver CLibMCDriver_ScanLabOIEDriver; +typedef CDriver_ScanLab_OIE CLibMCDriver_ScanLabOIEDriver_ScanLab_OIE; + +/************************************************************************************************************************* + Declaration of shared pointer types +**************************************************************************************************************************/ +typedef std::shared_ptr PWrapper; +typedef std::shared_ptr PBase; +typedef std::shared_ptr PDriver; +typedef std::shared_ptr PDriver_ScanLab_OIE; + +/************************************************************************************************************************* + Declaration of deprecated shared pointer types +**************************************************************************************************************************/ +typedef PWrapper PLibMCDriver_ScanLabOIEWrapper; +typedef PBase PLibMCDriver_ScanLabOIEBase; +typedef PDriver PLibMCDriver_ScanLabOIEDriver; +typedef PDriver_ScanLab_OIE PLibMCDriver_ScanLabOIEDriver_ScanLab_OIE; + + +/************************************************************************************************************************* + classParam Definition +**************************************************************************************************************************/ + +template class classParam { +private: + const T* m_ptr; + +public: + classParam(const T* ptr) + : m_ptr (ptr) + { + } + + classParam(std::shared_ptr sharedPtr) + : m_ptr (sharedPtr.get()) + { + } + + LibMCDriver_ScanLabOIEHandle GetHandle() + { + if (m_ptr != nullptr) + return m_ptr->handle(); + return nullptr; + } +}; + +/************************************************************************************************************************* + Class ELibMCDriver_ScanLabOIEException +**************************************************************************************************************************/ +class ELibMCDriver_ScanLabOIEException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibMCDriver_ScanLabOIEResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibMCDriver_ScanLabOIEException(LibMCDriver_ScanLabOIEResult errorCode, const std::string & sErrorMessage) + : m_errorMessage("LibMCDriver_ScanLabOIE Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") + { + m_errorCode = errorCode; + } + + /** + * Returns error code + */ + LibMCDriver_ScanLabOIEResult getErrorCode() const noexcept + { + return m_errorCode; + } + + /** + * Returns error message + */ + const char* what() const noexcept + { + return m_errorMessage.c_str(); + } + +}; + +/************************************************************************************************************************* + Class CInputVector +**************************************************************************************************************************/ +template +class CInputVector { +private: + + const T* m_data; + size_t m_size; + +public: + + CInputVector( const std::vector& vec) + : m_data( vec.data() ), m_size( vec.size() ) + { + } + + CInputVector( const T* in_data, size_t in_size) + : m_data( in_data ), m_size(in_size ) + { + } + + const T* data() const + { + return m_data; + } + + size_t size() const + { + return m_size; + } + +}; + +// declare deprecated class name +template +using CLibMCDriver_ScanLabOIEInputVector = CInputVector; + +/************************************************************************************************************************* + Class CWrapper +**************************************************************************************************************************/ +class CWrapper { +public: + + CWrapper(void* pSymbolLookupMethod) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod)); + + CheckError(nullptr, checkBinaryVersion()); + } + + CWrapper(const std::string &sFileName) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str())); + + CheckError(nullptr, checkBinaryVersion()); + } + + static PWrapper loadLibrary(const std::string &sFileName) + { + return std::make_shared(sFileName); + } + + static PWrapper loadLibraryFromSymbolLookupMethod(void* pSymbolLookupMethod) + { + return std::make_shared(pSymbolLookupMethod); + } + + ~CWrapper() + { + releaseWrapperTable(&m_WrapperTable); + } + + inline void CheckError(CBase * pBaseClass, LibMCDriver_ScanLabOIEResult nResult); + + inline void GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro); + inline bool GetLastError(classParam pInstance, std::string & sErrorMessage); + inline void ReleaseInstance(classParam pInstance); + inline void AcquireInstance(classParam pInstance); + inline void InjectComponent(const std::string & sNameSpace, const LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod); + inline LibMCDriver_ScanLabOIE_pvoid GetSymbolLookupMethod(); + inline PDriver CreateDriver(const std::string & sName, const std::string & sType, classParam pDriverEnvironment); + +private: + sLibMCDriver_ScanLabOIEDynamicWrapperTable m_WrapperTable; + // Injected Components + LibMCDriverEnv::PWrapper m_pLibMCDriverEnvWrapper; + + + LibMCDriver_ScanLabOIEResult checkBinaryVersion() + { + LibMCDriver_ScanLabOIE_uint32 nMajor, nMinor, nMicro; + GetVersion(nMajor, nMinor, nMicro); + if ( (nMajor != LIBMCDRIVER_SCANLABOIE_VERSION_MAJOR) || (nMinor < LIBMCDRIVER_SCANLABOIE_VERSION_MINOR) ) { + return LIBMCDRIVER_SCANLABOIE_ERROR_INCOMPATIBLEBINARYVERSION; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + LibMCDriver_ScanLabOIEResult initWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable); + LibMCDriver_ScanLabOIEResult releaseWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable); + LibMCDriver_ScanLabOIEResult loadWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName); + LibMCDriver_ScanLabOIEResult loadWrapperTableFromSymbolLookupMethod(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod); + + friend class CBase; + friend class CDriver; + friend class CDriver_ScanLab_OIE; + +}; + + +/************************************************************************************************************************* + Class CBase +**************************************************************************************************************************/ +class CBase { +public: + +protected: + /* Wrapper Object that created the class. */ + CWrapper * m_pWrapper; + /* Handle to Instance in library*/ + LibMCDriver_ScanLabOIEHandle m_pHandle; + + /* Checks for an Error code and raises Exceptions */ + void CheckError(LibMCDriver_ScanLabOIEResult nResult) + { + if (m_pWrapper != nullptr) + m_pWrapper->CheckError(this, nResult); + } +public: + /** + * CBase::CBase - Constructor for Base class. + */ + CBase(CWrapper * pWrapper, LibMCDriver_ScanLabOIEHandle pHandle) + : m_pWrapper(pWrapper), m_pHandle(pHandle) + { + } + + /** + * CBase::~CBase - Destructor for Base class. + */ + virtual ~CBase() + { + if (m_pWrapper != nullptr) + m_pWrapper->ReleaseInstance(this); + m_pWrapper = nullptr; + } + + /** + * CBase::handle - Returns handle to instance. + */ + LibMCDriver_ScanLabOIEHandle handle() const + { + return m_pHandle; + } + + /** + * CBase::wrapper - Returns wrapper instance. + */ + CWrapper * wrapper() const + { + return m_pWrapper; + } + + friend class CWrapper; +}; + +/************************************************************************************************************************* + Class CDriver +**************************************************************************************************************************/ +class CDriver : public CBase { +public: + + /** + * CDriver::CDriver - Constructor for Driver class. + */ + CDriver(CWrapper* pWrapper, LibMCDriver_ScanLabOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetName(); + inline std::string GetType(); + inline void GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro, std::string & sBuild); + inline void GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName); +}; + +/************************************************************************************************************************* + Class CDriver_ScanLab_OIE +**************************************************************************************************************************/ +class CDriver_ScanLab_OIE : public CDriver { +public: + + /** + * CDriver_ScanLab_OIE::CDriver_ScanLab_OIE - Constructor for Driver_ScanLab_OIE class. + */ + CDriver_ScanLab_OIE(CWrapper* pWrapper, LibMCDriver_ScanLabOIEHandle pHandle) + : CDriver(pWrapper, pHandle) + { + } + +}; + + /** + * CWrapper::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + inline void CWrapper::GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro) + { + CheckError(nullptr,m_WrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro)); + } + + /** + * CWrapper::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + inline bool CWrapper::GetLastError(classParam pInstance, std::string & sErrorMessage) + { + LibMCDriver_ScanLabOIEHandle hInstance = pInstance.GetHandle(); + LibMCDriver_ScanLabOIE_uint32 bytesNeededErrorMessage = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenErrorMessage = 0; + bool resultHasError = 0; + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, 0, &bytesNeededErrorMessage, nullptr, &resultHasError)); + std::vector bufferErrorMessage(bytesNeededErrorMessage); + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], &resultHasError)); + sErrorMessage = std::string(&bufferErrorMessage[0]); + + return resultHasError; + } + + /** + * CWrapper::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::ReleaseInstance(classParam pInstance) + { + LibMCDriver_ScanLabOIEHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_ReleaseInstance(hInstance)); + } + + /** + * CWrapper::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::AcquireInstance(classParam pInstance) + { + LibMCDriver_ScanLabOIEHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_AcquireInstance(hInstance)); + } + + /** + * CWrapper::InjectComponent - Injects an imported component for usage within this component + * @param[in] sNameSpace - NameSpace of the injected component + * @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component + */ + inline void CWrapper::InjectComponent(const std::string & sNameSpace, const LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod) + { + CheckError(nullptr,m_WrapperTable.m_InjectComponent(sNameSpace.c_str(), pSymbolAddressMethod)); + + bool bNameSpaceFound = false; + if (sNameSpace == "LibMCDriverEnv") { + if (m_pLibMCDriverEnvWrapper != nullptr) { + throw ELibMCDriver_ScanLabOIEException(LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY, "Library with namespace " + sNameSpace + " is already registered."); + } + m_pLibMCDriverEnvWrapper = LibMCDriverEnv::CWrapper::loadLibraryFromSymbolLookupMethod(pSymbolAddressMethod); + bNameSpaceFound = true; + } + if (!bNameSpaceFound) + throw ELibMCDriver_ScanLabOIEException(LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY, "Unknown namespace " + sNameSpace); + } + + /** + * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod + * @return Address of the SymbolAddressMethod + */ + inline LibMCDriver_ScanLabOIE_pvoid CWrapper::GetSymbolLookupMethod() + { + LibMCDriver_ScanLabOIE_pvoid resultSymbolLookupMethod = 0; + CheckError(nullptr,m_WrapperTable.m_GetSymbolLookupMethod(&resultSymbolLookupMethod)); + + return resultSymbolLookupMethod; + } + + /** + * CWrapper::CreateDriver - Creates a driver instance with a specific name. + * @param[in] sName - Name of driver to be created. + * @param[in] sType - Type of driver to be created. + * @param[in] pDriverEnvironment - Environment of this driver. + * @return New Driver instance + */ + inline PDriver CWrapper::CreateDriver(const std::string & sName, const std::string & sType, classParam pDriverEnvironment) + { + LibMCDriverEnvHandle hDriverEnvironment = pDriverEnvironment.GetHandle(); + LibMCDriver_ScanLabOIEHandle hInstance = nullptr; + CheckError(nullptr,m_WrapperTable.m_CreateDriver(sName.c_str(), sType.c_str(), hDriverEnvironment, &hInstance)); + + if (!hInstance) { + CheckError(nullptr,LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(this, hInstance); + } + + inline void CWrapper::CheckError(CBase * pBaseClass, LibMCDriver_ScanLabOIEResult nResult) + { + if (nResult != 0) { + std::string sErrorMessage; + if (pBaseClass != nullptr) { + GetLastError(pBaseClass, sErrorMessage); + } + throw ELibMCDriver_ScanLabOIEException(nResult, sErrorMessage); + } + } + + + inline LibMCDriver_ScanLabOIEResult CWrapper::initWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + + pWrapperTable->m_LibraryHandle = nullptr; + pWrapperTable->m_Driver_GetName = nullptr; + pWrapperTable->m_Driver_GetType = nullptr; + pWrapperTable->m_Driver_GetVersion = nullptr; + pWrapperTable->m_Driver_GetHeaderInformation = nullptr; + pWrapperTable->m_GetVersion = nullptr; + pWrapperTable->m_GetLastError = nullptr; + pWrapperTable->m_ReleaseInstance = nullptr; + pWrapperTable->m_AcquireInstance = nullptr; + pWrapperTable->m_InjectComponent = nullptr; + pWrapperTable->m_GetSymbolLookupMethod = nullptr; + pWrapperTable->m_CreateDriver = nullptr; + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + + inline LibMCDriver_ScanLabOIEResult CWrapper::releaseWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + + if (pWrapperTable->m_LibraryHandle != nullptr) { + #ifdef _WIN32 + HMODULE hModule = (HMODULE) pWrapperTable->m_LibraryHandle; + FreeLibrary(hModule); + #else // _WIN32 + dlclose(pWrapperTable->m_LibraryHandle); + #endif // _WIN32 + return initWrapperTable(pWrapperTable); + } + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + + inline LibMCDriver_ScanLabOIEResult CWrapper::loadWrapperTable(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName) + { + if (pWrapperTable == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + if (pLibraryFileName == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + + #ifdef _WIN32 + // Convert filename to UTF16-string + int nLength = (int)strlen(pLibraryFileName); + int nBufferSize = nLength * 2 + 2; + std::vector wsLibraryFileName(nBufferSize); + int nResult = MultiByteToWideChar(CP_UTF8, 0, pLibraryFileName, nLength, &wsLibraryFileName[0], nBufferSize); + if (nResult == 0) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY; + + HMODULE hLibrary = LoadLibraryW(wsLibraryFileName.data()); + if (hLibrary == 0) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY; + #else // _WIN32 + void* hLibrary = dlopen(pLibraryFileName, RTLD_LAZY); + if (hLibrary == 0) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY; + dlerror(); + #endif // _WIN32 + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetName = (PLibMCDriver_ScanLabOIEDriver_GetNamePtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_driver_getname"); + #else // _WIN32 + pWrapperTable->m_Driver_GetName = (PLibMCDriver_ScanLabOIEDriver_GetNamePtr) dlsym(hLibrary, "libmcdriver_scanlaboie_driver_getname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetName == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetType = (PLibMCDriver_ScanLabOIEDriver_GetTypePtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_driver_gettype"); + #else // _WIN32 + pWrapperTable->m_Driver_GetType = (PLibMCDriver_ScanLabOIEDriver_GetTypePtr) dlsym(hLibrary, "libmcdriver_scanlaboie_driver_gettype"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetType == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetVersion = (PLibMCDriver_ScanLabOIEDriver_GetVersionPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_driver_getversion"); + #else // _WIN32 + pWrapperTable->m_Driver_GetVersion = (PLibMCDriver_ScanLabOIEDriver_GetVersionPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_driver_getversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetVersion == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Driver_GetHeaderInformation = (PLibMCDriver_ScanLabOIEDriver_GetHeaderInformationPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_driver_getheaderinformation"); + #else // _WIN32 + pWrapperTable->m_Driver_GetHeaderInformation = (PLibMCDriver_ScanLabOIEDriver_GetHeaderInformationPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_driver_getheaderinformation"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Driver_GetHeaderInformation == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetVersion = (PLibMCDriver_ScanLabOIEGetVersionPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_getversion"); + #else // _WIN32 + pWrapperTable->m_GetVersion = (PLibMCDriver_ScanLabOIEGetVersionPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_getversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetVersion == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetLastError = (PLibMCDriver_ScanLabOIEGetLastErrorPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_getlasterror"); + #else // _WIN32 + pWrapperTable->m_GetLastError = (PLibMCDriver_ScanLabOIEGetLastErrorPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_getlasterror"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetLastError == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibMCDriver_ScanLabOIEReleaseInstancePtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_releaseinstance"); + #else // _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibMCDriver_ScanLabOIEReleaseInstancePtr) dlsym(hLibrary, "libmcdriver_scanlaboie_releaseinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_ReleaseInstance == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_AcquireInstance = (PLibMCDriver_ScanLabOIEAcquireInstancePtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_acquireinstance"); + #else // _WIN32 + pWrapperTable->m_AcquireInstance = (PLibMCDriver_ScanLabOIEAcquireInstancePtr) dlsym(hLibrary, "libmcdriver_scanlaboie_acquireinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_AcquireInstance == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_InjectComponent = (PLibMCDriver_ScanLabOIEInjectComponentPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_injectcomponent"); + #else // _WIN32 + pWrapperTable->m_InjectComponent = (PLibMCDriver_ScanLabOIEInjectComponentPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_injectcomponent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_InjectComponent == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibMCDriver_ScanLabOIEGetSymbolLookupMethodPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_getsymbollookupmethod"); + #else // _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibMCDriver_ScanLabOIEGetSymbolLookupMethodPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_getsymbollookupmethod"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetSymbolLookupMethod == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_CreateDriver = (PLibMCDriver_ScanLabOIECreateDriverPtr) GetProcAddress(hLibrary, "libmcdriver_scanlaboie_createdriver"); + #else // _WIN32 + pWrapperTable->m_CreateDriver = (PLibMCDriver_ScanLabOIECreateDriverPtr) dlsym(hLibrary, "libmcdriver_scanlaboie_createdriver"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_CreateDriver == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + pWrapperTable->m_LibraryHandle = hLibrary; + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + + inline LibMCDriver_ScanLabOIEResult CWrapper::loadWrapperTableFromSymbolLookupMethod(sLibMCDriver_ScanLabOIEDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod) +{ + if (pWrapperTable == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + if (pSymbolLookupMethod == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + + typedef LibMCDriver_ScanLabOIEResult(*SymbolLookupType)(const char*, void**); + + SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod; + + LibMCDriver_ScanLabOIEResult eLookupError = LIBMCDRIVER_SCANLABOIE_SUCCESS; + eLookupError = (*pLookup)("libmcdriver_scanlaboie_driver_getname", (void**)&(pWrapperTable->m_Driver_GetName)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetName == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_driver_gettype", (void**)&(pWrapperTable->m_Driver_GetType)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetType == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_driver_getversion", (void**)&(pWrapperTable->m_Driver_GetVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetVersion == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_driver_getheaderinformation", (void**)&(pWrapperTable->m_Driver_GetHeaderInformation)); + if ( (eLookupError != 0) || (pWrapperTable->m_Driver_GetHeaderInformation == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_getversion", (void**)&(pWrapperTable->m_GetVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetVersion == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_getlasterror", (void**)&(pWrapperTable->m_GetLastError)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetLastError == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_releaseinstance", (void**)&(pWrapperTable->m_ReleaseInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_ReleaseInstance == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_acquireinstance", (void**)&(pWrapperTable->m_AcquireInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_AcquireInstance == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_injectcomponent", (void**)&(pWrapperTable->m_InjectComponent)); + if ( (eLookupError != 0) || (pWrapperTable->m_InjectComponent == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_getsymbollookupmethod", (void**)&(pWrapperTable->m_GetSymbolLookupMethod)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetSymbolLookupMethod == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcdriver_scanlaboie_createdriver", (void**)&(pWrapperTable->m_CreateDriver)); + if ( (eLookupError != 0) || (pWrapperTable->m_CreateDriver == nullptr) ) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; +} + + + + /** + * Method definitions for class CBase + */ + + /** + * Method definitions for class CDriver + */ + + /** + * CDriver::GetName - returns the name identifier of the driver + * @return Name of the driver. + */ + std::string CDriver::GetName() + { + LibMCDriver_ScanLabOIE_uint32 bytesNeededName = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetName(m_pHandle, 0, &bytesNeededName, nullptr)); + std::vector bufferName(bytesNeededName); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetName(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); + + return std::string(&bufferName[0]); + } + + /** + * CDriver::GetType - returns the type identifier of the driver + * @return Type of the driver. + */ + std::string CDriver::GetType() + { + LibMCDriver_ScanLabOIE_uint32 bytesNeededType = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenType = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetType(m_pHandle, 0, &bytesNeededType, nullptr)); + std::vector bufferType(bytesNeededType); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetType(m_pHandle, bytesNeededType, &bytesWrittenType, &bufferType[0])); + + return std::string(&bufferType[0]); + } + + /** + * CDriver::GetVersion - returns the version identifiers of the driver + * @param[out] nMajor - Major version. + * @param[out] nMinor - Minor version. + * @param[out] nMicro - Micro version. + * @param[out] sBuild - Build identifier. + */ + void CDriver::GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro, std::string & sBuild) + { + LibMCDriver_ScanLabOIE_uint32 bytesNeededBuild = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenBuild = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetVersion(m_pHandle, &nMajor, &nMinor, &nMicro, 0, &bytesNeededBuild, nullptr)); + std::vector bufferBuild(bytesNeededBuild); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetVersion(m_pHandle, &nMajor, &nMinor, &nMicro, bytesNeededBuild, &bytesWrittenBuild, &bufferBuild[0])); + sBuild = std::string(&bufferBuild[0]); + } + + /** + * CDriver::GetHeaderInformation - returns the header information + * @param[out] sNameSpace - NameSpace of the driver. + * @param[out] sBaseName - BaseName of the driver. + */ + void CDriver::GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName) + { + LibMCDriver_ScanLabOIE_uint32 bytesNeededNameSpace = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenNameSpace = 0; + LibMCDriver_ScanLabOIE_uint32 bytesNeededBaseName = 0; + LibMCDriver_ScanLabOIE_uint32 bytesWrittenBaseName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetHeaderInformation(m_pHandle, 0, &bytesNeededNameSpace, nullptr, 0, &bytesNeededBaseName, nullptr)); + std::vector bufferNameSpace(bytesNeededNameSpace); + std::vector bufferBaseName(bytesNeededBaseName); + CheckError(m_pWrapper->m_WrapperTable.m_Driver_GetHeaderInformation(m_pHandle, bytesNeededNameSpace, &bytesWrittenNameSpace, &bufferNameSpace[0], bytesNeededBaseName, &bytesWrittenBaseName, &bufferBaseName[0])); + sNameSpace = std::string(&bufferNameSpace[0]); + sBaseName = std::string(&bufferBaseName[0]); + } + + /** + * Method definitions for class CDriver_ScanLab_OIE + */ + +} // namespace LibMCDriver_ScanLabOIE + +#endif // __LIBMCDRIVER_SCANLABOIE_CPPHEADER_DYNAMIC_CPP + diff --git a/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_types.hpp b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_types.hpp new file mode 100644 index 00000000..a2e1c637 --- /dev/null +++ b/Drivers/ScanLabOIE/Headers/CppDynamic/libmcdriver_scanlaboie_types.hpp @@ -0,0 +1,141 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP +#define __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +typedef unsigned char LibMCDriver_ScanLabOIE_uint8; +typedef unsigned short LibMCDriver_ScanLabOIE_uint16 ; +typedef unsigned int LibMCDriver_ScanLabOIE_uint32; +typedef unsigned long long LibMCDriver_ScanLabOIE_uint64; +typedef char LibMCDriver_ScanLabOIE_int8; +typedef short LibMCDriver_ScanLabOIE_int16; +typedef int LibMCDriver_ScanLabOIE_int32; +typedef long long LibMCDriver_ScanLabOIE_int64; + +#else // LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibMCDriver_ScanLabOIE_uint8; +typedef uint16_t LibMCDriver_ScanLabOIE_uint16; +typedef uint32_t LibMCDriver_ScanLabOIE_uint32; +typedef uint64_t LibMCDriver_ScanLabOIE_uint64; +typedef int8_t LibMCDriver_ScanLabOIE_int8; +typedef int16_t LibMCDriver_ScanLabOIE_int16; +typedef int32_t LibMCDriver_ScanLabOIE_int32; +typedef int64_t LibMCDriver_ScanLabOIE_int64 ; + +#endif // LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +typedef float LibMCDriver_ScanLabOIE_single; +typedef double LibMCDriver_ScanLabOIE_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibMCDriver_ScanLabOIE_int32 LibMCDriver_ScanLabOIEResult; +typedef void * LibMCDriver_ScanLabOIEHandle; +typedef void * LibMCDriver_ScanLabOIE_pvoid; + +/************************************************************************************************************************* + Version for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +#define LIBMCDRIVER_SCANLABOIE_VERSION_MAJOR 1 +#define LIBMCDRIVER_SCANLABOIE_VERSION_MINOR 0 +#define LIBMCDRIVER_SCANLABOIE_VERSION_MICRO 0 +#define LIBMCDRIVER_SCANLABOIE_VERSION_PRERELEASEINFO "" +#define LIBMCDRIVER_SCANLABOIE_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +#define LIBMCDRIVER_SCANLABOIE_SUCCESS 0 +#define LIBMCDRIVER_SCANLABOIE_ERROR_NOTIMPLEMENTED 1 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM 2 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST 3 +#define LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL 4 +#define LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION 5 +#define LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INCOMPATIBLEBINARYVERSION 8 + +/************************************************************************************************************************* + Error strings for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +inline const char * LIBMCDRIVER_SCANLABOIE_GETERRORSTRING (LibMCDriver_ScanLabOIEResult nErrorCode) { + switch (nErrorCode) { + case LIBMCDRIVER_SCANLABOIE_SUCCESS: return "no error"; + case LIBMCDRIVER_SCANLABOIE_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Base; +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Driver; +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Driver_ScanLab_OIE; + +namespace LibMCDriver_ScanLabOIE { + +} // namespace LibMCDriver_ScanLabOIE; + +// define legacy C-names for enums, structs and function types + +#endif // __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_abi.hpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_abi.hpp new file mode 100644 index 00000000..925ccef8 --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_abi.hpp @@ -0,0 +1,197 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_HEADER_CPP +#define __LIBMCDRIVER_SCANLABOIE_HEADER_CPP + +#ifdef __LIBMCDRIVER_SCANLABOIE_EXPORTS +#ifdef _WIN32 +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBMCDRIVER_SCANLABOIE_EXPORTS +#define LIBMCDRIVER_SCANLABOIE_DECLSPEC +#endif // __LIBMCDRIVER_SCANLABOIE_EXPORTS + +#include "libmcdriver_scanlaboie_types.hpp" + +#include "libmcdriverenv_dynamic.hpp" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Driver +**************************************************************************************************************************/ + +/** +* returns the name identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameBuffer - buffer of Name of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getname(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameNeededChars, char * pNameBuffer); + +/** +* returns the type identifier of the driver +* +* @param[in] pDriver - Driver instance. +* @param[in] nTypeBufferSize - size of the buffer (including trailing 0) +* @param[out] pTypeNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTypeBuffer - buffer of Type of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_gettype(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nTypeBufferSize, LibMCDriver_ScanLabOIE_uint32* pTypeNeededChars, char * pTypeBuffer); + +/** +* returns the version identifiers of the driver +* +* @param[in] pDriver - Driver instance. +* @param[out] pMajor - Major version. +* @param[out] pMinor - Minor version. +* @param[out] pMicro - Micro version. +* @param[in] nBuildBufferSize - size of the buffer (including trailing 0) +* @param[out] pBuildNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBuildBuffer - buffer of Build identifier., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getversion(LibMCDriver_ScanLabOIE_Driver pDriver, LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro, const LibMCDriver_ScanLabOIE_uint32 nBuildBufferSize, LibMCDriver_ScanLabOIE_uint32* pBuildNeededChars, char * pBuildBuffer); + +/** +* returns the header information +* +* @param[in] pDriver - Driver instance. +* @param[in] nNameSpaceBufferSize - size of the buffer (including trailing 0) +* @param[out] pNameSpaceNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pNameSpaceBuffer - buffer of NameSpace of the driver., may be NULL +* @param[in] nBaseNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pBaseNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pBaseNameBuffer - buffer of BaseName of the driver., may be NULL +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getheaderinformation(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameSpaceBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_ScanLabOIE_uint32 nBaseNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pBaseNameNeededChars, char * pBaseNameBuffer); + +/************************************************************************************************************************* + Class definition for Driver_ScanLab_OIE +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getversion(LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getlasterror(LibMCDriver_ScanLabOIE_Base pInstance, const LibMCDriver_ScanLabOIE_uint32 nErrorMessageBufferSize, LibMCDriver_ScanLabOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_releaseinstance(LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_acquireinstance(LibMCDriver_ScanLabOIE_Base pInstance); + +/** +* Injects an imported component for usage within this component +* +* @param[in] pNameSpace - NameSpace of the injected component +* @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_injectcomponent(const char * pNameSpace, LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getsymbollookupmethod(LibMCDriver_ScanLabOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a driver instance with a specific name. +* +* @param[in] pName - Name of driver to be created. +* @param[in] pType - Type of driver to be created. +* @param[in] pDriverEnvironment - Environment of this driver. +* @param[out] pInstance - New Driver instance +* @return error code or 0 (success) +*/ +LIBMCDRIVER_SCANLABOIE_DECLSPEC LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_ScanLabOIE_Driver * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBMCDRIVER_SCANLABOIE_HEADER_CPP + diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.cpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.cpp new file mode 100644 index 00000000..129a4454 --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.cpp @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Implementation file with the basic internal + exception type in order to allow an easy use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + + +#include + +#include "libmcdriver_scanlaboie_interfaceexception.hpp" + +/************************************************************************************************************************* + Class ELibMCDriver_ScanLabOIEInterfaceException +**************************************************************************************************************************/ +ELibMCDriver_ScanLabOIEInterfaceException::ELibMCDriver_ScanLabOIEInterfaceException(LibMCDriver_ScanLabOIEResult errorCode) + : m_errorMessage(LIBMCDRIVER_SCANLABOIE_GETERRORSTRING (errorCode)) +{ + m_errorCode = errorCode; +} + +ELibMCDriver_ScanLabOIEInterfaceException::ELibMCDriver_ScanLabOIEInterfaceException(LibMCDriver_ScanLabOIEResult errorCode, std::string errorMessage) + : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") +{ + m_errorCode = errorCode; +} + +LibMCDriver_ScanLabOIEResult ELibMCDriver_ScanLabOIEInterfaceException::getErrorCode () +{ + return m_errorCode; +} + +const char * ELibMCDriver_ScanLabOIEInterfaceException::what () const noexcept +{ + return m_errorMessage.c_str(); +} + diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.hpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.hpp new file mode 100644 index 00000000..5826f8ed --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaceexception.hpp @@ -0,0 +1,83 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Header file with the basic internal + exception type in order to allow an easy use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_INTERFACEEXCEPTION_HEADER +#define __LIBMCDRIVER_SCANLABOIE_INTERFACEEXCEPTION_HEADER + +#include +#include +#include "libmcdriver_scanlaboie_types.hpp" + +/************************************************************************************************************************* + Class ELibMCDriver_ScanLabOIEInterfaceException +**************************************************************************************************************************/ + + +class ELibMCDriver_ScanLabOIEInterfaceException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibMCDriver_ScanLabOIEResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibMCDriver_ScanLabOIEInterfaceException(LibMCDriver_ScanLabOIEResult errorCode); + + /** + * Custom Exception Constructor. + */ + ELibMCDriver_ScanLabOIEInterfaceException(LibMCDriver_ScanLabOIEResult errorCode, std::string errorMessage); + + /** + * Returns error code + */ + LibMCDriver_ScanLabOIEResult getErrorCode(); + /** + * Returns error message + */ + const char* what() const noexcept override; +}; + +#endif // __LIBMCDRIVER_SCANLABOIE_INTERFACEEXCEPTION_HEADER diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaces.hpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaces.hpp new file mode 100644 index 00000000..f00534f7 --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfaces.hpp @@ -0,0 +1,364 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ header file in order to allow easy +development of MC Driver ScanLab Open Interface Extension. The implementer of MC Driver ScanLab Open Interface Extension needs to +derive concrete classes from the abstract classes in this header. + +Interface version: 1.0.0 + +*/ + + +#ifndef __LIBMCDRIVER_SCANLABOIE_CPPINTERFACES +#define __LIBMCDRIVER_SCANLABOIE_CPPINTERFACES + +#include +#include + +#include "libmcdriver_scanlaboie_types.hpp" + + +#include "libmcdriverenv_dynamic.hpp" + +namespace LibMCDriver_ScanLabOIE { +namespace Impl { + +/** + Forward declarations of class interfaces +*/ +class IBase; +class IDriver; +class IDriver_ScanLab_OIE; + + + +/************************************************************************************************************************* + Parameter Cache definitions +**************************************************************************************************************************/ + +class ParameterCache { + public: + virtual ~ParameterCache() {} +}; + +template class ParameterCache_1 : public ParameterCache { + private: + T1 m_param1; + public: + ParameterCache_1 (const T1 & param1) + : m_param1 (param1) + { + } + + void retrieveData (T1 & param1) + { + param1 = m_param1; + } +}; + +template class ParameterCache_2 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + public: + ParameterCache_2 (const T1 & param1, const T2 & param2) + : m_param1 (param1), m_param2 (param2) + { + } + + void retrieveData (T1 & param1, T2 & param2) + { + param1 = m_param1; + param2 = m_param2; + } +}; + +template class ParameterCache_3 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + public: + ParameterCache_3 (const T1 & param1, const T2 & param2, const T3 & param3) + : m_param1 (param1), m_param2 (param2), m_param3 (param3) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + } +}; + +template class ParameterCache_4 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + T4 m_param4; + public: + ParameterCache_4 (const T1 & param1, const T2 & param2, const T3 & param3, const T4 & param4) + : m_param1 (param1), m_param2 (param2), m_param3 (param3), m_param4 (param4) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3, T4 & param4) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + param4 = m_param4; + } +}; + + +/************************************************************************************************************************* + Class interface for Base +**************************************************************************************************************************/ + +class IBase { +private: + std::unique_ptr m_ParameterCache; +public: + /** + * IBase::~IBase - virtual destructor of IBase + */ + virtual ~IBase() {}; + + /** + * IBase::ReleaseBaseClassInterface - Releases ownership of a base class interface. Deletes the reference, if necessary. + * @param[in] pIBase - The base class instance to release + */ + static void ReleaseBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->DecRefCount(); + } + }; + + /** + * IBase::AcquireBaseClassInterface - Acquires shared ownership of a base class interface. + * @param[in] pIBase - The base class instance to acquire + */ + static void AcquireBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->IncRefCount(); + } + }; + + + /** + * IBase::GetLastErrorMessage - Returns the last error registered of this class instance + * @param[out] sErrorMessage - Message of the last error registered + * @return Has an error been registered already + */ + virtual bool GetLastErrorMessage(std::string & sErrorMessage) = 0; + + /** + * IBase::ClearErrorMessages - Clears all registered messages of this class instance + */ + virtual void ClearErrorMessages() = 0; + + /** + * IBase::RegisterErrorMessage - Registers an error message with this class instance + * @param[in] sErrorMessage - Error message to register + */ + virtual void RegisterErrorMessage(const std::string & sErrorMessage) = 0; + + /** + * IBase::IncRefCount - Increases the reference count of a class instance + */ + virtual void IncRefCount() = 0; + + /** + * IBase::DecRefCount - Decreases the reference count of a class instance and free releases it, if the last reference has been removed + * @return Has the object been released + */ + virtual bool DecRefCount() = 0; + + /** + * IBase::_setCache - set parameter cache of object + */ + void _setCache(ParameterCache * pCache) + { + m_ParameterCache.reset(pCache); + } + + /** + * IBase::_getCache - returns parameter cache of object + */ + ParameterCache* _getCache() + { + return m_ParameterCache.get(); + } + +}; + + +/** + Definition of a shared pointer class for IBase +*/ +template +class IBaseSharedPtr : public std::shared_ptr +{ +public: + explicit IBaseSharedPtr(T* t = nullptr) + : std::shared_ptr(t, IBase::ReleaseBaseClassInterface) + { + t->IncRefCount(); + } + + // Reset function, as it also needs to properly set the deleter. + void reset(T* t = nullptr) + { + std::shared_ptr::reset(t, IBase::ReleaseBaseClassInterface); + } + + // Get-function that increases the Base class's reference count + T* getCoOwningPtr() + { + T* t = this->get(); + t->IncRefCount(); + return t; + } +}; + + +typedef IBaseSharedPtr PIBase; + + +/************************************************************************************************************************* + Class interface for Driver +**************************************************************************************************************************/ + +class IDriver : public virtual IBase { +public: + /** + * IDriver::GetName - returns the name identifier of the driver + * @return Name of the driver. + */ + virtual std::string GetName() = 0; + + /** + * IDriver::GetType - returns the type identifier of the driver + * @return Type of the driver. + */ + virtual std::string GetType() = 0; + + /** + * IDriver::GetVersion - returns the version identifiers of the driver + * @param[out] nMajor - Major version. + * @param[out] nMinor - Minor version. + * @param[out] nMicro - Micro version. + * @param[out] sBuild - Build identifier. + */ + virtual void GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro, std::string & sBuild) = 0; + + /** + * IDriver::GetHeaderInformation - returns the header information + * @param[out] sNameSpace - NameSpace of the driver. + * @param[out] sBaseName - BaseName of the driver. + */ + virtual void GetHeaderInformation(std::string & sNameSpace, std::string & sBaseName) = 0; + +}; + +typedef IBaseSharedPtr PIDriver; + + +/************************************************************************************************************************* + Class interface for Driver_ScanLab_OIE +**************************************************************************************************************************/ + +class IDriver_ScanLab_OIE : public virtual IDriver { +public: +}; + +typedef IBaseSharedPtr PIDriver_ScanLab_OIE; + + +/************************************************************************************************************************* + Global functions declarations +**************************************************************************************************************************/ +class CWrapper { +public: + // Injected Components + static LibMCDriverEnv::PWrapper sPLibMCDriverEnvWrapper; + + /** + * Ilibmcdriver_scanlaboie::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + static void GetVersion(LibMCDriver_ScanLabOIE_uint32 & nMajor, LibMCDriver_ScanLabOIE_uint32 & nMinor, LibMCDriver_ScanLabOIE_uint32 & nMicro); + + /** + * Ilibmcdriver_scanlaboie::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + static bool GetLastError(IBase* pInstance, std::string & sErrorMessage); + + /** + * Ilibmcdriver_scanlaboie::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void ReleaseInstance(IBase* pInstance); + + /** + * Ilibmcdriver_scanlaboie::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void AcquireInstance(IBase* pInstance); + + /** + * Ilibmcdriver_scanlaboie::CreateDriver - Creates a driver instance with a specific name. + * @param[in] sName - Name of driver to be created. + * @param[in] sType - Type of driver to be created. + * @param[in] pDriverEnvironment - Environment of this driver. + * @return New Driver instance + */ + static IDriver * CreateDriver(const std::string & sName, const std::string & sType, LibMCDriverEnv::PDriverEnvironment pDriverEnvironment); + +}; + +LibMCDriver_ScanLabOIEResult LibMCDriver_ScanLabOIE_GetProcAddress (const char * pProcName, void ** ppProcAddress); + +} // namespace Impl +} // namespace LibMCDriver_ScanLabOIE + +#endif // __LIBMCDRIVER_SCANLABOIE_CPPINTERFACES diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfacewrapper.cpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfacewrapper.cpp new file mode 100644 index 00000000..c2fa4a13 --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_interfacewrapper.cpp @@ -0,0 +1,552 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ implementation file in order to allow easy +development of MC Driver ScanLab Open Interface Extension. The functions in this file need to be implemented. It needs to be generated only once. + +Interface version: 1.0.0 + +*/ + +#include "libmcdriver_scanlaboie_abi.hpp" +#include "libmcdriver_scanlaboie_interfaces.hpp" +#include "libmcdriver_scanlaboie_interfaceexception.hpp" + +#include + +using namespace LibMCDriver_ScanLabOIE::Impl; + +LibMCDriver_ScanLabOIEResult handleLibMCDriver_ScanLabOIEException(IBase * pIBaseClass, ELibMCDriver_ScanLabOIEInterfaceException & Exception) +{ + LibMCDriver_ScanLabOIEResult errorCode = Exception.getErrorCode(); + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibMCDriver_ScanLabOIEResult handleStdException(IBase * pIBaseClass, std::exception & Exception) +{ + LibMCDriver_ScanLabOIEResult errorCode = LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibMCDriver_ScanLabOIEResult handleUnhandledException(IBase * pIBaseClass) +{ + LibMCDriver_ScanLabOIEResult errorCode = LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage("Unhandled Exception"); + + return errorCode; +} + + + +/************************************************************************************************************************* + Class implementation for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for Driver +**************************************************************************************************************************/ +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getname(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameNeededChars, char * pNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pNameBuffer) && !(pNameNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sName(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameBuffer == nullptr); + if (isCacheCall) { + sName = pIDriver->GetName(); + + pIDriver->_setCache (new ParameterCache_1 (sName)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + cache->retrieveData (sName); + pIDriver->_setCache (nullptr); + } + + if (pNameNeededChars) + *pNameNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sName.size()+1); + if (pNameBuffer) { + if (sName.size() >= nNameBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iName = 0; iName < sName.size(); iName++) + pNameBuffer[iName] = sName[iName]; + pNameBuffer[sName.size()] = 0; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_gettype(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nTypeBufferSize, LibMCDriver_ScanLabOIE_uint32* pTypeNeededChars, char * pTypeBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pTypeBuffer) && !(pTypeNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sType(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pTypeBuffer == nullptr); + if (isCacheCall) { + sType = pIDriver->GetType(); + + pIDriver->_setCache (new ParameterCache_1 (sType)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + cache->retrieveData (sType); + pIDriver->_setCache (nullptr); + } + + if (pTypeNeededChars) + *pTypeNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sType.size()+1); + if (pTypeBuffer) { + if (sType.size() >= nTypeBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iType = 0; iType < sType.size(); iType++) + pTypeBuffer[iType] = sType[iType]; + pTypeBuffer[sType.size()] = 0; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getversion(LibMCDriver_ScanLabOIE_Driver pDriver, LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro, const LibMCDriver_ScanLabOIE_uint32 nBuildBufferSize, LibMCDriver_ScanLabOIE_uint32* pBuildNeededChars, char * pBuildBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if (!pMajor) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (!pMinor) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (!pMicro) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if ( (!pBuildBuffer) && !(pBuildNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sBuild(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pBuildBuffer == nullptr); + if (isCacheCall) { + pIDriver->GetVersion(*pMajor, *pMinor, *pMicro, sBuild); + + pIDriver->_setCache (new ParameterCache_4 (*pMajor, *pMinor, *pMicro, sBuild)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + cache->retrieveData (*pMajor, *pMinor, *pMicro, sBuild); + pIDriver->_setCache (nullptr); + } + + if (pBuildNeededChars) + *pBuildNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sBuild.size()+1); + if (pBuildBuffer) { + if (sBuild.size() >= nBuildBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iBuild = 0; iBuild < sBuild.size(); iBuild++) + pBuildBuffer[iBuild] = sBuild[iBuild]; + pBuildBuffer[sBuild.size()] = 0; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_driver_getheaderinformation(LibMCDriver_ScanLabOIE_Driver pDriver, const LibMCDriver_ScanLabOIE_uint32 nNameSpaceBufferSize, LibMCDriver_ScanLabOIE_uint32* pNameSpaceNeededChars, char * pNameSpaceBuffer, const LibMCDriver_ScanLabOIE_uint32 nBaseNameBufferSize, LibMCDriver_ScanLabOIE_uint32* pBaseNameNeededChars, char * pBaseNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pDriver; + + try { + if ( (!pNameSpaceBuffer) && !(pNameSpaceNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if ( (!pBaseNameBuffer) && !(pBaseNameNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sNameSpace(""); + std::string sBaseName(""); + IDriver* pIDriver = dynamic_cast(pIBaseClass); + if (!pIDriver) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pNameSpaceBuffer == nullptr) || (pBaseNameBuffer == nullptr); + if (isCacheCall) { + pIDriver->GetHeaderInformation(sNameSpace, sBaseName); + + pIDriver->_setCache (new ParameterCache_2 (sNameSpace, sBaseName)); + } + else { + auto cache = dynamic_cast*> (pIDriver->_getCache ()); + if (cache == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + cache->retrieveData (sNameSpace, sBaseName); + pIDriver->_setCache (nullptr); + } + + if (pNameSpaceNeededChars) + *pNameSpaceNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sNameSpace.size()+1); + if (pNameSpaceBuffer) { + if (sNameSpace.size() >= nNameSpaceBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iNameSpace = 0; iNameSpace < sNameSpace.size(); iNameSpace++) + pNameSpaceBuffer[iNameSpace] = sNameSpace[iNameSpace]; + pNameSpaceBuffer[sNameSpace.size()] = 0; + } + if (pBaseNameNeededChars) + *pBaseNameNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sBaseName.size()+1); + if (pBaseNameBuffer) { + if (sBaseName.size() >= nBaseNameBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iBaseName = 0; iBaseName < sBaseName.size(); iBaseName++) + pBaseNameBuffer[iBaseName] = sBaseName[iBaseName]; + pBaseNameBuffer[sBaseName.size()] = 0; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Driver_ScanLab_OIE +**************************************************************************************************************************/ + + +/************************************************************************************************************************* + Function table lookup implementation +**************************************************************************************************************************/ + +LibMCDriver_ScanLabOIEResult LibMCDriver_ScanLabOIE::Impl::LibMCDriver_ScanLabOIE_GetProcAddress (const char * pProcName, void ** ppProcAddress) +{ + if (pProcName == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + if (ppProcAddress == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM; + *ppProcAddress = nullptr; + std::string sProcName (pProcName); + + if (sProcName == "libmcdriver_scanlaboie_driver_getname") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_driver_getname; + if (sProcName == "libmcdriver_scanlaboie_driver_gettype") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_driver_gettype; + if (sProcName == "libmcdriver_scanlaboie_driver_getversion") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_driver_getversion; + if (sProcName == "libmcdriver_scanlaboie_driver_getheaderinformation") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_driver_getheaderinformation; + if (sProcName == "libmcdriver_scanlaboie_getversion") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_getversion; + if (sProcName == "libmcdriver_scanlaboie_getlasterror") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_getlasterror; + if (sProcName == "libmcdriver_scanlaboie_releaseinstance") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_releaseinstance; + if (sProcName == "libmcdriver_scanlaboie_acquireinstance") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_acquireinstance; + if (sProcName == "libmcdriver_scanlaboie_injectcomponent") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_injectcomponent; + if (sProcName == "libmcdriver_scanlaboie_getsymbollookupmethod") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_getsymbollookupmethod; + if (sProcName == "libmcdriver_scanlaboie_createdriver") + *ppProcAddress = (void*) &libmcdriver_scanlaboie_createdriver; + + if (*ppProcAddress == nullptr) + return LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + return LIBMCDRIVER_SCANLABOIE_SUCCESS; +} + +/************************************************************************************************************************* + Global functions implementation +**************************************************************************************************************************/ +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getversion(LibMCDriver_ScanLabOIE_uint32 * pMajor, LibMCDriver_ScanLabOIE_uint32 * pMinor, LibMCDriver_ScanLabOIE_uint32 * pMicro) +{ + IBase* pIBaseClass = nullptr; + + try { + if (!pMajor) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (!pMinor) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (!pMicro) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + CWrapper::GetVersion(*pMajor, *pMinor, *pMicro); + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getlasterror(LibMCDriver_ScanLabOIE_Base pInstance, const LibMCDriver_ScanLabOIE_uint32 nErrorMessageBufferSize, LibMCDriver_ScanLabOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError) +{ + IBase* pIBaseClass = nullptr; + + try { + if ( (!pErrorMessageBuffer) && !(pErrorMessageNeededChars) ) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (pHasError == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + std::string sErrorMessage(""); + *pHasError = CWrapper::GetLastError(pIInstance, sErrorMessage); + + if (pErrorMessageNeededChars) + *pErrorMessageNeededChars = (LibMCDriver_ScanLabOIE_uint32) (sErrorMessage.size()+1); + if (pErrorMessageBuffer) { + if (sErrorMessage.size() >= nErrorMessageBufferSize) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL); + for (size_t iErrorMessage = 0; iErrorMessage < sErrorMessage.size(); iErrorMessage++) + pErrorMessageBuffer[iErrorMessage] = sErrorMessage[iErrorMessage]; + pErrorMessageBuffer[sErrorMessage.size()] = 0; + } + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_releaseinstance(LibMCDriver_ScanLabOIE_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + CWrapper::ReleaseInstance(pIInstance); + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_acquireinstance(LibMCDriver_ScanLabOIE_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + CWrapper::AcquireInstance(pIInstance); + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_injectcomponent(const char * pNameSpace, LibMCDriver_ScanLabOIE_pvoid pSymbolAddressMethod) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pNameSpace == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sNameSpace(pNameSpace); + + bool bNameSpaceFound = false; + + if (sNameSpace == "LibMCDriverEnv") { + if (CWrapper::sPLibMCDriverEnvWrapper.get() != nullptr) { + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY); + } + CWrapper::sPLibMCDriverEnvWrapper = LibMCDriverEnv::CWrapper::loadLibraryFromSymbolLookupMethod(pSymbolAddressMethod); + bNameSpaceFound = true; + } + + if (!bNameSpaceFound) + throw ELibMCDriver_ScanLabOIEInterfaceException(LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY); + + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_getsymbollookupmethod(LibMCDriver_ScanLabOIE_pvoid * pSymbolLookupMethod) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pSymbolLookupMethod == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + *pSymbolLookupMethod = (void*)&LibMCDriver_ScanLabOIE::Impl::LibMCDriver_ScanLabOIE_GetProcAddress; + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCDriver_ScanLabOIEResult libmcdriver_scanlaboie_createdriver(const char * pName, const char * pType, LibMCDriverEnv_DriverEnvironment pDriverEnvironment, LibMCDriver_ScanLabOIE_Driver * pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pName == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (pType == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + if (pInstance == nullptr) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM); + std::string sName(pName); + std::string sType(pType); + LibMCDriverEnv::PDriverEnvironment pIDriverEnvironment = std::make_shared(CWrapper::sPLibMCDriverEnvWrapper.get(), pDriverEnvironment); + CWrapper::sPLibMCDriverEnvWrapper->AcquireInstance(pIDriverEnvironment.get()); + if (!pIDriverEnvironment) + throw ELibMCDriver_ScanLabOIEInterfaceException (LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST); + + IBase* pBaseInstance(nullptr); + pBaseInstance = CWrapper::CreateDriver(sName, sType, pIDriverEnvironment); + + *pInstance = (IBase*)(pBaseInstance); + return LIBMCDRIVER_SCANLABOIE_SUCCESS; + } + catch (ELibMCDriver_ScanLabOIEInterfaceException & Exception) { + return handleLibMCDriver_ScanLabOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + diff --git a/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_types.hpp b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_types.hpp new file mode 100644 index 00000000..a2e1c637 --- /dev/null +++ b/Drivers/ScanLabOIE/Interfaces/libmcdriver_scanlaboie_types.hpp @@ -0,0 +1,141 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of MC Driver ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP +#define __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +typedef unsigned char LibMCDriver_ScanLabOIE_uint8; +typedef unsigned short LibMCDriver_ScanLabOIE_uint16 ; +typedef unsigned int LibMCDriver_ScanLabOIE_uint32; +typedef unsigned long long LibMCDriver_ScanLabOIE_uint64; +typedef char LibMCDriver_ScanLabOIE_int8; +typedef short LibMCDriver_ScanLabOIE_int16; +typedef int LibMCDriver_ScanLabOIE_int32; +typedef long long LibMCDriver_ScanLabOIE_int64; + +#else // LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibMCDriver_ScanLabOIE_uint8; +typedef uint16_t LibMCDriver_ScanLabOIE_uint16; +typedef uint32_t LibMCDriver_ScanLabOIE_uint32; +typedef uint64_t LibMCDriver_ScanLabOIE_uint64; +typedef int8_t LibMCDriver_ScanLabOIE_int8; +typedef int16_t LibMCDriver_ScanLabOIE_int16; +typedef int32_t LibMCDriver_ScanLabOIE_int32; +typedef int64_t LibMCDriver_ScanLabOIE_int64 ; + +#endif // LIBMCDRIVER_SCANLABOIE_USELEGACYINTEGERTYPES + +typedef float LibMCDriver_ScanLabOIE_single; +typedef double LibMCDriver_ScanLabOIE_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibMCDriver_ScanLabOIE_int32 LibMCDriver_ScanLabOIEResult; +typedef void * LibMCDriver_ScanLabOIEHandle; +typedef void * LibMCDriver_ScanLabOIE_pvoid; + +/************************************************************************************************************************* + Version for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +#define LIBMCDRIVER_SCANLABOIE_VERSION_MAJOR 1 +#define LIBMCDRIVER_SCANLABOIE_VERSION_MINOR 0 +#define LIBMCDRIVER_SCANLABOIE_VERSION_MICRO 0 +#define LIBMCDRIVER_SCANLABOIE_VERSION_PRERELEASEINFO "" +#define LIBMCDRIVER_SCANLABOIE_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +#define LIBMCDRIVER_SCANLABOIE_SUCCESS 0 +#define LIBMCDRIVER_SCANLABOIE_ERROR_NOTIMPLEMENTED 1 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM 2 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST 3 +#define LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL 4 +#define LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION 5 +#define LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBMCDRIVER_SCANLABOIE_ERROR_INCOMPATIBLEBINARYVERSION 8 + +/************************************************************************************************************************* + Error strings for LibMCDriver_ScanLabOIE +**************************************************************************************************************************/ + +inline const char * LIBMCDRIVER_SCANLABOIE_GETERRORSTRING (LibMCDriver_ScanLabOIEResult nErrorCode) { + switch (nErrorCode) { + case LIBMCDRIVER_SCANLABOIE_SUCCESS: return "no error"; + case LIBMCDRIVER_SCANLABOIE_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBMCDRIVER_SCANLABOIE_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBMCDRIVER_SCANLABOIE_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBMCDRIVER_SCANLABOIE_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBMCDRIVER_SCANLABOIE_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Base; +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Driver; +typedef LibMCDriver_ScanLabOIEHandle LibMCDriver_ScanLabOIE_Driver_ScanLab_OIE; + +namespace LibMCDriver_ScanLabOIE { + +} // namespace LibMCDriver_ScanLabOIE; + +// define legacy C-names for enums, structs and function types + +#endif // __LIBMCDRIVER_SCANLABOIE_TYPES_HEADER_CPP diff --git a/Drivers/ScanLabOIE/LibOIE/CMakeLists.txt b/Drivers/ScanLabOIE/LibOIE/CMakeLists.txt new file mode 100644 index 00000000..309fd867 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/CMakeLists.txt @@ -0,0 +1,84 @@ +#[[++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +]] + + +cmake_minimum_required(VERSION 3.5) + +project(LibOIE) + +if(NOT APPLE) + find_library(LIB_OPENSSL NAMES crypto ssl) + if(LIB_OPENSSL) + add_definitions(-DBRYNET_USE_OPENSSL) + SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed -ldl -lrt -lssl -lcrypto") + elseif() + message("not found openssl") + endif() +endif() + + +if(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest") +elseif(UNIX) + if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") + endif() + SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb -Wall -Wextra -D_DEBUG") + SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -ggdb -Wall -Wextra -DNDEBUG") + if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +endif() + +file(GLOB LIBOIE_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/Implementation/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces/*.cpp +) + +add_library(liboie SHARED ${LIBOIE_SRC}) +# Do not prefix the binary's name with "lib" on Unix systems: +set_target_properties(liboie PROPERTIES PREFIX "" IMPORT_PREFIX "" ) +# The following two properties are crucial to reduce the number of undesirably exported symbols +set_target_properties(liboie PROPERTIES CXX_VISIBILITY_PRESET hidden) +set_target_properties(liboie PROPERTIES VISIBILITY_INLINES_HIDDEN ON) +# This makes sure symbols are exported +target_compile_options(liboie PRIVATE "-D__LIBOIE_EXPORTS") +target_include_directories(liboie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Implementation) +target_include_directories(liboie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Interfaces) +target_include_directories(liboie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Libraries) + +IF(WIN32) + target_link_libraries(liboie Ws2_32.lib) +ENDIF(WIN32) + diff --git a/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_abi.hpp b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_abi.hpp new file mode 100644 index 00000000..6aee6dc5 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_abi.hpp @@ -0,0 +1,576 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_HEADER_CPP +#define __LIBOIE_HEADER_CPP + +#ifdef __LIBOIE_EXPORTS +#ifdef _WIN32 +#define LIBOIE_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBOIE_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBOIE_EXPORTS +#define LIBOIE_DECLSPEC +#endif // __LIBOIE_EXPORTS + +#include "liboie_types.hpp" + + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_movenext(LibOIE_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_moveprevious(LibOIE_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_getcurrent(LibOIE_Iterator pIterator, LibOIE_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_clone(LibOIE_Iterator pIterator, LibOIE_Iterator * pOutIterator); + +/** +* Returns the number of resoucres the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_count(LibOIE_Iterator pIterator, LibOIE_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for DataPackage +**************************************************************************************************************************/ + +/** +* Returns the raw payload. +* +* @param[in] pDataPackage - DataPackage instance. +* @param[in] nPayloadBufferSize - Number of elements in buffer +* @param[out] pPayloadNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPayloadBuffer - uint8 buffer of Raw payload data. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_datapackage_getrawpayload(LibOIE_DataPackage pDataPackage, const LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer); + +/** +* Releases memory of the data package. +* +* @param[in] pDataPackage - DataPackage instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_datapackage_release(LibOIE_DataPackage pDataPackage); + +/************************************************************************************************************************* + Class definition for PyroDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for PyroDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pPyroDataPackageIterator - PyroDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_pyrodatapackageiterator_getcurrentpyrodatapackage(LibOIE_PyroDataPackageIterator pPyroDataPackageIterator, LibOIE_PyroDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for OctDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for OctDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pOctDataPackageIterator - OctDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_octdatapackageiterator_getcurrentoctdatapackage(LibOIE_OctDataPackageIterator pOctDataPackageIterator, LibOIE_OctDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for RemoteFunctionCall +**************************************************************************************************************************/ + +/** +* Returns function name +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nFunctionNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFunctionNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFunctionNameBuffer - buffer of Function Name., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_getfunctionname(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nFunctionNameBufferSize, LibOIE_uint32* pFunctionNameNeededChars, char * pFunctionNameBuffer); + +/** +* Adds a function call parameter +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] pParameter - Parameter of the call. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_addparameter(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const char * pParameter); + +/** +* Sends a remote function call over its connection. +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nResultStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pResultStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pResultStringBuffer - buffer of Returns result if successful., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_send(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nResultStringBufferSize, LibOIE_uint32* pResultStringNeededChars, char * pResultStringBuffer); + +/************************************************************************************************************************* + Class definition for Connection +**************************************************************************************************************************/ + +/** +* Disconnects and closes the connection +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_disconnect(LibOIE_Connection pConnection); + +/** +* Sets timeout value for each poll request below. +* +* @param[in] pConnection - Connection instance. +* @param[in] nTimeout - Timeout in milliseconds. Default is 1000ms. Minimum 10ms, maximum 1000000ms. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setrequesttimeout(LibOIE_Connection pConnection, LibOIE_uint32 nTimeout); + +/** +* Sets the maximum error messages that can be received before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorCount - Max Error count. Default is 1024. Minimum 16, maximum 65535. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setmaxerrorcount(LibOIE_Connection pConnection, LibOIE_uint32 nErrorCount); + +/** +* Sets the maximum memory buffer the data packets can use before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1GB. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setmaxmemorycount(LibOIE_Connection pConnection, LibOIE_uint32 nMaxMemoryCount); + +/** +* Sets a temporary filename to which the packets are buffered. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename which should be used as buffer. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1TB. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setbufferfile(LibOIE_Connection pConnection, const char * pFileName, LibOIE_uint64 nMaxMemoryCount); + +/** +* Stops writing to disk. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_unsetbufferfile(LibOIE_Connection pConnection); + +/** +* Sets check alive interval. 0ms means no check alive request is sent. +* +* @param[in] pConnection - Connection instance. +* @param[in] nCheckAliveInterval - Timeout in milliseconds. Default is 1000ms. Max value is 1000000ms. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setcheckaliveinterval(LibOIE_Connection pConnection, LibOIE_uint32 nCheckAliveInterval); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the firmware to retrieve. +* @param[in] nFirmwareVersionBufferSize - size of the buffer (including trailing 0) +* @param[out] pFirmwareVersionNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFirmwareVersionBuffer - buffer of Version of the requested firmware., may be NULL +* @param[in] nFilenameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFilenameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFilenameBuffer - buffer of Filename of the requested firmware., may be NULL +* @param[in] nFiledateBufferSize - size of the buffer (including trailing 0) +* @param[out] pFiledateNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFiledateBuffer - buffer of Timestamp of the requested firmware in ISO8601 Time., may be NULL +* @param[in] nSHA256BufferSize - size of the buffer (including trailing 0) +* @param[out] pSHA256NeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pSHA256Buffer - buffer of Checksum of the requested firmware., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_retrievefirmwareversion(LibOIE_Connection pConnection, const char * pFirmwareName, const LibOIE_uint32 nFirmwareVersionBufferSize, LibOIE_uint32* pFirmwareVersionNeededChars, char * pFirmwareVersionBuffer, const LibOIE_uint32 nFilenameBufferSize, LibOIE_uint32* pFilenameNeededChars, char * pFilenameBuffer, const LibOIE_uint32 nFiledateBufferSize, LibOIE_uint32* pFiledateNeededChars, char * pFiledateBuffer, const LibOIE_uint32 nSHA256BufferSize, LibOIE_uint32* pSHA256NeededChars, char * pSHA256Buffer); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the new firmware. +* @param[in] pFirmwareVersion - Version of the new firmware. +* @param[in] pFileName - Filename of the new firmware. +* @param[in] pFileDate - Timestamp of the requested firmware in ISO8601 Time. +* @param[in] pSHA256 - Checksum of the new firmware. +* @param[in] nBinaryDataBufferSize - Number of elements in buffer +* @param[in] pBinaryDataBuffer - uint8 buffer of Blob of new firmware. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_updatefirmware(LibOIE_Connection pConnection, const char * pFirmwareName, const char * pFirmwareVersion, const char * pFileName, const char * pFileDate, const char * pSHA256, LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer); + +/** +* Starts firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to start. +* @param[out] pSuccess - Firmware successfully started. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_startfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* Stops firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to stop. +* @param[out] pSuccess - Firmware successfully stopped. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_stopfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* sets a callback that triggers when a connection error occured. +* +* @param[in] pConnection - Connection instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setconnectionerrorcallback(LibOIE_Connection pConnection, LibOIE::ConnectionErrorCallback pCallback); + +/** +* clears the error log. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_clearerrors(LibOIE_Connection pConnection); + +/** +* Returns the list of errors in the error log. +* +* @param[in] pConnection - Connection instance. +* @param[out] pErrorCount - Errors in the error log. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_geterrorcount(LibOIE_Connection pConnection, LibOIE_uint32 * pErrorCount); + +/** +* Returns an error message of the error log +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorIndex - Index of the error. +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the error., may be NULL +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of ISO8601 Time when the error was reported., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_geterror(LibOIE_Connection pConnection, LibOIE_uint32 nErrorIndex, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, const LibOIE_uint32 nTimestampBufferSize, LibOIE_uint32* pTimestampNeededChars, char * pTimestampBuffer); + +/** +* Creates a new remote function call. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFunctionName - Function name. +* @param[out] pInstance - Function call instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_createremotefunctioncall(LibOIE_Connection pConnection, const char * pFunctionName, LibOIE_RemoteFunctionCall * pInstance); + +/** +* Retrieves currently buffered pyro packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_getbufferedpyropackages(LibOIE_Connection pConnection, LibOIE_PyroDataPackageIterator * pIterator); + +/** +* Retrieves currently buffered oct packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_getbufferedoctpackages(LibOIE_Connection pConnection, LibOIE_OctDataPackageIterator * pIterator); + +/************************************************************************************************************************* + Class definition for ConnectionIterator +**************************************************************************************************************************/ + +/** +* Returns the connection the iterator points at. +* +* @param[in] pConnectionIterator - ConnectionIterator instance. +* @param[out] pCurrentInstance - returns the connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connectioniterator_getcurrentconnection(LibOIE_ConnectionIterator pConnectionIterator, LibOIE_Connection * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Server +**************************************************************************************************************************/ + +/** +* starts listening for connections. +* +* @param[in] pServer - Server instance. +* @param[in] pIPAddress - IP Address to run on +* @param[in] nPort - Port to run on +* @param[in] bIPv6 - flag if IPv6 should be used +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_start(LibOIE_Server pServer, const char * pIPAddress, LibOIE_uint32 nPort, bool bIPv6); + +/** +* stops listening for connections and disconnects existing ones. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_stop(LibOIE_Server pServer); + +/** +* disconnects all connections but does not stop listening. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_closeallconnections(LibOIE_Server pServer); + +/** +* sets the maximum thread count to use. Must be called before Start +* +* @param[in] pServer - Server instance. +* @param[in] nThreadCount - Thread count to use (must be larger than 4, default is 32) +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setthreadcount(LibOIE_Server pServer, LibOIE_uint32 nThreadCount); + +/** +* sets the receive buffer size +* +* @param[in] pServer - Server instance. +* @param[in] nRCVBufferSize - Receive buffer size to use in bytes (must be between 4kB and 1GB, default is 1MB) +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setbuffersize(LibOIE_Server pServer, LibOIE_uint32 nRCVBufferSize); + +/** +* adds an accepted device +* +* @param[in] pServer - Server instance. +* @param[in] pDeviceName - Device name to be accepted. Empty string means all devices. +* @param[in] pApplicationName - Application name to be accepted. Empty string means all applications. +* @param[in] pVersionName - Version name to be accepted. Empty string means all versions. +* @param[out] pRuleID - Returns identifier of acceptance rule. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_acceptdevice(LibOIE_Server pServer, const char * pDeviceName, const char * pApplicationName, const char * pVersionName, LibOIE_uint32 * pRuleID); + +/** +* removes an accepted +* +* @param[in] pServer - Server instance. +* @param[in] nRuleID - identifier of acceptance rule. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_unacceptdevice(LibOIE_Server pServer, LibOIE_uint32 nRuleID); + +/** +* clears all accepted device rules +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_clearaccepteddevices(LibOIE_Server pServer); + +/** +* lists all open connections +* +* @param[in] pServer - Server instance. +* @param[out] pConnectionIteratorInstance - list of all open connections. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_listconnections(LibOIE_Server pServer, LibOIE_ConnectionIterator * pConnectionIteratorInstance); + +/** +* sets a callback that triggers when a new connection was established. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setconnectionacceptedcallback(LibOIE_Server pServer, LibOIE::ConnectionAcceptedCallback pCallback); + +/** +* sets a callback that triggers when a new connection was rejected. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setconnectionrejectedcallback(LibOIE_Server pServer, LibOIE::ConnectionRejectedCallback pCallback); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getversion(LibOIE_uint32 * pMajor, LibOIE_uint32 * pMinor, LibOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getlasterror(LibOIE_Base pInstance, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_releaseinstance(LibOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_acquireinstance(LibOIE_Base pInstance); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getsymbollookupmethod(LibOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a open interface extension server instance. +* +* @param[out] pInstance - New Server instance +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_createserver(LibOIE_Server * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBOIE_HEADER_CPP + diff --git a/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.h b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.h new file mode 100644 index 00000000..dbb0a501 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.h @@ -0,0 +1,615 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_DYNAMICHEADER_CPPTYPES +#define __LIBOIE_DYNAMICHEADER_CPPTYPES + +#include "liboie_types.hpp" + + + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEIterator_MoveNextPtr) (LibOIE_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEIterator_MovePreviousPtr) (LibOIE_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEIterator_GetCurrentPtr) (LibOIE_Iterator pIterator, LibOIE_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEIterator_ClonePtr) (LibOIE_Iterator pIterator, LibOIE_Iterator * pOutIterator); + +/** +* Returns the number of resoucres the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEIterator_CountPtr) (LibOIE_Iterator pIterator, LibOIE_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for DataPackage +**************************************************************************************************************************/ + +/** +* Returns the raw payload. +* +* @param[in] pDataPackage - DataPackage instance. +* @param[in] nPayloadBufferSize - Number of elements in buffer +* @param[out] pPayloadNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPayloadBuffer - uint8 buffer of Raw payload data. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEDataPackage_GetRawPayloadPtr) (LibOIE_DataPackage pDataPackage, const LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer); + +/** +* Releases memory of the data package. +* +* @param[in] pDataPackage - DataPackage instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEDataPackage_ReleasePtr) (LibOIE_DataPackage pDataPackage); + +/************************************************************************************************************************* + Class definition for PyroDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for PyroDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pPyroDataPackageIterator - PyroDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEPyroDataPackageIterator_GetCurrentPyroDataPackagePtr) (LibOIE_PyroDataPackageIterator pPyroDataPackageIterator, LibOIE_PyroDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for OctDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for OctDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pOctDataPackageIterator - OctDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEOctDataPackageIterator_GetCurrentOctDataPackagePtr) (LibOIE_OctDataPackageIterator pOctDataPackageIterator, LibOIE_OctDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for RemoteFunctionCall +**************************************************************************************************************************/ + +/** +* Returns function name +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nFunctionNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFunctionNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFunctionNameBuffer - buffer of Function Name., may be NULL +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIERemoteFunctionCall_GetFunctionNamePtr) (LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nFunctionNameBufferSize, LibOIE_uint32* pFunctionNameNeededChars, char * pFunctionNameBuffer); + +/** +* Adds a function call parameter +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] pParameter - Parameter of the call. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIERemoteFunctionCall_AddParameterPtr) (LibOIE_RemoteFunctionCall pRemoteFunctionCall, const char * pParameter); + +/** +* Sends a remote function call over its connection. +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nResultStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pResultStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pResultStringBuffer - buffer of Returns result if successful., may be NULL +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIERemoteFunctionCall_SendPtr) (LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nResultStringBufferSize, LibOIE_uint32* pResultStringNeededChars, char * pResultStringBuffer); + +/************************************************************************************************************************* + Class definition for Connection +**************************************************************************************************************************/ + +/** +* Disconnects and closes the connection +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_DisconnectPtr) (LibOIE_Connection pConnection); + +/** +* Sets timeout value for each poll request below. +* +* @param[in] pConnection - Connection instance. +* @param[in] nTimeout - Timeout in milliseconds. Default is 1000ms. Minimum 10ms, maximum 1000000ms. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetRequestTimeoutPtr) (LibOIE_Connection pConnection, LibOIE_uint32 nTimeout); + +/** +* Sets the maximum error messages that can be received before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorCount - Max Error count. Default is 1024. Minimum 16, maximum 65535. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetMaxErrorCountPtr) (LibOIE_Connection pConnection, LibOIE_uint32 nErrorCount); + +/** +* Sets the maximum memory buffer the data packets can use before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1GB. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetMaxMemoryCountPtr) (LibOIE_Connection pConnection, LibOIE_uint32 nMaxMemoryCount); + +/** +* Sets a temporary filename to which the packets are buffered. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename which should be used as buffer. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1TB. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetBufferFilePtr) (LibOIE_Connection pConnection, const char * pFileName, LibOIE_uint64 nMaxMemoryCount); + +/** +* Stops writing to disk. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_UnsetBufferFilePtr) (LibOIE_Connection pConnection); + +/** +* Sets check alive interval. 0ms means no check alive request is sent. +* +* @param[in] pConnection - Connection instance. +* @param[in] nCheckAliveInterval - Timeout in milliseconds. Default is 1000ms. Max value is 1000000ms. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetCheckAliveIntervalPtr) (LibOIE_Connection pConnection, LibOIE_uint32 nCheckAliveInterval); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the firmware to retrieve. +* @param[in] nFirmwareVersionBufferSize - size of the buffer (including trailing 0) +* @param[out] pFirmwareVersionNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFirmwareVersionBuffer - buffer of Version of the requested firmware., may be NULL +* @param[in] nFilenameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFilenameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFilenameBuffer - buffer of Filename of the requested firmware., may be NULL +* @param[in] nFiledateBufferSize - size of the buffer (including trailing 0) +* @param[out] pFiledateNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFiledateBuffer - buffer of Timestamp of the requested firmware in ISO8601 Time., may be NULL +* @param[in] nSHA256BufferSize - size of the buffer (including trailing 0) +* @param[out] pSHA256NeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pSHA256Buffer - buffer of Checksum of the requested firmware., may be NULL +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_RetrieveFirmwareVersionPtr) (LibOIE_Connection pConnection, const char * pFirmwareName, const LibOIE_uint32 nFirmwareVersionBufferSize, LibOIE_uint32* pFirmwareVersionNeededChars, char * pFirmwareVersionBuffer, const LibOIE_uint32 nFilenameBufferSize, LibOIE_uint32* pFilenameNeededChars, char * pFilenameBuffer, const LibOIE_uint32 nFiledateBufferSize, LibOIE_uint32* pFiledateNeededChars, char * pFiledateBuffer, const LibOIE_uint32 nSHA256BufferSize, LibOIE_uint32* pSHA256NeededChars, char * pSHA256Buffer); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the new firmware. +* @param[in] pFirmwareVersion - Version of the new firmware. +* @param[in] pFileName - Filename of the new firmware. +* @param[in] pFileDate - Timestamp of the requested firmware in ISO8601 Time. +* @param[in] pSHA256 - Checksum of the new firmware. +* @param[in] nBinaryDataBufferSize - Number of elements in buffer +* @param[in] pBinaryDataBuffer - uint8 buffer of Blob of new firmware. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_UpdateFirmwarePtr) (LibOIE_Connection pConnection, const char * pFirmwareName, const char * pFirmwareVersion, const char * pFileName, const char * pFileDate, const char * pSHA256, LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer); + +/** +* Starts firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to start. +* @param[out] pSuccess - Firmware successfully started. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_StartFirmwarePtr) (LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* Stops firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to stop. +* @param[out] pSuccess - Firmware successfully stopped. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_StopFirmwarePtr) (LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* sets a callback that triggers when a connection error occured. +* +* @param[in] pConnection - Connection instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_SetConnectionErrorCallbackPtr) (LibOIE_Connection pConnection, LibOIE::ConnectionErrorCallback pCallback); + +/** +* clears the error log. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_ClearErrorsPtr) (LibOIE_Connection pConnection); + +/** +* Returns the list of errors in the error log. +* +* @param[in] pConnection - Connection instance. +* @param[out] pErrorCount - Errors in the error log. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_GetErrorCountPtr) (LibOIE_Connection pConnection, LibOIE_uint32 * pErrorCount); + +/** +* Returns an error message of the error log +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorIndex - Index of the error. +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the error., may be NULL +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of ISO8601 Time when the error was reported., may be NULL +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_GetErrorPtr) (LibOIE_Connection pConnection, LibOIE_uint32 nErrorIndex, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, const LibOIE_uint32 nTimestampBufferSize, LibOIE_uint32* pTimestampNeededChars, char * pTimestampBuffer); + +/** +* Creates a new remote function call. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFunctionName - Function name. +* @param[out] pInstance - Function call instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_CreateRemoteFunctionCallPtr) (LibOIE_Connection pConnection, const char * pFunctionName, LibOIE_RemoteFunctionCall * pInstance); + +/** +* Retrieves currently buffered pyro packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_GetBufferedPyroPackagesPtr) (LibOIE_Connection pConnection, LibOIE_PyroDataPackageIterator * pIterator); + +/** +* Retrieves currently buffered oct packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnection_GetBufferedOctPackagesPtr) (LibOIE_Connection pConnection, LibOIE_OctDataPackageIterator * pIterator); + +/************************************************************************************************************************* + Class definition for ConnectionIterator +**************************************************************************************************************************/ + +/** +* Returns the connection the iterator points at. +* +* @param[in] pConnectionIterator - ConnectionIterator instance. +* @param[out] pCurrentInstance - returns the connection instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEConnectionIterator_GetCurrentConnectionPtr) (LibOIE_ConnectionIterator pConnectionIterator, LibOIE_Connection * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Server +**************************************************************************************************************************/ + +/** +* starts listening for connections. +* +* @param[in] pServer - Server instance. +* @param[in] pIPAddress - IP Address to run on +* @param[in] nPort - Port to run on +* @param[in] bIPv6 - flag if IPv6 should be used +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_StartPtr) (LibOIE_Server pServer, const char * pIPAddress, LibOIE_uint32 nPort, bool bIPv6); + +/** +* stops listening for connections and disconnects existing ones. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_StopPtr) (LibOIE_Server pServer); + +/** +* disconnects all connections but does not stop listening. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_CloseAllConnectionsPtr) (LibOIE_Server pServer); + +/** +* sets the maximum thread count to use. Must be called before Start +* +* @param[in] pServer - Server instance. +* @param[in] nThreadCount - Thread count to use (must be larger than 4, default is 32) +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_SetThreadCountPtr) (LibOIE_Server pServer, LibOIE_uint32 nThreadCount); + +/** +* sets the receive buffer size +* +* @param[in] pServer - Server instance. +* @param[in] nRCVBufferSize - Receive buffer size to use in bytes (must be between 4kB and 1GB, default is 1MB) +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_SetBufferSizePtr) (LibOIE_Server pServer, LibOIE_uint32 nRCVBufferSize); + +/** +* adds an accepted device +* +* @param[in] pServer - Server instance. +* @param[in] pDeviceName - Device name to be accepted. Empty string means all devices. +* @param[in] pApplicationName - Application name to be accepted. Empty string means all applications. +* @param[in] pVersionName - Version name to be accepted. Empty string means all versions. +* @param[out] pRuleID - Returns identifier of acceptance rule. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_AcceptDevicePtr) (LibOIE_Server pServer, const char * pDeviceName, const char * pApplicationName, const char * pVersionName, LibOIE_uint32 * pRuleID); + +/** +* removes an accepted +* +* @param[in] pServer - Server instance. +* @param[in] nRuleID - identifier of acceptance rule. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_UnAcceptDevicePtr) (LibOIE_Server pServer, LibOIE_uint32 nRuleID); + +/** +* clears all accepted device rules +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_ClearAcceptedDevicesPtr) (LibOIE_Server pServer); + +/** +* lists all open connections +* +* @param[in] pServer - Server instance. +* @param[out] pConnectionIteratorInstance - list of all open connections. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_ListConnectionsPtr) (LibOIE_Server pServer, LibOIE_ConnectionIterator * pConnectionIteratorInstance); + +/** +* sets a callback that triggers when a new connection was established. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_SetConnectionAcceptedCallbackPtr) (LibOIE_Server pServer, LibOIE::ConnectionAcceptedCallback pCallback); + +/** +* sets a callback that triggers when a new connection was rejected. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEServer_SetConnectionRejectedCallbackPtr) (LibOIE_Server pServer, LibOIE::ConnectionRejectedCallback pCallback); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEGetVersionPtr) (LibOIE_uint32 * pMajor, LibOIE_uint32 * pMinor, LibOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEGetLastErrorPtr) (LibOIE_Base pInstance, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEReleaseInstancePtr) (LibOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEAcquireInstancePtr) (LibOIE_Base pInstance); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIEGetSymbolLookupMethodPtr) (LibOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a open interface extension server instance. +* +* @param[out] pInstance - New Server instance +* @return error code or 0 (success) +*/ +typedef LibOIEResult (*PLibOIECreateServerPtr) (LibOIE_Server * pInstance); + +/************************************************************************************************************************* + Function Table Structure +**************************************************************************************************************************/ + +typedef struct { + void * m_LibraryHandle; + PLibOIEIterator_MoveNextPtr m_Iterator_MoveNext; + PLibOIEIterator_MovePreviousPtr m_Iterator_MovePrevious; + PLibOIEIterator_GetCurrentPtr m_Iterator_GetCurrent; + PLibOIEIterator_ClonePtr m_Iterator_Clone; + PLibOIEIterator_CountPtr m_Iterator_Count; + PLibOIEDataPackage_GetRawPayloadPtr m_DataPackage_GetRawPayload; + PLibOIEDataPackage_ReleasePtr m_DataPackage_Release; + PLibOIEPyroDataPackageIterator_GetCurrentPyroDataPackagePtr m_PyroDataPackageIterator_GetCurrentPyroDataPackage; + PLibOIEOctDataPackageIterator_GetCurrentOctDataPackagePtr m_OctDataPackageIterator_GetCurrentOctDataPackage; + PLibOIERemoteFunctionCall_GetFunctionNamePtr m_RemoteFunctionCall_GetFunctionName; + PLibOIERemoteFunctionCall_AddParameterPtr m_RemoteFunctionCall_AddParameter; + PLibOIERemoteFunctionCall_SendPtr m_RemoteFunctionCall_Send; + PLibOIEConnection_DisconnectPtr m_Connection_Disconnect; + PLibOIEConnection_SetRequestTimeoutPtr m_Connection_SetRequestTimeout; + PLibOIEConnection_SetMaxErrorCountPtr m_Connection_SetMaxErrorCount; + PLibOIEConnection_SetMaxMemoryCountPtr m_Connection_SetMaxMemoryCount; + PLibOIEConnection_SetBufferFilePtr m_Connection_SetBufferFile; + PLibOIEConnection_UnsetBufferFilePtr m_Connection_UnsetBufferFile; + PLibOIEConnection_SetCheckAliveIntervalPtr m_Connection_SetCheckAliveInterval; + PLibOIEConnection_RetrieveFirmwareVersionPtr m_Connection_RetrieveFirmwareVersion; + PLibOIEConnection_UpdateFirmwarePtr m_Connection_UpdateFirmware; + PLibOIEConnection_StartFirmwarePtr m_Connection_StartFirmware; + PLibOIEConnection_StopFirmwarePtr m_Connection_StopFirmware; + PLibOIEConnection_SetConnectionErrorCallbackPtr m_Connection_SetConnectionErrorCallback; + PLibOIEConnection_ClearErrorsPtr m_Connection_ClearErrors; + PLibOIEConnection_GetErrorCountPtr m_Connection_GetErrorCount; + PLibOIEConnection_GetErrorPtr m_Connection_GetError; + PLibOIEConnection_CreateRemoteFunctionCallPtr m_Connection_CreateRemoteFunctionCall; + PLibOIEConnection_GetBufferedPyroPackagesPtr m_Connection_GetBufferedPyroPackages; + PLibOIEConnection_GetBufferedOctPackagesPtr m_Connection_GetBufferedOctPackages; + PLibOIEConnectionIterator_GetCurrentConnectionPtr m_ConnectionIterator_GetCurrentConnection; + PLibOIEServer_StartPtr m_Server_Start; + PLibOIEServer_StopPtr m_Server_Stop; + PLibOIEServer_CloseAllConnectionsPtr m_Server_CloseAllConnections; + PLibOIEServer_SetThreadCountPtr m_Server_SetThreadCount; + PLibOIEServer_SetBufferSizePtr m_Server_SetBufferSize; + PLibOIEServer_AcceptDevicePtr m_Server_AcceptDevice; + PLibOIEServer_UnAcceptDevicePtr m_Server_UnAcceptDevice; + PLibOIEServer_ClearAcceptedDevicesPtr m_Server_ClearAcceptedDevices; + PLibOIEServer_ListConnectionsPtr m_Server_ListConnections; + PLibOIEServer_SetConnectionAcceptedCallbackPtr m_Server_SetConnectionAcceptedCallback; + PLibOIEServer_SetConnectionRejectedCallbackPtr m_Server_SetConnectionRejectedCallback; + PLibOIEGetVersionPtr m_GetVersion; + PLibOIEGetLastErrorPtr m_GetLastError; + PLibOIEReleaseInstancePtr m_ReleaseInstance; + PLibOIEAcquireInstancePtr m_AcquireInstance; + PLibOIEGetSymbolLookupMethodPtr m_GetSymbolLookupMethod; + PLibOIECreateServerPtr m_CreateServer; +} sLibOIEDynamicWrapperTable; + +#endif // __LIBOIE_DYNAMICHEADER_CPPTYPES + diff --git a/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.hpp b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.hpp new file mode 100644 index 00000000..725e194f --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_dynamic.hpp @@ -0,0 +1,1958 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_CPPHEADER_DYNAMIC_CPP +#define __LIBOIE_CPPHEADER_DYNAMIC_CPP + +#include "liboie_types.hpp" +#include "liboie_dynamic.h" + + +#ifdef _WIN32 +#include +#else // _WIN32 +#include +#endif // _WIN32 +#include +#include +#include +#include + +namespace LibOIE { + +/************************************************************************************************************************* + Forward Declaration of all classes +**************************************************************************************************************************/ +class CWrapper; +class CBase; +class CIterator; +class CDataPackage; +class CPyroDataPackage; +class CPyroDataPackageIterator; +class COctDataPackage; +class COctDataPackageIterator; +class CRemoteFunctionCall; +class CConnection; +class CConnectionIterator; +class CServer; + +/************************************************************************************************************************* + Declaration of deprecated class types +**************************************************************************************************************************/ +typedef CWrapper CLibOIEWrapper; +typedef CBase CLibOIEBase; +typedef CIterator CLibOIEIterator; +typedef CDataPackage CLibOIEDataPackage; +typedef CPyroDataPackage CLibOIEPyroDataPackage; +typedef CPyroDataPackageIterator CLibOIEPyroDataPackageIterator; +typedef COctDataPackage CLibOIEOctDataPackage; +typedef COctDataPackageIterator CLibOIEOctDataPackageIterator; +typedef CRemoteFunctionCall CLibOIERemoteFunctionCall; +typedef CConnection CLibOIEConnection; +typedef CConnectionIterator CLibOIEConnectionIterator; +typedef CServer CLibOIEServer; + +/************************************************************************************************************************* + Declaration of shared pointer types +**************************************************************************************************************************/ +typedef std::shared_ptr PWrapper; +typedef std::shared_ptr PBase; +typedef std::shared_ptr PIterator; +typedef std::shared_ptr PDataPackage; +typedef std::shared_ptr PPyroDataPackage; +typedef std::shared_ptr PPyroDataPackageIterator; +typedef std::shared_ptr POctDataPackage; +typedef std::shared_ptr POctDataPackageIterator; +typedef std::shared_ptr PRemoteFunctionCall; +typedef std::shared_ptr PConnection; +typedef std::shared_ptr PConnectionIterator; +typedef std::shared_ptr PServer; + +/************************************************************************************************************************* + Declaration of deprecated shared pointer types +**************************************************************************************************************************/ +typedef PWrapper PLibOIEWrapper; +typedef PBase PLibOIEBase; +typedef PIterator PLibOIEIterator; +typedef PDataPackage PLibOIEDataPackage; +typedef PPyroDataPackage PLibOIEPyroDataPackage; +typedef PPyroDataPackageIterator PLibOIEPyroDataPackageIterator; +typedef POctDataPackage PLibOIEOctDataPackage; +typedef POctDataPackageIterator PLibOIEOctDataPackageIterator; +typedef PRemoteFunctionCall PLibOIERemoteFunctionCall; +typedef PConnection PLibOIEConnection; +typedef PConnectionIterator PLibOIEConnectionIterator; +typedef PServer PLibOIEServer; + + +/************************************************************************************************************************* + classParam Definition +**************************************************************************************************************************/ + +template class classParam { +private: + const T* m_ptr; + +public: + classParam(const T* ptr) + : m_ptr (ptr) + { + } + + classParam(std::shared_ptr sharedPtr) + : m_ptr (sharedPtr.get()) + { + } + + LibOIEHandle GetHandle() + { + if (m_ptr != nullptr) + return m_ptr->handle(); + return nullptr; + } +}; + +/************************************************************************************************************************* + Class ELibOIEException +**************************************************************************************************************************/ +class ELibOIEException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibOIEResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibOIEException(LibOIEResult errorCode, const std::string & sErrorMessage) + : m_errorMessage("LibOIE Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") + { + m_errorCode = errorCode; + } + + /** + * Returns error code + */ + LibOIEResult getErrorCode() const noexcept + { + return m_errorCode; + } + + /** + * Returns error message + */ + const char* what() const noexcept + { + return m_errorMessage.c_str(); + } + +}; + +/************************************************************************************************************************* + Class CInputVector +**************************************************************************************************************************/ +template +class CInputVector { +private: + + const T* m_data; + size_t m_size; + +public: + + CInputVector( const std::vector& vec) + : m_data( vec.data() ), m_size( vec.size() ) + { + } + + CInputVector( const T* in_data, size_t in_size) + : m_data( in_data ), m_size(in_size ) + { + } + + const T* data() const + { + return m_data; + } + + size_t size() const + { + return m_size; + } + +}; + +// declare deprecated class name +template +using CLibOIEInputVector = CInputVector; + +/************************************************************************************************************************* + Class CWrapper +**************************************************************************************************************************/ +class CWrapper { +public: + + CWrapper(void* pSymbolLookupMethod) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod)); + + CheckError(nullptr, checkBinaryVersion()); + } + + CWrapper(const std::string &sFileName) + { + CheckError(nullptr, initWrapperTable(&m_WrapperTable)); + CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str())); + + CheckError(nullptr, checkBinaryVersion()); + } + + static PWrapper loadLibrary(const std::string &sFileName) + { + return std::make_shared(sFileName); + } + + static PWrapper loadLibraryFromSymbolLookupMethod(void* pSymbolLookupMethod) + { + return std::make_shared(pSymbolLookupMethod); + } + + ~CWrapper() + { + releaseWrapperTable(&m_WrapperTable); + } + + inline void CheckError(CBase * pBaseClass, LibOIEResult nResult); + + inline void GetVersion(LibOIE_uint32 & nMajor, LibOIE_uint32 & nMinor, LibOIE_uint32 & nMicro); + inline bool GetLastError(classParam pInstance, std::string & sErrorMessage); + inline void ReleaseInstance(classParam pInstance); + inline void AcquireInstance(classParam pInstance); + inline LibOIE_pvoid GetSymbolLookupMethod(); + inline PServer CreateServer(); + +private: + sLibOIEDynamicWrapperTable m_WrapperTable; + + LibOIEResult checkBinaryVersion() + { + LibOIE_uint32 nMajor, nMinor, nMicro; + GetVersion(nMajor, nMinor, nMicro); + if ( (nMajor != LIBOIE_VERSION_MAJOR) || (nMinor < LIBOIE_VERSION_MINOR) ) { + return LIBOIE_ERROR_INCOMPATIBLEBINARYVERSION; + } + return LIBOIE_SUCCESS; + } + LibOIEResult initWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable); + LibOIEResult releaseWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable); + LibOIEResult loadWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName); + LibOIEResult loadWrapperTableFromSymbolLookupMethod(sLibOIEDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod); + + friend class CBase; + friend class CIterator; + friend class CDataPackage; + friend class CPyroDataPackage; + friend class CPyroDataPackageIterator; + friend class COctDataPackage; + friend class COctDataPackageIterator; + friend class CRemoteFunctionCall; + friend class CConnection; + friend class CConnectionIterator; + friend class CServer; + +}; + + +/************************************************************************************************************************* + Class CBase +**************************************************************************************************************************/ +class CBase { +public: + +protected: + /* Wrapper Object that created the class. */ + CWrapper * m_pWrapper; + /* Handle to Instance in library*/ + LibOIEHandle m_pHandle; + + /* Checks for an Error code and raises Exceptions */ + void CheckError(LibOIEResult nResult) + { + if (m_pWrapper != nullptr) + m_pWrapper->CheckError(this, nResult); + } +public: + /** + * CBase::CBase - Constructor for Base class. + */ + CBase(CWrapper * pWrapper, LibOIEHandle pHandle) + : m_pWrapper(pWrapper), m_pHandle(pHandle) + { + } + + /** + * CBase::~CBase - Destructor for Base class. + */ + virtual ~CBase() + { + if (m_pWrapper != nullptr) + m_pWrapper->ReleaseInstance(this); + m_pWrapper = nullptr; + } + + /** + * CBase::handle - Returns handle to instance. + */ + LibOIEHandle handle() const + { + return m_pHandle; + } + + /** + * CBase::wrapper - Returns wrapper instance. + */ + CWrapper * wrapper() const + { + return m_pWrapper; + } + + friend class CWrapper; +}; + +/************************************************************************************************************************* + Class CIterator +**************************************************************************************************************************/ +class CIterator : public CBase { +public: + + /** + * CIterator::CIterator - Constructor for Iterator class. + */ + CIterator(CWrapper* pWrapper, LibOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline bool MoveNext(); + inline bool MovePrevious(); + inline PBase GetCurrent(); + inline PIterator Clone(); + inline LibOIE_uint64 Count(); +}; + +/************************************************************************************************************************* + Class CDataPackage +**************************************************************************************************************************/ +class CDataPackage : public CBase { +public: + + /** + * CDataPackage::CDataPackage - Constructor for DataPackage class. + */ + CDataPackage(CWrapper* pWrapper, LibOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void GetRawPayload(std::vector & PayloadBuffer); + inline void Release(); +}; + +/************************************************************************************************************************* + Class CPyroDataPackage +**************************************************************************************************************************/ +class CPyroDataPackage : public CDataPackage { +public: + + /** + * CPyroDataPackage::CPyroDataPackage - Constructor for PyroDataPackage class. + */ + CPyroDataPackage(CWrapper* pWrapper, LibOIEHandle pHandle) + : CDataPackage(pWrapper, pHandle) + { + } + +}; + +/************************************************************************************************************************* + Class CPyroDataPackageIterator +**************************************************************************************************************************/ +class CPyroDataPackageIterator : public CIterator { +public: + + /** + * CPyroDataPackageIterator::CPyroDataPackageIterator - Constructor for PyroDataPackageIterator class. + */ + CPyroDataPackageIterator(CWrapper* pWrapper, LibOIEHandle pHandle) + : CIterator(pWrapper, pHandle) + { + } + + inline PPyroDataPackage GetCurrentPyroDataPackage(); +}; + +/************************************************************************************************************************* + Class COctDataPackage +**************************************************************************************************************************/ +class COctDataPackage : public CDataPackage { +public: + + /** + * COctDataPackage::COctDataPackage - Constructor for OctDataPackage class. + */ + COctDataPackage(CWrapper* pWrapper, LibOIEHandle pHandle) + : CDataPackage(pWrapper, pHandle) + { + } + +}; + +/************************************************************************************************************************* + Class COctDataPackageIterator +**************************************************************************************************************************/ +class COctDataPackageIterator : public CIterator { +public: + + /** + * COctDataPackageIterator::COctDataPackageIterator - Constructor for OctDataPackageIterator class. + */ + COctDataPackageIterator(CWrapper* pWrapper, LibOIEHandle pHandle) + : CIterator(pWrapper, pHandle) + { + } + + inline POctDataPackage GetCurrentOctDataPackage(); +}; + +/************************************************************************************************************************* + Class CRemoteFunctionCall +**************************************************************************************************************************/ +class CRemoteFunctionCall : public CBase { +public: + + /** + * CRemoteFunctionCall::CRemoteFunctionCall - Constructor for RemoteFunctionCall class. + */ + CRemoteFunctionCall(CWrapper* pWrapper, LibOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline std::string GetFunctionName(); + inline void AddParameter(const std::string & sParameter); + inline std::string Send(); +}; + +/************************************************************************************************************************* + Class CConnection +**************************************************************************************************************************/ +class CConnection : public CBase { +public: + + /** + * CConnection::CConnection - Constructor for Connection class. + */ + CConnection(CWrapper* pWrapper, LibOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void Disconnect(); + inline void SetRequestTimeout(const LibOIE_uint32 nTimeout); + inline void SetMaxErrorCount(const LibOIE_uint32 nErrorCount); + inline void SetMaxMemoryCount(const LibOIE_uint32 nMaxMemoryCount); + inline void SetBufferFile(const std::string & sFileName, const LibOIE_uint64 nMaxMemoryCount); + inline void UnsetBufferFile(); + inline void SetCheckAliveInterval(const LibOIE_uint32 nCheckAliveInterval); + inline void RetrieveFirmwareVersion(const std::string & sFirmwareName, std::string & sFirmwareVersion, std::string & sFilename, std::string & sFiledate, std::string & sSHA256); + inline void UpdateFirmware(const std::string & sFirmwareName, const std::string & sFirmwareVersion, const std::string & sFileName, const std::string & sFileDate, const std::string & sSHA256, const CInputVector & BinaryDataBuffer); + inline bool StartFirmware(const std::string & sFileName); + inline bool StopFirmware(const std::string & sFileName); + inline void SetConnectionErrorCallback(const ConnectionErrorCallback pCallback); + inline void ClearErrors(); + inline LibOIE_uint32 GetErrorCount(); + inline void GetError(const LibOIE_uint32 nErrorIndex, std::string & sErrorMessage, std::string & sTimestamp); + inline PRemoteFunctionCall CreateRemoteFunctionCall(const std::string & sFunctionName); + inline PPyroDataPackageIterator GetBufferedPyroPackages(); + inline POctDataPackageIterator GetBufferedOctPackages(); +}; + +/************************************************************************************************************************* + Class CConnectionIterator +**************************************************************************************************************************/ +class CConnectionIterator : public CIterator { +public: + + /** + * CConnectionIterator::CConnectionIterator - Constructor for ConnectionIterator class. + */ + CConnectionIterator(CWrapper* pWrapper, LibOIEHandle pHandle) + : CIterator(pWrapper, pHandle) + { + } + + inline PConnection GetCurrentConnection(); +}; + +/************************************************************************************************************************* + Class CServer +**************************************************************************************************************************/ +class CServer : public CBase { +public: + + /** + * CServer::CServer - Constructor for Server class. + */ + CServer(CWrapper* pWrapper, LibOIEHandle pHandle) + : CBase(pWrapper, pHandle) + { + } + + inline void Start(const std::string & sIPAddress, const LibOIE_uint32 nPort, const bool bIPv6); + inline void Stop(); + inline void CloseAllConnections(); + inline void SetThreadCount(const LibOIE_uint32 nThreadCount); + inline void SetBufferSize(const LibOIE_uint32 nRCVBufferSize); + inline LibOIE_uint32 AcceptDevice(const std::string & sDeviceName, const std::string & sApplicationName, const std::string & sVersionName); + inline void UnAcceptDevice(const LibOIE_uint32 nRuleID); + inline void ClearAcceptedDevices(); + inline PConnectionIterator ListConnections(); + inline void SetConnectionAcceptedCallback(const ConnectionAcceptedCallback pCallback); + inline void SetConnectionRejectedCallback(const ConnectionRejectedCallback pCallback); +}; + + /** + * CWrapper::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + inline void CWrapper::GetVersion(LibOIE_uint32 & nMajor, LibOIE_uint32 & nMinor, LibOIE_uint32 & nMicro) + { + CheckError(nullptr,m_WrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro)); + } + + /** + * CWrapper::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + inline bool CWrapper::GetLastError(classParam pInstance, std::string & sErrorMessage) + { + LibOIEHandle hInstance = pInstance.GetHandle(); + LibOIE_uint32 bytesNeededErrorMessage = 0; + LibOIE_uint32 bytesWrittenErrorMessage = 0; + bool resultHasError = 0; + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, 0, &bytesNeededErrorMessage, nullptr, &resultHasError)); + std::vector bufferErrorMessage(bytesNeededErrorMessage); + CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], &resultHasError)); + sErrorMessage = std::string(&bufferErrorMessage[0]); + + return resultHasError; + } + + /** + * CWrapper::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::ReleaseInstance(classParam pInstance) + { + LibOIEHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_ReleaseInstance(hInstance)); + } + + /** + * CWrapper::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + inline void CWrapper::AcquireInstance(classParam pInstance) + { + LibOIEHandle hInstance = pInstance.GetHandle(); + CheckError(nullptr,m_WrapperTable.m_AcquireInstance(hInstance)); + } + + /** + * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod + * @return Address of the SymbolAddressMethod + */ + inline LibOIE_pvoid CWrapper::GetSymbolLookupMethod() + { + LibOIE_pvoid resultSymbolLookupMethod = 0; + CheckError(nullptr,m_WrapperTable.m_GetSymbolLookupMethod(&resultSymbolLookupMethod)); + + return resultSymbolLookupMethod; + } + + /** + * CWrapper::CreateServer - Creates a open interface extension server instance. + * @return New Server instance + */ + inline PServer CWrapper::CreateServer() + { + LibOIEHandle hInstance = nullptr; + CheckError(nullptr,m_WrapperTable.m_CreateServer(&hInstance)); + + if (!hInstance) { + CheckError(nullptr,LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(this, hInstance); + } + + inline void CWrapper::CheckError(CBase * pBaseClass, LibOIEResult nResult) + { + if (nResult != 0) { + std::string sErrorMessage; + if (pBaseClass != nullptr) { + GetLastError(pBaseClass, sErrorMessage); + } + throw ELibOIEException(nResult, sErrorMessage); + } + } + + + inline LibOIEResult CWrapper::initWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + + pWrapperTable->m_LibraryHandle = nullptr; + pWrapperTable->m_Iterator_MoveNext = nullptr; + pWrapperTable->m_Iterator_MovePrevious = nullptr; + pWrapperTable->m_Iterator_GetCurrent = nullptr; + pWrapperTable->m_Iterator_Clone = nullptr; + pWrapperTable->m_Iterator_Count = nullptr; + pWrapperTable->m_DataPackage_GetRawPayload = nullptr; + pWrapperTable->m_DataPackage_Release = nullptr; + pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage = nullptr; + pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage = nullptr; + pWrapperTable->m_RemoteFunctionCall_GetFunctionName = nullptr; + pWrapperTable->m_RemoteFunctionCall_AddParameter = nullptr; + pWrapperTable->m_RemoteFunctionCall_Send = nullptr; + pWrapperTable->m_Connection_Disconnect = nullptr; + pWrapperTable->m_Connection_SetRequestTimeout = nullptr; + pWrapperTable->m_Connection_SetMaxErrorCount = nullptr; + pWrapperTable->m_Connection_SetMaxMemoryCount = nullptr; + pWrapperTable->m_Connection_SetBufferFile = nullptr; + pWrapperTable->m_Connection_UnsetBufferFile = nullptr; + pWrapperTable->m_Connection_SetCheckAliveInterval = nullptr; + pWrapperTable->m_Connection_RetrieveFirmwareVersion = nullptr; + pWrapperTable->m_Connection_UpdateFirmware = nullptr; + pWrapperTable->m_Connection_StartFirmware = nullptr; + pWrapperTable->m_Connection_StopFirmware = nullptr; + pWrapperTable->m_Connection_SetConnectionErrorCallback = nullptr; + pWrapperTable->m_Connection_ClearErrors = nullptr; + pWrapperTable->m_Connection_GetErrorCount = nullptr; + pWrapperTable->m_Connection_GetError = nullptr; + pWrapperTable->m_Connection_CreateRemoteFunctionCall = nullptr; + pWrapperTable->m_Connection_GetBufferedPyroPackages = nullptr; + pWrapperTable->m_Connection_GetBufferedOctPackages = nullptr; + pWrapperTable->m_ConnectionIterator_GetCurrentConnection = nullptr; + pWrapperTable->m_Server_Start = nullptr; + pWrapperTable->m_Server_Stop = nullptr; + pWrapperTable->m_Server_CloseAllConnections = nullptr; + pWrapperTable->m_Server_SetThreadCount = nullptr; + pWrapperTable->m_Server_SetBufferSize = nullptr; + pWrapperTable->m_Server_AcceptDevice = nullptr; + pWrapperTable->m_Server_UnAcceptDevice = nullptr; + pWrapperTable->m_Server_ClearAcceptedDevices = nullptr; + pWrapperTable->m_Server_ListConnections = nullptr; + pWrapperTable->m_Server_SetConnectionAcceptedCallback = nullptr; + pWrapperTable->m_Server_SetConnectionRejectedCallback = nullptr; + pWrapperTable->m_GetVersion = nullptr; + pWrapperTable->m_GetLastError = nullptr; + pWrapperTable->m_ReleaseInstance = nullptr; + pWrapperTable->m_AcquireInstance = nullptr; + pWrapperTable->m_GetSymbolLookupMethod = nullptr; + pWrapperTable->m_CreateServer = nullptr; + + return LIBOIE_SUCCESS; + } + + inline LibOIEResult CWrapper::releaseWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable) + { + if (pWrapperTable == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + + if (pWrapperTable->m_LibraryHandle != nullptr) { + #ifdef _WIN32 + HMODULE hModule = (HMODULE) pWrapperTable->m_LibraryHandle; + FreeLibrary(hModule); + #else // _WIN32 + dlclose(pWrapperTable->m_LibraryHandle); + #endif // _WIN32 + return initWrapperTable(pWrapperTable); + } + + return LIBOIE_SUCCESS; + } + + inline LibOIEResult CWrapper::loadWrapperTable(sLibOIEDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName) + { + if (pWrapperTable == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + if (pLibraryFileName == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + + #ifdef _WIN32 + // Convert filename to UTF16-string + int nLength = (int)strlen(pLibraryFileName); + int nBufferSize = nLength * 2 + 2; + std::vector wsLibraryFileName(nBufferSize); + int nResult = MultiByteToWideChar(CP_UTF8, 0, pLibraryFileName, nLength, &wsLibraryFileName[0], nBufferSize); + if (nResult == 0) + return LIBOIE_ERROR_COULDNOTLOADLIBRARY; + + HMODULE hLibrary = LoadLibraryW(wsLibraryFileName.data()); + if (hLibrary == 0) + return LIBOIE_ERROR_COULDNOTLOADLIBRARY; + #else // _WIN32 + void* hLibrary = dlopen(pLibraryFileName, RTLD_LAZY); + if (hLibrary == 0) + return LIBOIE_ERROR_COULDNOTLOADLIBRARY; + dlerror(); + #endif // _WIN32 + + #ifdef _WIN32 + pWrapperTable->m_Iterator_MoveNext = (PLibOIEIterator_MoveNextPtr) GetProcAddress(hLibrary, "liboie_iterator_movenext"); + #else // _WIN32 + pWrapperTable->m_Iterator_MoveNext = (PLibOIEIterator_MoveNextPtr) dlsym(hLibrary, "liboie_iterator_movenext"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_MoveNext == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_MovePrevious = (PLibOIEIterator_MovePreviousPtr) GetProcAddress(hLibrary, "liboie_iterator_moveprevious"); + #else // _WIN32 + pWrapperTable->m_Iterator_MovePrevious = (PLibOIEIterator_MovePreviousPtr) dlsym(hLibrary, "liboie_iterator_moveprevious"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_MovePrevious == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_GetCurrent = (PLibOIEIterator_GetCurrentPtr) GetProcAddress(hLibrary, "liboie_iterator_getcurrent"); + #else // _WIN32 + pWrapperTable->m_Iterator_GetCurrent = (PLibOIEIterator_GetCurrentPtr) dlsym(hLibrary, "liboie_iterator_getcurrent"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_GetCurrent == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_Clone = (PLibOIEIterator_ClonePtr) GetProcAddress(hLibrary, "liboie_iterator_clone"); + #else // _WIN32 + pWrapperTable->m_Iterator_Clone = (PLibOIEIterator_ClonePtr) dlsym(hLibrary, "liboie_iterator_clone"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_Clone == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Iterator_Count = (PLibOIEIterator_CountPtr) GetProcAddress(hLibrary, "liboie_iterator_count"); + #else // _WIN32 + pWrapperTable->m_Iterator_Count = (PLibOIEIterator_CountPtr) dlsym(hLibrary, "liboie_iterator_count"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Iterator_Count == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_DataPackage_GetRawPayload = (PLibOIEDataPackage_GetRawPayloadPtr) GetProcAddress(hLibrary, "liboie_datapackage_getrawpayload"); + #else // _WIN32 + pWrapperTable->m_DataPackage_GetRawPayload = (PLibOIEDataPackage_GetRawPayloadPtr) dlsym(hLibrary, "liboie_datapackage_getrawpayload"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_DataPackage_GetRawPayload == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_DataPackage_Release = (PLibOIEDataPackage_ReleasePtr) GetProcAddress(hLibrary, "liboie_datapackage_release"); + #else // _WIN32 + pWrapperTable->m_DataPackage_Release = (PLibOIEDataPackage_ReleasePtr) dlsym(hLibrary, "liboie_datapackage_release"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_DataPackage_Release == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage = (PLibOIEPyroDataPackageIterator_GetCurrentPyroDataPackagePtr) GetProcAddress(hLibrary, "liboie_pyrodatapackageiterator_getcurrentpyrodatapackage"); + #else // _WIN32 + pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage = (PLibOIEPyroDataPackageIterator_GetCurrentPyroDataPackagePtr) dlsym(hLibrary, "liboie_pyrodatapackageiterator_getcurrentpyrodatapackage"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage = (PLibOIEOctDataPackageIterator_GetCurrentOctDataPackagePtr) GetProcAddress(hLibrary, "liboie_octdatapackageiterator_getcurrentoctdatapackage"); + #else // _WIN32 + pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage = (PLibOIEOctDataPackageIterator_GetCurrentOctDataPackagePtr) dlsym(hLibrary, "liboie_octdatapackageiterator_getcurrentoctdatapackage"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_RemoteFunctionCall_GetFunctionName = (PLibOIERemoteFunctionCall_GetFunctionNamePtr) GetProcAddress(hLibrary, "liboie_remotefunctioncall_getfunctionname"); + #else // _WIN32 + pWrapperTable->m_RemoteFunctionCall_GetFunctionName = (PLibOIERemoteFunctionCall_GetFunctionNamePtr) dlsym(hLibrary, "liboie_remotefunctioncall_getfunctionname"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_RemoteFunctionCall_GetFunctionName == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_RemoteFunctionCall_AddParameter = (PLibOIERemoteFunctionCall_AddParameterPtr) GetProcAddress(hLibrary, "liboie_remotefunctioncall_addparameter"); + #else // _WIN32 + pWrapperTable->m_RemoteFunctionCall_AddParameter = (PLibOIERemoteFunctionCall_AddParameterPtr) dlsym(hLibrary, "liboie_remotefunctioncall_addparameter"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_RemoteFunctionCall_AddParameter == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_RemoteFunctionCall_Send = (PLibOIERemoteFunctionCall_SendPtr) GetProcAddress(hLibrary, "liboie_remotefunctioncall_send"); + #else // _WIN32 + pWrapperTable->m_RemoteFunctionCall_Send = (PLibOIERemoteFunctionCall_SendPtr) dlsym(hLibrary, "liboie_remotefunctioncall_send"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_RemoteFunctionCall_Send == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_Disconnect = (PLibOIEConnection_DisconnectPtr) GetProcAddress(hLibrary, "liboie_connection_disconnect"); + #else // _WIN32 + pWrapperTable->m_Connection_Disconnect = (PLibOIEConnection_DisconnectPtr) dlsym(hLibrary, "liboie_connection_disconnect"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_Disconnect == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetRequestTimeout = (PLibOIEConnection_SetRequestTimeoutPtr) GetProcAddress(hLibrary, "liboie_connection_setrequesttimeout"); + #else // _WIN32 + pWrapperTable->m_Connection_SetRequestTimeout = (PLibOIEConnection_SetRequestTimeoutPtr) dlsym(hLibrary, "liboie_connection_setrequesttimeout"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetRequestTimeout == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetMaxErrorCount = (PLibOIEConnection_SetMaxErrorCountPtr) GetProcAddress(hLibrary, "liboie_connection_setmaxerrorcount"); + #else // _WIN32 + pWrapperTable->m_Connection_SetMaxErrorCount = (PLibOIEConnection_SetMaxErrorCountPtr) dlsym(hLibrary, "liboie_connection_setmaxerrorcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetMaxErrorCount == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetMaxMemoryCount = (PLibOIEConnection_SetMaxMemoryCountPtr) GetProcAddress(hLibrary, "liboie_connection_setmaxmemorycount"); + #else // _WIN32 + pWrapperTable->m_Connection_SetMaxMemoryCount = (PLibOIEConnection_SetMaxMemoryCountPtr) dlsym(hLibrary, "liboie_connection_setmaxmemorycount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetMaxMemoryCount == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetBufferFile = (PLibOIEConnection_SetBufferFilePtr) GetProcAddress(hLibrary, "liboie_connection_setbufferfile"); + #else // _WIN32 + pWrapperTable->m_Connection_SetBufferFile = (PLibOIEConnection_SetBufferFilePtr) dlsym(hLibrary, "liboie_connection_setbufferfile"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetBufferFile == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_UnsetBufferFile = (PLibOIEConnection_UnsetBufferFilePtr) GetProcAddress(hLibrary, "liboie_connection_unsetbufferfile"); + #else // _WIN32 + pWrapperTable->m_Connection_UnsetBufferFile = (PLibOIEConnection_UnsetBufferFilePtr) dlsym(hLibrary, "liboie_connection_unsetbufferfile"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_UnsetBufferFile == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetCheckAliveInterval = (PLibOIEConnection_SetCheckAliveIntervalPtr) GetProcAddress(hLibrary, "liboie_connection_setcheckaliveinterval"); + #else // _WIN32 + pWrapperTable->m_Connection_SetCheckAliveInterval = (PLibOIEConnection_SetCheckAliveIntervalPtr) dlsym(hLibrary, "liboie_connection_setcheckaliveinterval"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetCheckAliveInterval == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_RetrieveFirmwareVersion = (PLibOIEConnection_RetrieveFirmwareVersionPtr) GetProcAddress(hLibrary, "liboie_connection_retrievefirmwareversion"); + #else // _WIN32 + pWrapperTable->m_Connection_RetrieveFirmwareVersion = (PLibOIEConnection_RetrieveFirmwareVersionPtr) dlsym(hLibrary, "liboie_connection_retrievefirmwareversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_RetrieveFirmwareVersion == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_UpdateFirmware = (PLibOIEConnection_UpdateFirmwarePtr) GetProcAddress(hLibrary, "liboie_connection_updatefirmware"); + #else // _WIN32 + pWrapperTable->m_Connection_UpdateFirmware = (PLibOIEConnection_UpdateFirmwarePtr) dlsym(hLibrary, "liboie_connection_updatefirmware"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_UpdateFirmware == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_StartFirmware = (PLibOIEConnection_StartFirmwarePtr) GetProcAddress(hLibrary, "liboie_connection_startfirmware"); + #else // _WIN32 + pWrapperTable->m_Connection_StartFirmware = (PLibOIEConnection_StartFirmwarePtr) dlsym(hLibrary, "liboie_connection_startfirmware"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_StartFirmware == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_StopFirmware = (PLibOIEConnection_StopFirmwarePtr) GetProcAddress(hLibrary, "liboie_connection_stopfirmware"); + #else // _WIN32 + pWrapperTable->m_Connection_StopFirmware = (PLibOIEConnection_StopFirmwarePtr) dlsym(hLibrary, "liboie_connection_stopfirmware"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_StopFirmware == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_SetConnectionErrorCallback = (PLibOIEConnection_SetConnectionErrorCallbackPtr) GetProcAddress(hLibrary, "liboie_connection_setconnectionerrorcallback"); + #else // _WIN32 + pWrapperTable->m_Connection_SetConnectionErrorCallback = (PLibOIEConnection_SetConnectionErrorCallbackPtr) dlsym(hLibrary, "liboie_connection_setconnectionerrorcallback"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_SetConnectionErrorCallback == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_ClearErrors = (PLibOIEConnection_ClearErrorsPtr) GetProcAddress(hLibrary, "liboie_connection_clearerrors"); + #else // _WIN32 + pWrapperTable->m_Connection_ClearErrors = (PLibOIEConnection_ClearErrorsPtr) dlsym(hLibrary, "liboie_connection_clearerrors"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_ClearErrors == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_GetErrorCount = (PLibOIEConnection_GetErrorCountPtr) GetProcAddress(hLibrary, "liboie_connection_geterrorcount"); + #else // _WIN32 + pWrapperTable->m_Connection_GetErrorCount = (PLibOIEConnection_GetErrorCountPtr) dlsym(hLibrary, "liboie_connection_geterrorcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_GetErrorCount == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_GetError = (PLibOIEConnection_GetErrorPtr) GetProcAddress(hLibrary, "liboie_connection_geterror"); + #else // _WIN32 + pWrapperTable->m_Connection_GetError = (PLibOIEConnection_GetErrorPtr) dlsym(hLibrary, "liboie_connection_geterror"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_GetError == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_CreateRemoteFunctionCall = (PLibOIEConnection_CreateRemoteFunctionCallPtr) GetProcAddress(hLibrary, "liboie_connection_createremotefunctioncall"); + #else // _WIN32 + pWrapperTable->m_Connection_CreateRemoteFunctionCall = (PLibOIEConnection_CreateRemoteFunctionCallPtr) dlsym(hLibrary, "liboie_connection_createremotefunctioncall"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_CreateRemoteFunctionCall == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_GetBufferedPyroPackages = (PLibOIEConnection_GetBufferedPyroPackagesPtr) GetProcAddress(hLibrary, "liboie_connection_getbufferedpyropackages"); + #else // _WIN32 + pWrapperTable->m_Connection_GetBufferedPyroPackages = (PLibOIEConnection_GetBufferedPyroPackagesPtr) dlsym(hLibrary, "liboie_connection_getbufferedpyropackages"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_GetBufferedPyroPackages == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Connection_GetBufferedOctPackages = (PLibOIEConnection_GetBufferedOctPackagesPtr) GetProcAddress(hLibrary, "liboie_connection_getbufferedoctpackages"); + #else // _WIN32 + pWrapperTable->m_Connection_GetBufferedOctPackages = (PLibOIEConnection_GetBufferedOctPackagesPtr) dlsym(hLibrary, "liboie_connection_getbufferedoctpackages"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Connection_GetBufferedOctPackages == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_ConnectionIterator_GetCurrentConnection = (PLibOIEConnectionIterator_GetCurrentConnectionPtr) GetProcAddress(hLibrary, "liboie_connectioniterator_getcurrentconnection"); + #else // _WIN32 + pWrapperTable->m_ConnectionIterator_GetCurrentConnection = (PLibOIEConnectionIterator_GetCurrentConnectionPtr) dlsym(hLibrary, "liboie_connectioniterator_getcurrentconnection"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_ConnectionIterator_GetCurrentConnection == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_Start = (PLibOIEServer_StartPtr) GetProcAddress(hLibrary, "liboie_server_start"); + #else // _WIN32 + pWrapperTable->m_Server_Start = (PLibOIEServer_StartPtr) dlsym(hLibrary, "liboie_server_start"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_Start == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_Stop = (PLibOIEServer_StopPtr) GetProcAddress(hLibrary, "liboie_server_stop"); + #else // _WIN32 + pWrapperTable->m_Server_Stop = (PLibOIEServer_StopPtr) dlsym(hLibrary, "liboie_server_stop"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_Stop == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_CloseAllConnections = (PLibOIEServer_CloseAllConnectionsPtr) GetProcAddress(hLibrary, "liboie_server_closeallconnections"); + #else // _WIN32 + pWrapperTable->m_Server_CloseAllConnections = (PLibOIEServer_CloseAllConnectionsPtr) dlsym(hLibrary, "liboie_server_closeallconnections"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_CloseAllConnections == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_SetThreadCount = (PLibOIEServer_SetThreadCountPtr) GetProcAddress(hLibrary, "liboie_server_setthreadcount"); + #else // _WIN32 + pWrapperTable->m_Server_SetThreadCount = (PLibOIEServer_SetThreadCountPtr) dlsym(hLibrary, "liboie_server_setthreadcount"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_SetThreadCount == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_SetBufferSize = (PLibOIEServer_SetBufferSizePtr) GetProcAddress(hLibrary, "liboie_server_setbuffersize"); + #else // _WIN32 + pWrapperTable->m_Server_SetBufferSize = (PLibOIEServer_SetBufferSizePtr) dlsym(hLibrary, "liboie_server_setbuffersize"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_SetBufferSize == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_AcceptDevice = (PLibOIEServer_AcceptDevicePtr) GetProcAddress(hLibrary, "liboie_server_acceptdevice"); + #else // _WIN32 + pWrapperTable->m_Server_AcceptDevice = (PLibOIEServer_AcceptDevicePtr) dlsym(hLibrary, "liboie_server_acceptdevice"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_AcceptDevice == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_UnAcceptDevice = (PLibOIEServer_UnAcceptDevicePtr) GetProcAddress(hLibrary, "liboie_server_unacceptdevice"); + #else // _WIN32 + pWrapperTable->m_Server_UnAcceptDevice = (PLibOIEServer_UnAcceptDevicePtr) dlsym(hLibrary, "liboie_server_unacceptdevice"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_UnAcceptDevice == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_ClearAcceptedDevices = (PLibOIEServer_ClearAcceptedDevicesPtr) GetProcAddress(hLibrary, "liboie_server_clearaccepteddevices"); + #else // _WIN32 + pWrapperTable->m_Server_ClearAcceptedDevices = (PLibOIEServer_ClearAcceptedDevicesPtr) dlsym(hLibrary, "liboie_server_clearaccepteddevices"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_ClearAcceptedDevices == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_ListConnections = (PLibOIEServer_ListConnectionsPtr) GetProcAddress(hLibrary, "liboie_server_listconnections"); + #else // _WIN32 + pWrapperTable->m_Server_ListConnections = (PLibOIEServer_ListConnectionsPtr) dlsym(hLibrary, "liboie_server_listconnections"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_ListConnections == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_SetConnectionAcceptedCallback = (PLibOIEServer_SetConnectionAcceptedCallbackPtr) GetProcAddress(hLibrary, "liboie_server_setconnectionacceptedcallback"); + #else // _WIN32 + pWrapperTable->m_Server_SetConnectionAcceptedCallback = (PLibOIEServer_SetConnectionAcceptedCallbackPtr) dlsym(hLibrary, "liboie_server_setconnectionacceptedcallback"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_SetConnectionAcceptedCallback == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Server_SetConnectionRejectedCallback = (PLibOIEServer_SetConnectionRejectedCallbackPtr) GetProcAddress(hLibrary, "liboie_server_setconnectionrejectedcallback"); + #else // _WIN32 + pWrapperTable->m_Server_SetConnectionRejectedCallback = (PLibOIEServer_SetConnectionRejectedCallbackPtr) dlsym(hLibrary, "liboie_server_setconnectionrejectedcallback"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Server_SetConnectionRejectedCallback == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetVersion = (PLibOIEGetVersionPtr) GetProcAddress(hLibrary, "liboie_getversion"); + #else // _WIN32 + pWrapperTable->m_GetVersion = (PLibOIEGetVersionPtr) dlsym(hLibrary, "liboie_getversion"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetVersion == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetLastError = (PLibOIEGetLastErrorPtr) GetProcAddress(hLibrary, "liboie_getlasterror"); + #else // _WIN32 + pWrapperTable->m_GetLastError = (PLibOIEGetLastErrorPtr) dlsym(hLibrary, "liboie_getlasterror"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetLastError == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibOIEReleaseInstancePtr) GetProcAddress(hLibrary, "liboie_releaseinstance"); + #else // _WIN32 + pWrapperTable->m_ReleaseInstance = (PLibOIEReleaseInstancePtr) dlsym(hLibrary, "liboie_releaseinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_ReleaseInstance == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_AcquireInstance = (PLibOIEAcquireInstancePtr) GetProcAddress(hLibrary, "liboie_acquireinstance"); + #else // _WIN32 + pWrapperTable->m_AcquireInstance = (PLibOIEAcquireInstancePtr) dlsym(hLibrary, "liboie_acquireinstance"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_AcquireInstance == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibOIEGetSymbolLookupMethodPtr) GetProcAddress(hLibrary, "liboie_getsymbollookupmethod"); + #else // _WIN32 + pWrapperTable->m_GetSymbolLookupMethod = (PLibOIEGetSymbolLookupMethodPtr) dlsym(hLibrary, "liboie_getsymbollookupmethod"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_GetSymbolLookupMethod == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_CreateServer = (PLibOIECreateServerPtr) GetProcAddress(hLibrary, "liboie_createserver"); + #else // _WIN32 + pWrapperTable->m_CreateServer = (PLibOIECreateServerPtr) dlsym(hLibrary, "liboie_createserver"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_CreateServer == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + pWrapperTable->m_LibraryHandle = hLibrary; + return LIBOIE_SUCCESS; + } + + inline LibOIEResult CWrapper::loadWrapperTableFromSymbolLookupMethod(sLibOIEDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod) +{ + if (pWrapperTable == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + if (pSymbolLookupMethod == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + + typedef LibOIEResult(*SymbolLookupType)(const char*, void**); + + SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod; + + LibOIEResult eLookupError = LIBOIE_SUCCESS; + eLookupError = (*pLookup)("liboie_iterator_movenext", (void**)&(pWrapperTable->m_Iterator_MoveNext)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_MoveNext == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_iterator_moveprevious", (void**)&(pWrapperTable->m_Iterator_MovePrevious)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_MovePrevious == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_iterator_getcurrent", (void**)&(pWrapperTable->m_Iterator_GetCurrent)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_GetCurrent == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_iterator_clone", (void**)&(pWrapperTable->m_Iterator_Clone)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_Clone == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_iterator_count", (void**)&(pWrapperTable->m_Iterator_Count)); + if ( (eLookupError != 0) || (pWrapperTable->m_Iterator_Count == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_datapackage_getrawpayload", (void**)&(pWrapperTable->m_DataPackage_GetRawPayload)); + if ( (eLookupError != 0) || (pWrapperTable->m_DataPackage_GetRawPayload == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_datapackage_release", (void**)&(pWrapperTable->m_DataPackage_Release)); + if ( (eLookupError != 0) || (pWrapperTable->m_DataPackage_Release == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_pyrodatapackageiterator_getcurrentpyrodatapackage", (void**)&(pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage)); + if ( (eLookupError != 0) || (pWrapperTable->m_PyroDataPackageIterator_GetCurrentPyroDataPackage == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_octdatapackageiterator_getcurrentoctdatapackage", (void**)&(pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage)); + if ( (eLookupError != 0) || (pWrapperTable->m_OctDataPackageIterator_GetCurrentOctDataPackage == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_remotefunctioncall_getfunctionname", (void**)&(pWrapperTable->m_RemoteFunctionCall_GetFunctionName)); + if ( (eLookupError != 0) || (pWrapperTable->m_RemoteFunctionCall_GetFunctionName == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_remotefunctioncall_addparameter", (void**)&(pWrapperTable->m_RemoteFunctionCall_AddParameter)); + if ( (eLookupError != 0) || (pWrapperTable->m_RemoteFunctionCall_AddParameter == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_remotefunctioncall_send", (void**)&(pWrapperTable->m_RemoteFunctionCall_Send)); + if ( (eLookupError != 0) || (pWrapperTable->m_RemoteFunctionCall_Send == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_disconnect", (void**)&(pWrapperTable->m_Connection_Disconnect)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_Disconnect == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setrequesttimeout", (void**)&(pWrapperTable->m_Connection_SetRequestTimeout)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetRequestTimeout == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setmaxerrorcount", (void**)&(pWrapperTable->m_Connection_SetMaxErrorCount)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetMaxErrorCount == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setmaxmemorycount", (void**)&(pWrapperTable->m_Connection_SetMaxMemoryCount)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetMaxMemoryCount == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setbufferfile", (void**)&(pWrapperTable->m_Connection_SetBufferFile)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetBufferFile == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_unsetbufferfile", (void**)&(pWrapperTable->m_Connection_UnsetBufferFile)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_UnsetBufferFile == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setcheckaliveinterval", (void**)&(pWrapperTable->m_Connection_SetCheckAliveInterval)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetCheckAliveInterval == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_retrievefirmwareversion", (void**)&(pWrapperTable->m_Connection_RetrieveFirmwareVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_RetrieveFirmwareVersion == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_updatefirmware", (void**)&(pWrapperTable->m_Connection_UpdateFirmware)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_UpdateFirmware == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_startfirmware", (void**)&(pWrapperTable->m_Connection_StartFirmware)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_StartFirmware == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_stopfirmware", (void**)&(pWrapperTable->m_Connection_StopFirmware)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_StopFirmware == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_setconnectionerrorcallback", (void**)&(pWrapperTable->m_Connection_SetConnectionErrorCallback)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetConnectionErrorCallback == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_clearerrors", (void**)&(pWrapperTable->m_Connection_ClearErrors)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_ClearErrors == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_geterrorcount", (void**)&(pWrapperTable->m_Connection_GetErrorCount)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetErrorCount == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_geterror", (void**)&(pWrapperTable->m_Connection_GetError)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetError == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_createremotefunctioncall", (void**)&(pWrapperTable->m_Connection_CreateRemoteFunctionCall)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_CreateRemoteFunctionCall == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_getbufferedpyropackages", (void**)&(pWrapperTable->m_Connection_GetBufferedPyroPackages)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetBufferedPyroPackages == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connection_getbufferedoctpackages", (void**)&(pWrapperTable->m_Connection_GetBufferedOctPackages)); + if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetBufferedOctPackages == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_connectioniterator_getcurrentconnection", (void**)&(pWrapperTable->m_ConnectionIterator_GetCurrentConnection)); + if ( (eLookupError != 0) || (pWrapperTable->m_ConnectionIterator_GetCurrentConnection == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_start", (void**)&(pWrapperTable->m_Server_Start)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_Start == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_stop", (void**)&(pWrapperTable->m_Server_Stop)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_Stop == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_closeallconnections", (void**)&(pWrapperTable->m_Server_CloseAllConnections)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_CloseAllConnections == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_setthreadcount", (void**)&(pWrapperTable->m_Server_SetThreadCount)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_SetThreadCount == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_setbuffersize", (void**)&(pWrapperTable->m_Server_SetBufferSize)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_SetBufferSize == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_acceptdevice", (void**)&(pWrapperTable->m_Server_AcceptDevice)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_AcceptDevice == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_unacceptdevice", (void**)&(pWrapperTable->m_Server_UnAcceptDevice)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_UnAcceptDevice == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_clearaccepteddevices", (void**)&(pWrapperTable->m_Server_ClearAcceptedDevices)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_ClearAcceptedDevices == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_listconnections", (void**)&(pWrapperTable->m_Server_ListConnections)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_ListConnections == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_setconnectionacceptedcallback", (void**)&(pWrapperTable->m_Server_SetConnectionAcceptedCallback)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_SetConnectionAcceptedCallback == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_server_setconnectionrejectedcallback", (void**)&(pWrapperTable->m_Server_SetConnectionRejectedCallback)); + if ( (eLookupError != 0) || (pWrapperTable->m_Server_SetConnectionRejectedCallback == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_getversion", (void**)&(pWrapperTable->m_GetVersion)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetVersion == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_getlasterror", (void**)&(pWrapperTable->m_GetLastError)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetLastError == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_releaseinstance", (void**)&(pWrapperTable->m_ReleaseInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_ReleaseInstance == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_acquireinstance", (void**)&(pWrapperTable->m_AcquireInstance)); + if ( (eLookupError != 0) || (pWrapperTable->m_AcquireInstance == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_getsymbollookupmethod", (void**)&(pWrapperTable->m_GetSymbolLookupMethod)); + if ( (eLookupError != 0) || (pWrapperTable->m_GetSymbolLookupMethod == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("liboie_createserver", (void**)&(pWrapperTable->m_CreateServer)); + if ( (eLookupError != 0) || (pWrapperTable->m_CreateServer == nullptr) ) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + + return LIBOIE_SUCCESS; +} + + + + /** + * Method definitions for class CBase + */ + + /** + * Method definitions for class CIterator + */ + + /** + * CIterator::MoveNext - Iterates to the next resource in the list. + * @return Iterates to the next resource in the list. + */ + bool CIterator::MoveNext() + { + bool resultHasNext = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_MoveNext(m_pHandle, &resultHasNext)); + + return resultHasNext; + } + + /** + * CIterator::MovePrevious - Iterates to the previous resource in the list. + * @return Iterates to the previous resource in the list. + */ + bool CIterator::MovePrevious() + { + bool resultHasPrevious = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_MovePrevious(m_pHandle, &resultHasPrevious)); + + return resultHasPrevious; + } + + /** + * CIterator::GetCurrent - Returns the resource the iterator points at. + * @return returns the resource instance. + */ + PBase CIterator::GetCurrent() + { + LibOIEHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_GetCurrent(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * CIterator::Clone - Creates a new resource iterator with the same resource list. + * @return returns the cloned Iterator instance + */ + PIterator CIterator::Clone() + { + LibOIEHandle hOutIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_Clone(m_pHandle, &hOutIterator)); + + if (!hOutIterator) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hOutIterator); + } + + /** + * CIterator::Count - Returns the number of resoucres the iterator captures. + * @return returns the number of resources the iterator captures. + */ + LibOIE_uint64 CIterator::Count() + { + LibOIE_uint64 resultCount = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Iterator_Count(m_pHandle, &resultCount)); + + return resultCount; + } + + /** + * Method definitions for class CDataPackage + */ + + /** + * CDataPackage::GetRawPayload - Returns the raw payload. + * @param[out] PayloadBuffer - Raw payload data. + */ + void CDataPackage::GetRawPayload(std::vector & PayloadBuffer) + { + LibOIE_uint64 elementsNeededPayload = 0; + LibOIE_uint64 elementsWrittenPayload = 0; + CheckError(m_pWrapper->m_WrapperTable.m_DataPackage_GetRawPayload(m_pHandle, 0, &elementsNeededPayload, nullptr)); + PayloadBuffer.resize((size_t) elementsNeededPayload); + CheckError(m_pWrapper->m_WrapperTable.m_DataPackage_GetRawPayload(m_pHandle, elementsNeededPayload, &elementsWrittenPayload, PayloadBuffer.data())); + } + + /** + * CDataPackage::Release - Releases memory of the data package. + */ + void CDataPackage::Release() + { + CheckError(m_pWrapper->m_WrapperTable.m_DataPackage_Release(m_pHandle)); + } + + /** + * Method definitions for class CPyroDataPackage + */ + + /** + * Method definitions for class CPyroDataPackageIterator + */ + + /** + * CPyroDataPackageIterator::GetCurrentPyroDataPackage - Returns the data package the iterator points at. + * @return returns the data package instance. + */ + PPyroDataPackage CPyroDataPackageIterator::GetCurrentPyroDataPackage() + { + LibOIEHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_PyroDataPackageIterator_GetCurrentPyroDataPackage(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * Method definitions for class COctDataPackage + */ + + /** + * Method definitions for class COctDataPackageIterator + */ + + /** + * COctDataPackageIterator::GetCurrentOctDataPackage - Returns the data package the iterator points at. + * @return returns the data package instance. + */ + POctDataPackage COctDataPackageIterator::GetCurrentOctDataPackage() + { + LibOIEHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_OctDataPackageIterator_GetCurrentOctDataPackage(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * Method definitions for class CRemoteFunctionCall + */ + + /** + * CRemoteFunctionCall::GetFunctionName - Returns function name + * @return Function Name. + */ + std::string CRemoteFunctionCall::GetFunctionName() + { + LibOIE_uint32 bytesNeededFunctionName = 0; + LibOIE_uint32 bytesWrittenFunctionName = 0; + CheckError(m_pWrapper->m_WrapperTable.m_RemoteFunctionCall_GetFunctionName(m_pHandle, 0, &bytesNeededFunctionName, nullptr)); + std::vector bufferFunctionName(bytesNeededFunctionName); + CheckError(m_pWrapper->m_WrapperTable.m_RemoteFunctionCall_GetFunctionName(m_pHandle, bytesNeededFunctionName, &bytesWrittenFunctionName, &bufferFunctionName[0])); + + return std::string(&bufferFunctionName[0]); + } + + /** + * CRemoteFunctionCall::AddParameter - Adds a function call parameter + * @param[in] sParameter - Parameter of the call. + */ + void CRemoteFunctionCall::AddParameter(const std::string & sParameter) + { + CheckError(m_pWrapper->m_WrapperTable.m_RemoteFunctionCall_AddParameter(m_pHandle, sParameter.c_str())); + } + + /** + * CRemoteFunctionCall::Send - Sends a remote function call over its connection. + * @return Returns result if successful. + */ + std::string CRemoteFunctionCall::Send() + { + LibOIE_uint32 bytesNeededResultString = 0; + LibOIE_uint32 bytesWrittenResultString = 0; + CheckError(m_pWrapper->m_WrapperTable.m_RemoteFunctionCall_Send(m_pHandle, 0, &bytesNeededResultString, nullptr)); + std::vector bufferResultString(bytesNeededResultString); + CheckError(m_pWrapper->m_WrapperTable.m_RemoteFunctionCall_Send(m_pHandle, bytesNeededResultString, &bytesWrittenResultString, &bufferResultString[0])); + + return std::string(&bufferResultString[0]); + } + + /** + * Method definitions for class CConnection + */ + + /** + * CConnection::Disconnect - Disconnects and closes the connection + */ + void CConnection::Disconnect() + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_Disconnect(m_pHandle)); + } + + /** + * CConnection::SetRequestTimeout - Sets timeout value for each poll request below. + * @param[in] nTimeout - Timeout in milliseconds. Default is 1000ms. Minimum 10ms, maximum 1000000ms. + */ + void CConnection::SetRequestTimeout(const LibOIE_uint32 nTimeout) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetRequestTimeout(m_pHandle, nTimeout)); + } + + /** + * CConnection::SetMaxErrorCount - Sets the maximum error messages that can be received before the connection is terminated. + * @param[in] nErrorCount - Max Error count. Default is 1024. Minimum 16, maximum 65535. + */ + void CConnection::SetMaxErrorCount(const LibOIE_uint32 nErrorCount) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetMaxErrorCount(m_pHandle, nErrorCount)); + } + + /** + * CConnection::SetMaxMemoryCount - Sets the maximum memory buffer the data packets can use before the connection is terminated. + * @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1GB. + */ + void CConnection::SetMaxMemoryCount(const LibOIE_uint32 nMaxMemoryCount) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetMaxMemoryCount(m_pHandle, nMaxMemoryCount)); + } + + /** + * CConnection::SetBufferFile - Sets a temporary filename to which the packets are buffered. + * @param[in] sFileName - Filename which should be used as buffer. + * @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1TB. + */ + void CConnection::SetBufferFile(const std::string & sFileName, const LibOIE_uint64 nMaxMemoryCount) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetBufferFile(m_pHandle, sFileName.c_str(), nMaxMemoryCount)); + } + + /** + * CConnection::UnsetBufferFile - Stops writing to disk. + */ + void CConnection::UnsetBufferFile() + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_UnsetBufferFile(m_pHandle)); + } + + /** + * CConnection::SetCheckAliveInterval - Sets check alive interval. 0ms means no check alive request is sent. + * @param[in] nCheckAliveInterval - Timeout in milliseconds. Default is 1000ms. Max value is 1000000ms. + */ + void CConnection::SetCheckAliveInterval(const LibOIE_uint32 nCheckAliveInterval) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetCheckAliveInterval(m_pHandle, nCheckAliveInterval)); + } + + /** + * CConnection::RetrieveFirmwareVersion - Retrieves Firmware Version. Fails if firmware is not existing. + * @param[in] sFirmwareName - Name of the firmware to retrieve. + * @param[out] sFirmwareVersion - Version of the requested firmware. + * @param[out] sFilename - Filename of the requested firmware. + * @param[out] sFiledate - Timestamp of the requested firmware in ISO8601 Time. + * @param[out] sSHA256 - Checksum of the requested firmware. + */ + void CConnection::RetrieveFirmwareVersion(const std::string & sFirmwareName, std::string & sFirmwareVersion, std::string & sFilename, std::string & sFiledate, std::string & sSHA256) + { + LibOIE_uint32 bytesNeededFirmwareVersion = 0; + LibOIE_uint32 bytesWrittenFirmwareVersion = 0; + LibOIE_uint32 bytesNeededFilename = 0; + LibOIE_uint32 bytesWrittenFilename = 0; + LibOIE_uint32 bytesNeededFiledate = 0; + LibOIE_uint32 bytesWrittenFiledate = 0; + LibOIE_uint32 bytesNeededSHA256 = 0; + LibOIE_uint32 bytesWrittenSHA256 = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_RetrieveFirmwareVersion(m_pHandle, sFirmwareName.c_str(), 0, &bytesNeededFirmwareVersion, nullptr, 0, &bytesNeededFilename, nullptr, 0, &bytesNeededFiledate, nullptr, 0, &bytesNeededSHA256, nullptr)); + std::vector bufferFirmwareVersion(bytesNeededFirmwareVersion); + std::vector bufferFilename(bytesNeededFilename); + std::vector bufferFiledate(bytesNeededFiledate); + std::vector bufferSHA256(bytesNeededSHA256); + CheckError(m_pWrapper->m_WrapperTable.m_Connection_RetrieveFirmwareVersion(m_pHandle, sFirmwareName.c_str(), bytesNeededFirmwareVersion, &bytesWrittenFirmwareVersion, &bufferFirmwareVersion[0], bytesNeededFilename, &bytesWrittenFilename, &bufferFilename[0], bytesNeededFiledate, &bytesWrittenFiledate, &bufferFiledate[0], bytesNeededSHA256, &bytesWrittenSHA256, &bufferSHA256[0])); + sFirmwareVersion = std::string(&bufferFirmwareVersion[0]); + sFilename = std::string(&bufferFilename[0]); + sFiledate = std::string(&bufferFiledate[0]); + sSHA256 = std::string(&bufferSHA256[0]); + } + + /** + * CConnection::UpdateFirmware - Retrieves Firmware Version. Fails if firmware is not existing. + * @param[in] sFirmwareName - Name of the new firmware. + * @param[in] sFirmwareVersion - Version of the new firmware. + * @param[in] sFileName - Filename of the new firmware. + * @param[in] sFileDate - Timestamp of the requested firmware in ISO8601 Time. + * @param[in] sSHA256 - Checksum of the new firmware. + * @param[in] BinaryDataBuffer - Blob of new firmware. + */ + void CConnection::UpdateFirmware(const std::string & sFirmwareName, const std::string & sFirmwareVersion, const std::string & sFileName, const std::string & sFileDate, const std::string & sSHA256, const CInputVector & BinaryDataBuffer) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_UpdateFirmware(m_pHandle, sFirmwareName.c_str(), sFirmwareVersion.c_str(), sFileName.c_str(), sFileDate.c_str(), sSHA256.c_str(), (LibOIE_uint64)BinaryDataBuffer.size(), BinaryDataBuffer.data())); + } + + /** + * CConnection::StartFirmware - Starts firmware on Open Interface Extension. + * @param[in] sFileName - Filename of the firmware to start. + * @return Firmware successfully started. + */ + bool CConnection::StartFirmware(const std::string & sFileName) + { + bool resultSuccess = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_StartFirmware(m_pHandle, sFileName.c_str(), &resultSuccess)); + + return resultSuccess; + } + + /** + * CConnection::StopFirmware - Stops firmware on Open Interface Extension. + * @param[in] sFileName - Filename of the firmware to stop. + * @return Firmware successfully stopped. + */ + bool CConnection::StopFirmware(const std::string & sFileName) + { + bool resultSuccess = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_StopFirmware(m_pHandle, sFileName.c_str(), &resultSuccess)); + + return resultSuccess; + } + + /** + * CConnection::SetConnectionErrorCallback - sets a callback that triggers when a connection error occured. + * @param[in] pCallback - callback pointer. + */ + void CConnection::SetConnectionErrorCallback(const ConnectionErrorCallback pCallback) + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetConnectionErrorCallback(m_pHandle, pCallback)); + } + + /** + * CConnection::ClearErrors - clears the error log. + */ + void CConnection::ClearErrors() + { + CheckError(m_pWrapper->m_WrapperTable.m_Connection_ClearErrors(m_pHandle)); + } + + /** + * CConnection::GetErrorCount - Returns the list of errors in the error log. + * @return Errors in the error log. + */ + LibOIE_uint32 CConnection::GetErrorCount() + { + LibOIE_uint32 resultErrorCount = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetErrorCount(m_pHandle, &resultErrorCount)); + + return resultErrorCount; + } + + /** + * CConnection::GetError - Returns an error message of the error log + * @param[in] nErrorIndex - Index of the error. + * @param[out] sErrorMessage - Message of the error. + * @param[out] sTimestamp - ISO8601 Time when the error was reported. + */ + void CConnection::GetError(const LibOIE_uint32 nErrorIndex, std::string & sErrorMessage, std::string & sTimestamp) + { + LibOIE_uint32 bytesNeededErrorMessage = 0; + LibOIE_uint32 bytesWrittenErrorMessage = 0; + LibOIE_uint32 bytesNeededTimestamp = 0; + LibOIE_uint32 bytesWrittenTimestamp = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetError(m_pHandle, nErrorIndex, 0, &bytesNeededErrorMessage, nullptr, 0, &bytesNeededTimestamp, nullptr)); + std::vector bufferErrorMessage(bytesNeededErrorMessage); + std::vector bufferTimestamp(bytesNeededTimestamp); + CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetError(m_pHandle, nErrorIndex, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], bytesNeededTimestamp, &bytesWrittenTimestamp, &bufferTimestamp[0])); + sErrorMessage = std::string(&bufferErrorMessage[0]); + sTimestamp = std::string(&bufferTimestamp[0]); + } + + /** + * CConnection::CreateRemoteFunctionCall - Creates a new remote function call. + * @param[in] sFunctionName - Function name. + * @return Function call instance. + */ + PRemoteFunctionCall CConnection::CreateRemoteFunctionCall(const std::string & sFunctionName) + { + LibOIEHandle hInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_CreateRemoteFunctionCall(m_pHandle, sFunctionName.c_str(), &hInstance)); + + if (!hInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hInstance); + } + + /** + * CConnection::GetBufferedPyroPackages - Retrieves currently buffered pyro packages. + * @return Iterator of buffered packages. + */ + PPyroDataPackageIterator CConnection::GetBufferedPyroPackages() + { + LibOIEHandle hIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBufferedPyroPackages(m_pHandle, &hIterator)); + + if (!hIterator) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hIterator); + } + + /** + * CConnection::GetBufferedOctPackages - Retrieves currently buffered oct packages. + * @return Iterator of buffered packages. + */ + POctDataPackageIterator CConnection::GetBufferedOctPackages() + { + LibOIEHandle hIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBufferedOctPackages(m_pHandle, &hIterator)); + + if (!hIterator) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hIterator); + } + + /** + * Method definitions for class CConnectionIterator + */ + + /** + * CConnectionIterator::GetCurrentConnection - Returns the connection the iterator points at. + * @return returns the connection instance. + */ + PConnection CConnectionIterator::GetCurrentConnection() + { + LibOIEHandle hCurrentInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_ConnectionIterator_GetCurrentConnection(m_pHandle, &hCurrentInstance)); + + if (!hCurrentInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hCurrentInstance); + } + + /** + * Method definitions for class CServer + */ + + /** + * CServer::Start - starts listening for connections. + * @param[in] sIPAddress - IP Address to run on + * @param[in] nPort - Port to run on + * @param[in] bIPv6 - flag if IPv6 should be used + */ + void CServer::Start(const std::string & sIPAddress, const LibOIE_uint32 nPort, const bool bIPv6) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_Start(m_pHandle, sIPAddress.c_str(), nPort, bIPv6)); + } + + /** + * CServer::Stop - stops listening for connections and disconnects existing ones. + */ + void CServer::Stop() + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_Stop(m_pHandle)); + } + + /** + * CServer::CloseAllConnections - disconnects all connections but does not stop listening. + */ + void CServer::CloseAllConnections() + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_CloseAllConnections(m_pHandle)); + } + + /** + * CServer::SetThreadCount - sets the maximum thread count to use. Must be called before Start + * @param[in] nThreadCount - Thread count to use (must be larger than 4, default is 32) + */ + void CServer::SetThreadCount(const LibOIE_uint32 nThreadCount) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_SetThreadCount(m_pHandle, nThreadCount)); + } + + /** + * CServer::SetBufferSize - sets the receive buffer size + * @param[in] nRCVBufferSize - Receive buffer size to use in bytes (must be between 4kB and 1GB, default is 1MB) + */ + void CServer::SetBufferSize(const LibOIE_uint32 nRCVBufferSize) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_SetBufferSize(m_pHandle, nRCVBufferSize)); + } + + /** + * CServer::AcceptDevice - adds an accepted device + * @param[in] sDeviceName - Device name to be accepted. Empty string means all devices. + * @param[in] sApplicationName - Application name to be accepted. Empty string means all applications. + * @param[in] sVersionName - Version name to be accepted. Empty string means all versions. + * @return Returns identifier of acceptance rule. + */ + LibOIE_uint32 CServer::AcceptDevice(const std::string & sDeviceName, const std::string & sApplicationName, const std::string & sVersionName) + { + LibOIE_uint32 resultRuleID = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Server_AcceptDevice(m_pHandle, sDeviceName.c_str(), sApplicationName.c_str(), sVersionName.c_str(), &resultRuleID)); + + return resultRuleID; + } + + /** + * CServer::UnAcceptDevice - removes an accepted + * @param[in] nRuleID - identifier of acceptance rule. + */ + void CServer::UnAcceptDevice(const LibOIE_uint32 nRuleID) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_UnAcceptDevice(m_pHandle, nRuleID)); + } + + /** + * CServer::ClearAcceptedDevices - clears all accepted device rules + */ + void CServer::ClearAcceptedDevices() + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_ClearAcceptedDevices(m_pHandle)); + } + + /** + * CServer::ListConnections - lists all open connections + * @return list of all open connections. + */ + PConnectionIterator CServer::ListConnections() + { + LibOIEHandle hConnectionIteratorInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_Server_ListConnections(m_pHandle, &hConnectionIteratorInstance)); + + if (!hConnectionIteratorInstance) { + CheckError(LIBOIE_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hConnectionIteratorInstance); + } + + /** + * CServer::SetConnectionAcceptedCallback - sets a callback that triggers when a new connection was established. + * @param[in] pCallback - callback pointer. + */ + void CServer::SetConnectionAcceptedCallback(const ConnectionAcceptedCallback pCallback) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_SetConnectionAcceptedCallback(m_pHandle, pCallback)); + } + + /** + * CServer::SetConnectionRejectedCallback - sets a callback that triggers when a new connection was rejected. + * @param[in] pCallback - callback pointer. + */ + void CServer::SetConnectionRejectedCallback(const ConnectionRejectedCallback pCallback) + { + CheckError(m_pWrapper->m_WrapperTable.m_Server_SetConnectionRejectedCallback(m_pHandle, pCallback)); + } + +} // namespace LibOIE + +#endif // __LIBOIE_CPPHEADER_DYNAMIC_CPP + diff --git a/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_types.hpp b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_types.hpp new file mode 100644 index 00000000..5f378c1e --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Headers/CppDynamic/liboie_types.hpp @@ -0,0 +1,181 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_TYPES_HEADER_CPP +#define __LIBOIE_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBOIE_USELEGACYINTEGERTYPES + +typedef unsigned char LibOIE_uint8; +typedef unsigned short LibOIE_uint16 ; +typedef unsigned int LibOIE_uint32; +typedef unsigned long long LibOIE_uint64; +typedef char LibOIE_int8; +typedef short LibOIE_int16; +typedef int LibOIE_int32; +typedef long long LibOIE_int64; + +#else // LIBOIE_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibOIE_uint8; +typedef uint16_t LibOIE_uint16; +typedef uint32_t LibOIE_uint32; +typedef uint64_t LibOIE_uint64; +typedef int8_t LibOIE_int8; +typedef int16_t LibOIE_int16; +typedef int32_t LibOIE_int32; +typedef int64_t LibOIE_int64 ; + +#endif // LIBOIE_USELEGACYINTEGERTYPES + +typedef float LibOIE_single; +typedef double LibOIE_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibOIE_int32 LibOIEResult; +typedef void * LibOIEHandle; +typedef void * LibOIE_pvoid; + +/************************************************************************************************************************* + Version for LibOIE +**************************************************************************************************************************/ + +#define LIBOIE_VERSION_MAJOR 1 +#define LIBOIE_VERSION_MINOR 0 +#define LIBOIE_VERSION_MICRO 0 +#define LIBOIE_VERSION_PRERELEASEINFO "" +#define LIBOIE_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibOIE +**************************************************************************************************************************/ + +#define LIBOIE_SUCCESS 0 +#define LIBOIE_ERROR_NOTIMPLEMENTED 1 +#define LIBOIE_ERROR_INVALIDPARAM 2 +#define LIBOIE_ERROR_INVALIDCAST 3 +#define LIBOIE_ERROR_BUFFERTOOSMALL 4 +#define LIBOIE_ERROR_GENERICEXCEPTION 5 +#define LIBOIE_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBOIE_ERROR_INCOMPATIBLEBINARYVERSION 8 + +/************************************************************************************************************************* + Error strings for LibOIE +**************************************************************************************************************************/ + +inline const char * LIBOIE_GETERRORSTRING (LibOIEResult nErrorCode) { + switch (nErrorCode) { + case LIBOIE_SUCCESS: return "no error"; + case LIBOIE_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBOIE_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBOIE_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBOIE_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBOIE_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBOIE_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBOIE_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibOIEHandle LibOIE_Base; +typedef LibOIEHandle LibOIE_Iterator; +typedef LibOIEHandle LibOIE_DataPackage; +typedef LibOIEHandle LibOIE_PyroDataPackage; +typedef LibOIEHandle LibOIE_PyroDataPackageIterator; +typedef LibOIEHandle LibOIE_OctDataPackage; +typedef LibOIEHandle LibOIE_OctDataPackageIterator; +typedef LibOIEHandle LibOIE_RemoteFunctionCall; +typedef LibOIEHandle LibOIE_Connection; +typedef LibOIEHandle LibOIE_ConnectionIterator; +typedef LibOIEHandle LibOIE_Server; + +namespace LibOIE { + + /************************************************************************************************************************* + Declaration of function pointers + **************************************************************************************************************************/ + + /** + * ConnectionAcceptedCallback - A callback that is triggered when a device or application has connected. + * + * @param[in] pConnectionInstance - Returns whether the calculation should be aborted + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ConnectionAcceptedCallback)(LibOIE_Connection, LibOIE_pvoid); + + /** + * ConnectionRejectedCallback - A callback that is triggered when a device or application has been denied connecting. + * + * @param[in] pDeviceName - Device name that was sent. + * @param[in] pApplicationName - Application name that was sent. + * @param[in] pVersionName - Version name that was sent. + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ConnectionRejectedCallback)(const char *, const char *, const char *, LibOIE_pvoid); + + /** + * ConnectionErrorCallback - A callback that is triggered when a connection sends an error state. + * + * @param[in] pErrorMessage - Error string that was triggered. + */ + typedef void(*ConnectionErrorCallback)(const char *); + +} // namespace LibOIE; + +// define legacy C-names for enums, structs and function types +typedef LibOIE::ConnectionAcceptedCallback LibOIEConnectionAcceptedCallback; +typedef LibOIE::ConnectionRejectedCallback LibOIEConnectionRejectedCallback; +typedef LibOIE::ConnectionErrorCallback LibOIEConnectionErrorCallback; + +#endif // __LIBOIE_TYPES_HEADER_CPP diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie.cpp new file mode 100644 index 00000000..43775b1a --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie.cpp @@ -0,0 +1,78 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ implementation file in order to allow easy +development of ScanLab Open Interface Extension. It needs to be generated only once. + +Interface version: 1.0.0 + +*/ + +#include "liboie_abi.hpp" +#include "liboie_interfaces.hpp" +#include "liboie_interfaceexception.hpp" +#include "liboie_server.hpp" + +using namespace LibOIE; +using namespace LibOIE::Impl; + +void CWrapper::GetVersion(LibOIE_uint32 & nMajor, LibOIE_uint32 & nMinor, LibOIE_uint32 & nMicro) +{ + nMajor = LIBOIE_VERSION_MAJOR; + nMinor = LIBOIE_VERSION_MINOR; + nMicro = LIBOIE_VERSION_MICRO; +} + +bool CWrapper::GetLastError(IBase* pInstance, std::string & sErrorMessage) +{ + if (pInstance) { + return pInstance->GetLastErrorMessage (sErrorMessage); + } else { + return false; + } +} + +void CWrapper::ReleaseInstance(IBase* pInstance) +{ + IBase::ReleaseBaseClassInterface(pInstance); +} + +void CWrapper::AcquireInstance(IBase* pInstance) +{ + IBase::AcquireBaseClassInterface(pInstance); +} + +IServer * CWrapper::CreateServer() +{ + return new CServer(); +} + + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.cpp new file mode 100644 index 00000000..fc00fbdc --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.cpp @@ -0,0 +1,84 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CBase + +*/ + +#include "liboie_base.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CBase +**************************************************************************************************************************/ + +bool CBase::GetLastErrorMessage(std::string & sErrorMessage) +{ + if (m_pLastError.get() != nullptr) { + sErrorMessage = *m_pLastError; + return true; + } else { + sErrorMessage = ""; + return false; + } +} + +void CBase::ClearErrorMessages() +{ + m_pLastError.reset(); +} + +void CBase::RegisterErrorMessage(const std::string & sErrorMessage) +{ + if (m_pLastError.get() == nullptr) { + m_pLastError.reset(new std::string()); + } + *m_pLastError = sErrorMessage; +} + +void CBase::IncRefCount() +{ + ++m_nReferenceCount; +} + +bool CBase::DecRefCount() +{ + m_nReferenceCount--; + if (!m_nReferenceCount) { + delete this; + return true; + } + return false; +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.hpp new file mode 100644 index 00000000..ab04e706 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_base.hpp @@ -0,0 +1,97 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CBase + +*/ + + +#ifndef __LIBOIE_BASE +#define __LIBOIE_BASE + +#include "liboie_interfaces.hpp" +#include +#include +#include + + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CBase +**************************************************************************************************************************/ + +class CBase : public virtual IBase { +private: + + std::unique_ptr m_pLastError; + uint32_t m_nReferenceCount = 1; + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + bool GetLastErrorMessage(std::string & sErrorMessage) override; + + void ClearErrorMessages() override; + + void RegisterErrorMessage(const std::string & sErrorMessage) override; + + void IncRefCount() override; + + bool DecRefCount() override; + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace LibOIE + +#endif // __LIBOIE_BASE diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.cpp new file mode 100644 index 00000000..d6eb8c49 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.cpp @@ -0,0 +1,135 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CConnection + +*/ + +#include "liboie_connection.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CConnection +**************************************************************************************************************************/ + +void CConnection::Disconnect() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetRequestTimeout(const LibOIE_uint32 nTimeout) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetMaxErrorCount(const LibOIE_uint32 nErrorCount) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetMaxMemoryCount(const LibOIE_uint32 nMaxMemoryCount) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetBufferFile(const std::string & sFileName, const LibOIE_uint64 nMaxMemoryCount) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::UnsetBufferFile() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetCheckAliveInterval(const LibOIE_uint32 nCheckAliveInterval) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::RetrieveFirmwareVersion(const std::string & sFirmwareName, std::string & sFirmwareVersion, std::string & sFilename, std::string & sFiledate, std::string & sSHA256) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::UpdateFirmware(const std::string & sFirmwareName, const std::string & sFirmwareVersion, const std::string & sFileName, const std::string & sFileDate, const std::string & sSHA256, const LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +bool CConnection::StartFirmware(const std::string & sFileName) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +bool CConnection::StopFirmware(const std::string & sFileName) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::SetConnectionErrorCallback(const LibOIE::ConnectionErrorCallback pCallback) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::ClearErrors() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +LibOIE_uint32 CConnection::GetErrorCount() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CConnection::GetError(const LibOIE_uint32 nErrorIndex, std::string & sErrorMessage, std::string & sTimestamp) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IRemoteFunctionCall * CConnection::CreateRemoteFunctionCall(const std::string & sFunctionName) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IPyroDataPackageIterator * CConnection::GetBufferedPyroPackages() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IOctDataPackageIterator * CConnection::GetBufferedOctPackages() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.hpp new file mode 100644 index 00000000..c15060b5 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connection.hpp @@ -0,0 +1,126 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CConnection + +*/ + + +#ifndef __LIBOIE_CONNECTION +#define __LIBOIE_CONNECTION + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CConnection +**************************************************************************************************************************/ + +class CConnection : public virtual IConnection, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + void Disconnect() override; + + void SetRequestTimeout(const LibOIE_uint32 nTimeout) override; + + void SetMaxErrorCount(const LibOIE_uint32 nErrorCount) override; + + void SetMaxMemoryCount(const LibOIE_uint32 nMaxMemoryCount) override; + + void SetBufferFile(const std::string & sFileName, const LibOIE_uint64 nMaxMemoryCount) override; + + void UnsetBufferFile() override; + + void SetCheckAliveInterval(const LibOIE_uint32 nCheckAliveInterval) override; + + void RetrieveFirmwareVersion(const std::string & sFirmwareName, std::string & sFirmwareVersion, std::string & sFilename, std::string & sFiledate, std::string & sSHA256) override; + + void UpdateFirmware(const std::string & sFirmwareName, const std::string & sFirmwareVersion, const std::string & sFileName, const std::string & sFileDate, const std::string & sSHA256, const LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer) override; + + bool StartFirmware(const std::string & sFileName) override; + + bool StopFirmware(const std::string & sFileName) override; + + void SetConnectionErrorCallback(const LibOIE::ConnectionErrorCallback pCallback) override; + + void ClearErrors() override; + + LibOIE_uint32 GetErrorCount() override; + + void GetError(const LibOIE_uint32 nErrorIndex, std::string & sErrorMessage, std::string & sTimestamp) override; + + IRemoteFunctionCall * CreateRemoteFunctionCall(const std::string & sFunctionName) override; + + IPyroDataPackageIterator * GetBufferedPyroPackages() override; + + IOctDataPackageIterator * GetBufferedOctPackages() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_CONNECTION diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.cpp new file mode 100644 index 00000000..3199980f --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.cpp @@ -0,0 +1,50 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CConnectionIterator + +*/ + +#include "liboie_connectioniterator.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CConnectionIterator +**************************************************************************************************************************/ + +IConnection * CConnectionIterator::GetCurrentConnection() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.hpp new file mode 100644 index 00000000..9b44c7c9 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_connectioniterator.hpp @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CConnectionIterator + +*/ + + +#ifndef __LIBOIE_CONNECTIONITERATOR +#define __LIBOIE_CONNECTIONITERATOR + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CConnectionIterator +**************************************************************************************************************************/ + +class CConnectionIterator : public virtual IConnectionIterator, public virtual CIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + IConnection * GetCurrentConnection() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_CONNECTIONITERATOR diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.cpp new file mode 100644 index 00000000..552fabec --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.cpp @@ -0,0 +1,55 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CDataPackage + +*/ + +#include "liboie_datapackage.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CDataPackage +**************************************************************************************************************************/ + +void CDataPackage::GetRawPayload(LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CDataPackage::Release() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.hpp new file mode 100644 index 00000000..74bedb0b --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_datapackage.hpp @@ -0,0 +1,94 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CDataPackage + +*/ + + +#ifndef __LIBOIE_DATAPACKAGE +#define __LIBOIE_DATAPACKAGE + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CDataPackage +**************************************************************************************************************************/ + +class CDataPackage : public virtual IDataPackage, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + void GetRawPayload(LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer) override; + + void Release() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_DATAPACKAGE diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.cpp new file mode 100644 index 00000000..026c6fe0 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.cpp @@ -0,0 +1,70 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CIterator + +*/ + +#include "liboie_iterator.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CIterator +**************************************************************************************************************************/ + +bool CIterator::MoveNext() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +bool CIterator::MovePrevious() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IBase * CIterator::GetCurrent() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IIterator * CIterator::Clone() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +LibOIE_uint64 CIterator::Count() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.hpp new file mode 100644 index 00000000..1093addc --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_iterator.hpp @@ -0,0 +1,100 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CIterator + +*/ + + +#ifndef __LIBOIE_ITERATOR +#define __LIBOIE_ITERATOR + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CIterator +**************************************************************************************************************************/ + +class CIterator : public virtual IIterator, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + bool MoveNext() override; + + bool MovePrevious() override; + + IBase * GetCurrent() override; + + IIterator * Clone() override; + + LibOIE_uint64 Count() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_ITERATOR diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.cpp new file mode 100644 index 00000000..55fbd00f --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.cpp @@ -0,0 +1,45 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of COctDataPackage + +*/ + +#include "liboie_octdatapackage.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of COctDataPackage +**************************************************************************************************************************/ + diff --git a/Implementation/LibMC/libmc_apiresponse.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.hpp similarity index 57% rename from Implementation/LibMC/libmc_apiresponse.hpp rename to Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.hpp index b2a7e4ed..dc9ce7b4 100644 --- a/Implementation/LibMC/libmc_apiresponse.hpp +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackage.hpp @@ -6,16 +6,16 @@ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Autodesk Inc. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY @@ -26,18 +26,19 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +Abstract: This is the class declaration of COctDataPackage + +*/ -#ifndef __LIBMC_APIRESPONSE -#define __LIBMC_APIRESPONSE -#include "libmc_interfaces.hpp" +#ifndef __LIBOIE_OCTDATAPACKAGE +#define __LIBOIE_OCTDATAPACKAGE -#include "API/amc_api_response.hpp" +#include "liboie_interfaces.hpp" // Parent classes -#include "libmc_base.hpp" +#include "liboie_datapackage.hpp" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4250) @@ -46,39 +47,44 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Include custom headers here. -namespace LibMC { +namespace LibOIE { namespace Impl { /************************************************************************************************************************* - Class declaration of CAPIResponse + Class declaration of COctDataPackage **************************************************************************************************************************/ -class CAPIResponse : public virtual IAPIResponse, public virtual CBase { +class COctDataPackage : public virtual IOctDataPackage, public virtual CDataPackage { private: - AMC::PAPIResponse m_pResponse; - - uint32_t m_nErrorCode; + /** + * Put private members here. + */ protected: -public: + /** + * Put protected members here. + */ - CAPIResponse (AMC::PAPIResponse pResponse, uint32_t nErrorCode); +public: - LibMC_uint32 GetHTTPCode() override; + /** + * Put additional public members here. They will not be visible in the external API. + */ - std::string GetContentType() override; - void GetData(LibMC_uint64 nDataBufferSize, LibMC_uint64* pDataNeededCount, LibMC_uint8 * pDataBuffer) override; + /** + * Public member functions to implement. + */ }; } // namespace Impl -} // namespace LibMC +} // namespace LibOIE #ifdef _MSC_VER #pragma warning(pop) #endif -#endif // __LIBMC_APIRESPONSE +#endif // __LIBOIE_OCTDATAPACKAGE diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.cpp new file mode 100644 index 00000000..a98ea82b --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.cpp @@ -0,0 +1,50 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of COctDataPackageIterator + +*/ + +#include "liboie_octdatapackageiterator.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of COctDataPackageIterator +**************************************************************************************************************************/ + +IOctDataPackage * COctDataPackageIterator::GetCurrentOctDataPackage() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.hpp new file mode 100644 index 00000000..2aef70c8 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_octdatapackageiterator.hpp @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of COctDataPackageIterator + +*/ + + +#ifndef __LIBOIE_OCTDATAPACKAGEITERATOR +#define __LIBOIE_OCTDATAPACKAGEITERATOR + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of COctDataPackageIterator +**************************************************************************************************************************/ + +class COctDataPackageIterator : public virtual IOctDataPackageIterator, public virtual CIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + IOctDataPackage * GetCurrentOctDataPackage() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_OCTDATAPACKAGEITERATOR diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.cpp new file mode 100644 index 00000000..332f9474 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.cpp @@ -0,0 +1,45 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CPyroDataPackage + +*/ + +#include "liboie_pyrodatapackage.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CPyroDataPackage +**************************************************************************************************************************/ + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.hpp new file mode 100644 index 00000000..ec118be5 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackage.hpp @@ -0,0 +1,90 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CPyroDataPackage + +*/ + + +#ifndef __LIBOIE_PYRODATAPACKAGE +#define __LIBOIE_PYRODATAPACKAGE + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_datapackage.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CPyroDataPackage +**************************************************************************************************************************/ + +class CPyroDataPackage : public virtual IPyroDataPackage, public virtual CDataPackage { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_PYRODATAPACKAGE diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.cpp new file mode 100644 index 00000000..e4c825f4 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.cpp @@ -0,0 +1,50 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CPyroDataPackageIterator + +*/ + +#include "liboie_pyrodatapackageiterator.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CPyroDataPackageIterator +**************************************************************************************************************************/ + +IPyroDataPackage * CPyroDataPackageIterator::GetCurrentPyroDataPackage() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.hpp new file mode 100644 index 00000000..edd551ab --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_pyrodatapackageiterator.hpp @@ -0,0 +1,92 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CPyroDataPackageIterator + +*/ + + +#ifndef __LIBOIE_PYRODATAPACKAGEITERATOR +#define __LIBOIE_PYRODATAPACKAGEITERATOR + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CPyroDataPackageIterator +**************************************************************************************************************************/ + +class CPyroDataPackageIterator : public virtual IPyroDataPackageIterator, public virtual CIterator { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + IPyroDataPackage * GetCurrentPyroDataPackage() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_PYRODATAPACKAGEITERATOR diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.cpp new file mode 100644 index 00000000..097aa406 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.cpp @@ -0,0 +1,60 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CRemoteFunctionCall + +*/ + +#include "liboie_remotefunctioncall.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CRemoteFunctionCall +**************************************************************************************************************************/ + +std::string CRemoteFunctionCall::GetFunctionName() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CRemoteFunctionCall::AddParameter(const std::string & sParameter) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +std::string CRemoteFunctionCall::Send() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.hpp new file mode 100644 index 00000000..87768e4b --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_remotefunctioncall.hpp @@ -0,0 +1,96 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CRemoteFunctionCall + +*/ + + +#ifndef __LIBOIE_REMOTEFUNCTIONCALL +#define __LIBOIE_REMOTEFUNCTIONCALL + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CRemoteFunctionCall +**************************************************************************************************************************/ + +class CRemoteFunctionCall : public virtual IRemoteFunctionCall, public virtual CBase { +private: + + /** + * Put private members here. + */ + +protected: + + /** + * Put protected members here. + */ + +public: + + /** + * Put additional public members here. They will not be visible in the external API. + */ + + + /** + * Public member functions to implement. + */ + + std::string GetFunctionName() override; + + void AddParameter(const std::string & sParameter) override; + + std::string Send() override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_REMOTEFUNCTIONCALL diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.cpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.cpp new file mode 100644 index 00000000..277d3318 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.cpp @@ -0,0 +1,161 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CServer + +*/ + +#include "liboie_server.hpp" +#include "liboie_interfaceexception.hpp" + +// Include custom headers here. +#include +#include +#include +#include + +using namespace LibOIE::Impl; + +/************************************************************************************************************************* + Class definition of CServer +**************************************************************************************************************************/ + +CServer::CServer() + : m_nThreadCount (LIBOIE_THREADCOUNT_DEFAULT), m_nReceiveBufferSize (LIBOIE_RECEIVEBUFFERSIZE_DEFAULT) +{ + +} + + +void CServer::Start(const std::string& sIPAddress, const LibOIE_uint32 nPort, const bool bIPv6) +{ + + + m_pService = brynet::net::TcpService::Create(); + + m_pService->startWorkerThread(m_nThreadCount, nullptr); + + auto enterCallback = [](const brynet::net::TcpConnection::Ptr& session) { + //total_client_num++; + + session->setDataCallback([session](const char* buffer, size_t len) { + session->send(buffer, len); + //TotalRecvSize += len; + //total_packet_num++; + return len; + }); + + session->setDisConnectCallback([](const brynet::net::TcpConnection::Ptr& session) { + (void)session; + //total_client_num--; + }); + + }; + + + m_pListener = std::make_shared(); + m_pListener->configureService(m_pService) + .configureSocketOptions({ + [](brynet::net::TcpSocket& socket) { + socket.setNodelay(); + } + }) + .configureConnectionOptions({ + brynet::net::AddSocketOption::WithMaxRecvBufferSize(m_nReceiveBufferSize), + brynet::net::AddSocketOption::AddEnterCallback(enterCallback) + }) + .configureListen([=](brynet::net::wrapper::BuildListenConfig config) { + config.setAddr (bIPv6, sIPAddress, nPort); + }) + .asyncRun(); + +} + + + +void CServer::Stop() +{ + +} + +void CServer::SetThreadCount(const LibOIE_uint32 nThreadCount) +{ + if (nThreadCount < LIBOIE_THREADCOUNT_MIN) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDPARAM); + if (nThreadCount > LIBOIE_THREADCOUNT_MAX) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDPARAM); + m_nThreadCount = nThreadCount; +} + +void CServer::SetBufferSize(const LibOIE_uint32 nRCVBufferSize) +{ + if (nRCVBufferSize < LIBOIE_RECEIVEBUFFERSIZE_MIN) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDPARAM); + if (nRCVBufferSize > LIBOIE_RECEIVEBUFFERSIZE_MAX) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDPARAM); + + m_nReceiveBufferSize = nRCVBufferSize; +} + +void CServer::CloseAllConnections() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + + +LibOIE_uint32 CServer::AcceptDevice(const std::string & sDeviceName, const std::string & sApplicationName, const std::string & sVersionName) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CServer::UnAcceptDevice(const LibOIE_uint32 nRuleID) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CServer::ClearAcceptedDevices() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +IConnectionIterator * CServer::ListConnections() +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CServer::SetConnectionAcceptedCallback(const LibOIE::ConnectionAcceptedCallback pCallback) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + +void CServer::SetConnectionRejectedCallback(const LibOIE::ConnectionRejectedCallback pCallback) +{ + throw ELibOIEInterfaceException(LIBOIE_ERROR_NOTIMPLEMENTED); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.hpp b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.hpp new file mode 100644 index 00000000..dca28438 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Implementation/liboie_server.hpp @@ -0,0 +1,120 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CServer + +*/ + + +#ifndef __LIBOIE_SERVER +#define __LIBOIE_SERVER + +#include "liboie_interfaces.hpp" + +// Parent classes +#include "liboie_base.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +namespace brynet { + namespace net { + class TcpService; + + namespace wrapper { + class ListenerBuilder; + } + + } +} +#define LIBOIE_THREADCOUNT_MIN 4 +#define LIBOIE_THREADCOUNT_MAX 1024 +#define LIBOIE_THREADCOUNT_DEFAULT 32 + +#define LIBOIE_RECEIVEBUFFERSIZE_MIN 4096 +#define LIBOIE_RECEIVEBUFFERSIZE_MAX (1024 * 1024 * 1024) +#define LIBOIE_RECEIVEBUFFERSIZE_DEFAULT (1024 * 1024) + + +namespace LibOIE { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CServer +**************************************************************************************************************************/ + +class CServer : public virtual IServer, public virtual CBase { +private: + uint32_t m_nThreadCount; + uint32_t m_nReceiveBufferSize; + + std::shared_ptr m_pService; + std::shared_ptr m_pListener; + +protected: + + +public: + + CServer(); + + void Start(const std::string & sIPAddress, const LibOIE_uint32 nPort, const bool bIPv6) override; + + void Stop() override; + + void CloseAllConnections() override; + + void SetThreadCount(const LibOIE_uint32 nThreadCount) override; + + void SetBufferSize(const LibOIE_uint32 nRCVBufferSize) override; + + LibOIE_uint32 AcceptDevice(const std::string & sDeviceName, const std::string & sApplicationName, const std::string & sVersionName) override; + + void UnAcceptDevice(const LibOIE_uint32 nRuleID) override; + + void ClearAcceptedDevices() override; + + IConnectionIterator * ListConnections() override; + + void SetConnectionAcceptedCallback(const LibOIE::ConnectionAcceptedCallback pCallback) override; + + void SetConnectionRejectedCallback(const LibOIE::ConnectionRejectedCallback pCallback) override; + +}; + +} // namespace Impl +} // namespace LibOIE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBOIE_SERVER diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_abi.hpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_abi.hpp new file mode 100644 index 00000000..6aee6dc5 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_abi.hpp @@ -0,0 +1,576 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file in order to allow an easy + use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_HEADER_CPP +#define __LIBOIE_HEADER_CPP + +#ifdef __LIBOIE_EXPORTS +#ifdef _WIN32 +#define LIBOIE_DECLSPEC __declspec (dllexport) +#else // _WIN32 +#define LIBOIE_DECLSPEC __attribute__((visibility("default"))) +#endif // _WIN32 +#else // __LIBOIE_EXPORTS +#define LIBOIE_DECLSPEC +#endif // __LIBOIE_EXPORTS + +#include "liboie_types.hpp" + + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************************************* + Class definition for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for Iterator +**************************************************************************************************************************/ + +/** +* Iterates to the next resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasNext - Iterates to the next resource in the list. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_movenext(LibOIE_Iterator pIterator, bool * pHasNext); + +/** +* Iterates to the previous resource in the list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pHasPrevious - Iterates to the previous resource in the list. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_moveprevious(LibOIE_Iterator pIterator, bool * pHasPrevious); + +/** +* Returns the resource the iterator points at. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCurrentInstance - returns the resource instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_getcurrent(LibOIE_Iterator pIterator, LibOIE_Base * pCurrentInstance); + +/** +* Creates a new resource iterator with the same resource list. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pOutIterator - returns the cloned Iterator instance +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_clone(LibOIE_Iterator pIterator, LibOIE_Iterator * pOutIterator); + +/** +* Returns the number of resoucres the iterator captures. +* +* @param[in] pIterator - Iterator instance. +* @param[out] pCount - returns the number of resources the iterator captures. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_iterator_count(LibOIE_Iterator pIterator, LibOIE_uint64 * pCount); + +/************************************************************************************************************************* + Class definition for DataPackage +**************************************************************************************************************************/ + +/** +* Returns the raw payload. +* +* @param[in] pDataPackage - DataPackage instance. +* @param[in] nPayloadBufferSize - Number of elements in buffer +* @param[out] pPayloadNeededCount - will be filled with the count of the written elements, or needed buffer size. +* @param[out] pPayloadBuffer - uint8 buffer of Raw payload data. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_datapackage_getrawpayload(LibOIE_DataPackage pDataPackage, const LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer); + +/** +* Releases memory of the data package. +* +* @param[in] pDataPackage - DataPackage instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_datapackage_release(LibOIE_DataPackage pDataPackage); + +/************************************************************************************************************************* + Class definition for PyroDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for PyroDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pPyroDataPackageIterator - PyroDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_pyrodatapackageiterator_getcurrentpyrodatapackage(LibOIE_PyroDataPackageIterator pPyroDataPackageIterator, LibOIE_PyroDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for OctDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class definition for OctDataPackageIterator +**************************************************************************************************************************/ + +/** +* Returns the data package the iterator points at. +* +* @param[in] pOctDataPackageIterator - OctDataPackageIterator instance. +* @param[out] pCurrentInstance - returns the data package instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_octdatapackageiterator_getcurrentoctdatapackage(LibOIE_OctDataPackageIterator pOctDataPackageIterator, LibOIE_OctDataPackage * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for RemoteFunctionCall +**************************************************************************************************************************/ + +/** +* Returns function name +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nFunctionNameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFunctionNameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFunctionNameBuffer - buffer of Function Name., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_getfunctionname(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nFunctionNameBufferSize, LibOIE_uint32* pFunctionNameNeededChars, char * pFunctionNameBuffer); + +/** +* Adds a function call parameter +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] pParameter - Parameter of the call. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_addparameter(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const char * pParameter); + +/** +* Sends a remote function call over its connection. +* +* @param[in] pRemoteFunctionCall - RemoteFunctionCall instance. +* @param[in] nResultStringBufferSize - size of the buffer (including trailing 0) +* @param[out] pResultStringNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pResultStringBuffer - buffer of Returns result if successful., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_remotefunctioncall_send(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nResultStringBufferSize, LibOIE_uint32* pResultStringNeededChars, char * pResultStringBuffer); + +/************************************************************************************************************************* + Class definition for Connection +**************************************************************************************************************************/ + +/** +* Disconnects and closes the connection +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_disconnect(LibOIE_Connection pConnection); + +/** +* Sets timeout value for each poll request below. +* +* @param[in] pConnection - Connection instance. +* @param[in] nTimeout - Timeout in milliseconds. Default is 1000ms. Minimum 10ms, maximum 1000000ms. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setrequesttimeout(LibOIE_Connection pConnection, LibOIE_uint32 nTimeout); + +/** +* Sets the maximum error messages that can be received before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorCount - Max Error count. Default is 1024. Minimum 16, maximum 65535. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setmaxerrorcount(LibOIE_Connection pConnection, LibOIE_uint32 nErrorCount); + +/** +* Sets the maximum memory buffer the data packets can use before the connection is terminated. +* +* @param[in] pConnection - Connection instance. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1GB. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setmaxmemorycount(LibOIE_Connection pConnection, LibOIE_uint32 nMaxMemoryCount); + +/** +* Sets a temporary filename to which the packets are buffered. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename which should be used as buffer. +* @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1TB. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setbufferfile(LibOIE_Connection pConnection, const char * pFileName, LibOIE_uint64 nMaxMemoryCount); + +/** +* Stops writing to disk. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_unsetbufferfile(LibOIE_Connection pConnection); + +/** +* Sets check alive interval. 0ms means no check alive request is sent. +* +* @param[in] pConnection - Connection instance. +* @param[in] nCheckAliveInterval - Timeout in milliseconds. Default is 1000ms. Max value is 1000000ms. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setcheckaliveinterval(LibOIE_Connection pConnection, LibOIE_uint32 nCheckAliveInterval); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the firmware to retrieve. +* @param[in] nFirmwareVersionBufferSize - size of the buffer (including trailing 0) +* @param[out] pFirmwareVersionNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFirmwareVersionBuffer - buffer of Version of the requested firmware., may be NULL +* @param[in] nFilenameBufferSize - size of the buffer (including trailing 0) +* @param[out] pFilenameNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFilenameBuffer - buffer of Filename of the requested firmware., may be NULL +* @param[in] nFiledateBufferSize - size of the buffer (including trailing 0) +* @param[out] pFiledateNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pFiledateBuffer - buffer of Timestamp of the requested firmware in ISO8601 Time., may be NULL +* @param[in] nSHA256BufferSize - size of the buffer (including trailing 0) +* @param[out] pSHA256NeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pSHA256Buffer - buffer of Checksum of the requested firmware., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_retrievefirmwareversion(LibOIE_Connection pConnection, const char * pFirmwareName, const LibOIE_uint32 nFirmwareVersionBufferSize, LibOIE_uint32* pFirmwareVersionNeededChars, char * pFirmwareVersionBuffer, const LibOIE_uint32 nFilenameBufferSize, LibOIE_uint32* pFilenameNeededChars, char * pFilenameBuffer, const LibOIE_uint32 nFiledateBufferSize, LibOIE_uint32* pFiledateNeededChars, char * pFiledateBuffer, const LibOIE_uint32 nSHA256BufferSize, LibOIE_uint32* pSHA256NeededChars, char * pSHA256Buffer); + +/** +* Retrieves Firmware Version. Fails if firmware is not existing. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFirmwareName - Name of the new firmware. +* @param[in] pFirmwareVersion - Version of the new firmware. +* @param[in] pFileName - Filename of the new firmware. +* @param[in] pFileDate - Timestamp of the requested firmware in ISO8601 Time. +* @param[in] pSHA256 - Checksum of the new firmware. +* @param[in] nBinaryDataBufferSize - Number of elements in buffer +* @param[in] pBinaryDataBuffer - uint8 buffer of Blob of new firmware. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_updatefirmware(LibOIE_Connection pConnection, const char * pFirmwareName, const char * pFirmwareVersion, const char * pFileName, const char * pFileDate, const char * pSHA256, LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer); + +/** +* Starts firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to start. +* @param[out] pSuccess - Firmware successfully started. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_startfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* Stops firmware on Open Interface Extension. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFileName - Filename of the firmware to stop. +* @param[out] pSuccess - Firmware successfully stopped. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_stopfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess); + +/** +* sets a callback that triggers when a connection error occured. +* +* @param[in] pConnection - Connection instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_setconnectionerrorcallback(LibOIE_Connection pConnection, LibOIE::ConnectionErrorCallback pCallback); + +/** +* clears the error log. +* +* @param[in] pConnection - Connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_clearerrors(LibOIE_Connection pConnection); + +/** +* Returns the list of errors in the error log. +* +* @param[in] pConnection - Connection instance. +* @param[out] pErrorCount - Errors in the error log. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_geterrorcount(LibOIE_Connection pConnection, LibOIE_uint32 * pErrorCount); + +/** +* Returns an error message of the error log +* +* @param[in] pConnection - Connection instance. +* @param[in] nErrorIndex - Index of the error. +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the error., may be NULL +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of ISO8601 Time when the error was reported., may be NULL +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_geterror(LibOIE_Connection pConnection, LibOIE_uint32 nErrorIndex, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, const LibOIE_uint32 nTimestampBufferSize, LibOIE_uint32* pTimestampNeededChars, char * pTimestampBuffer); + +/** +* Creates a new remote function call. +* +* @param[in] pConnection - Connection instance. +* @param[in] pFunctionName - Function name. +* @param[out] pInstance - Function call instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_createremotefunctioncall(LibOIE_Connection pConnection, const char * pFunctionName, LibOIE_RemoteFunctionCall * pInstance); + +/** +* Retrieves currently buffered pyro packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_getbufferedpyropackages(LibOIE_Connection pConnection, LibOIE_PyroDataPackageIterator * pIterator); + +/** +* Retrieves currently buffered oct packages. +* +* @param[in] pConnection - Connection instance. +* @param[out] pIterator - Iterator of buffered packages. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connection_getbufferedoctpackages(LibOIE_Connection pConnection, LibOIE_OctDataPackageIterator * pIterator); + +/************************************************************************************************************************* + Class definition for ConnectionIterator +**************************************************************************************************************************/ + +/** +* Returns the connection the iterator points at. +* +* @param[in] pConnectionIterator - ConnectionIterator instance. +* @param[out] pCurrentInstance - returns the connection instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_connectioniterator_getcurrentconnection(LibOIE_ConnectionIterator pConnectionIterator, LibOIE_Connection * pCurrentInstance); + +/************************************************************************************************************************* + Class definition for Server +**************************************************************************************************************************/ + +/** +* starts listening for connections. +* +* @param[in] pServer - Server instance. +* @param[in] pIPAddress - IP Address to run on +* @param[in] nPort - Port to run on +* @param[in] bIPv6 - flag if IPv6 should be used +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_start(LibOIE_Server pServer, const char * pIPAddress, LibOIE_uint32 nPort, bool bIPv6); + +/** +* stops listening for connections and disconnects existing ones. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_stop(LibOIE_Server pServer); + +/** +* disconnects all connections but does not stop listening. +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_closeallconnections(LibOIE_Server pServer); + +/** +* sets the maximum thread count to use. Must be called before Start +* +* @param[in] pServer - Server instance. +* @param[in] nThreadCount - Thread count to use (must be larger than 4, default is 32) +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setthreadcount(LibOIE_Server pServer, LibOIE_uint32 nThreadCount); + +/** +* sets the receive buffer size +* +* @param[in] pServer - Server instance. +* @param[in] nRCVBufferSize - Receive buffer size to use in bytes (must be between 4kB and 1GB, default is 1MB) +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setbuffersize(LibOIE_Server pServer, LibOIE_uint32 nRCVBufferSize); + +/** +* adds an accepted device +* +* @param[in] pServer - Server instance. +* @param[in] pDeviceName - Device name to be accepted. Empty string means all devices. +* @param[in] pApplicationName - Application name to be accepted. Empty string means all applications. +* @param[in] pVersionName - Version name to be accepted. Empty string means all versions. +* @param[out] pRuleID - Returns identifier of acceptance rule. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_acceptdevice(LibOIE_Server pServer, const char * pDeviceName, const char * pApplicationName, const char * pVersionName, LibOIE_uint32 * pRuleID); + +/** +* removes an accepted +* +* @param[in] pServer - Server instance. +* @param[in] nRuleID - identifier of acceptance rule. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_unacceptdevice(LibOIE_Server pServer, LibOIE_uint32 nRuleID); + +/** +* clears all accepted device rules +* +* @param[in] pServer - Server instance. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_clearaccepteddevices(LibOIE_Server pServer); + +/** +* lists all open connections +* +* @param[in] pServer - Server instance. +* @param[out] pConnectionIteratorInstance - list of all open connections. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_listconnections(LibOIE_Server pServer, LibOIE_ConnectionIterator * pConnectionIteratorInstance); + +/** +* sets a callback that triggers when a new connection was established. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setconnectionacceptedcallback(LibOIE_Server pServer, LibOIE::ConnectionAcceptedCallback pCallback); + +/** +* sets a callback that triggers when a new connection was rejected. +* +* @param[in] pServer - Server instance. +* @param[in] pCallback - callback pointer. +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_server_setconnectionrejectedcallback(LibOIE_Server pServer, LibOIE::ConnectionRejectedCallback pCallback); + +/************************************************************************************************************************* + Global functions +**************************************************************************************************************************/ + +/** +* retrieves the binary version of this library. +* +* @param[out] pMajor - returns the major version of this library +* @param[out] pMinor - returns the minor version of this library +* @param[out] pMicro - returns the micro version of this library +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getversion(LibOIE_uint32 * pMajor, LibOIE_uint32 * pMinor, LibOIE_uint32 * pMicro); + +/** +* Returns the last error recorded on this object +* +* @param[in] pInstance - Instance Handle +* @param[in] nErrorMessageBufferSize - size of the buffer (including trailing 0) +* @param[out] pErrorMessageNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pErrorMessageBuffer - buffer of Message of the last error, may be NULL +* @param[out] pHasError - Is there a last error to query +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getlasterror(LibOIE_Base pInstance, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError); + +/** +* Releases shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_releaseinstance(LibOIE_Base pInstance); + +/** +* Acquires shared ownership of an Instance +* +* @param[in] pInstance - Instance Handle +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_acquireinstance(LibOIE_Base pInstance); + +/** +* Returns the address of the SymbolLookupMethod +* +* @param[out] pSymbolLookupMethod - Address of the SymbolAddressMethod +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_getsymbollookupmethod(LibOIE_pvoid * pSymbolLookupMethod); + +/** +* Creates a open interface extension server instance. +* +* @param[out] pInstance - New Server instance +* @return error code or 0 (success) +*/ +LIBOIE_DECLSPEC LibOIEResult liboie_createserver(LibOIE_Server * pInstance); + +#ifdef __cplusplus +} +#endif + +#endif // __LIBOIE_HEADER_CPP + diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.cpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.cpp new file mode 100644 index 00000000..99737786 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.cpp @@ -0,0 +1,68 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Implementation file with the basic internal + exception type in order to allow an easy use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + + +#include + +#include "liboie_interfaceexception.hpp" + +/************************************************************************************************************************* + Class ELibOIEInterfaceException +**************************************************************************************************************************/ +ELibOIEInterfaceException::ELibOIEInterfaceException(LibOIEResult errorCode) + : m_errorMessage(LIBOIE_GETERRORSTRING (errorCode)) +{ + m_errorCode = errorCode; +} + +ELibOIEInterfaceException::ELibOIEInterfaceException(LibOIEResult errorCode, std::string errorMessage) + : m_errorMessage(errorMessage + " (" + std::to_string (errorCode) + ")") +{ + m_errorCode = errorCode; +} + +LibOIEResult ELibOIEInterfaceException::getErrorCode () +{ + return m_errorCode; +} + +const char * ELibOIEInterfaceException::what () const noexcept +{ + return m_errorMessage.c_str(); +} + diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.hpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.hpp new file mode 100644 index 00000000..f214c4c8 --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaceexception.hpp @@ -0,0 +1,83 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ Header file with the basic internal + exception type in order to allow an easy use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_INTERFACEEXCEPTION_HEADER +#define __LIBOIE_INTERFACEEXCEPTION_HEADER + +#include +#include +#include "liboie_types.hpp" + +/************************************************************************************************************************* + Class ELibOIEInterfaceException +**************************************************************************************************************************/ + + +class ELibOIEInterfaceException : public std::exception { +protected: + /** + * Error code for the Exception. + */ + LibOIEResult m_errorCode; + /** + * Error message for the Exception. + */ + std::string m_errorMessage; + +public: + /** + * Exception Constructor. + */ + ELibOIEInterfaceException(LibOIEResult errorCode); + + /** + * Custom Exception Constructor. + */ + ELibOIEInterfaceException(LibOIEResult errorCode, std::string errorMessage); + + /** + * Returns error code + */ + LibOIEResult getErrorCode(); + /** + * Returns error message + */ + const char* what() const noexcept override; +}; + +#endif // __LIBOIE_INTERFACEEXCEPTION_HEADER diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaces.hpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaces.hpp new file mode 100644 index 00000000..d9fa5a8a --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfaces.hpp @@ -0,0 +1,693 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ header file in order to allow easy +development of ScanLab Open Interface Extension. The implementer of ScanLab Open Interface Extension needs to +derive concrete classes from the abstract classes in this header. + +Interface version: 1.0.0 + +*/ + + +#ifndef __LIBOIE_CPPINTERFACES +#define __LIBOIE_CPPINTERFACES + +#include +#include + +#include "liboie_types.hpp" + + + +namespace LibOIE { +namespace Impl { + +/** + Forward declarations of class interfaces +*/ +class IBase; +class IIterator; +class IDataPackage; +class IPyroDataPackage; +class IPyroDataPackageIterator; +class IOctDataPackage; +class IOctDataPackageIterator; +class IRemoteFunctionCall; +class IConnection; +class IConnectionIterator; +class IServer; + + + +/************************************************************************************************************************* + Parameter Cache definitions +**************************************************************************************************************************/ + +class ParameterCache { + public: + virtual ~ParameterCache() {} +}; + +template class ParameterCache_1 : public ParameterCache { + private: + T1 m_param1; + public: + ParameterCache_1 (const T1 & param1) + : m_param1 (param1) + { + } + + void retrieveData (T1 & param1) + { + param1 = m_param1; + } +}; + +template class ParameterCache_2 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + public: + ParameterCache_2 (const T1 & param1, const T2 & param2) + : m_param1 (param1), m_param2 (param2) + { + } + + void retrieveData (T1 & param1, T2 & param2) + { + param1 = m_param1; + param2 = m_param2; + } +}; + +template class ParameterCache_3 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + public: + ParameterCache_3 (const T1 & param1, const T2 & param2, const T3 & param3) + : m_param1 (param1), m_param2 (param2), m_param3 (param3) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + } +}; + +template class ParameterCache_4 : public ParameterCache { + private: + T1 m_param1; + T2 m_param2; + T3 m_param3; + T4 m_param4; + public: + ParameterCache_4 (const T1 & param1, const T2 & param2, const T3 & param3, const T4 & param4) + : m_param1 (param1), m_param2 (param2), m_param3 (param3), m_param4 (param4) + { + } + + void retrieveData (T1 & param1, T2 & param2, T3 & param3, T4 & param4) + { + param1 = m_param1; + param2 = m_param2; + param3 = m_param3; + param4 = m_param4; + } +}; + + +/************************************************************************************************************************* + Class interface for Base +**************************************************************************************************************************/ + +class IBase { +private: + std::unique_ptr m_ParameterCache; +public: + /** + * IBase::~IBase - virtual destructor of IBase + */ + virtual ~IBase() {}; + + /** + * IBase::ReleaseBaseClassInterface - Releases ownership of a base class interface. Deletes the reference, if necessary. + * @param[in] pIBase - The base class instance to release + */ + static void ReleaseBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->DecRefCount(); + } + }; + + /** + * IBase::AcquireBaseClassInterface - Acquires shared ownership of a base class interface. + * @param[in] pIBase - The base class instance to acquire + */ + static void AcquireBaseClassInterface(IBase* pIBase) + { + if (pIBase) { + pIBase->IncRefCount(); + } + }; + + + /** + * IBase::GetLastErrorMessage - Returns the last error registered of this class instance + * @param[out] sErrorMessage - Message of the last error registered + * @return Has an error been registered already + */ + virtual bool GetLastErrorMessage(std::string & sErrorMessage) = 0; + + /** + * IBase::ClearErrorMessages - Clears all registered messages of this class instance + */ + virtual void ClearErrorMessages() = 0; + + /** + * IBase::RegisterErrorMessage - Registers an error message with this class instance + * @param[in] sErrorMessage - Error message to register + */ + virtual void RegisterErrorMessage(const std::string & sErrorMessage) = 0; + + /** + * IBase::IncRefCount - Increases the reference count of a class instance + */ + virtual void IncRefCount() = 0; + + /** + * IBase::DecRefCount - Decreases the reference count of a class instance and free releases it, if the last reference has been removed + * @return Has the object been released + */ + virtual bool DecRefCount() = 0; + + /** + * IBase::_setCache - set parameter cache of object + */ + void _setCache(ParameterCache * pCache) + { + m_ParameterCache.reset(pCache); + } + + /** + * IBase::_getCache - returns parameter cache of object + */ + ParameterCache* _getCache() + { + return m_ParameterCache.get(); + } + +}; + + +/** + Definition of a shared pointer class for IBase +*/ +template +class IBaseSharedPtr : public std::shared_ptr +{ +public: + explicit IBaseSharedPtr(T* t = nullptr) + : std::shared_ptr(t, IBase::ReleaseBaseClassInterface) + { + t->IncRefCount(); + } + + // Reset function, as it also needs to properly set the deleter. + void reset(T* t = nullptr) + { + std::shared_ptr::reset(t, IBase::ReleaseBaseClassInterface); + } + + // Get-function that increases the Base class's reference count + T* getCoOwningPtr() + { + T* t = this->get(); + t->IncRefCount(); + return t; + } +}; + + +typedef IBaseSharedPtr PIBase; + + +/************************************************************************************************************************* + Class interface for Iterator +**************************************************************************************************************************/ + +class IIterator : public virtual IBase { +public: + /** + * IIterator::MoveNext - Iterates to the next resource in the list. + * @return Iterates to the next resource in the list. + */ + virtual bool MoveNext() = 0; + + /** + * IIterator::MovePrevious - Iterates to the previous resource in the list. + * @return Iterates to the previous resource in the list. + */ + virtual bool MovePrevious() = 0; + + /** + * IIterator::GetCurrent - Returns the resource the iterator points at. + * @return returns the resource instance. + */ + virtual IBase * GetCurrent() = 0; + + /** + * IIterator::Clone - Creates a new resource iterator with the same resource list. + * @return returns the cloned Iterator instance + */ + virtual IIterator * Clone() = 0; + + /** + * IIterator::Count - Returns the number of resoucres the iterator captures. + * @return returns the number of resources the iterator captures. + */ + virtual LibOIE_uint64 Count() = 0; + +}; + +typedef IBaseSharedPtr PIIterator; + + +/************************************************************************************************************************* + Class interface for DataPackage +**************************************************************************************************************************/ + +class IDataPackage : public virtual IBase { +public: + /** + * IDataPackage::GetRawPayload - Returns the raw payload. + * @param[in] nPayloadBufferSize - Number of elements in buffer + * @param[out] pPayloadNeededCount - will be filled with the count of the written structs, or needed buffer size. + * @param[out] pPayloadBuffer - uint8 buffer of Raw payload data. + */ + virtual void GetRawPayload(LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer) = 0; + + /** + * IDataPackage::Release - Releases memory of the data package. + */ + virtual void Release() = 0; + +}; + +typedef IBaseSharedPtr PIDataPackage; + + +/************************************************************************************************************************* + Class interface for PyroDataPackage +**************************************************************************************************************************/ + +class IPyroDataPackage : public virtual IDataPackage { +public: +}; + +typedef IBaseSharedPtr PIPyroDataPackage; + + +/************************************************************************************************************************* + Class interface for PyroDataPackageIterator +**************************************************************************************************************************/ + +class IPyroDataPackageIterator : public virtual IIterator { +public: + /** + * IPyroDataPackageIterator::GetCurrentPyroDataPackage - Returns the data package the iterator points at. + * @return returns the data package instance. + */ + virtual IPyroDataPackage * GetCurrentPyroDataPackage() = 0; + +}; + +typedef IBaseSharedPtr PIPyroDataPackageIterator; + + +/************************************************************************************************************************* + Class interface for OctDataPackage +**************************************************************************************************************************/ + +class IOctDataPackage : public virtual IDataPackage { +public: +}; + +typedef IBaseSharedPtr PIOctDataPackage; + + +/************************************************************************************************************************* + Class interface for OctDataPackageIterator +**************************************************************************************************************************/ + +class IOctDataPackageIterator : public virtual IIterator { +public: + /** + * IOctDataPackageIterator::GetCurrentOctDataPackage - Returns the data package the iterator points at. + * @return returns the data package instance. + */ + virtual IOctDataPackage * GetCurrentOctDataPackage() = 0; + +}; + +typedef IBaseSharedPtr PIOctDataPackageIterator; + + +/************************************************************************************************************************* + Class interface for RemoteFunctionCall +**************************************************************************************************************************/ + +class IRemoteFunctionCall : public virtual IBase { +public: + /** + * IRemoteFunctionCall::GetFunctionName - Returns function name + * @return Function Name. + */ + virtual std::string GetFunctionName() = 0; + + /** + * IRemoteFunctionCall::AddParameter - Adds a function call parameter + * @param[in] sParameter - Parameter of the call. + */ + virtual void AddParameter(const std::string & sParameter) = 0; + + /** + * IRemoteFunctionCall::Send - Sends a remote function call over its connection. + * @return Returns result if successful. + */ + virtual std::string Send() = 0; + +}; + +typedef IBaseSharedPtr PIRemoteFunctionCall; + + +/************************************************************************************************************************* + Class interface for Connection +**************************************************************************************************************************/ + +class IConnection : public virtual IBase { +public: + /** + * IConnection::Disconnect - Disconnects and closes the connection + */ + virtual void Disconnect() = 0; + + /** + * IConnection::SetRequestTimeout - Sets timeout value for each poll request below. + * @param[in] nTimeout - Timeout in milliseconds. Default is 1000ms. Minimum 10ms, maximum 1000000ms. + */ + virtual void SetRequestTimeout(const LibOIE_uint32 nTimeout) = 0; + + /** + * IConnection::SetMaxErrorCount - Sets the maximum error messages that can be received before the connection is terminated. + * @param[in] nErrorCount - Max Error count. Default is 1024. Minimum 16, maximum 65535. + */ + virtual void SetMaxErrorCount(const LibOIE_uint32 nErrorCount) = 0; + + /** + * IConnection::SetMaxMemoryCount - Sets the maximum memory buffer the data packets can use before the connection is terminated. + * @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1GB. + */ + virtual void SetMaxMemoryCount(const LibOIE_uint32 nMaxMemoryCount) = 0; + + /** + * IConnection::SetBufferFile - Sets a temporary filename to which the packets are buffered. + * @param[in] sFileName - Filename which should be used as buffer. + * @param[in] nMaxMemoryCount - Max memory count in bytes. Default is 1MB. Minimum 1kB, maximum 1TB. + */ + virtual void SetBufferFile(const std::string & sFileName, const LibOIE_uint64 nMaxMemoryCount) = 0; + + /** + * IConnection::UnsetBufferFile - Stops writing to disk. + */ + virtual void UnsetBufferFile() = 0; + + /** + * IConnection::SetCheckAliveInterval - Sets check alive interval. 0ms means no check alive request is sent. + * @param[in] nCheckAliveInterval - Timeout in milliseconds. Default is 1000ms. Max value is 1000000ms. + */ + virtual void SetCheckAliveInterval(const LibOIE_uint32 nCheckAliveInterval) = 0; + + /** + * IConnection::RetrieveFirmwareVersion - Retrieves Firmware Version. Fails if firmware is not existing. + * @param[in] sFirmwareName - Name of the firmware to retrieve. + * @param[out] sFirmwareVersion - Version of the requested firmware. + * @param[out] sFilename - Filename of the requested firmware. + * @param[out] sFiledate - Timestamp of the requested firmware in ISO8601 Time. + * @param[out] sSHA256 - Checksum of the requested firmware. + */ + virtual void RetrieveFirmwareVersion(const std::string & sFirmwareName, std::string & sFirmwareVersion, std::string & sFilename, std::string & sFiledate, std::string & sSHA256) = 0; + + /** + * IConnection::UpdateFirmware - Retrieves Firmware Version. Fails if firmware is not existing. + * @param[in] sFirmwareName - Name of the new firmware. + * @param[in] sFirmwareVersion - Version of the new firmware. + * @param[in] sFileName - Filename of the new firmware. + * @param[in] sFileDate - Timestamp of the requested firmware in ISO8601 Time. + * @param[in] sSHA256 - Checksum of the new firmware. + * @param[in] nBinaryDataBufferSize - Number of elements in buffer + * @param[in] pBinaryDataBuffer - Blob of new firmware. + */ + virtual void UpdateFirmware(const std::string & sFirmwareName, const std::string & sFirmwareVersion, const std::string & sFileName, const std::string & sFileDate, const std::string & sSHA256, const LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer) = 0; + + /** + * IConnection::StartFirmware - Starts firmware on Open Interface Extension. + * @param[in] sFileName - Filename of the firmware to start. + * @return Firmware successfully started. + */ + virtual bool StartFirmware(const std::string & sFileName) = 0; + + /** + * IConnection::StopFirmware - Stops firmware on Open Interface Extension. + * @param[in] sFileName - Filename of the firmware to stop. + * @return Firmware successfully stopped. + */ + virtual bool StopFirmware(const std::string & sFileName) = 0; + + /** + * IConnection::SetConnectionErrorCallback - sets a callback that triggers when a connection error occured. + * @param[in] pCallback - callback function + */ + virtual void SetConnectionErrorCallback(const LibOIE::ConnectionErrorCallback pCallback) = 0; + + /** + * IConnection::ClearErrors - clears the error log. + */ + virtual void ClearErrors() = 0; + + /** + * IConnection::GetErrorCount - Returns the list of errors in the error log. + * @return Errors in the error log. + */ + virtual LibOIE_uint32 GetErrorCount() = 0; + + /** + * IConnection::GetError - Returns an error message of the error log + * @param[in] nErrorIndex - Index of the error. + * @param[out] sErrorMessage - Message of the error. + * @param[out] sTimestamp - ISO8601 Time when the error was reported. + */ + virtual void GetError(const LibOIE_uint32 nErrorIndex, std::string & sErrorMessage, std::string & sTimestamp) = 0; + + /** + * IConnection::CreateRemoteFunctionCall - Creates a new remote function call. + * @param[in] sFunctionName - Function name. + * @return Function call instance. + */ + virtual IRemoteFunctionCall * CreateRemoteFunctionCall(const std::string & sFunctionName) = 0; + + /** + * IConnection::GetBufferedPyroPackages - Retrieves currently buffered pyro packages. + * @return Iterator of buffered packages. + */ + virtual IPyroDataPackageIterator * GetBufferedPyroPackages() = 0; + + /** + * IConnection::GetBufferedOctPackages - Retrieves currently buffered oct packages. + * @return Iterator of buffered packages. + */ + virtual IOctDataPackageIterator * GetBufferedOctPackages() = 0; + +}; + +typedef IBaseSharedPtr PIConnection; + + +/************************************************************************************************************************* + Class interface for ConnectionIterator +**************************************************************************************************************************/ + +class IConnectionIterator : public virtual IIterator { +public: + /** + * IConnectionIterator::GetCurrentConnection - Returns the connection the iterator points at. + * @return returns the connection instance. + */ + virtual IConnection * GetCurrentConnection() = 0; + +}; + +typedef IBaseSharedPtr PIConnectionIterator; + + +/************************************************************************************************************************* + Class interface for Server +**************************************************************************************************************************/ + +class IServer : public virtual IBase { +public: + /** + * IServer::Start - starts listening for connections. + * @param[in] sIPAddress - IP Address to run on + * @param[in] nPort - Port to run on + * @param[in] bIPv6 - flag if IPv6 should be used + */ + virtual void Start(const std::string & sIPAddress, const LibOIE_uint32 nPort, const bool bIPv6) = 0; + + /** + * IServer::Stop - stops listening for connections and disconnects existing ones. + */ + virtual void Stop() = 0; + + /** + * IServer::CloseAllConnections - disconnects all connections but does not stop listening. + */ + virtual void CloseAllConnections() = 0; + + /** + * IServer::SetThreadCount - sets the maximum thread count to use. Must be called before Start + * @param[in] nThreadCount - Thread count to use (must be larger than 4, default is 32) + */ + virtual void SetThreadCount(const LibOIE_uint32 nThreadCount) = 0; + + /** + * IServer::SetBufferSize - sets the receive buffer size + * @param[in] nRCVBufferSize - Receive buffer size to use in bytes (must be between 4kB and 1GB, default is 1MB) + */ + virtual void SetBufferSize(const LibOIE_uint32 nRCVBufferSize) = 0; + + /** + * IServer::AcceptDevice - adds an accepted device + * @param[in] sDeviceName - Device name to be accepted. Empty string means all devices. + * @param[in] sApplicationName - Application name to be accepted. Empty string means all applications. + * @param[in] sVersionName - Version name to be accepted. Empty string means all versions. + * @return Returns identifier of acceptance rule. + */ + virtual LibOIE_uint32 AcceptDevice(const std::string & sDeviceName, const std::string & sApplicationName, const std::string & sVersionName) = 0; + + /** + * IServer::UnAcceptDevice - removes an accepted + * @param[in] nRuleID - identifier of acceptance rule. + */ + virtual void UnAcceptDevice(const LibOIE_uint32 nRuleID) = 0; + + /** + * IServer::ClearAcceptedDevices - clears all accepted device rules + */ + virtual void ClearAcceptedDevices() = 0; + + /** + * IServer::ListConnections - lists all open connections + * @return list of all open connections. + */ + virtual IConnectionIterator * ListConnections() = 0; + + /** + * IServer::SetConnectionAcceptedCallback - sets a callback that triggers when a new connection was established. + * @param[in] pCallback - callback function + */ + virtual void SetConnectionAcceptedCallback(const LibOIE::ConnectionAcceptedCallback pCallback) = 0; + + /** + * IServer::SetConnectionRejectedCallback - sets a callback that triggers when a new connection was rejected. + * @param[in] pCallback - callback function + */ + virtual void SetConnectionRejectedCallback(const LibOIE::ConnectionRejectedCallback pCallback) = 0; + +}; + +typedef IBaseSharedPtr PIServer; + + +/************************************************************************************************************************* + Global functions declarations +**************************************************************************************************************************/ +class CWrapper { +public: + /** + * Iliboie::GetVersion - retrieves the binary version of this library. + * @param[out] nMajor - returns the major version of this library + * @param[out] nMinor - returns the minor version of this library + * @param[out] nMicro - returns the micro version of this library + */ + static void GetVersion(LibOIE_uint32 & nMajor, LibOIE_uint32 & nMinor, LibOIE_uint32 & nMicro); + + /** + * Iliboie::GetLastError - Returns the last error recorded on this object + * @param[in] pInstance - Instance Handle + * @param[out] sErrorMessage - Message of the last error + * @return Is there a last error to query + */ + static bool GetLastError(IBase* pInstance, std::string & sErrorMessage); + + /** + * Iliboie::ReleaseInstance - Releases shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void ReleaseInstance(IBase* pInstance); + + /** + * Iliboie::AcquireInstance - Acquires shared ownership of an Instance + * @param[in] pInstance - Instance Handle + */ + static void AcquireInstance(IBase* pInstance); + + /** + * Iliboie::CreateServer - Creates a open interface extension server instance. + * @return New Server instance + */ + static IServer * CreateServer(); + +}; + +LibOIEResult LibOIE_GetProcAddress (const char * pProcName, void ** ppProcAddress); + +} // namespace Impl +} // namespace LibOIE + +#endif // __LIBOIE_CPPINTERFACES diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfacewrapper.cpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfacewrapper.cpp new file mode 100644 index 00000000..7b0f048f --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_interfacewrapper.cpp @@ -0,0 +1,1653 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++ implementation file in order to allow easy +development of ScanLab Open Interface Extension. The functions in this file need to be implemented. It needs to be generated only once. + +Interface version: 1.0.0 + +*/ + +#include "liboie_abi.hpp" +#include "liboie_interfaces.hpp" +#include "liboie_interfaceexception.hpp" + +#include + +using namespace LibOIE::Impl; + +LibOIEResult handleLibOIEException(IBase * pIBaseClass, ELibOIEInterfaceException & Exception) +{ + LibOIEResult errorCode = Exception.getErrorCode(); + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibOIEResult handleStdException(IBase * pIBaseClass, std::exception & Exception) +{ + LibOIEResult errorCode = LIBOIE_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage(Exception.what()); + + return errorCode; +} + +LibOIEResult handleUnhandledException(IBase * pIBaseClass) +{ + LibOIEResult errorCode = LIBOIE_ERROR_GENERICEXCEPTION; + + if (pIBaseClass != nullptr) + pIBaseClass->RegisterErrorMessage("Unhandled Exception"); + + return errorCode; +} + + + +/************************************************************************************************************************* + Class implementation for Base +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for Iterator +**************************************************************************************************************************/ +LibOIEResult liboie_iterator_movenext(LibOIE_Iterator pIterator, bool * pHasNext) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pHasNext == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pHasNext = pIIterator->MoveNext(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_iterator_moveprevious(LibOIE_Iterator pIterator, bool * pHasPrevious) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pHasPrevious == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pHasPrevious = pIIterator->MovePrevious(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_iterator_getcurrent(LibOIE_Iterator pIterator, LibOIE_Base * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIIterator->GetCurrent(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_iterator_clone(LibOIE_Iterator pIterator, LibOIE_Iterator * pOutIterator) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pOutIterator == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseOutIterator(nullptr); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseOutIterator = pIIterator->Clone(); + + *pOutIterator = (IBase*)(pBaseOutIterator); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_iterator_count(LibOIE_Iterator pIterator, LibOIE_uint64 * pCount) +{ + IBase* pIBaseClass = (IBase *)pIterator; + + try { + if (pCount == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IIterator* pIIterator = dynamic_cast(pIBaseClass); + if (!pIIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pCount = pIIterator->Count(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for DataPackage +**************************************************************************************************************************/ +LibOIEResult liboie_datapackage_getrawpayload(LibOIE_DataPackage pDataPackage, const LibOIE_uint64 nPayloadBufferSize, LibOIE_uint64* pPayloadNeededCount, LibOIE_uint8 * pPayloadBuffer) +{ + IBase* pIBaseClass = (IBase *)pDataPackage; + + try { + if ((!pPayloadBuffer) && !(pPayloadNeededCount)) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IDataPackage* pIDataPackage = dynamic_cast(pIBaseClass); + if (!pIDataPackage) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIDataPackage->GetRawPayload(nPayloadBufferSize, pPayloadNeededCount, pPayloadBuffer); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_datapackage_release(LibOIE_DataPackage pDataPackage) +{ + IBase* pIBaseClass = (IBase *)pDataPackage; + + try { + IDataPackage* pIDataPackage = dynamic_cast(pIBaseClass); + if (!pIDataPackage) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIDataPackage->Release(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for PyroDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for PyroDataPackageIterator +**************************************************************************************************************************/ +LibOIEResult liboie_pyrodatapackageiterator_getcurrentpyrodatapackage(LibOIE_PyroDataPackageIterator pPyroDataPackageIterator, LibOIE_PyroDataPackage * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pPyroDataPackageIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IPyroDataPackageIterator* pIPyroDataPackageIterator = dynamic_cast(pIBaseClass); + if (!pIPyroDataPackageIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIPyroDataPackageIterator->GetCurrentPyroDataPackage(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for OctDataPackage +**************************************************************************************************************************/ + +/************************************************************************************************************************* + Class implementation for OctDataPackageIterator +**************************************************************************************************************************/ +LibOIEResult liboie_octdatapackageiterator_getcurrentoctdatapackage(LibOIE_OctDataPackageIterator pOctDataPackageIterator, LibOIE_OctDataPackage * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pOctDataPackageIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IOctDataPackageIterator* pIOctDataPackageIterator = dynamic_cast(pIBaseClass); + if (!pIOctDataPackageIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIOctDataPackageIterator->GetCurrentOctDataPackage(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for RemoteFunctionCall +**************************************************************************************************************************/ +LibOIEResult liboie_remotefunctioncall_getfunctionname(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nFunctionNameBufferSize, LibOIE_uint32* pFunctionNameNeededChars, char * pFunctionNameBuffer) +{ + IBase* pIBaseClass = (IBase *)pRemoteFunctionCall; + + try { + if ( (!pFunctionNameBuffer) && !(pFunctionNameNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFunctionName(""); + IRemoteFunctionCall* pIRemoteFunctionCall = dynamic_cast(pIBaseClass); + if (!pIRemoteFunctionCall) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pFunctionNameBuffer == nullptr); + if (isCacheCall) { + sFunctionName = pIRemoteFunctionCall->GetFunctionName(); + + pIRemoteFunctionCall->_setCache (new ParameterCache_1 (sFunctionName)); + } + else { + auto cache = dynamic_cast*> (pIRemoteFunctionCall->_getCache ()); + if (cache == nullptr) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + cache->retrieveData (sFunctionName); + pIRemoteFunctionCall->_setCache (nullptr); + } + + if (pFunctionNameNeededChars) + *pFunctionNameNeededChars = (LibOIE_uint32) (sFunctionName.size()+1); + if (pFunctionNameBuffer) { + if (sFunctionName.size() >= nFunctionNameBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iFunctionName = 0; iFunctionName < sFunctionName.size(); iFunctionName++) + pFunctionNameBuffer[iFunctionName] = sFunctionName[iFunctionName]; + pFunctionNameBuffer[sFunctionName.size()] = 0; + } + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_remotefunctioncall_addparameter(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const char * pParameter) +{ + IBase* pIBaseClass = (IBase *)pRemoteFunctionCall; + + try { + if (pParameter == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sParameter(pParameter); + IRemoteFunctionCall* pIRemoteFunctionCall = dynamic_cast(pIBaseClass); + if (!pIRemoteFunctionCall) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIRemoteFunctionCall->AddParameter(sParameter); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_remotefunctioncall_send(LibOIE_RemoteFunctionCall pRemoteFunctionCall, const LibOIE_uint32 nResultStringBufferSize, LibOIE_uint32* pResultStringNeededChars, char * pResultStringBuffer) +{ + IBase* pIBaseClass = (IBase *)pRemoteFunctionCall; + + try { + if ( (!pResultStringBuffer) && !(pResultStringNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sResultString(""); + IRemoteFunctionCall* pIRemoteFunctionCall = dynamic_cast(pIBaseClass); + if (!pIRemoteFunctionCall) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pResultStringBuffer == nullptr); + if (isCacheCall) { + sResultString = pIRemoteFunctionCall->Send(); + + pIRemoteFunctionCall->_setCache (new ParameterCache_1 (sResultString)); + } + else { + auto cache = dynamic_cast*> (pIRemoteFunctionCall->_getCache ()); + if (cache == nullptr) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + cache->retrieveData (sResultString); + pIRemoteFunctionCall->_setCache (nullptr); + } + + if (pResultStringNeededChars) + *pResultStringNeededChars = (LibOIE_uint32) (sResultString.size()+1); + if (pResultStringBuffer) { + if (sResultString.size() >= nResultStringBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iResultString = 0; iResultString < sResultString.size(); iResultString++) + pResultStringBuffer[iResultString] = sResultString[iResultString]; + pResultStringBuffer[sResultString.size()] = 0; + } + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Connection +**************************************************************************************************************************/ +LibOIEResult liboie_connection_disconnect(LibOIE_Connection pConnection) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->Disconnect(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setrequesttimeout(LibOIE_Connection pConnection, LibOIE_uint32 nTimeout) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetRequestTimeout(nTimeout); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setmaxerrorcount(LibOIE_Connection pConnection, LibOIE_uint32 nErrorCount) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetMaxErrorCount(nErrorCount); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setmaxmemorycount(LibOIE_Connection pConnection, LibOIE_uint32 nMaxMemoryCount) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetMaxMemoryCount(nMaxMemoryCount); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setbufferfile(LibOIE_Connection pConnection, const char * pFileName, LibOIE_uint64 nMaxMemoryCount) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFileName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFileName(pFileName); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetBufferFile(sFileName, nMaxMemoryCount); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_unsetbufferfile(LibOIE_Connection pConnection) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->UnsetBufferFile(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setcheckaliveinterval(LibOIE_Connection pConnection, LibOIE_uint32 nCheckAliveInterval) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetCheckAliveInterval(nCheckAliveInterval); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_retrievefirmwareversion(LibOIE_Connection pConnection, const char * pFirmwareName, const LibOIE_uint32 nFirmwareVersionBufferSize, LibOIE_uint32* pFirmwareVersionNeededChars, char * pFirmwareVersionBuffer, const LibOIE_uint32 nFilenameBufferSize, LibOIE_uint32* pFilenameNeededChars, char * pFilenameBuffer, const LibOIE_uint32 nFiledateBufferSize, LibOIE_uint32* pFiledateNeededChars, char * pFiledateBuffer, const LibOIE_uint32 nSHA256BufferSize, LibOIE_uint32* pSHA256NeededChars, char * pSHA256Buffer) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFirmwareName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pFirmwareVersionBuffer) && !(pFirmwareVersionNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pFilenameBuffer) && !(pFilenameNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pFiledateBuffer) && !(pFiledateNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pSHA256Buffer) && !(pSHA256NeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFirmwareName(pFirmwareName); + std::string sFirmwareVersion(""); + std::string sFilename(""); + std::string sFiledate(""); + std::string sSHA256(""); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pFirmwareVersionBuffer == nullptr) || (pFilenameBuffer == nullptr) || (pFiledateBuffer == nullptr) || (pSHA256Buffer == nullptr); + if (isCacheCall) { + pIConnection->RetrieveFirmwareVersion(sFirmwareName, sFirmwareVersion, sFilename, sFiledate, sSHA256); + + pIConnection->_setCache (new ParameterCache_4 (sFirmwareVersion, sFilename, sFiledate, sSHA256)); + } + else { + auto cache = dynamic_cast*> (pIConnection->_getCache ()); + if (cache == nullptr) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + cache->retrieveData (sFirmwareVersion, sFilename, sFiledate, sSHA256); + pIConnection->_setCache (nullptr); + } + + if (pFirmwareVersionNeededChars) + *pFirmwareVersionNeededChars = (LibOIE_uint32) (sFirmwareVersion.size()+1); + if (pFirmwareVersionBuffer) { + if (sFirmwareVersion.size() >= nFirmwareVersionBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iFirmwareVersion = 0; iFirmwareVersion < sFirmwareVersion.size(); iFirmwareVersion++) + pFirmwareVersionBuffer[iFirmwareVersion] = sFirmwareVersion[iFirmwareVersion]; + pFirmwareVersionBuffer[sFirmwareVersion.size()] = 0; + } + if (pFilenameNeededChars) + *pFilenameNeededChars = (LibOIE_uint32) (sFilename.size()+1); + if (pFilenameBuffer) { + if (sFilename.size() >= nFilenameBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iFilename = 0; iFilename < sFilename.size(); iFilename++) + pFilenameBuffer[iFilename] = sFilename[iFilename]; + pFilenameBuffer[sFilename.size()] = 0; + } + if (pFiledateNeededChars) + *pFiledateNeededChars = (LibOIE_uint32) (sFiledate.size()+1); + if (pFiledateBuffer) { + if (sFiledate.size() >= nFiledateBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iFiledate = 0; iFiledate < sFiledate.size(); iFiledate++) + pFiledateBuffer[iFiledate] = sFiledate[iFiledate]; + pFiledateBuffer[sFiledate.size()] = 0; + } + if (pSHA256NeededChars) + *pSHA256NeededChars = (LibOIE_uint32) (sSHA256.size()+1); + if (pSHA256Buffer) { + if (sSHA256.size() >= nSHA256BufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iSHA256 = 0; iSHA256 < sSHA256.size(); iSHA256++) + pSHA256Buffer[iSHA256] = sSHA256[iSHA256]; + pSHA256Buffer[sSHA256.size()] = 0; + } + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_updatefirmware(LibOIE_Connection pConnection, const char * pFirmwareName, const char * pFirmwareVersion, const char * pFileName, const char * pFileDate, const char * pSHA256, LibOIE_uint64 nBinaryDataBufferSize, const LibOIE_uint8 * pBinaryDataBuffer) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFirmwareName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pFirmwareVersion == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pFileName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pFileDate == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pSHA256 == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pBinaryDataBuffer) && (nBinaryDataBufferSize>0)) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFirmwareName(pFirmwareName); + std::string sFirmwareVersion(pFirmwareVersion); + std::string sFileName(pFileName); + std::string sFileDate(pFileDate); + std::string sSHA256(pSHA256); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->UpdateFirmware(sFirmwareName, sFirmwareVersion, sFileName, sFileDate, sSHA256, nBinaryDataBufferSize, pBinaryDataBuffer); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_startfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFileName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pSuccess == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFileName(pFileName); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pSuccess = pIConnection->StartFirmware(sFileName); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_stopfirmware(LibOIE_Connection pConnection, const char * pFileName, bool * pSuccess) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFileName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pSuccess == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFileName(pFileName); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pSuccess = pIConnection->StopFirmware(sFileName); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_setconnectionerrorcallback(LibOIE_Connection pConnection, LibOIEConnectionErrorCallback pCallback) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->SetConnectionErrorCallback(pCallback); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_clearerrors(LibOIE_Connection pConnection) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIConnection->ClearErrors(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_geterrorcount(LibOIE_Connection pConnection, LibOIE_uint32 * pErrorCount) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pErrorCount == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pErrorCount = pIConnection->GetErrorCount(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_geterror(LibOIE_Connection pConnection, LibOIE_uint32 nErrorIndex, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, const LibOIE_uint32 nTimestampBufferSize, LibOIE_uint32* pTimestampNeededChars, char * pTimestampBuffer) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if ( (!pErrorMessageBuffer) && !(pErrorMessageNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if ( (!pTimestampBuffer) && !(pTimestampNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sErrorMessage(""); + std::string sTimestamp(""); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + bool isCacheCall = (pErrorMessageBuffer == nullptr) || (pTimestampBuffer == nullptr); + if (isCacheCall) { + pIConnection->GetError(nErrorIndex, sErrorMessage, sTimestamp); + + pIConnection->_setCache (new ParameterCache_2 (sErrorMessage, sTimestamp)); + } + else { + auto cache = dynamic_cast*> (pIConnection->_getCache ()); + if (cache == nullptr) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + cache->retrieveData (sErrorMessage, sTimestamp); + pIConnection->_setCache (nullptr); + } + + if (pErrorMessageNeededChars) + *pErrorMessageNeededChars = (LibOIE_uint32) (sErrorMessage.size()+1); + if (pErrorMessageBuffer) { + if (sErrorMessage.size() >= nErrorMessageBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iErrorMessage = 0; iErrorMessage < sErrorMessage.size(); iErrorMessage++) + pErrorMessageBuffer[iErrorMessage] = sErrorMessage[iErrorMessage]; + pErrorMessageBuffer[sErrorMessage.size()] = 0; + } + if (pTimestampNeededChars) + *pTimestampNeededChars = (LibOIE_uint32) (sTimestamp.size()+1); + if (pTimestampBuffer) { + if (sTimestamp.size() >= nTimestampBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iTimestamp = 0; iTimestamp < sTimestamp.size(); iTimestamp++) + pTimestampBuffer[iTimestamp] = sTimestamp[iTimestamp]; + pTimestampBuffer[sTimestamp.size()] = 0; + } + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_createremotefunctioncall(LibOIE_Connection pConnection, const char * pFunctionName, LibOIE_RemoteFunctionCall * pInstance) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pFunctionName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sFunctionName(pFunctionName); + IBase* pBaseInstance(nullptr); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseInstance = pIConnection->CreateRemoteFunctionCall(sFunctionName); + + *pInstance = (IBase*)(pBaseInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_getbufferedpyropackages(LibOIE_Connection pConnection, LibOIE_PyroDataPackageIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pIterator == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseIterator = pIConnection->GetBufferedPyroPackages(); + + *pIterator = (IBase*)(pBaseIterator); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_connection_getbufferedoctpackages(LibOIE_Connection pConnection, LibOIE_OctDataPackageIterator * pIterator) +{ + IBase* pIBaseClass = (IBase *)pConnection; + + try { + if (pIterator == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseIterator(nullptr); + IConnection* pIConnection = dynamic_cast(pIBaseClass); + if (!pIConnection) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseIterator = pIConnection->GetBufferedOctPackages(); + + *pIterator = (IBase*)(pBaseIterator); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for ConnectionIterator +**************************************************************************************************************************/ +LibOIEResult liboie_connectioniterator_getcurrentconnection(LibOIE_ConnectionIterator pConnectionIterator, LibOIE_Connection * pCurrentInstance) +{ + IBase* pIBaseClass = (IBase *)pConnectionIterator; + + try { + if (pCurrentInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseCurrentInstance(nullptr); + IConnectionIterator* pIConnectionIterator = dynamic_cast(pIBaseClass); + if (!pIConnectionIterator) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseCurrentInstance = pIConnectionIterator->GetCurrentConnection(); + + *pCurrentInstance = (IBase*)(pBaseCurrentInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + +/************************************************************************************************************************* + Class implementation for Server +**************************************************************************************************************************/ +LibOIEResult liboie_server_start(LibOIE_Server pServer, const char * pIPAddress, LibOIE_uint32 nPort, bool bIPv6) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + if (pIPAddress == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sIPAddress(pIPAddress); + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->Start(sIPAddress, nPort, bIPv6); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_stop(LibOIE_Server pServer) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->Stop(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_closeallconnections(LibOIE_Server pServer) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->CloseAllConnections(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_setthreadcount(LibOIE_Server pServer, LibOIE_uint32 nThreadCount) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->SetThreadCount(nThreadCount); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_setbuffersize(LibOIE_Server pServer, LibOIE_uint32 nRCVBufferSize) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->SetBufferSize(nRCVBufferSize); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_acceptdevice(LibOIE_Server pServer, const char * pDeviceName, const char * pApplicationName, const char * pVersionName, LibOIE_uint32 * pRuleID) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + if (pDeviceName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pApplicationName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pVersionName == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pRuleID == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + std::string sDeviceName(pDeviceName); + std::string sApplicationName(pApplicationName); + std::string sVersionName(pVersionName); + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + *pRuleID = pIServer->AcceptDevice(sDeviceName, sApplicationName, sVersionName); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_unacceptdevice(LibOIE_Server pServer, LibOIE_uint32 nRuleID) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->UnAcceptDevice(nRuleID); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_clearaccepteddevices(LibOIE_Server pServer) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->ClearAcceptedDevices(); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_listconnections(LibOIE_Server pServer, LibOIE_ConnectionIterator * pConnectionIteratorInstance) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + if (pConnectionIteratorInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseConnectionIteratorInstance(nullptr); + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pBaseConnectionIteratorInstance = pIServer->ListConnections(); + + *pConnectionIteratorInstance = (IBase*)(pBaseConnectionIteratorInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_setconnectionacceptedcallback(LibOIE_Server pServer, LibOIEConnectionAcceptedCallback pCallback) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->SetConnectionAcceptedCallback(pCallback); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_server_setconnectionrejectedcallback(LibOIE_Server pServer, LibOIEConnectionRejectedCallback pCallback) +{ + IBase* pIBaseClass = (IBase *)pServer; + + try { + IServer* pIServer = dynamic_cast(pIBaseClass); + if (!pIServer) + throw ELibOIEInterfaceException(LIBOIE_ERROR_INVALIDCAST); + + pIServer->SetConnectionRejectedCallback(pCallback); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + + +/************************************************************************************************************************* + Function table lookup implementation +**************************************************************************************************************************/ + +LibOIEResult LibOIE::Impl::LibOIE_GetProcAddress (const char * pProcName, void ** ppProcAddress) +{ + if (pProcName == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + if (ppProcAddress == nullptr) + return LIBOIE_ERROR_INVALIDPARAM; + *ppProcAddress = nullptr; + std::string sProcName (pProcName); + + if (sProcName == "liboie_iterator_movenext") + *ppProcAddress = (void*) &liboie_iterator_movenext; + if (sProcName == "liboie_iterator_moveprevious") + *ppProcAddress = (void*) &liboie_iterator_moveprevious; + if (sProcName == "liboie_iterator_getcurrent") + *ppProcAddress = (void*) &liboie_iterator_getcurrent; + if (sProcName == "liboie_iterator_clone") + *ppProcAddress = (void*) &liboie_iterator_clone; + if (sProcName == "liboie_iterator_count") + *ppProcAddress = (void*) &liboie_iterator_count; + if (sProcName == "liboie_datapackage_getrawpayload") + *ppProcAddress = (void*) &liboie_datapackage_getrawpayload; + if (sProcName == "liboie_datapackage_release") + *ppProcAddress = (void*) &liboie_datapackage_release; + if (sProcName == "liboie_pyrodatapackageiterator_getcurrentpyrodatapackage") + *ppProcAddress = (void*) &liboie_pyrodatapackageiterator_getcurrentpyrodatapackage; + if (sProcName == "liboie_octdatapackageiterator_getcurrentoctdatapackage") + *ppProcAddress = (void*) &liboie_octdatapackageiterator_getcurrentoctdatapackage; + if (sProcName == "liboie_remotefunctioncall_getfunctionname") + *ppProcAddress = (void*) &liboie_remotefunctioncall_getfunctionname; + if (sProcName == "liboie_remotefunctioncall_addparameter") + *ppProcAddress = (void*) &liboie_remotefunctioncall_addparameter; + if (sProcName == "liboie_remotefunctioncall_send") + *ppProcAddress = (void*) &liboie_remotefunctioncall_send; + if (sProcName == "liboie_connection_disconnect") + *ppProcAddress = (void*) &liboie_connection_disconnect; + if (sProcName == "liboie_connection_setrequesttimeout") + *ppProcAddress = (void*) &liboie_connection_setrequesttimeout; + if (sProcName == "liboie_connection_setmaxerrorcount") + *ppProcAddress = (void*) &liboie_connection_setmaxerrorcount; + if (sProcName == "liboie_connection_setmaxmemorycount") + *ppProcAddress = (void*) &liboie_connection_setmaxmemorycount; + if (sProcName == "liboie_connection_setbufferfile") + *ppProcAddress = (void*) &liboie_connection_setbufferfile; + if (sProcName == "liboie_connection_unsetbufferfile") + *ppProcAddress = (void*) &liboie_connection_unsetbufferfile; + if (sProcName == "liboie_connection_setcheckaliveinterval") + *ppProcAddress = (void*) &liboie_connection_setcheckaliveinterval; + if (sProcName == "liboie_connection_retrievefirmwareversion") + *ppProcAddress = (void*) &liboie_connection_retrievefirmwareversion; + if (sProcName == "liboie_connection_updatefirmware") + *ppProcAddress = (void*) &liboie_connection_updatefirmware; + if (sProcName == "liboie_connection_startfirmware") + *ppProcAddress = (void*) &liboie_connection_startfirmware; + if (sProcName == "liboie_connection_stopfirmware") + *ppProcAddress = (void*) &liboie_connection_stopfirmware; + if (sProcName == "liboie_connection_setconnectionerrorcallback") + *ppProcAddress = (void*) &liboie_connection_setconnectionerrorcallback; + if (sProcName == "liboie_connection_clearerrors") + *ppProcAddress = (void*) &liboie_connection_clearerrors; + if (sProcName == "liboie_connection_geterrorcount") + *ppProcAddress = (void*) &liboie_connection_geterrorcount; + if (sProcName == "liboie_connection_geterror") + *ppProcAddress = (void*) &liboie_connection_geterror; + if (sProcName == "liboie_connection_createremotefunctioncall") + *ppProcAddress = (void*) &liboie_connection_createremotefunctioncall; + if (sProcName == "liboie_connection_getbufferedpyropackages") + *ppProcAddress = (void*) &liboie_connection_getbufferedpyropackages; + if (sProcName == "liboie_connection_getbufferedoctpackages") + *ppProcAddress = (void*) &liboie_connection_getbufferedoctpackages; + if (sProcName == "liboie_connectioniterator_getcurrentconnection") + *ppProcAddress = (void*) &liboie_connectioniterator_getcurrentconnection; + if (sProcName == "liboie_server_start") + *ppProcAddress = (void*) &liboie_server_start; + if (sProcName == "liboie_server_stop") + *ppProcAddress = (void*) &liboie_server_stop; + if (sProcName == "liboie_server_closeallconnections") + *ppProcAddress = (void*) &liboie_server_closeallconnections; + if (sProcName == "liboie_server_setthreadcount") + *ppProcAddress = (void*) &liboie_server_setthreadcount; + if (sProcName == "liboie_server_setbuffersize") + *ppProcAddress = (void*) &liboie_server_setbuffersize; + if (sProcName == "liboie_server_acceptdevice") + *ppProcAddress = (void*) &liboie_server_acceptdevice; + if (sProcName == "liboie_server_unacceptdevice") + *ppProcAddress = (void*) &liboie_server_unacceptdevice; + if (sProcName == "liboie_server_clearaccepteddevices") + *ppProcAddress = (void*) &liboie_server_clearaccepteddevices; + if (sProcName == "liboie_server_listconnections") + *ppProcAddress = (void*) &liboie_server_listconnections; + if (sProcName == "liboie_server_setconnectionacceptedcallback") + *ppProcAddress = (void*) &liboie_server_setconnectionacceptedcallback; + if (sProcName == "liboie_server_setconnectionrejectedcallback") + *ppProcAddress = (void*) &liboie_server_setconnectionrejectedcallback; + if (sProcName == "liboie_getversion") + *ppProcAddress = (void*) &liboie_getversion; + if (sProcName == "liboie_getlasterror") + *ppProcAddress = (void*) &liboie_getlasterror; + if (sProcName == "liboie_releaseinstance") + *ppProcAddress = (void*) &liboie_releaseinstance; + if (sProcName == "liboie_acquireinstance") + *ppProcAddress = (void*) &liboie_acquireinstance; + if (sProcName == "liboie_getsymbollookupmethod") + *ppProcAddress = (void*) &liboie_getsymbollookupmethod; + if (sProcName == "liboie_createserver") + *ppProcAddress = (void*) &liboie_createserver; + + if (*ppProcAddress == nullptr) + return LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT; + return LIBOIE_SUCCESS; +} + +/************************************************************************************************************************* + Global functions implementation +**************************************************************************************************************************/ +LibOIEResult liboie_getversion(LibOIE_uint32 * pMajor, LibOIE_uint32 * pMinor, LibOIE_uint32 * pMicro) +{ + IBase* pIBaseClass = nullptr; + + try { + if (!pMajor) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (!pMinor) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (!pMicro) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + CWrapper::GetVersion(*pMajor, *pMinor, *pMicro); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_getlasterror(LibOIE_Base pInstance, const LibOIE_uint32 nErrorMessageBufferSize, LibOIE_uint32* pErrorMessageNeededChars, char * pErrorMessageBuffer, bool * pHasError) +{ + IBase* pIBaseClass = nullptr; + + try { + if ( (!pErrorMessageBuffer) && !(pErrorMessageNeededChars) ) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + if (pHasError == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDCAST); + + std::string sErrorMessage(""); + *pHasError = CWrapper::GetLastError(pIInstance, sErrorMessage); + + if (pErrorMessageNeededChars) + *pErrorMessageNeededChars = (LibOIE_uint32) (sErrorMessage.size()+1); + if (pErrorMessageBuffer) { + if (sErrorMessage.size() >= nErrorMessageBufferSize) + throw ELibOIEInterfaceException (LIBOIE_ERROR_BUFFERTOOSMALL); + for (size_t iErrorMessage = 0; iErrorMessage < sErrorMessage.size(); iErrorMessage++) + pErrorMessageBuffer[iErrorMessage] = sErrorMessage[iErrorMessage]; + pErrorMessageBuffer[sErrorMessage.size()] = 0; + } + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_releaseinstance(LibOIE_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDCAST); + + CWrapper::ReleaseInstance(pIInstance); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_acquireinstance(LibOIE_Base pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + IBase* pIBaseClassInstance = (IBase *)pInstance; + IBase* pIInstance = dynamic_cast(pIBaseClassInstance); + if (!pIInstance) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDCAST); + + CWrapper::AcquireInstance(pIInstance); + + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_getsymbollookupmethod(LibOIE_pvoid * pSymbolLookupMethod) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pSymbolLookupMethod == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + *pSymbolLookupMethod = (void*)&LibOIE::Impl::LibOIE_GetProcAddress; + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibOIEResult liboie_createserver(LibOIE_Server * pInstance) +{ + IBase* pIBaseClass = nullptr; + + try { + if (pInstance == nullptr) + throw ELibOIEInterfaceException (LIBOIE_ERROR_INVALIDPARAM); + IBase* pBaseInstance(nullptr); + pBaseInstance = CWrapper::CreateServer(); + + *pInstance = (IBase*)(pBaseInstance); + return LIBOIE_SUCCESS; + } + catch (ELibOIEInterfaceException & Exception) { + return handleLibOIEException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + diff --git a/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_types.hpp b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_types.hpp new file mode 100644 index 00000000..5f378c1e --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Interfaces/liboie_types.hpp @@ -0,0 +1,181 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. + +Abstract: This is an autogenerated C++-Header file with basic types in +order to allow an easy use of ScanLab Open Interface Extension + +Interface version: 1.0.0 + +*/ + +#ifndef __LIBOIE_TYPES_HEADER_CPP +#define __LIBOIE_TYPES_HEADER_CPP + + +/************************************************************************************************************************* + Scalar types definition +**************************************************************************************************************************/ + +#ifdef LIBOIE_USELEGACYINTEGERTYPES + +typedef unsigned char LibOIE_uint8; +typedef unsigned short LibOIE_uint16 ; +typedef unsigned int LibOIE_uint32; +typedef unsigned long long LibOIE_uint64; +typedef char LibOIE_int8; +typedef short LibOIE_int16; +typedef int LibOIE_int32; +typedef long long LibOIE_int64; + +#else // LIBOIE_USELEGACYINTEGERTYPES + +#include + +typedef uint8_t LibOIE_uint8; +typedef uint16_t LibOIE_uint16; +typedef uint32_t LibOIE_uint32; +typedef uint64_t LibOIE_uint64; +typedef int8_t LibOIE_int8; +typedef int16_t LibOIE_int16; +typedef int32_t LibOIE_int32; +typedef int64_t LibOIE_int64 ; + +#endif // LIBOIE_USELEGACYINTEGERTYPES + +typedef float LibOIE_single; +typedef double LibOIE_double; + +/************************************************************************************************************************* + General type definitions +**************************************************************************************************************************/ + +typedef LibOIE_int32 LibOIEResult; +typedef void * LibOIEHandle; +typedef void * LibOIE_pvoid; + +/************************************************************************************************************************* + Version for LibOIE +**************************************************************************************************************************/ + +#define LIBOIE_VERSION_MAJOR 1 +#define LIBOIE_VERSION_MINOR 0 +#define LIBOIE_VERSION_MICRO 0 +#define LIBOIE_VERSION_PRERELEASEINFO "" +#define LIBOIE_VERSION_BUILDINFO "" + +/************************************************************************************************************************* + Error constants for LibOIE +**************************************************************************************************************************/ + +#define LIBOIE_SUCCESS 0 +#define LIBOIE_ERROR_NOTIMPLEMENTED 1 +#define LIBOIE_ERROR_INVALIDPARAM 2 +#define LIBOIE_ERROR_INVALIDCAST 3 +#define LIBOIE_ERROR_BUFFERTOOSMALL 4 +#define LIBOIE_ERROR_GENERICEXCEPTION 5 +#define LIBOIE_ERROR_COULDNOTLOADLIBRARY 6 +#define LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT 7 +#define LIBOIE_ERROR_INCOMPATIBLEBINARYVERSION 8 + +/************************************************************************************************************************* + Error strings for LibOIE +**************************************************************************************************************************/ + +inline const char * LIBOIE_GETERRORSTRING (LibOIEResult nErrorCode) { + switch (nErrorCode) { + case LIBOIE_SUCCESS: return "no error"; + case LIBOIE_ERROR_NOTIMPLEMENTED: return "functionality not implemented"; + case LIBOIE_ERROR_INVALIDPARAM: return "an invalid parameter was passed"; + case LIBOIE_ERROR_INVALIDCAST: return "a type cast failed"; + case LIBOIE_ERROR_BUFFERTOOSMALL: return "a provided buffer is too small"; + case LIBOIE_ERROR_GENERICEXCEPTION: return "a generic exception occurred"; + case LIBOIE_ERROR_COULDNOTLOADLIBRARY: return "the library could not be loaded"; + case LIBOIE_ERROR_COULDNOTFINDLIBRARYEXPORT: return "a required exported symbol could not be found in the library"; + case LIBOIE_ERROR_INCOMPATIBLEBINARYVERSION: return "the version of the binary interface does not match the bindings interface"; + default: return "unknown error"; + } +} + +/************************************************************************************************************************* + Declaration of handle classes +**************************************************************************************************************************/ + +typedef LibOIEHandle LibOIE_Base; +typedef LibOIEHandle LibOIE_Iterator; +typedef LibOIEHandle LibOIE_DataPackage; +typedef LibOIEHandle LibOIE_PyroDataPackage; +typedef LibOIEHandle LibOIE_PyroDataPackageIterator; +typedef LibOIEHandle LibOIE_OctDataPackage; +typedef LibOIEHandle LibOIE_OctDataPackageIterator; +typedef LibOIEHandle LibOIE_RemoteFunctionCall; +typedef LibOIEHandle LibOIE_Connection; +typedef LibOIEHandle LibOIE_ConnectionIterator; +typedef LibOIEHandle LibOIE_Server; + +namespace LibOIE { + + /************************************************************************************************************************* + Declaration of function pointers + **************************************************************************************************************************/ + + /** + * ConnectionAcceptedCallback - A callback that is triggered when a device or application has connected. + * + * @param[in] pConnectionInstance - Returns whether the calculation should be aborted + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ConnectionAcceptedCallback)(LibOIE_Connection, LibOIE_pvoid); + + /** + * ConnectionRejectedCallback - A callback that is triggered when a device or application has been denied connecting. + * + * @param[in] pDeviceName - Device name that was sent. + * @param[in] pApplicationName - Application name that was sent. + * @param[in] pVersionName - Version name that was sent. + * @param[in] pUserData - Userdata that is passed to the callback function + */ + typedef void(*ConnectionRejectedCallback)(const char *, const char *, const char *, LibOIE_pvoid); + + /** + * ConnectionErrorCallback - A callback that is triggered when a connection sends an error state. + * + * @param[in] pErrorMessage - Error string that was triggered. + */ + typedef void(*ConnectionErrorCallback)(const char *); + +} // namespace LibOIE; + +// define legacy C-names for enums, structs and function types +typedef LibOIE::ConnectionAcceptedCallback LibOIEConnectionAcceptedCallback; +typedef LibOIE::ConnectionRejectedCallback LibOIEConnectionRejectedCallback; +typedef LibOIE::ConnectionErrorCallback LibOIEConnectionErrorCallback; + +#endif // __LIBOIE_TYPES_HEADER_CPP diff --git a/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/LICENSE b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/LICENSE new file mode 100644 index 00000000..3ac9185c --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 IronsDu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/README.md b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/README.md new file mode 100644 index 00000000..04c46d4d --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/README.md @@ -0,0 +1,122 @@ +Brynet +======= +Header Only Cross platform high performance TCP network library using C++ 11. + +[](https://996.icu) +[-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) +[](https://sonarcloud.io/dashboard/index/brynet) +[](https://github.com/IronsDu/brynet) + +## Build status +Windows : [](https://ci.appveyor.com/project/IronsDu/brynet/branch/master) +Linux/MacOS : [](https://travis-ci.org/IronsDu/brynet) + +## Features +* Header only +* Cross platform (Linux | Windows | MacOS) +* High performance and safety use. +* None depend +* Multi-threaded +* SSL support +* Support HTTPã€HTTPSã€WebSocket +* IPv6 support + +## Documentation +- [ç®€ä½“ä¸æ–‡](https://github.com/IronsDu/brynet/blob/master/docs/main.zh-cn.md) + +## Compatibility +* Visual C++ 2013+ (32/64-bit) +* GCC 4.8+ (32/64-bit) +* Clang (Supported C++ 11) + +## Macro +* BRYNET_VERSION +* BRYNET_USE_OPENSSL + + +## Build Example +1. `cmake . -Dbrynet_BUILD_EXAMPLES=ON -Dbrynet_BUILD_TESTS=ON` +2. If you use Windows, please open brynet.sln then build. If on Linux or MacOS, only enter `make`. + +## Only Install +1. `cmake .` +2. `sudo make install` + +## Usages +* [Examples](#examples) +* [Users](#users) + +## Benchmark + Under localhost, use CentOS 6.5 virtual mahcine(host machine is Win10 i5) +* PingPong + + Benchamrk's server and client both only use one thread, and packet size is 4k + +  + +* Broadcast + + Server use two network threads and one logic thread, client use one network(also process logic) thread. every packet size is 46 bytes. + every packet contain client's id. + server broadcast packet to all client when recv one packet from any client. + client send one packet when recv packet from server and packet's id equal self. + +  + +* Ab HTTP(1 network thread) + Document Path: / + Document Length: 18 bytes + + Concurrency Level: 100 + Time taken for tests: 5.871 seconds + Complete requests: 100000 + Failed requests: 0 + Write errors: 0 + Non-2xx responses: 100000 + Total transferred: 5200000 bytes + HTML transferred: 1800000 bytes + Requests per second: 17031.62 [#/sec] (mean) + Time per request: 5.871 [ms] (mean) + Time per request: 0.059 [ms] (mean, across all concurrent requests) + Transfer rate: 864.89 [Kbytes/sec] received + + Connection Times (ms) + min mean[+/-sd] median max + Connect: 0 2 0.7 2 8 + Processing: 1 3 0.7 3 9 + Waiting: 0 3 0.8 3 8 + Total: 2 6 0.8 6 11 + + Percentage of the requests served within a certain time (ms) + 50% 6 + 66% 6 + 75% 6 + 80% 6 + 90% 7 + 95% 7 + 98% 7 + 99% 8 + 100% 11 (longest request) + + +Examples +---------------------------- +* [PingPongServer](https://github.com/IronsDu/dodo/blob/master/examples/PingPongServer.cpp) +* [PingPongClient](https://github.com/IronsDu/dodo/blob/master/examples/PingPongClient.cpp) +* [BroadCastServer](https://github.com/IronsDu/dodo/blob/master/examples/BroadCastServer.cpp) +* [BroadCastClient](https://github.com/IronsDu/dodo/blob/master/examples/BroadCastClient.cpp) +* [Http&Websocket Server](https://github.com/IronsDu/dodo/blob/master/examples/HttpServer.cpp) +* [HttpServerClient](https://github.com/IronsDu/dodo/blob/master/examples/HttpClient.cpp) +* [BenchWebsocket](https://github.com/IronsDu/dodo/blob/master/examples/BenchWebsocket.cpp) benchmark websocket client +* [PromiseReceive](https://github.com/IronsDu/brynet/blob/master/examples/PromiseReceive.cpp) use the promise style receive http response +* [WebSocketProxy](https://github.com/IronsDu/dodo/blob/master/examples/WebBinaryProxy.cpp) one proxy server between websocket client and binary protocol server +* more examples please see [examples](https://github.com/IronsDu/dodo/tree/master/examples); + +Users +---------------------------- +* [ARK - distributed plugin framework](https://github.com/ArkNX/ARK) +* [Redis proxy](https://github.com/IronsDu/DBProxy) +* [gayrpc](https://github.com/IronsDu/gayrpc) +* [gaylord - distributed virtual actor framework](https://github.com/IronsDu/gaylord) +* [Joynet - Lua network library](https://github.com/IronsDu/Joynet) +* [grpc-gateway](https://github.com/IronsDu/grpc-gateway) diff --git a/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/Version.hpp b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/Version.hpp new file mode 100644 index 00000000..89a5883f --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/Version.hpp @@ -0,0 +1,3 @@ +#pragma once + +#define BRYNET_VERSION 1007000 diff --git a/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/base/Any.hpp b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/base/Any.hpp new file mode 100644 index 00000000..6e3d58ae --- /dev/null +++ b/Drivers/ScanLabOIE/LibOIE/Libraries/brynet/base/Any.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include + +#ifdef BRYNET_HAVE_LANG_CXX17 +#include +#else +#include +#endif + +namespace brynet { namespace base { + +#ifdef BRYNET_HAVE_LANG_CXX17 + using BrynetAny = std::any; + + template + auto cast(const BrynetAny& ud) + { + return std::any_cast(&ud); + } +#else + using BrynetAny = int64_t; + template
- Drag your build file here to begin or click to browse -
- Uploading {{ fileCount }} files... -