-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #388 from micro-manager/allied-vision
Allied vision device adapter
- Loading branch information
Showing
18 changed files
with
2,788 additions
and
1 deletion.
There are no files selected for viewing
1,411 changes: 1,411 additions & 0 deletions
1,411
DeviceAdapters/AlliedVisionCamera/AlliedVisionCamera.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
DeviceAdapters/AlliedVisionCamera/AlliedVisionCamera.vcxproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="AlliedVisionCamera.h" /> | ||
<ClInclude Include="AlliedVisionDeviceBase.h" /> | ||
<ClInclude Include="AlliedVisionHub.h" /> | ||
<ClInclude Include="Loader\Constants.h" /> | ||
<ClInclude Include="Loader\LibLoader.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="AlliedVisionCamera.cpp" /> | ||
<ClCompile Include="AlliedVisionDeviceBase.cpp" /> | ||
<ClCompile Include="AlliedVisionHub.cpp" /> | ||
<ClCompile Include="Loader\LibLoader.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\MMDevice\MMDevice-SharedRuntime.vcxproj"> | ||
<Project>{b8c95f39-54bf-40a9-807b-598df2821d55}</Project> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{12e75cb0-4b48-4d7c-bb26-d928f18488c2}</ProjectGuid> | ||
<RootNamespace>AlliedVisionCamera</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
<Import Project="..\..\buildscripts\VisualStudio\MMCommon.props" /> | ||
<Import Project="..\..\buildscripts\VisualStudio\MMDeviceAdapter.props" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
<Import Project="..\..\buildscripts\VisualStudio\MMCommon.props" /> | ||
<Import Project="..\..\buildscripts\VisualStudio\MMDeviceAdapter.props" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<OutDir>C:\Program Files\Micro-Manager-2.0\</OutDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;ALLIEDVISIONCAMERA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeaderFile /> | ||
<AdditionalIncludeDirectories>$(MM_3RDPARTYPRIVATE)\AVT\VimbaX-2023-1-Win64\api\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;ALLIEDVISIONCAMERA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<PrecompiledHeaderFile /> | ||
<AdditionalIncludeDirectories>$(MM_3RDPARTYPRIVATE)\AVT\VimbaX-2023-1-Win64\api\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Windows</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableUAC>false</EnableUAC> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
48 changes: 48 additions & 0 deletions
48
DeviceAdapters/AlliedVisionCamera/AlliedVisionCamera.vcxproj.filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="AlliedVisionCamera.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="AlliedVisionHub.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="AlliedVisionDeviceBase.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Loader\Constants.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Loader\LibLoader.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="AlliedVisionCamera.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="AlliedVisionHub.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="AlliedVisionDeviceBase.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="Loader\LibLoader.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "AlliedVisionDeviceBase.h" |
85 changes: 85 additions & 0 deletions
85
DeviceAdapters/AlliedVisionCamera/AlliedVisionDeviceBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*============================================================================= | ||
Copyright (C) 2023 Allied Vision Technologies. All Rights Reserved. | ||
This file is distributed under the BSD license. | ||
License text is included with the source distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | ||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, | ||
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. | ||
=============================================================================*/ | ||
#ifndef ALLIEDVISIONDEVICEBASE_H | ||
#define ALLIEDVISIONDEVICEBASE_H | ||
|
||
#include "DeviceBase.h" | ||
#include "Loader/LibLoader.h" | ||
|
||
#define LOG_ERROR(err, message) logError(err, message, __FUNCTION__, __LINE__) | ||
|
||
/** | ||
* @brief Base class for Allied Vision devices | ||
*/ | ||
template <typename T, typename U> class AlliedVisionDeviceBase : public CDeviceBase<T, U> | ||
{ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// PUBLIC | ||
/////////////////////////////////////////////////////////////////////////////// | ||
public: | ||
/** | ||
* @brief Constructor | ||
*/ | ||
AlliedVisionDeviceBase() | ||
{ | ||
CDeviceBase<T, U>::InitializeDefaultErrorMessages(); | ||
setApiErrorMessages(); | ||
}; | ||
|
||
/** | ||
* @brief Destructor | ||
*/ | ||
virtual ~AlliedVisionDeviceBase() = default; | ||
|
||
void logError(int error, std::string message, std::string function = "", int line = 0) const | ||
{ | ||
std::string prefix = "[" + function + "():" + std::to_string(line) + "] "; | ||
CDeviceBase<T, U>::LogMessage(prefix + message); | ||
CDeviceBase<T, U>::LogMessageCode(error); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// PRIVATE | ||
/////////////////////////////////////////////////////////////////////////////// | ||
private: | ||
/** | ||
* @brief Setup error messages for Vimba API | ||
*/ | ||
void setApiErrorMessages() | ||
{ | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorApiNotStarted, "Vimba X API not started"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorNotFound, "Device cannot be found"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorDeviceNotOpen, "Device cannot be opened"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorBadParameter, "Invalid parameter passed to the function"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorNotImplemented, "Feature not implemented"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorNotSupported, "Feature not supported"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorUnknown, "Unknown error"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorInvalidValue, "The value is not valid: either out of bounds or not an " | ||
"increment of the minimum"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorBadHandle, "Given device handle is not valid"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorInvalidAccess, "Operation is invalid with the current access mode"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorTimeout, "Timeout occured"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorNotAvailable, "Something is not available"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorNotInitialized, "Something is not initialized"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorAlready, "The operation has been already done"); | ||
CDeviceBase<T, U>::SetErrorText(VmbErrorFeaturesUnavailable, "Feature is currently unavailable"); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*============================================================================= | ||
Copyright (C) 2023 Allied Vision Technologies. All Rights Reserved. | ||
This file is distributed under the BSD license. | ||
License text is included with the source distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | ||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, | ||
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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 "AlliedVisionHub.h" | ||
|
||
#include "AlliedVisionCamera.h" | ||
|
||
AlliedVisionHub::AlliedVisionHub() : | ||
m_sdk(std::make_shared<VimbaXApi>()) | ||
{ | ||
} | ||
|
||
int AlliedVisionHub::DetectInstalledDevices() | ||
{ | ||
LogMessage("Detecting installed cameras..."); | ||
VmbUint32_t camNum; | ||
// Get the number of connected cameras first | ||
VmbError_t err = m_sdk->VmbCamerasList_t(nullptr, 0, &camNum, 0); | ||
if (VmbErrorSuccess == err) | ||
{ | ||
VmbCameraInfo_t *camInfo = new VmbCameraInfo_t[camNum]; | ||
|
||
// Get the cameras | ||
err = m_sdk->VmbCamerasList_t(camInfo, camNum, &camNum, sizeof *camInfo); | ||
|
||
if (err == VmbErrorSuccess) | ||
{ | ||
for (VmbUint32_t i = 0; i < camNum; ++i) | ||
{ | ||
if (camInfo[i].permittedAccess & VmbAccessModeFull) | ||
{ | ||
MM::Device *pDev = new AlliedVisionCamera(camInfo[i].cameraIdString); | ||
AddInstalledDevice(pDev); | ||
} | ||
} | ||
} | ||
|
||
delete[] camInfo; | ||
} | ||
else | ||
{ | ||
LOG_ERROR(err, "Cannot get installed devices!"); | ||
} | ||
|
||
return err; | ||
} | ||
|
||
int AlliedVisionHub::Initialize() | ||
{ | ||
LogMessage("Init HUB"); | ||
if (m_sdk->isInitialized()) | ||
{ | ||
return DEVICE_OK; | ||
} | ||
else | ||
{ | ||
LOG_ERROR(VmbErrorApiNotStarted, "SDK not initialized!"); | ||
return VmbErrorApiNotStarted; | ||
} | ||
} | ||
|
||
int AlliedVisionHub::Shutdown() | ||
{ | ||
LogMessage("Shutting down HUB"); | ||
return DEVICE_OK; | ||
} | ||
|
||
void AlliedVisionHub::GetName(char *name) const | ||
{ | ||
CDeviceUtils::CopyLimitedString(name, g_hubName); | ||
} | ||
|
||
bool AlliedVisionHub::Busy() | ||
{ | ||
return false; | ||
} | ||
|
||
std::shared_ptr<VimbaXApi> &AlliedVisionHub::getSDK() | ||
{ | ||
return m_sdk; | ||
} |
Oops, something went wrong.