AVT相机arm版本SDK
This commit is contained in:
129
Vimba_6_0/VimbaCPP/Source/AncillaryData.cpp
Normal file
129
Vimba_6_0/VimbaCPP/Source/AncillaryData.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: AncillaryData.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::AncillaryData.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Include/AncillaryData.h>
|
||||
|
||||
#define IMAGE_CHUNK_TRAILER_LENGTH 8
|
||||
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct AncillaryData::Impl
|
||||
{
|
||||
VmbFrame_t *m_pFrame;
|
||||
};
|
||||
|
||||
AncillaryData::AncillaryData()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
AncillaryData::AncillaryData( const AncillaryData& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
AncillaryData& AncillaryData::operator=( const AncillaryData& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
AncillaryData::AncillaryData( VmbFrame_t *pFrame )
|
||||
: m_pImpl( new Impl() )
|
||||
{
|
||||
m_pImpl->m_pFrame = pFrame;
|
||||
}
|
||||
|
||||
AncillaryData::~AncillaryData()
|
||||
{
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
VmbErrorType AncillaryData::GetBuffer( VmbUchar_t* &rpValue )
|
||||
{
|
||||
VmbErrorType result = VmbErrorNotSupported;
|
||||
|
||||
if (m_pImpl->m_pFrame->ancillarySize > 0)
|
||||
{
|
||||
rpValue = (VmbUchar_t*)m_pImpl->m_pFrame->buffer + m_pImpl->m_pFrame->imageSize + IMAGE_CHUNK_TRAILER_LENGTH;
|
||||
result = VmbErrorSuccess;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VmbErrorType AncillaryData::GetBuffer( const VmbUchar_t* &rpValue ) const
|
||||
{
|
||||
VmbErrorType result = VmbErrorNotSupported;
|
||||
|
||||
if (m_pImpl->m_pFrame->ancillarySize > 0)
|
||||
{
|
||||
rpValue = (VmbUchar_t*)m_pImpl->m_pFrame->buffer + m_pImpl->m_pFrame->imageSize + IMAGE_CHUNK_TRAILER_LENGTH;
|
||||
result = VmbErrorSuccess;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VmbErrorType AncillaryData::GetSize( VmbUint32_t &nSize ) const
|
||||
{
|
||||
nSize = m_pImpl->m_pFrame->ancillarySize;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType AncillaryData::Open()
|
||||
{
|
||||
VmbError_t res;
|
||||
VmbHandle_t hHandle;
|
||||
|
||||
res = VmbAncillaryDataOpen( m_pImpl->m_pFrame, &hHandle );
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
SetHandle( hHandle );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbError_t AncillaryData::Close()
|
||||
{
|
||||
VmbError_t res = VmbErrorSuccess;
|
||||
|
||||
res = VmbAncillaryDataClose( GetHandle() );
|
||||
|
||||
Reset();
|
||||
|
||||
RevokeHandle();
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
877
Vimba_6_0/VimbaCPP/Source/BaseFeature.cpp
Normal file
877
Vimba_6_0/VimbaCPP/Source/BaseFeature.cpp
Normal file
@@ -0,0 +1,877 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: BaseFeature.cpp
|
||||
|
||||
Description: Implementation of base class AVT::VmbAPI::BaseFeature.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#pragma warning(default:4996)
|
||||
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
#include <VimbaCPP/Include/VimbaSystem.h>
|
||||
#include <VimbaCPP/Source/ConditionHelper.h>
|
||||
#include <VimbaCPP/Source/Helper.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct BaseFeature::Impl
|
||||
{
|
||||
LockableVector<IFeatureObserverPtr> m_observers;
|
||||
|
||||
FeaturePtrVector m_affectedFeatures;
|
||||
FeaturePtrVector m_selectedFeatures;
|
||||
bool m_bAffectedFeaturesFetched;
|
||||
bool m_bSelectedFeaturesFetched;
|
||||
|
||||
ConditionHelper m_observersConditionHelper;
|
||||
ConditionHelper m_conditionHelper;
|
||||
|
||||
static void VMB_CALL InvalidationCallback( const VmbHandle_t handle, const char *name, void *context );
|
||||
};
|
||||
|
||||
BaseFeature::BaseFeature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer )
|
||||
: m_pImpl( new Impl() )
|
||||
, m_pFeatureContainer( pFeatureContainer )
|
||||
{
|
||||
m_pImpl->m_bAffectedFeaturesFetched = false;
|
||||
m_pImpl->m_bSelectedFeaturesFetched = false;
|
||||
|
||||
if ( NULL != pFeatureInfo )
|
||||
{
|
||||
m_featureInfo.category.assign( pFeatureInfo->category ? pFeatureInfo->category : "" );
|
||||
m_featureInfo.description.assign( pFeatureInfo->description ? pFeatureInfo->description : "" );
|
||||
m_featureInfo.displayName.assign( pFeatureInfo->displayName ? pFeatureInfo->displayName : "" );
|
||||
m_featureInfo.featureDataType = pFeatureInfo->featureDataType;
|
||||
m_featureInfo.featureFlags = pFeatureInfo->featureFlags;
|
||||
m_featureInfo.hasAffectedFeatures = pFeatureInfo->hasAffectedFeatures;
|
||||
m_featureInfo.hasSelectedFeatures = pFeatureInfo->hasSelectedFeatures;
|
||||
m_featureInfo.name.assign( pFeatureInfo->name ? pFeatureInfo->name : "" );
|
||||
m_featureInfo.pollingTime = pFeatureInfo->pollingTime;
|
||||
m_featureInfo.representation.assign( pFeatureInfo->representation ? pFeatureInfo->representation : "" );
|
||||
m_featureInfo.sfncNamespace.assign( pFeatureInfo->sfncNamespace ? pFeatureInfo->sfncNamespace : "" );
|
||||
m_featureInfo.tooltip.assign( pFeatureInfo->tooltip ? pFeatureInfo->tooltip : "" );
|
||||
m_featureInfo.unit.assign( pFeatureInfo->unit ? pFeatureInfo->unit : "" );
|
||||
m_featureInfo.visibility = pFeatureInfo->visibility;
|
||||
m_featureInfo.isStreamable = pFeatureInfo->isStreamable;
|
||||
|
||||
if ( NULL == m_pFeatureContainer ) // m_pFeatureContainer == NULL (Just for safety)
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "No valid feature container pointer passed" );
|
||||
}
|
||||
}
|
||||
else // m_featureInfo == NULL (Just for safety)
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "No valid feature info pointer passed" );
|
||||
}
|
||||
}
|
||||
|
||||
BaseFeature::BaseFeature()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
BaseFeature::BaseFeature( const BaseFeature& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
BaseFeature::~BaseFeature()
|
||||
{
|
||||
// Before destruction we unregister all observers and all callbacks
|
||||
ResetFeatureContainer();
|
||||
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
// Unregisters all observers before it resets the feature container pointer.
|
||||
void BaseFeature::ResetFeatureContainer()
|
||||
{
|
||||
if ( NULL != m_pFeatureContainer )
|
||||
{
|
||||
// Camera still open
|
||||
if ( NULL != m_pFeatureContainer->GetHandle() )
|
||||
{
|
||||
VmbFeatureInvalidationUnregister( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), m_pImpl->InvalidationCallback );
|
||||
}
|
||||
|
||||
// Begin exclusive write lock this feature
|
||||
if ( true == m_pImpl->m_conditionHelper.EnterWriteLock( GetMutex(), true ))
|
||||
{
|
||||
m_pFeatureContainer = NULL;
|
||||
|
||||
// End write lock this feature
|
||||
m_pImpl->m_conditionHelper.ExitWriteLock( GetMutex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not reset a feature's feature container reference. ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Begin exclusive write lock observer list
|
||||
if ( true == m_pImpl->m_observersConditionHelper.EnterWriteLock( m_pImpl->m_observers, true ))
|
||||
{
|
||||
m_pImpl->m_observers.Vector.clear();
|
||||
|
||||
// End write lock observer list
|
||||
m_pImpl->m_observersConditionHelper.ExitWriteLock( m_pImpl->m_observers );
|
||||
}
|
||||
}
|
||||
|
||||
void VMB_CALL BaseFeature::Impl::InvalidationCallback( const VmbHandle_t handle, const char * /*name*/, void *context )
|
||||
{
|
||||
BaseFeature *pFeature = (BaseFeature*)context;
|
||||
if ( NULL != pFeature )
|
||||
{
|
||||
if ( NULL != handle )
|
||||
{
|
||||
// Begin read lock this feature
|
||||
if ( true == pFeature->m_pImpl->m_conditionHelper.EnterReadLock( pFeature->GetMutex() ))
|
||||
{
|
||||
if ( NULL != pFeature->m_pFeatureContainer )
|
||||
{
|
||||
FeaturePtr pFeaturePtrFromMap;
|
||||
if ( VmbErrorSuccess == pFeature->m_pFeatureContainer->GetFeatureByName( pFeature->m_featureInfo.name.c_str(), pFeaturePtrFromMap ) )
|
||||
{
|
||||
// Begin read lock observer list
|
||||
if ( true == pFeature->m_pImpl->m_observersConditionHelper.EnterReadLock( pFeature->m_pImpl->m_observers ))
|
||||
{
|
||||
for ( IFeatureObserverPtrVector::iterator iter = pFeature->m_pImpl->m_observers.Vector.begin();
|
||||
pFeature->m_pImpl->m_observers.Vector.end() != iter;
|
||||
++iter)
|
||||
{
|
||||
SP_ACCESS(( *iter ))->FeatureChanged( pFeaturePtrFromMap );
|
||||
}
|
||||
|
||||
// End read lock observer list
|
||||
pFeature->m_pImpl->m_observersConditionHelper.ExitReadLock( pFeature->m_pImpl->m_observers );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not lock feature observer list.")
|
||||
}
|
||||
}
|
||||
else // GetFeatureByName() failed
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "GetFeatureByName failed" )
|
||||
}
|
||||
}
|
||||
else // m_pFeatureContainer == NULL (Feature destroyed or device closed / destroyed)
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "Feature destroyed or device closed / destroyed" );
|
||||
}
|
||||
|
||||
// End read lock this feature
|
||||
pFeature->m_pImpl->m_conditionHelper.ExitReadLock( pFeature->GetMutex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not lock feature.")
|
||||
}
|
||||
}
|
||||
else // m_handle == NULL (device closed / destroyed)
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "Device closed / destroyed" )
|
||||
}
|
||||
}
|
||||
else // pFeature == NULL (Just for safety)
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "Feature pointer is null" )
|
||||
}
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::RegisterObserver( const IFeatureObserverPtr &rObserver )
|
||||
{
|
||||
if ( SP_ISNULL( rObserver ))
|
||||
{
|
||||
return VmbErrorBadParameter;
|
||||
}
|
||||
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
VmbError_t res = VmbErrorSuccess;
|
||||
|
||||
// Begin write lock observer list
|
||||
if ( true == m_pImpl->m_observersConditionHelper.EnterWriteLock( m_pImpl->m_observers ))
|
||||
{
|
||||
// The very same observer cannot be registered twice
|
||||
for ( size_t i=0; i<m_pImpl->m_observers.Vector.size(); ++i )
|
||||
{
|
||||
if ( SP_ISEQUAL( rObserver, m_pImpl->m_observers.Vector[i] ))
|
||||
{
|
||||
res = VmbErrorInvalidCall;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
if ( 0 == m_pImpl->m_observers.Vector.size() )
|
||||
{
|
||||
res = VmbFeatureInvalidationRegister( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), m_pImpl->InvalidationCallback, this );
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
m_pImpl->m_observers.Vector.push_back( rObserver );
|
||||
}
|
||||
}
|
||||
|
||||
// End write lock observer list
|
||||
m_pImpl->m_observersConditionHelper.ExitWriteLock( m_pImpl->m_observers );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::UnregisterObserver( const IFeatureObserverPtr &rObserver )
|
||||
{
|
||||
if ( SP_ISNULL( rObserver ))
|
||||
{
|
||||
return VmbErrorBadParameter;
|
||||
}
|
||||
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
VmbError_t res = VmbErrorNotFound;
|
||||
|
||||
// Begin exclusive write lock observer list
|
||||
if ( true == m_pImpl->m_observersConditionHelper.EnterWriteLock( m_pImpl->m_observers, true ))
|
||||
{
|
||||
for ( IFeatureObserverPtrVector::iterator iter = m_pImpl->m_observers.Vector.begin();
|
||||
m_pImpl->m_observers.Vector.end() != iter;)
|
||||
{
|
||||
if ( SP_ISEQUAL( rObserver, *iter ))
|
||||
{
|
||||
// If we are about to unregister the last observer we cancel all invalidation notifications
|
||||
if ( 1 == m_pImpl->m_observers.Vector.size() )
|
||||
{
|
||||
res = VmbFeatureInvalidationUnregister( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), m_pImpl->InvalidationCallback );
|
||||
}
|
||||
if ( VmbErrorSuccess == res
|
||||
|| 1 < m_pImpl->m_observers.Vector.size() )
|
||||
{
|
||||
iter = m_pImpl->m_observers.Vector.erase( iter );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
// End write lock observer list
|
||||
m_pImpl->m_observersConditionHelper.ExitWriteLock( m_pImpl->m_observers );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not lock feature observer list.")
|
||||
res = VmbErrorInternalFault;
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType BaseFeature::GetValue( VmbInt64_t & /*rnValue*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType BaseFeature::SetValue( const VmbInt64_t & /*rnValue*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType BaseFeature::SetValue( const VmbInt32_t & /*rnValue*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the range of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType BaseFeature::GetRange( VmbInt64_t & /*rnMinimum*/, VmbInt64_t & /*rnMaximum*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::HasIncrement( VmbBool_t & /*incrementSupported*/) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
// Gets the increment of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType BaseFeature::GetIncrement( VmbInt64_t & /*rnIncrement*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the increment of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType BaseFeature::GetIncrement( double & /*rnIncrement*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType BaseFeature::GetValue( double & /*rfValue*/) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType BaseFeature::SetValue( const double & /*rfValue*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the range of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType BaseFeature::GetRange( double & /*rfMinimum*/, double & /*rfMaximum*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataEnum
|
||||
// Sets the value of a feature of type VmbFeatureDataString
|
||||
VmbErrorType BaseFeature::SetValue( const char * /*pStrValue*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the enum entry of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType BaseFeature::GetEntry( EnumEntry & /*entry*/, const char * /*pStrEntryName*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets all possible enum entries of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType BaseFeature::GetEntries( EnumEntry * /*pEnumEntries*/, VmbUint32_t & /*size*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets all possible values as string of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType BaseFeature::GetValues( const char ** /*pStrValues*/, VmbUint32_t & /*rnSize*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets all possible values as integer of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType BaseFeature::GetValues( VmbInt64_t * /*pnValues*/, VmbUint32_t & /*rnSize*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Indicates whether a particular enum value as string of a feature of type VmbFeatureDataEnum is available
|
||||
VmbErrorType BaseFeature::IsValueAvailable( const char * /*pStrValue*/, bool & /*bAvailable*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Indicates whether a particular enum value as integer of a feature of type VmbFeatureDataEnum is available
|
||||
VmbErrorType BaseFeature::IsValueAvailable( const VmbInt64_t /*nValue*/, bool & /*bAvailable*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataString
|
||||
// Gets the value of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType BaseFeature::GetValue( char * const /*pStrValue*/, VmbUint32_t & /*length*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataBool
|
||||
VmbErrorType BaseFeature::GetValue( bool & /*rbValue*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataBool
|
||||
VmbErrorType BaseFeature::SetValue( bool /*bValue*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Executes a feature of type VmbFeatureDataCommand
|
||||
VmbErrorType BaseFeature::RunCommand()
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Indicates whether a feature of type VmbFeatureDataCommand finished execution
|
||||
VmbErrorType BaseFeature::IsCommandDone( bool & /*bIsDone*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataRaw
|
||||
VmbErrorType BaseFeature::GetValue( VmbUchar_t * /*pValue*/, VmbUint32_t & /*rnSize*/, VmbUint32_t & /*rnSizeFilled*/ ) const
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataRaw
|
||||
VmbErrorType BaseFeature::SetValue( const VmbUchar_t * /*pValue*/, VmbUint32_t /*nSize*/ )
|
||||
{
|
||||
return VmbErrorWrongType;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrName )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.name.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.name.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.name.begin(), m_featureInfo.name.end(), pStrName );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.name.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetDisplayName( char * const pStrDisplayName, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrDisplayName )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.displayName.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.displayName.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.displayName.begin(), m_featureInfo.displayName.end(), pStrDisplayName );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.displayName.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetDataType( VmbFeatureDataType &reDataType ) const
|
||||
{
|
||||
reDataType = (VmbFeatureDataType)m_featureInfo.featureDataType;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetFlags( VmbFeatureFlagsType &reFlags ) const
|
||||
{
|
||||
reFlags = (VmbFeatureFlagsType)m_featureInfo.featureFlags;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetCategory( char * const pStrCategory, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrCategory )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.category.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.category.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.category.begin(), m_featureInfo.category.end(), pStrCategory );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.category.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetPollingTime( VmbUint32_t &rnPollingTime ) const
|
||||
{
|
||||
rnPollingTime = m_featureInfo.pollingTime;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetUnit( char * const pStrUnit, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrUnit )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.unit.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.unit.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.unit.begin(), m_featureInfo.unit.end(), pStrUnit );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.unit.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetRepresentation( char * const pStrRepresentation, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrRepresentation )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.representation.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.representation.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.representation.begin(), m_featureInfo.representation.end(), pStrRepresentation );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.representation.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetVisibility( VmbFeatureVisibilityType &reVisibility ) const
|
||||
{
|
||||
reVisibility = (VmbFeatureVisibilityType)m_featureInfo.visibility;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetToolTip( char * const pStrToolTip, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrToolTip )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.tooltip.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.tooltip.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.tooltip.begin(), m_featureInfo.tooltip.end(), pStrToolTip );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.tooltip.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetDescription( char * const pStrDescription, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrDescription )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.description.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.description.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.description.begin(), m_featureInfo.description.end(), pStrDescription );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.description.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetSFNCNamespace( char * const pStrSFNCNamespace, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrSFNCNamespace )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_featureInfo.sfncNamespace.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_featureInfo.sfncNamespace.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_featureInfo.sfncNamespace.begin(), m_featureInfo.sfncNamespace.end(), pStrSFNCNamespace );
|
||||
rnLength = (VmbUint32_t)m_featureInfo.sfncNamespace.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &rnSize )
|
||||
{
|
||||
VmbError_t res;
|
||||
|
||||
if ( NULL == pAffectedFeatures )
|
||||
{
|
||||
// Affected features were fetched before
|
||||
if ( true == m_pImpl->m_bAffectedFeaturesFetched )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_affectedFeatures.size();
|
||||
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
// Affected features have not been fetched before
|
||||
else
|
||||
{
|
||||
return (VmbErrorType)VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &rnSize, sizeof(VmbFeatureInfo_t) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Affected features were fetched before
|
||||
if ( true == m_pImpl->m_bAffectedFeaturesFetched )
|
||||
{
|
||||
if ( rnSize < m_pImpl->m_affectedFeatures.size() )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_affectedFeatures.size();
|
||||
|
||||
std::copy( m_pImpl->m_affectedFeatures.begin(), m_pImpl->m_affectedFeatures.end(), pAffectedFeatures );
|
||||
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
// Affected features have not been fetched before
|
||||
else
|
||||
{
|
||||
// Check whether the given array size fits
|
||||
VmbUint32_t nSize = 0;
|
||||
res = VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nSize, sizeof(VmbFeatureInfo_t) );
|
||||
|
||||
m_pImpl->m_bAffectedFeaturesFetched = true;
|
||||
|
||||
if ( rnSize < nSize )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)nSize;
|
||||
|
||||
if ( VmbErrorSuccess != res
|
||||
|| 0 == rnSize )
|
||||
{
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
// Fetch affected features and store them as well as hand them out
|
||||
std::vector<VmbFeatureInfo_t> affectedFeatureInfos;
|
||||
affectedFeatureInfos.resize( rnSize );
|
||||
|
||||
res = VmbFeatureListAffected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &affectedFeatureInfos[0], (VmbUint32_t)affectedFeatureInfos.size(), &nSize, sizeof(VmbFeatureInfo_t) );
|
||||
|
||||
if ( rnSize < nSize )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)nSize;
|
||||
|
||||
for ( VmbUint32_t i=0; i<rnSize; ++i )
|
||||
{
|
||||
FeaturePtr pFeature;
|
||||
res = m_pFeatureContainer->GetFeatureByName( affectedFeatureInfos[i].name, pFeature );
|
||||
if ( VmbErrorSuccess != res )
|
||||
{
|
||||
m_pImpl->m_affectedFeatures.clear();
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
m_pImpl->m_affectedFeatures.push_back( pFeature );
|
||||
pAffectedFeatures[i] = m_pImpl->m_affectedFeatures[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &rnSize )
|
||||
{
|
||||
VmbError_t res;
|
||||
|
||||
if ( NULL == pSelectedFeatures )
|
||||
{
|
||||
// Selected features were fetched before
|
||||
if ( true == m_pImpl->m_bSelectedFeaturesFetched )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_selectedFeatures.size();
|
||||
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
// Selected features have not been fetched before
|
||||
else
|
||||
{
|
||||
return (VmbErrorType)VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &rnSize, sizeof(VmbFeatureInfo_t) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Selected features were fetched before
|
||||
if ( true == m_pImpl->m_bSelectedFeaturesFetched )
|
||||
{
|
||||
if ( rnSize < m_pImpl->m_selectedFeatures.size() )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_selectedFeatures.size();
|
||||
|
||||
std::copy( m_pImpl->m_selectedFeatures.begin(), m_pImpl->m_selectedFeatures.end(), pSelectedFeatures );
|
||||
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
// Selected features have not been fetched before
|
||||
else
|
||||
{
|
||||
// Check whether the given array size fits
|
||||
VmbUint32_t nSize = 0;
|
||||
res = VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nSize, sizeof(VmbFeatureInfo_t) );
|
||||
|
||||
m_pImpl->m_bSelectedFeaturesFetched = true;
|
||||
|
||||
if ( rnSize < nSize )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)nSize;
|
||||
|
||||
if ( VmbErrorSuccess != res
|
||||
|| 0 == rnSize )
|
||||
{
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
// Fetch selected features and store them as well as hand them out
|
||||
std::vector<VmbFeatureInfo_t> selectedFeatureInfos;
|
||||
selectedFeatureInfos.resize( rnSize );
|
||||
|
||||
res = VmbFeatureListSelected( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &selectedFeatureInfos[0], (VmbUint32_t)selectedFeatureInfos.size(), &nSize, sizeof(VmbFeatureInfo_t) );
|
||||
|
||||
if ( rnSize < nSize )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
rnSize = (VmbUint32_t)nSize;
|
||||
|
||||
for ( VmbUint32_t i=0; i<rnSize; ++i )
|
||||
{
|
||||
FeaturePtr pFeature;
|
||||
res = m_pFeatureContainer->GetFeatureByName( selectedFeatureInfos[i].name, pFeature );
|
||||
if ( VmbErrorSuccess != res )
|
||||
{
|
||||
m_pImpl->m_selectedFeatures.clear();
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
m_pImpl->m_selectedFeatures.push_back( pFeature );
|
||||
pSelectedFeatures[i] = m_pImpl->m_selectedFeatures[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::IsReadable( bool &rbIsReadable )
|
||||
{
|
||||
bool bIsWritable = false;
|
||||
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureAccessQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rbIsReadable, &bIsWritable );
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::IsWritable( bool &rbIsWritable )
|
||||
{
|
||||
bool bIsReadable = false;
|
||||
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureAccessQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &bIsReadable, &rbIsWritable );
|
||||
}
|
||||
|
||||
VmbErrorType BaseFeature::IsStreamable( bool &rbIsStreamable ) const
|
||||
{
|
||||
rbIsStreamable = m_featureInfo.isStreamable;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
144
Vimba_6_0/VimbaCPP/Source/BaseFeature.h
Normal file
144
Vimba_6_0/VimbaCPP/Source/BaseFeature.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: BaseFeature.h
|
||||
|
||||
Description: Definition of base class AVT::VmbAPI::BaseFeature.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_BASEFEATURE_H
|
||||
#define AVT_VMBAPI_BASEFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Include/BasicLockable.h>
|
||||
#include <VimbaCPP/Include/Feature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class BaseFeature : public virtual BasicLockable
|
||||
{
|
||||
friend class Feature;
|
||||
|
||||
public:
|
||||
BaseFeature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer );
|
||||
virtual ~BaseFeature();
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetValue( VmbInt64_t &value ) const;
|
||||
IMEXPORT virtual VmbErrorType GetValue( double &value ) const;
|
||||
IMEXPORT virtual VmbErrorType GetValue( bool &value ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbInt32_t &value );
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbInt64_t &value );
|
||||
IMEXPORT virtual VmbErrorType SetValue( const double &value );
|
||||
IMEXPORT virtual VmbErrorType SetValue( const char *pValue );
|
||||
IMEXPORT virtual VmbErrorType SetValue( bool value );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetEntry( EnumEntry &entry, const char * pStrEntryName ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetRange( VmbInt64_t &minimum, VmbInt64_t &maximum ) const;
|
||||
IMEXPORT virtual VmbErrorType GetRange( double &minimum, double &maximum ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType HasIncrement( VmbBool_t &incrementSupported) const;
|
||||
IMEXPORT virtual VmbErrorType GetIncrement( VmbInt64_t &increment ) const;
|
||||
IMEXPORT virtual VmbErrorType GetIncrement( double &increment ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType IsValueAvailable( const char *pValue, bool &available ) const;
|
||||
IMEXPORT virtual VmbErrorType IsValueAvailable( const VmbInt64_t value, bool &available ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType RunCommand();
|
||||
IMEXPORT virtual VmbErrorType IsCommandDone( bool &isDone ) const;
|
||||
|
||||
IMEXPORT VmbErrorType GetDataType( VmbFeatureDataType &dataType ) const;
|
||||
IMEXPORT VmbErrorType GetFlags( VmbFeatureFlagsType &flags ) const;
|
||||
IMEXPORT VmbErrorType GetPollingTime( VmbUint32_t &pollingTime ) const;
|
||||
IMEXPORT VmbErrorType GetVisibility( VmbFeatureVisibilityType &visibility ) const;
|
||||
IMEXPORT VmbErrorType IsReadable( bool &isReadable );
|
||||
IMEXPORT VmbErrorType IsWritable( bool &isWritable );
|
||||
IMEXPORT VmbErrorType IsStreamable( bool &isStreamable ) const;
|
||||
|
||||
IMEXPORT VmbErrorType RegisterObserver( const IFeatureObserverPtr &observer );
|
||||
IMEXPORT VmbErrorType UnregisterObserver( const IFeatureObserverPtr &observer );
|
||||
|
||||
void ResetFeatureContainer();
|
||||
|
||||
protected:
|
||||
// Copy of feature infos
|
||||
struct FeatureInfo
|
||||
{
|
||||
std::string name; // Verbose name
|
||||
VmbFeatureData_t featureDataType; // Data type of this feature
|
||||
VmbFeatureFlags_t featureFlags; // Access flags for this feature
|
||||
bool hasAffectedFeatures; // true if the feature selects or invalidates other features
|
||||
bool hasSelectedFeatures; // true if the feature selects other features
|
||||
std::string category; // Category this feature can be found in
|
||||
std::string displayName; // Feature name to be used in GUIs
|
||||
VmbUint32_t pollingTime; // Predefined polling time for volatile features
|
||||
std::string unit; // Measuring unit as given in the XML file
|
||||
std::string representation; // Representation of a numeric feature
|
||||
VmbFeatureVisibility_t visibility; // GUI visibility
|
||||
std::string tooltip; // Short description
|
||||
std::string description; // Longer description
|
||||
std::string sfncNamespace; // Namespace this feature resides in
|
||||
bool isStreamable; // Feature can be stored or loaded from/into a file
|
||||
};
|
||||
|
||||
FeatureInfo m_featureInfo;
|
||||
|
||||
FeatureContainer *m_pFeatureContainer;
|
||||
|
||||
private:
|
||||
// Default ctor
|
||||
BaseFeature();
|
||||
|
||||
// Copy ctor
|
||||
BaseFeature( const BaseFeature& );
|
||||
|
||||
struct Impl;
|
||||
Impl *m_pImpl;
|
||||
|
||||
// Array functions to pass data across DLL boundaries
|
||||
IMEXPORT virtual VmbErrorType GetValue( char * const pValue, VmbUint32_t &length ) const;
|
||||
IMEXPORT virtual VmbErrorType GetValue( VmbUchar_t *pValue, VmbUint32_t &size, VmbUint32_t &sizeFilled ) const;
|
||||
IMEXPORT virtual VmbErrorType GetValues( const char **pValues, VmbUint32_t &size );
|
||||
IMEXPORT virtual VmbErrorType GetValues( VmbInt64_t *pValues, VmbUint32_t &Size );
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbUchar_t *pValue, VmbUint32_t size );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetEntries( EnumEntry *pEntries, VmbUint32_t &size );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetName( char * const pName, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetDisplayName( char * const pDisplayName, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetCategory( char * const pCategory, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetUnit( char * const pUnit, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetRepresentation( char * const pRepresentation, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetToolTip( char * const pToolTip, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetDescription( char * const pDescription, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetSFNCNamespace( char * const pSFNCNamespace, VmbUint32_t &length ) const;
|
||||
IMEXPORT VmbErrorType GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &nSize );
|
||||
IMEXPORT VmbErrorType GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &nSize );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
57
Vimba_6_0/VimbaCPP/Source/BasicLockable.cpp
Normal file
57
Vimba_6_0/VimbaCPP/Source/BasicLockable.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: BasicLockable.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::BasicLockable.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Include/BasicLockable.h>
|
||||
#include <VimbaCPP/Include/LoggerDefines.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
BasicLockable::BasicLockable()
|
||||
: m_pMutex( MutexPtr( new Mutex() ))
|
||||
{
|
||||
}
|
||||
|
||||
BasicLockable::~BasicLockable()
|
||||
{
|
||||
}
|
||||
|
||||
BasicLockable::BasicLockable( MutexPtr pMutex )
|
||||
: m_pMutex( pMutex )
|
||||
{
|
||||
}
|
||||
|
||||
MutexPtr& BasicLockable::GetMutex()
|
||||
{
|
||||
return m_pMutex;
|
||||
}
|
||||
const MutexPtr& BasicLockable::GetMutex() const
|
||||
{
|
||||
return m_pMutex;
|
||||
}
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
58
Vimba_6_0/VimbaCPP/Source/BoolFeature.cpp
Normal file
58
Vimba_6_0/VimbaCPP/Source/BoolFeature.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: BoolFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::BoolFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/BoolFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
BoolFeature::BoolFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
|
||||
: BaseFeature( featureInfo, pFeatureContainer )
|
||||
{}
|
||||
|
||||
VmbErrorType BoolFeature::GetValue( bool &rbValue ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureBoolGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rbValue );
|
||||
}
|
||||
|
||||
VmbErrorType BoolFeature::SetValue( bool bValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureBoolSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), bValue );
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
66
Vimba_6_0/VimbaCPP/Source/BoolFeature.h
Normal file
66
Vimba_6_0/VimbaCPP/Source/BoolFeature.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: BoolFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::BoolFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_BOOLFEATURE_H
|
||||
#define AVT_VMBAPI_BOOLFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class BoolFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
BoolFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer );
|
||||
|
||||
//
|
||||
// Method: GetValue()
|
||||
// Purpose: Get the value of a boolean feature
|
||||
// Parameters:
|
||||
// [out] bool& value bool value
|
||||
// Returns:
|
||||
// - VmbErrorSuccess: If no error
|
||||
// - VmbErrorWrongType: Feature is not a bool feature
|
||||
// - VmbInternalError: Value could not get queried
|
||||
//
|
||||
IMEXPORT virtual VmbErrorType GetValue( bool &value ) const;
|
||||
|
||||
//
|
||||
// Method: SetValue()
|
||||
// Purpose: Set the value of a boolean feature
|
||||
//
|
||||
IMEXPORT virtual VmbErrorType SetValue( bool value );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
1413
Vimba_6_0/VimbaCPP/Source/Camera.cpp
Normal file
1413
Vimba_6_0/VimbaCPP/Source/Camera.cpp
Normal file
File diff suppressed because it is too large
Load Diff
148
Vimba_6_0/VimbaCPP/Source/Clock.cpp
Normal file
148
Vimba_6_0/VimbaCPP/Source/Clock.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Clock.cpp
|
||||
|
||||
Description: Implementation of a platform independent Sleep.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <sys/timeb.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <VimbaCPP/Source/Clock.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Clock::Clock()
|
||||
: m_dStartTime(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
Clock::~Clock()
|
||||
{
|
||||
}
|
||||
|
||||
void Clock::Reset()
|
||||
{
|
||||
m_dStartTime = 0.0;
|
||||
}
|
||||
|
||||
void Clock::SetStartTime()
|
||||
{
|
||||
m_dStartTime = GetAbsTime();
|
||||
}
|
||||
|
||||
void Clock::SetStartTime( double dStartTime )
|
||||
{
|
||||
m_dStartTime = dStartTime;
|
||||
}
|
||||
|
||||
double Clock::GetTime() const
|
||||
{
|
||||
double dTime = 0.0;
|
||||
|
||||
#ifdef WIN32
|
||||
_timeb currSysTime;
|
||||
|
||||
_ftime_s(&currSysTime);
|
||||
|
||||
dTime = (currSysTime.time + ((double)currSysTime.millitm) / 1000.0);
|
||||
#else
|
||||
timeval now;
|
||||
|
||||
if(gettimeofday(&now, (struct timezone *)0)) return 0.0;
|
||||
|
||||
dTime = ((double)now.tv_sec) + ((double)(now.tv_usec) / 1000000.0);
|
||||
#endif
|
||||
|
||||
return dTime - m_dStartTime;
|
||||
}
|
||||
|
||||
double Clock::GetAbsTime()
|
||||
{
|
||||
double dAbsTime = 0.0;
|
||||
|
||||
#ifdef WIN32
|
||||
_timeb currSysTime;
|
||||
|
||||
_ftime_s(&currSysTime);
|
||||
|
||||
dAbsTime = (currSysTime.time + ((double)currSysTime.millitm) / 1000.0);
|
||||
#else
|
||||
timeval now;
|
||||
|
||||
if(gettimeofday(&now, (struct timezone *)0)) return 0.0;
|
||||
|
||||
dAbsTime = ((double)now.tv_sec) + ((double)(now.tv_usec) / 1000000.0);
|
||||
#endif
|
||||
|
||||
return dAbsTime;
|
||||
}
|
||||
|
||||
void Clock::Sleep(double dTime)
|
||||
{
|
||||
#ifdef WIN32
|
||||
::Sleep((unsigned long)(dTime * 1000.0));
|
||||
#else
|
||||
::usleep((unsigned long)(dTime * 1000000.0));
|
||||
#endif
|
||||
}
|
||||
|
||||
void Clock::SleepMS(unsigned long nTimeMS)
|
||||
{
|
||||
#ifdef WIN32
|
||||
::Sleep(nTimeMS);
|
||||
#else
|
||||
::usleep(nTimeMS * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Clock::SleepAbs(double dAbsTime)
|
||||
{
|
||||
Clock clock;
|
||||
double dTimeDiff = dAbsTime - clock.GetTime();
|
||||
|
||||
#ifdef WIN32
|
||||
if(dTimeDiff > 4000000.0) dTimeDiff = 4000000.0;
|
||||
#else
|
||||
if(dTimeDiff >= 4000.0) dTimeDiff = 4000.0;
|
||||
#endif
|
||||
while(dTimeDiff > 0.0)
|
||||
{
|
||||
Sleep(dTimeDiff);
|
||||
dTimeDiff = dAbsTime - clock.GetTime();
|
||||
#ifdef WIN32
|
||||
if(dTimeDiff > 4000000.0) dTimeDiff = 4000000.0;
|
||||
#else
|
||||
if(dTimeDiff >= 4000.0) dTimeDiff = 4000.0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
58
Vimba_6_0/VimbaCPP/Source/Clock.h
Normal file
58
Vimba_6_0/VimbaCPP/Source/Clock.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Clock.h
|
||||
|
||||
Description: Definition of a platform independent Sleep.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_CLOCK
|
||||
#define AVT_VMBAPI_CLOCK
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class Clock
|
||||
{
|
||||
public:
|
||||
Clock();
|
||||
virtual ~Clock();
|
||||
|
||||
virtual void Reset();
|
||||
virtual void SetStartTime();
|
||||
virtual void SetStartTime( double dStartTime );
|
||||
virtual double GetTime() const;
|
||||
|
||||
static double GetAbsTime();
|
||||
|
||||
static void Sleep( double dTime );
|
||||
static void SleepMS( unsigned long nTimeMS );
|
||||
static void SleepAbs( double dAbsTime );
|
||||
|
||||
protected:
|
||||
double m_dStartTime;
|
||||
};
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
|
||||
#endif //AVT_VMBAPI_CLOCK
|
||||
60
Vimba_6_0/VimbaCPP/Source/CommandFeature.cpp
Normal file
60
Vimba_6_0/VimbaCPP/Source/CommandFeature.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: CommandFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::CommandFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/CommandFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
CommandFeature::CommandFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer *pFeatureContainer )
|
||||
:BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType CommandFeature::RunCommand()
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureCommandRun( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str() );
|
||||
}
|
||||
|
||||
VmbErrorType CommandFeature::IsCommandDone( bool &rbIsDone ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureCommandIsDone( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rbIsDone );
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
52
Vimba_6_0/VimbaCPP/Source/CommandFeature.h
Normal file
52
Vimba_6_0/VimbaCPP/Source/CommandFeature.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: CommandFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::CommandFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_COMMANDFEATURE_H
|
||||
#define AVT_VMBAPI_COMMANDFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VmbCommonTypes.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class CommandFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
CommandFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer *pFeatureContainer );
|
||||
|
||||
IMEXPORT virtual VmbErrorType RunCommand();
|
||||
|
||||
IMEXPORT virtual VmbErrorType IsCommandDone( bool & isDone ) const;
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
105
Vimba_6_0/VimbaCPP/Source/Condition.cpp
Normal file
105
Vimba_6_0/VimbaCPP/Source/Condition.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Condition.cpp
|
||||
|
||||
Description: Implementation of a condition class.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/Condition.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Condition::Condition()
|
||||
: m_nWaiterNumber( 0 )
|
||||
, m_nReleaseNumber( 0 )
|
||||
, m_bLocked( true )
|
||||
{
|
||||
SP_SET( m_Semaphore, new Semaphore() );
|
||||
}
|
||||
|
||||
void Condition::Wait( const BasicLockable &rLockable )
|
||||
{
|
||||
Wait( rLockable.GetMutex() );
|
||||
}
|
||||
|
||||
void Condition::Wait( const MutexPtr &rMutex )
|
||||
{
|
||||
m_nWaiterNumber++;
|
||||
|
||||
SP_ACCESS( rMutex )->Unlock();
|
||||
|
||||
SP_ACCESS( m_Semaphore )->Acquire();
|
||||
|
||||
SP_ACCESS( rMutex) ->Lock();
|
||||
|
||||
if ( m_nWaiterNumber > 0 )
|
||||
{
|
||||
m_nWaiterNumber--;
|
||||
}
|
||||
|
||||
if ( m_nReleaseNumber > 0 )
|
||||
{
|
||||
m_nReleaseNumber--;
|
||||
}
|
||||
|
||||
if( m_nWaiterNumber > 0
|
||||
&& m_nReleaseNumber > 0 )
|
||||
{
|
||||
SP_ACCESS( m_Semaphore )->Release();
|
||||
m_bLocked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bLocked = true;
|
||||
}
|
||||
|
||||
if( m_nReleaseNumber > m_nWaiterNumber )
|
||||
{
|
||||
m_nReleaseNumber = m_nWaiterNumber;
|
||||
}
|
||||
}
|
||||
|
||||
void Condition::Signal( bool bSingle )
|
||||
{
|
||||
if( m_nWaiterNumber > m_nReleaseNumber )
|
||||
{
|
||||
if( true == bSingle )
|
||||
{
|
||||
m_nReleaseNumber++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nReleaseNumber = m_nWaiterNumber;
|
||||
}
|
||||
|
||||
if( true == m_bLocked )
|
||||
{
|
||||
SP_ACCESS( m_Semaphore )->Release();
|
||||
m_bLocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
59
Vimba_6_0/VimbaCPP/Source/Condition.h
Normal file
59
Vimba_6_0/VimbaCPP/Source/Condition.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Condition.h
|
||||
|
||||
Description: Definition of a condition class.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_CONDITION_H
|
||||
#define AVT_VMBAPI_CONDITION_H
|
||||
|
||||
#include <VimbaCPP/Include/Mutex.h>
|
||||
#include <VimbaCPP/Source/Semaphore.h>
|
||||
#include <VimbaCPP/Include/BasicLockable.h>
|
||||
#include <VimbaCPP/Include/SharedPointerDefines.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class Condition
|
||||
{
|
||||
private:
|
||||
unsigned long m_nReleaseNumber;
|
||||
unsigned long m_nWaiterNumber;
|
||||
bool m_bLocked;
|
||||
SP_DECL( Semaphore ) m_Semaphore; // A binary semaphore (non recursive mutex)
|
||||
|
||||
public:
|
||||
Condition();
|
||||
|
||||
void Wait( const BasicLockable &rLockable );
|
||||
void Wait( const MutexPtr &rMutex );
|
||||
|
||||
void Signal( bool bSingle = false );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif //CONDITION_H
|
||||
119
Vimba_6_0/VimbaCPP/Source/ConditionHelper.cpp
Normal file
119
Vimba_6_0/VimbaCPP/Source/ConditionHelper.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: ConditionHelper.cpp
|
||||
|
||||
Description: Implementation of helper class for conditions.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/ConditionHelper.h>
|
||||
|
||||
#include <VimbaCPP/Source/MutexGuard.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
ConditionHelper::ConditionHelper()
|
||||
: m_nNumListReads( 0 )
|
||||
, m_bIsWritingList( false )
|
||||
, m_bExclusive( false )
|
||||
{
|
||||
}
|
||||
|
||||
bool ConditionHelper::EnterReadLock( BasicLockable &rLockable )
|
||||
{
|
||||
return EnterReadLock( rLockable.GetMutex() );
|
||||
}
|
||||
bool ConditionHelper::EnterReadLock( MutexPtr &pMutex )
|
||||
{
|
||||
MutexGuard guard( pMutex );
|
||||
if ( true == m_bExclusive )
|
||||
{
|
||||
guard.Release();
|
||||
return false;
|
||||
}
|
||||
while ( true == m_bIsWritingList )
|
||||
{
|
||||
m_WriteCondition.Wait( pMutex );
|
||||
}
|
||||
++m_nNumListReads;
|
||||
guard.Release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConditionHelper::ExitReadLock( BasicLockable &rLockable )
|
||||
{
|
||||
ExitReadLock( rLockable.GetMutex() );
|
||||
}
|
||||
void ConditionHelper::ExitReadLock( MutexPtr &pMutex )
|
||||
{
|
||||
MutexGuard guard( pMutex );
|
||||
if ( 0 == --m_nNumListReads )
|
||||
{
|
||||
m_ReadCondition.Signal();
|
||||
}
|
||||
guard.Release();
|
||||
}
|
||||
|
||||
bool ConditionHelper::EnterWriteLock( BasicLockable &rLockable, bool bExclusive )
|
||||
{
|
||||
return EnterWriteLock( rLockable.GetMutex(), bExclusive );
|
||||
}
|
||||
bool ConditionHelper::EnterWriteLock( MutexPtr &pMutex, bool bExclusive )
|
||||
{
|
||||
MutexGuard guard( pMutex );
|
||||
if ( true == m_bExclusive )
|
||||
{
|
||||
guard.Release();
|
||||
return false;
|
||||
}
|
||||
while ( true == m_bIsWritingList )
|
||||
{
|
||||
m_WriteCondition.Wait( pMutex );
|
||||
}
|
||||
m_bIsWritingList = true;
|
||||
m_bExclusive = bExclusive;
|
||||
while ( 0 < m_nNumListReads )
|
||||
{
|
||||
m_ReadCondition.Wait( pMutex );
|
||||
}
|
||||
guard.Release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConditionHelper::ExitWriteLock( BasicLockable &rLockable )
|
||||
{
|
||||
ExitWriteLock( rLockable.GetMutex() );
|
||||
}
|
||||
void ConditionHelper::ExitWriteLock( MutexPtr &pMutex )
|
||||
{
|
||||
MutexGuard guard( pMutex );
|
||||
m_bIsWritingList = false;
|
||||
m_bExclusive = false;
|
||||
m_WriteCondition.Signal();
|
||||
guard.Release();
|
||||
}
|
||||
|
||||
}} // namespace AV::VimbaAPI
|
||||
68
Vimba_6_0/VimbaCPP/Source/ConditionHelper.h
Normal file
68
Vimba_6_0/VimbaCPP/Source/ConditionHelper.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: ConditionHelper.h
|
||||
|
||||
Description: Definition of helper class for conditions.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_CONDITIONHELPER_H
|
||||
#define AVT_VMBAPI_CONDITIONHELPER_H
|
||||
|
||||
#include <VimbaCPP/Source/Condition.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class ConditionHelper
|
||||
{
|
||||
public:
|
||||
ConditionHelper();
|
||||
|
||||
// Waits until writing access has finished and returns true.
|
||||
// If exclusive writing access was granted the function exits immediately without locking and returns false
|
||||
bool EnterReadLock( BasicLockable &rLockable );
|
||||
bool EnterReadLock( MutexPtr &pMutex );
|
||||
void ExitReadLock( BasicLockable &rLockable );
|
||||
void ExitReadLock( MutexPtr &pMutex );
|
||||
|
||||
// Waits until writing and reading access have finished and returns true.
|
||||
// If exclusive writing access was granted the function exits immediately without locking and returns false
|
||||
bool EnterWriteLock( BasicLockable &rLockable, bool bExclusive = false );
|
||||
bool EnterWriteLock( MutexPtr &pMutex, bool bExclusive = false );
|
||||
void ExitWriteLock( BasicLockable &rLockable );
|
||||
void ExitWriteLock( MutexPtr &pMutex );
|
||||
|
||||
private:
|
||||
Condition m_ReadCondition;
|
||||
Condition m_WriteCondition;
|
||||
bool m_bIsWritingList;
|
||||
bool m_bExclusive;
|
||||
int m_nNumListReads;
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif // CONDITIONHELPER_H
|
||||
49
Vimba_6_0/VimbaCPP/Source/DefaultCameraFactory.cpp
Normal file
49
Vimba_6_0/VimbaCPP/Source/DefaultCameraFactory.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: DefaultCameraFactory.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::DefaultCameraFactory used to
|
||||
create new Camera objects if no user defined camera factory
|
||||
class was provided.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/DefaultCameraFactory.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
CameraPtr DefaultCameraFactory::CreateCamera( const char *pCameraID,
|
||||
const char *pCameraName,
|
||||
const char *pCameraModel,
|
||||
const char *pCameraSerialNumber,
|
||||
const char *pInterfaceID,
|
||||
VmbInterfaceType eInterfaceType,
|
||||
const char * /*pInterfaceName*/,
|
||||
const char * /*pInterfaceSerialNumber*/,
|
||||
VmbAccessModeType /*interfacePermittedAccess*/ )
|
||||
{
|
||||
return CameraPtr( new Camera( pCameraID, pCameraName, pCameraModel, pCameraSerialNumber, pInterfaceID, eInterfaceType ));
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
55
Vimba_6_0/VimbaCPP/Source/DefaultCameraFactory.h
Normal file
55
Vimba_6_0/VimbaCPP/Source/DefaultCameraFactory.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: DefaultCameraFactory.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::DefaultCameraFactory used to
|
||||
create new Camera objects if no user defined camera factory
|
||||
class was provided.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_DEFAULTCAMERAFACTORY_H
|
||||
#define AVT_VMBAPI_DEFAULTCAMERAFACTORY_H
|
||||
|
||||
#include <VimbaCPP/Include/ICameraFactory.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class DefaultCameraFactory : public virtual ICameraFactory
|
||||
{
|
||||
public:
|
||||
virtual CameraPtr CreateCamera( const char *pCameraID,
|
||||
const char *pCameraName,
|
||||
const char *pCameraModel,
|
||||
const char *pCameraSerialNumber,
|
||||
const char *pInterfaceID,
|
||||
VmbInterfaceType interfaceType,
|
||||
const char *pInterfaceName,
|
||||
const char *pInterfaceSerialNumber,
|
||||
VmbAccessModeType interfacePermittedAccess );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
299
Vimba_6_0/VimbaCPP/Source/EnumEntry.cpp
Normal file
299
Vimba_6_0/VimbaCPP/Source/EnumEntry.cpp
Normal file
@@ -0,0 +1,299 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: EnumEntry.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::EnumEntry.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Include/EnumEntry.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct EnumEntry::PrivateImpl
|
||||
{
|
||||
std::string m_strName;
|
||||
std::string m_strDisplayName;
|
||||
std::string m_strDescription;
|
||||
std::string m_strTooltip;
|
||||
std::string m_strNamespace;
|
||||
VmbFeatureVisibilityType m_Visibility;
|
||||
VmbInt64_t m_nValue;
|
||||
PrivateImpl( const char *pStrName,
|
||||
const char *pStrDisplayName,
|
||||
const char *pStrDescription,
|
||||
const char *pStrTooltip,
|
||||
const char *pStrSNFCNamespace,
|
||||
VmbFeatureVisibility_t visibility,
|
||||
VmbInt64_t nValue)
|
||||
: m_nValue( nValue )
|
||||
, m_Visibility ( (VmbFeatureVisibilityType)visibility )
|
||||
{
|
||||
m_strName = pStrName != NULL ? std::string( pStrName ) : "";
|
||||
m_strDisplayName = pStrDisplayName != NULL ? std::string( pStrDisplayName ) : "";
|
||||
m_strDescription = pStrDescription != NULL ? std::string( pStrDescription ) : "";
|
||||
m_strTooltip = pStrTooltip != NULL ? std::string( pStrTooltip ) : "";
|
||||
m_strNamespace = pStrSNFCNamespace != NULL ? std::string( pStrSNFCNamespace ) : "";
|
||||
}
|
||||
VmbErrorType GetName( char * const pStrName, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrName )
|
||||
{
|
||||
rnSize = static_cast<VmbUint32_t>( m_strName.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_strName.size() <= rnSize )
|
||||
{
|
||||
std::copy( m_strName.begin(), m_strName.end(), pStrName );
|
||||
rnSize = static_cast<VmbUint32_t>( m_strName.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType GetDisplayName( char * const pStrDisplayName, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrDisplayName )
|
||||
{
|
||||
rnSize = static_cast<VmbUint32_t>( m_strDisplayName.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_strDisplayName.size() <= rnSize )
|
||||
{
|
||||
std::copy( m_strDisplayName.begin(), m_strDisplayName.end(), pStrDisplayName );
|
||||
rnSize = static_cast<VmbUint32_t>( m_strDisplayName.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType GetDescription( char * const pStrDescription, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrDescription )
|
||||
{
|
||||
rnSize = static_cast<VmbUint32_t>( m_strDescription.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_strDescription.size() <= rnSize )
|
||||
{
|
||||
std::copy( m_strDescription.begin(), m_strDescription.end(), pStrDescription );
|
||||
rnSize = static_cast<VmbUint32_t>( m_strDescription.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType GetTooltip( char * const pStrTooltip, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrTooltip )
|
||||
{
|
||||
rnSize = static_cast<VmbUint32_t>( m_strTooltip.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_strTooltip.size() <= rnSize )
|
||||
{
|
||||
std::copy( m_strTooltip.begin(), m_strTooltip.end(), pStrTooltip );
|
||||
rnSize = static_cast<VmbUint32_t>( m_strTooltip.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType GetSFNCNamespace( char * const pStrNamespace, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrNamespace )
|
||||
{
|
||||
rnSize = static_cast<VmbUint32_t>( m_strNamespace.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_strNamespace.size() <= rnSize )
|
||||
{
|
||||
std::copy( m_strNamespace.begin(), m_strNamespace.end(), pStrNamespace );
|
||||
rnSize = static_cast<VmbUint32_t>( m_strNamespace.size() );
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType GetValue( VmbInt64_t &rnValue ) const
|
||||
{
|
||||
rnValue = m_nValue;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType GetVisibility( VmbFeatureVisibilityType &rVisibility ) const
|
||||
{
|
||||
rVisibility = m_Visibility;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
EnumEntry::EnumEntry( const char *pStrName,
|
||||
const char *pStrDisplayName,
|
||||
const char *pStrDescription,
|
||||
const char *pStrTooltip,
|
||||
const char *pStrSNFCNamespace,
|
||||
VmbFeatureVisibility_t visibility,
|
||||
VmbInt64_t nValue)
|
||||
: m_pImpl( new PrivateImpl(pStrName, pStrDisplayName, pStrDescription, pStrTooltip, pStrSNFCNamespace, visibility, nValue) )
|
||||
{
|
||||
}
|
||||
EnumEntry::EnumEntry( const EnumEntry &other)
|
||||
: m_pImpl( NULL == other.m_pImpl ? NULL : new PrivateImpl( *other.m_pImpl) )
|
||||
{
|
||||
}
|
||||
EnumEntry& EnumEntry::operator=( const EnumEntry&other)
|
||||
{
|
||||
if( this != &other)
|
||||
{
|
||||
PrivateImpl *tmp = NULL == other.m_pImpl ? NULL : new PrivateImpl(*other.m_pImpl);
|
||||
if( NULL != tmp)
|
||||
{
|
||||
delete m_pImpl;
|
||||
m_pImpl = tmp;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
EnumEntry::EnumEntry()
|
||||
: m_pImpl()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
EnumEntry::~EnumEntry()
|
||||
{
|
||||
if( NULL != m_pImpl)
|
||||
{
|
||||
delete m_pImpl;
|
||||
m_pImpl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetName( char * const pStrName, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
return m_pImpl->GetName( pStrName, rnSize );
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetDisplayName( char * const pStrDisplayName, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
return m_pImpl->GetDisplayName( pStrDisplayName, rnSize);
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetDescription( char * const pStrDescription, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
return m_pImpl->GetDescription( pStrDescription, rnSize);
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetTooltip( char * const pStrTooltip, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
return m_pImpl->GetTooltip( pStrTooltip, rnSize );
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetSFNCNamespace( char * const pStrNamespace, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
return m_pImpl->GetSFNCNamespace( pStrNamespace, rnSize);
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetValue( VmbInt64_t &rnValue ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
rnValue = m_pImpl->m_nValue;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType EnumEntry::GetVisibility( VmbFeatureVisibilityType &rVisibility ) const
|
||||
{
|
||||
if( NULL == m_pImpl )
|
||||
{
|
||||
return VmbErrorInternalFault;
|
||||
}
|
||||
rVisibility = m_pImpl->m_Visibility;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
341
Vimba_6_0/VimbaCPP/Source/EnumFeature.cpp
Normal file
341
Vimba_6_0/VimbaCPP/Source/EnumFeature.cpp
Normal file
@@ -0,0 +1,341 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: EnumFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::EnumFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/EnumFeature.h>
|
||||
#include <memory.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
EnumFeature::EnumFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
|
||||
:BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetValue( char * const pStrValue, VmbUint32_t &rnSize ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
const char* pStrTempValue;
|
||||
res = (VmbErrorType)VmbFeatureEnumGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &pStrTempValue );
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
VmbUint32_t nLength=0;
|
||||
while ( pStrTempValue[nLength] != '\0' )
|
||||
{
|
||||
++nLength;
|
||||
}
|
||||
|
||||
if ( NULL == pStrValue )
|
||||
{
|
||||
rnSize = nLength;
|
||||
}
|
||||
else if ( nLength <= rnSize )
|
||||
{
|
||||
::memcpy( pStrValue, pStrTempValue, (size_t)nLength );
|
||||
rnSize = nLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetValue( VmbInt64_t &rnValue ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
const char *pName = NULL;
|
||||
VmbError_t res = VmbFeatureEnumGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &pName );
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
res = VmbFeatureEnumAsInt( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pName, &rnValue );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetEntry( EnumEntry &rEntry, const char * pStrEntryName ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
VmbFeatureEnumEntry_t entry;
|
||||
VmbError_t res = VmbFeatureEnumEntryGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrEntryName, &entry, sizeof( VmbFeatureEnumEntry_t ));
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
rEntry = EnumEntry( entry.name, entry.displayName, entry.description, entry.tooltip, entry.sfncNamespace, entry.visibility, entry.intValue );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::SetValue( const char *pStrValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureEnumSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrValue );
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::SetValue( const VmbInt64_t &rnValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
const char *pName = NULL;
|
||||
VmbError_t res = VmbFeatureEnumAsString( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), rnValue, &pName );
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
res = VmbFeatureEnumSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pName );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetValues( const char **pRange, VmbUint32_t &rnSize )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
VmbUint32_t nCount = 0;
|
||||
VmbError_t res = VmbFeatureEnumRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), NULL, 0, &nCount );
|
||||
|
||||
if ( VmbErrorSuccess == res
|
||||
&& 0 < nCount )
|
||||
{
|
||||
std::vector<const char*> data( nCount );
|
||||
|
||||
res = VmbFeatureEnumRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &data[0], nCount, &nCount );
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
m_EnumStringValues.clear();
|
||||
|
||||
for ( std::vector<const char*>::iterator iter = data.begin();
|
||||
data.end() != iter;
|
||||
++iter )
|
||||
{
|
||||
m_EnumStringValues.push_back( std::string( *iter ));
|
||||
}
|
||||
|
||||
if ( NULL == pRange )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_EnumStringValues.size();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_EnumStringValues.size() <= rnSize )
|
||||
{
|
||||
VmbUint32_t i = 0;
|
||||
for ( StringVector::iterator iter = m_EnumStringValues.begin();
|
||||
m_EnumStringValues.end() != iter;
|
||||
++iter, ++i )
|
||||
{
|
||||
pRange[i] = iter->c_str();
|
||||
}
|
||||
rnSize = (VmbUint32_t)m_EnumStringValues.size();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetValues( VmbInt64_t *pValues, VmbUint32_t &rnSize )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
VmbUint32_t nCount = 0;
|
||||
VmbError_t res = GetValues( (const char**)NULL, nCount );
|
||||
|
||||
if ( VmbErrorSuccess == res
|
||||
&& 0 < nCount )
|
||||
{
|
||||
std::vector<const char*> data( nCount );
|
||||
|
||||
res = GetValues( &data[0], nCount );
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
m_EnumIntValues.clear();
|
||||
|
||||
VmbInt64_t nValue;
|
||||
for ( std::vector<const char*>::iterator iter = data.begin();
|
||||
data.end() != iter;
|
||||
++iter )
|
||||
{
|
||||
res = VmbFeatureEnumAsInt( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), (*iter), &nValue );
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
m_EnumIntValues.push_back( nValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EnumIntValues.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
if ( NULL == pValues )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_EnumIntValues.size();
|
||||
}
|
||||
else if ( m_EnumIntValues.size() <= rnSize )
|
||||
{
|
||||
VmbUint32_t i = 0;
|
||||
for ( Int64Vector::iterator iter = m_EnumIntValues.begin();
|
||||
m_EnumIntValues.end() != iter;
|
||||
++iter, ++i )
|
||||
{
|
||||
pValues[i] = (*iter);
|
||||
}
|
||||
rnSize = (VmbUint32_t)m_EnumIntValues.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::GetEntries( EnumEntry *pEntries, VmbUint32_t &rnSize )
|
||||
{
|
||||
VmbErrorType res = GetValues( (const char**)NULL, rnSize );
|
||||
|
||||
if ( 0 < m_EnumStringValues.size()
|
||||
&& VmbErrorSuccess == res )
|
||||
{
|
||||
m_EnumEntries.clear();
|
||||
|
||||
for ( StringVector::iterator iter = m_EnumStringValues.begin();
|
||||
m_EnumStringValues.end() != iter;
|
||||
++iter )
|
||||
{
|
||||
EnumEntry entry;
|
||||
res = GetEntry( entry, (*iter).c_str() );
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
m_EnumEntries.push_back( entry );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_EnumEntries.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
if ( NULL == pEntries )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_EnumEntries.size();
|
||||
}
|
||||
else if ( m_EnumEntries.size() <= rnSize )
|
||||
{
|
||||
VmbUint32_t i = 0;
|
||||
for ( EnumEntryVector::iterator iter = m_EnumEntries.begin();
|
||||
m_EnumEntries.end() != iter;
|
||||
++iter, ++i )
|
||||
{
|
||||
pEntries[i] = (*iter);
|
||||
}
|
||||
rnSize = (VmbUint32_t)m_EnumIntValues.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::IsValueAvailable( const char *pStrValue, bool &bAvailable ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureEnumIsAvailable( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrValue, &bAvailable );
|
||||
}
|
||||
|
||||
VmbErrorType EnumFeature::IsValueAvailable( const VmbInt64_t nValue, bool &rbAvailable ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
const char* pName = NULL;
|
||||
VmbError_t res = VmbFeatureEnumAsString( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), nValue, &pName );
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
res = IsValueAvailable( pName, rbAvailable );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
70
Vimba_6_0/VimbaCPP/Source/EnumFeature.h
Normal file
70
Vimba_6_0/VimbaCPP/Source/EnumFeature.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: EnumFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::EnumFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_ENUMFEATURE_H
|
||||
#define AVT_VMBAPI_ENUMFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class EnumFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
EnumFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer );
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const char *pValue );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetEntry( EnumEntry &entry, const char *pEntryName ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetValue( VmbInt64_t &value ) const;
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbInt64_t &value );
|
||||
|
||||
IMEXPORT virtual VmbErrorType IsValueAvailable( const char *pStrValue, bool &available ) const;
|
||||
IMEXPORT virtual VmbErrorType IsValueAvailable( const VmbInt64_t value, bool &available ) const;
|
||||
|
||||
private:
|
||||
// Copy of enum elements
|
||||
StringVector m_EnumStringValues;
|
||||
Int64Vector m_EnumIntValues;
|
||||
EnumEntryVector m_EnumEntries;
|
||||
|
||||
// Array functions to pass data across DLL boundaries
|
||||
IMEXPORT virtual VmbErrorType GetValue( char * const pValue, VmbUint32_t &size ) const;
|
||||
IMEXPORT virtual VmbErrorType GetValues( const char **pValues, VmbUint32_t &size );
|
||||
IMEXPORT virtual VmbErrorType GetValues( VmbInt64_t *pValue, VmbUint32_t &size );
|
||||
IMEXPORT virtual VmbErrorType GetEntries( EnumEntry *pEntries, VmbUint32_t &size );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
329
Vimba_6_0/VimbaCPP/Source/Feature.cpp
Normal file
329
Vimba_6_0/VimbaCPP/Source/Feature.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Feature.cpp
|
||||
|
||||
Description: Implementation of wrapper class AVT::VmbAPI::Feature.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Include/Feature.h>
|
||||
#pragma warning(disable:4996)
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#pragma warning(default:4996)
|
||||
#include <VimbaCPP/Source/BoolFeature.h>
|
||||
#include <VimbaCPP/Source/CommandFeature.h>
|
||||
#include <VimbaCPP/Source/EnumFeature.h>
|
||||
#include <VimbaCPP/Source/FloatFeature.h>
|
||||
#include <VimbaCPP/Source/IntFeature.h>
|
||||
#include <VimbaCPP/Source/StringFeature.h>
|
||||
#include <VimbaCPP/Source/RawFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Feature::Feature( const VmbFeatureInfo_t *pFeatureInfo, FeatureContainer *pFeatureContainer )
|
||||
: m_pImpl( new BaseFeature( pFeatureInfo, pFeatureContainer ))
|
||||
{
|
||||
if ( NULL != pFeatureInfo )
|
||||
{
|
||||
delete m_pImpl;
|
||||
switch ( pFeatureInfo->featureDataType )
|
||||
{
|
||||
case VmbFeatureDataBool: m_pImpl = new BoolFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataEnum: m_pImpl = new EnumFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataFloat: m_pImpl = new FloatFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataInt: m_pImpl = new IntFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataString: m_pImpl = new StringFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataCommand: m_pImpl = new CommandFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
case VmbFeatureDataRaw: m_pImpl = new RawFeature( pFeatureInfo, pFeatureContainer );
|
||||
break;
|
||||
default: m_pImpl = new BaseFeature( pFeatureInfo, pFeatureContainer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Feature::Feature()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
Feature::Feature( const Feature& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
Feature::~Feature()
|
||||
{
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
void Feature::ResetFeatureContainer()
|
||||
{
|
||||
m_pImpl->ResetFeatureContainer();
|
||||
}
|
||||
|
||||
VmbErrorType Feature::RegisterObserver( const IFeatureObserverPtr &rObserver )
|
||||
{
|
||||
return m_pImpl->RegisterObserver( rObserver );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::UnregisterObserver( const IFeatureObserverPtr &rObserver )
|
||||
{
|
||||
return m_pImpl->UnregisterObserver( rObserver );
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType Feature::GetValue( VmbInt64_t &rnValue ) const
|
||||
{
|
||||
return m_pImpl->GetValue( rnValue );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType Feature::SetValue( const VmbInt64_t &rnValue )
|
||||
{
|
||||
return m_pImpl->SetValue( rnValue );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType Feature::SetValue( const VmbInt32_t &rnValue )
|
||||
{
|
||||
return m_pImpl->SetValue( (const VmbInt64_t)rnValue );
|
||||
}
|
||||
|
||||
// Gets the range of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType Feature::GetRange( VmbInt64_t &rnMinimum, VmbInt64_t &rnMaximum ) const
|
||||
{
|
||||
return m_pImpl->GetRange( rnMinimum, rnMaximum );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::HasIncrement( VmbBool_t &incrementSupported) const
|
||||
{
|
||||
return m_pImpl->HasIncrement( incrementSupported);
|
||||
}
|
||||
// Gets the increment of a feature of type VmbFeatureDataInt
|
||||
VmbErrorType Feature::GetIncrement( VmbInt64_t &rnIncrement ) const
|
||||
{
|
||||
return m_pImpl->GetIncrement( rnIncrement );
|
||||
}
|
||||
|
||||
// Gets the increment of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType Feature::GetIncrement( double &rnIncrement ) const
|
||||
{
|
||||
return m_pImpl->GetIncrement( rnIncrement );
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType Feature::GetValue( double &rfValue) const
|
||||
{
|
||||
return m_pImpl->GetValue( rfValue );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType Feature::SetValue( const double &rfValue )
|
||||
{
|
||||
return m_pImpl->SetValue( rfValue );
|
||||
}
|
||||
|
||||
// Gets the range of a feature of type VmbFeatureDataFloat
|
||||
VmbErrorType Feature::GetRange( double &rfMinimum, double &rfMaximum ) const
|
||||
{
|
||||
return m_pImpl->GetRange( rfMinimum, rfMaximum );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataEnum
|
||||
// Sets the value of a feature of type VmbFeatureDataString
|
||||
VmbErrorType Feature::SetValue( const char *pStrValue )
|
||||
{
|
||||
return m_pImpl->SetValue( pStrValue );
|
||||
}
|
||||
|
||||
// Gets all possible values as string of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType Feature::GetValues( const char **pStrValues, VmbUint32_t &rnSize )
|
||||
{
|
||||
return m_pImpl->GetValues( pStrValues, rnSize );
|
||||
}
|
||||
|
||||
// Gets all possible values as integer of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType Feature::GetValues( VmbInt64_t *pnValues, VmbUint32_t &rnSize )
|
||||
{
|
||||
return m_pImpl->GetValues( pnValues, rnSize );
|
||||
}
|
||||
|
||||
// Gets the currently selected enum entry of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType Feature::GetEntry( EnumEntry &entry, const char *pStrEntryName ) const
|
||||
{
|
||||
return m_pImpl->GetEntry( entry, pStrEntryName );
|
||||
}
|
||||
|
||||
// Gets all possible enum entries of a feature of type VmbFeatureDataEnum
|
||||
VmbErrorType Feature::GetEntries( EnumEntry *pEnumEntries, VmbUint32_t &rnSize )
|
||||
{
|
||||
return m_pImpl->GetEntries( pEnumEntries, rnSize );
|
||||
}
|
||||
|
||||
// Indicates whether a particular enum value as string of a feature of type VmbFeatureDataEnum is available
|
||||
VmbErrorType Feature::IsValueAvailable( const char *pStrValue, bool &rbAvailable ) const
|
||||
{
|
||||
return m_pImpl->IsValueAvailable( pStrValue, rbAvailable );
|
||||
}
|
||||
|
||||
// Indicates whether a particular enum value as integer of a feature of type VmbFeatureDataEnum is available
|
||||
VmbErrorType Feature::IsValueAvailable( const VmbInt64_t nValue, bool &rbAvailable ) const
|
||||
{
|
||||
return m_pImpl->IsValueAvailable( nValue, rbAvailable );
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataString
|
||||
VmbErrorType Feature::GetValue( char * const pStrValue, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetValue( pStrValue, rnLength );
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataBool
|
||||
VmbErrorType Feature::GetValue( bool &rbValue ) const
|
||||
{
|
||||
return m_pImpl->GetValue( rbValue );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataBool
|
||||
VmbErrorType Feature::SetValue( bool bValue )
|
||||
{
|
||||
return m_pImpl->SetValue( bValue );
|
||||
}
|
||||
|
||||
// Executes a feature of type VmbFeatureDataCommand
|
||||
VmbErrorType Feature::RunCommand()
|
||||
{
|
||||
return m_pImpl->RunCommand();
|
||||
}
|
||||
|
||||
// Indicates whether a feature of type VmbFeatureDataCommand finished execution
|
||||
VmbErrorType Feature::IsCommandDone( bool &bIsDone ) const
|
||||
{
|
||||
return m_pImpl->IsCommandDone( bIsDone );
|
||||
}
|
||||
|
||||
// Gets the value of a feature of type VmbFeatureDataRaw
|
||||
VmbErrorType Feature::GetValue( VmbUchar_t *pValue, VmbUint32_t &rnSize, VmbUint32_t &rnSizeFilled ) const
|
||||
{
|
||||
return m_pImpl->GetValue( pValue, rnSize, rnSizeFilled );
|
||||
}
|
||||
|
||||
// Sets the value of a feature of type VmbFeatureDataRaw
|
||||
VmbErrorType Feature::SetValue( const VmbUchar_t *pValue, VmbUint32_t nSize )
|
||||
{
|
||||
return m_pImpl->SetValue( pValue, nSize );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetName( pStrName, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetDisplayName( char * const pStrDisplayName, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetDisplayName( pStrDisplayName, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetDataType( VmbFeatureDataType &reDataType ) const
|
||||
{
|
||||
return m_pImpl->GetDataType( reDataType );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetFlags( VmbFeatureFlagsType &reFlags ) const
|
||||
{
|
||||
return m_pImpl->GetFlags( reFlags );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetCategory( char * const pStrCategory, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetCategory( pStrCategory, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetPollingTime( VmbUint32_t &rnPollingTime ) const
|
||||
{
|
||||
return m_pImpl->GetPollingTime( rnPollingTime );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetUnit( char * const pStrUnit, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetUnit( pStrUnit, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetRepresentation( char * const pStrRepresentation, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetRepresentation( pStrRepresentation, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetVisibility( VmbFeatureVisibilityType &reVisibility ) const
|
||||
{
|
||||
return m_pImpl->GetVisibility( reVisibility );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetToolTip( char * const pStrToolTip, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetToolTip( pStrToolTip, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetDescription( char * const pStrDescription, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetDescription( pStrDescription, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetSFNCNamespace( char * const pStrSFNCNamespace, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
return m_pImpl->GetSFNCNamespace( pStrSFNCNamespace, rnLength );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetAffectedFeatures( FeaturePtr *pAffectedFeatures, VmbUint32_t &rnSize )
|
||||
{
|
||||
return m_pImpl->GetAffectedFeatures( pAffectedFeatures, rnSize );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::GetSelectedFeatures( FeaturePtr *pSelectedFeatures, VmbUint32_t &rnSize )
|
||||
{
|
||||
return m_pImpl->GetSelectedFeatures( pSelectedFeatures, rnSize );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::IsReadable( bool &rbIsReadable )
|
||||
{
|
||||
return m_pImpl->IsReadable( rbIsReadable );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::IsWritable( bool &rbIsWritable )
|
||||
{
|
||||
return m_pImpl->IsWritable( rbIsWritable );
|
||||
}
|
||||
|
||||
VmbErrorType Feature::IsStreamable( bool &rbIsStreamable ) const
|
||||
{
|
||||
return m_pImpl->IsStreamable( rbIsStreamable );
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
227
Vimba_6_0/VimbaCPP/Source/FeatureContainer.cpp
Normal file
227
Vimba_6_0/VimbaCPP/Source/FeatureContainer.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FeatureContainer.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::FeatureContainer.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <string>
|
||||
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
#include <VimbaCPP/Include/VimbaSystem.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct FeatureContainer::Impl
|
||||
{
|
||||
VmbHandle_t m_handle;
|
||||
|
||||
bool m_bAllFeaturesFetched;
|
||||
|
||||
FeaturePtrMap m_features;
|
||||
};
|
||||
|
||||
FeatureContainer::FeatureContainer()
|
||||
: m_pImpl ( new Impl() )
|
||||
{
|
||||
m_pImpl->m_bAllFeaturesFetched = false;
|
||||
m_pImpl->m_handle = NULL;
|
||||
}
|
||||
|
||||
FeatureContainer::FeatureContainer( const FeatureContainer& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
FeatureContainer& FeatureContainer::operator=( const FeatureContainer& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
FeatureContainer::~FeatureContainer()
|
||||
{
|
||||
Reset();
|
||||
RevokeHandle();
|
||||
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
VmbErrorType FeatureContainer::GetFeatureByName( const char *name, FeaturePtr &rFeature )
|
||||
{
|
||||
VmbError_t res;
|
||||
|
||||
if ( NULL == name )
|
||||
{
|
||||
return VmbErrorBadParameter;
|
||||
}
|
||||
|
||||
if ( NULL == m_pImpl->m_handle )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
FeaturePtrMap::iterator iter = m_pImpl->m_features.find( name );
|
||||
if ( iter != m_pImpl->m_features.end() )
|
||||
{
|
||||
rFeature = iter->second;
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbFeatureInfo_t featureInfo;
|
||||
|
||||
res = VmbFeatureInfoQuery( m_pImpl->m_handle, name, &featureInfo, sizeof( VmbFeatureInfo_t ));
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
rFeature = FeaturePtr( new Feature( &featureInfo, this ));
|
||||
// Only add visible features to the feature list
|
||||
if ( VmbFeatureVisibilityInvisible != featureInfo.visibility )
|
||||
{
|
||||
m_pImpl->m_features[name] = rFeature;
|
||||
}
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType FeatureContainer::GetFeatures( FeaturePtr *pFeatures, VmbUint32_t &rnSize )
|
||||
{
|
||||
VmbError_t res;
|
||||
|
||||
if ( NULL == m_pImpl->m_handle )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
// Feature list is static and therefore needs to be fetched only once per lifetime
|
||||
if ( false == m_pImpl->m_bAllFeaturesFetched )
|
||||
{
|
||||
std::vector<VmbFeatureInfo_t> featureInfoList;
|
||||
|
||||
res = VmbFeaturesList( m_pImpl->m_handle, NULL, 0, &rnSize, sizeof(VmbFeatureInfo_t) );
|
||||
if ( 0 == rnSize || VmbErrorSuccess != res )
|
||||
{
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
featureInfoList.resize( rnSize );
|
||||
res = VmbFeaturesList( m_pImpl->m_handle, &featureInfoList[0], rnSize, &rnSize, sizeof(VmbFeatureInfo_t) );
|
||||
if ( VmbErrorSuccess != res )
|
||||
{
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
for ( std::vector<VmbFeatureInfo_t>::iterator iter = featureInfoList.begin();
|
||||
featureInfoList.end() != iter;
|
||||
++iter )
|
||||
{
|
||||
std::string strName = iter->name;
|
||||
if ( 0 != strName.length() )
|
||||
{
|
||||
if ( SP_ISNULL( m_pImpl->m_features[strName] ))
|
||||
{
|
||||
m_pImpl->m_features[strName] = FeaturePtr( new Feature( &(*iter), this ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pImpl->m_bAllFeaturesFetched = true;
|
||||
}
|
||||
else // Features have been fetched before
|
||||
{
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
if ( NULL == pFeatures )
|
||||
{
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_features.size();
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_pImpl->m_features.size() <= rnSize )
|
||||
{
|
||||
VmbUint32_t i = 0;
|
||||
for ( FeaturePtrMap::iterator iter = m_pImpl->m_features.begin();
|
||||
m_pImpl->m_features.end() != iter;
|
||||
++iter, ++i )
|
||||
{
|
||||
pFeatures[i] = iter->second;
|
||||
}
|
||||
rnSize = (VmbUint32_t)m_pImpl->m_features.size();
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
}
|
||||
|
||||
VmbHandle_t FeatureContainer::GetHandle() const
|
||||
{
|
||||
return m_pImpl->m_handle;
|
||||
}
|
||||
|
||||
void FeatureContainer::SetHandle( const VmbHandle_t handle )
|
||||
{
|
||||
if ( NULL == handle )
|
||||
{
|
||||
Reset();
|
||||
RevokeHandle();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pImpl->m_handle = handle;
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the C handle to NULL
|
||||
void FeatureContainer::RevokeHandle()
|
||||
{
|
||||
m_pImpl->m_handle = NULL;
|
||||
}
|
||||
|
||||
// Sets the back reference to feature container that each feature holds to NULL
|
||||
// and resets all known features
|
||||
void FeatureContainer::Reset()
|
||||
{
|
||||
for ( FeaturePtrMap::iterator iter = m_pImpl->m_features.begin();
|
||||
m_pImpl->m_features.end() != iter;
|
||||
++iter)
|
||||
{
|
||||
SP_ACCESS( iter->second )->ResetFeatureContainer();
|
||||
}
|
||||
|
||||
m_pImpl->m_features.clear();
|
||||
m_pImpl->m_bAllFeaturesFetched = false;
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
205
Vimba_6_0/VimbaCPP/Source/FileLogger.cpp
Normal file
205
Vimba_6_0/VimbaCPP/Source/FileLogger.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FileLogger.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::FileLogger.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <ctime>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <VimbaCPP/Include/FileLogger.h>
|
||||
#include <VimbaCPP/Source/MutexGuard.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable: 4996)
|
||||
#else //_WIN32
|
||||
#include <sys/stat.h>
|
||||
#endif //_WIN32
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
FileLogger::FileLogger( const char *pFileName, bool bAppend )
|
||||
: m_pMutex( MutexPtr( new Mutex() ))
|
||||
{
|
||||
std::string strTempPath = GetTempPath();
|
||||
std::string strFileName( pFileName );
|
||||
|
||||
if ( 0 < strTempPath.length() )
|
||||
{
|
||||
strFileName = strTempPath.append( strFileName );
|
||||
if( true == bAppend )
|
||||
{
|
||||
m_File.open( strFileName.c_str(), std::fstream::app );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_File.open( strFileName.c_str() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
FileLogger::FileLogger( const FileLogger& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
FileLogger& FileLogger::operator=( const FileLogger& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileLogger::~FileLogger()
|
||||
{
|
||||
if( true == m_File.is_open() )
|
||||
{
|
||||
m_File.close();
|
||||
}
|
||||
}
|
||||
|
||||
void FileLogger::Log( const std::string &rStrMessage )
|
||||
{
|
||||
MutexGuard guard( m_pMutex );
|
||||
|
||||
if( true == m_File.is_open() )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
time_t nTime = time( &nTime );
|
||||
tm timeInfo;
|
||||
localtime_s( &timeInfo, &nTime );
|
||||
char strTime[100];
|
||||
asctime_s( strTime, 100, &timeInfo );
|
||||
#else
|
||||
time_t nTime = time( NULL );
|
||||
std::string strTime = asctime( localtime( &nTime ) );
|
||||
#endif
|
||||
|
||||
m_File << strTime << ": " << rStrMessage << std::endl;
|
||||
m_File.flush();
|
||||
}
|
||||
}
|
||||
|
||||
std::string FileLogger::GetTempPath()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
std::string tmpDir;
|
||||
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
char *pPath = std::getenv("TMPDIR");
|
||||
if(NULL != pPath)
|
||||
{
|
||||
struct stat lStats;
|
||||
if(stat(pPath, &lStats) == 0)
|
||||
{
|
||||
tmpDir = pPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
char *pPath = std::getenv("TEMP");
|
||||
if(NULL != pPath)
|
||||
{
|
||||
struct stat lStats;
|
||||
if(stat(pPath, &lStats) == 0)
|
||||
{
|
||||
tmpDir = pPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
char *pPath = std::getenv("TMP");
|
||||
if(NULL != pPath)
|
||||
{
|
||||
struct stat lStats;
|
||||
if(stat(pPath, &lStats) == 0)
|
||||
{
|
||||
tmpDir = pPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
std::string path = "/tmp";
|
||||
struct stat lStats;
|
||||
if(stat(path.c_str(), &lStats) == 0)
|
||||
{
|
||||
tmpDir = path;
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
std::string path = "/var/tmp";
|
||||
struct stat lStats;
|
||||
if(stat(path.c_str(), &lStats) == 0)
|
||||
{
|
||||
tmpDir = path;
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
std::string path = "/usr/tmp";
|
||||
struct stat lStats;
|
||||
if(stat(path.c_str(), &lStats) == 0)
|
||||
{
|
||||
tmpDir = path;
|
||||
}
|
||||
}
|
||||
if(tmpDir.size() == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
// everyone expects delimiter on the outside
|
||||
if( (*tmpDir.rbegin()) != '/' )
|
||||
{
|
||||
tmpDir +='/';
|
||||
}
|
||||
return tmpDir;
|
||||
#else
|
||||
DWORD length = ::GetTempPathA( 0, NULL );
|
||||
if( length == 0 )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<TCHAR> tempPath( length );
|
||||
|
||||
length = ::GetTempPath( static_cast<DWORD>( tempPath.size() ), &tempPath[0] );
|
||||
if( length == 0 || length > tempPath.size() )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return std::string( tempPath.begin(), tempPath.begin() + static_cast<std::size_t>(length) );
|
||||
#endif
|
||||
}
|
||||
|
||||
}} //namespace AV::VmbAPI
|
||||
100
Vimba_6_0/VimbaCPP/Source/FloatFeature.cpp
Normal file
100
Vimba_6_0/VimbaCPP/Source/FloatFeature.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FloatFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::FloatFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/FloatFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
FloatFeature::FloatFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
|
||||
: BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType FloatFeature::GetValue( double &rfValue ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureFloatGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rfValue );
|
||||
}
|
||||
|
||||
VmbErrorType FloatFeature::SetValue( const double &rfValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureFloatSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), rfValue );
|
||||
}
|
||||
|
||||
VmbErrorType FloatFeature::GetRange( double &rfMinimum, double &rfMaximum ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureFloatRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rfMinimum, &rfMaximum );
|
||||
}
|
||||
|
||||
VmbErrorType FloatFeature::HasIncrement( VmbBool_t &incrementSupported ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
VmbBool_t hasIncrement;
|
||||
VmbError_t Result =VmbFeatureFloatIncrementQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(),&hasIncrement, NULL );
|
||||
if( VmbErrorSuccess == Result)
|
||||
{
|
||||
incrementSupported = hasIncrement;
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
return static_cast<VmbErrorType>( Result);
|
||||
}
|
||||
|
||||
VmbErrorType FloatFeature::GetIncrement( double &rnIncrement ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
VmbBool_t hasIncrement;
|
||||
VmbError_t Result =VmbFeatureFloatIncrementQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(),&hasIncrement, &rnIncrement );
|
||||
if( VmbErrorSuccess == Result && !hasIncrement)
|
||||
{
|
||||
return VmbErrorNotImplemented;
|
||||
}
|
||||
return static_cast<VmbErrorType>( Result);
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
58
Vimba_6_0/VimbaCPP/Source/FloatFeature.h
Normal file
58
Vimba_6_0/VimbaCPP/Source/FloatFeature.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FloatFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::FloatFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_FLOATFEATURE_H
|
||||
#define AVT_VMBAPI_FLOATFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class FloatFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
FloatFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetValue( double &value ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const double &rfValue );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetRange( double &minimum, double &maximum ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType HasIncrement( VmbBool_t &incrementSupported) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetIncrement( double &increment ) const;
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
295
Vimba_6_0/VimbaCPP/Source/Frame.cpp
Normal file
295
Vimba_6_0/VimbaCPP/Source/Frame.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Frame.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::Frame.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 "VimbaCPP/Include/Frame.h"
|
||||
|
||||
#include "VimbaCPP/Include/LoggerDefines.h"
|
||||
#include "VimbaCPP/Include/VimbaSystem.h"
|
||||
#include "VimbaCPP/Source/ConditionHelper.h"
|
||||
#include "VimbaCPP/Include/SharedPointerDefines.h"
|
||||
#include "VimbaCPP/Source/FrameImpl.h"
|
||||
#include "VimbaCPP/Source/MutexGuard.h"
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Frame::Frame()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
Frame::Frame( Frame& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
Frame& Frame::operator=( const Frame& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
Frame::Frame( VmbInt64_t nBufferSize, FrameAllocationMode allocationMode /*=FrameAllocation_AnnounceFrame*/ )
|
||||
: m_pImpl( new Impl() )
|
||||
{
|
||||
m_pImpl->m_bAlreadyAnnounced = false;
|
||||
m_pImpl->m_bAlreadyQueued = false;
|
||||
m_pImpl->m_bIsSelfAllocatedBuffer = (allocationMode == FrameAllocation_AnnounceFrame) ? true : false;
|
||||
SP_SET( m_pImpl->m_pObserverMutex, new Mutex() );
|
||||
m_pImpl->Init();
|
||||
m_pImpl->m_pBuffer = (allocationMode == FrameAllocation_AnnounceFrame) ? new VmbUchar_t[ (VmbUint32_t)nBufferSize ] : NULL;
|
||||
m_pImpl->m_frame.bufferSize = (VmbUint32_t)nBufferSize;
|
||||
m_pImpl->m_frame.buffer = m_pImpl->m_pBuffer;
|
||||
}
|
||||
|
||||
Frame::Frame( VmbUchar_t *pBuffer, VmbInt64_t nBufferSize )
|
||||
: m_pImpl( new Impl() )
|
||||
{
|
||||
m_pImpl->m_bAlreadyAnnounced = false;
|
||||
m_pImpl->m_bAlreadyQueued = false;
|
||||
m_pImpl->m_bIsSelfAllocatedBuffer = false;
|
||||
m_pImpl->m_pBuffer = NULL;
|
||||
SP_SET( m_pImpl->m_pObserverMutex, new Mutex());
|
||||
m_pImpl->Init();
|
||||
if ( NULL != pBuffer )
|
||||
{
|
||||
m_pImpl->m_pBuffer = pBuffer;
|
||||
m_pImpl->m_frame.bufferSize = (VmbUint32_t)nBufferSize;
|
||||
m_pImpl->m_frame.buffer = m_pImpl->m_pBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do some logging
|
||||
LOG_FREE_TEXT( "No valid buffer passed when constructing frame." )
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::Impl::Init()
|
||||
{
|
||||
m_frame.ancillarySize = 0;
|
||||
m_frame.buffer = NULL;
|
||||
m_frame.bufferSize = 0;
|
||||
for ( int i=0; i<4; ++i)
|
||||
{
|
||||
m_frame.context[i] = NULL;
|
||||
}
|
||||
m_frame.frameID = 0;
|
||||
m_frame.height = 0;
|
||||
m_frame.imageSize = 0;
|
||||
m_frame.offsetX = 0;
|
||||
m_frame.offsetY = 0;
|
||||
m_frame.pixelFormat = 0;
|
||||
m_frame.receiveFlags = VmbFrameFlagsNone;
|
||||
m_frame.receiveStatus = VmbFrameStatusInvalid;
|
||||
m_frame.timestamp = 0;
|
||||
m_frame.width = 0;
|
||||
}
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
UnregisterObserver();
|
||||
if ( true == m_pImpl->m_bIsSelfAllocatedBuffer
|
||||
&& NULL != m_pImpl->m_pBuffer )
|
||||
{
|
||||
delete [] m_pImpl->m_pBuffer;
|
||||
}
|
||||
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::RegisterObserver( const IFrameObserverPtr &rObserver )
|
||||
{
|
||||
if ( SP_ISNULL( rObserver ))
|
||||
{
|
||||
return VmbErrorBadParameter;
|
||||
}
|
||||
|
||||
// Begin exclusive write lock observer
|
||||
MutexGuard local_lock( m_pImpl->m_pObserverMutex );
|
||||
m_pImpl->m_pObserver = rObserver;
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::UnregisterObserver()
|
||||
{
|
||||
VmbErrorType res = VmbErrorSuccess;
|
||||
|
||||
// Begin exclusive write lock observer
|
||||
MutexGuard local_lock( m_pImpl->m_pObserverMutex );
|
||||
if ( SP_ISNULL( m_pImpl->m_pObserver ))
|
||||
{
|
||||
res = VmbErrorNotFound;
|
||||
}
|
||||
else
|
||||
{
|
||||
SP_RESET( m_pImpl->m_pObserver );
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Frame::GetObserver( IFrameObserverPtr &rObserver ) const
|
||||
{
|
||||
MutexGuard local_lock( m_pImpl->m_pObserverMutex );
|
||||
if ( SP_ISNULL( m_pImpl->m_pObserver ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rObserver = m_pImpl->m_pObserver;
|
||||
return true;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetAncillaryData( AncillaryDataPtr &rAncillaryData )
|
||||
{
|
||||
if ( m_pImpl->m_frame.ancillarySize == 0 )
|
||||
{
|
||||
return VmbErrorNotFound;
|
||||
}
|
||||
|
||||
SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetAncillaryData( ConstAncillaryDataPtr &rAncillaryData ) const
|
||||
{
|
||||
if ( m_pImpl->m_frame.ancillarySize == 0 )
|
||||
{
|
||||
return VmbErrorNotFound;
|
||||
}
|
||||
|
||||
SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetBuffer( VmbUchar_t* &rpBuffer )
|
||||
{
|
||||
rpBuffer = m_pImpl->m_pBuffer;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetBuffer( const VmbUchar_t* &rpBuffer ) const
|
||||
{
|
||||
rpBuffer = m_pImpl->m_pBuffer;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetImage( VmbUchar_t* &rpBuffer )
|
||||
{
|
||||
// HINT: On Allied Vision cameras image data always is at the beginning of the buffer
|
||||
rpBuffer = m_pImpl->m_pBuffer;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetImage( const VmbUchar_t* &rpBuffer ) const
|
||||
{
|
||||
// HINT: On Allied Vision cameras image data always is at the beginning of the buffer
|
||||
rpBuffer = m_pImpl->m_pBuffer;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetReceiveStatus( VmbFrameStatusType &rStatus ) const
|
||||
{
|
||||
rStatus = (VmbFrameStatusType)m_pImpl->m_frame.receiveStatus;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetImageSize( VmbUint32_t &rnImageSize ) const
|
||||
{
|
||||
rnImageSize = m_pImpl->m_frame.imageSize;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetAncillarySize( VmbUint32_t &rnAncillarySize ) const
|
||||
{
|
||||
rnAncillarySize = m_pImpl->m_frame.ancillarySize;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetBufferSize( VmbUint32_t &rnBufferSize ) const
|
||||
{
|
||||
rnBufferSize =m_pImpl-> m_frame.bufferSize;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetPixelFormat( VmbPixelFormatType &rPixelFormat ) const
|
||||
{
|
||||
rPixelFormat = (VmbPixelFormatType)m_pImpl->m_frame.pixelFormat;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetWidth( VmbUint32_t &rnWidth ) const
|
||||
{
|
||||
rnWidth = m_pImpl->m_frame.width;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetHeight( VmbUint32_t &rnHeight ) const
|
||||
{
|
||||
rnHeight = m_pImpl->m_frame.height;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetOffsetX( VmbUint32_t &rnOffsetX ) const
|
||||
{
|
||||
rnOffsetX = m_pImpl->m_frame.offsetX;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetOffsetY( VmbUint32_t &rnOffsetY ) const
|
||||
{
|
||||
rnOffsetY = m_pImpl->m_frame.offsetY;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetFrameID( VmbUint64_t &rnFrameID ) const
|
||||
{
|
||||
rnFrameID = m_pImpl->m_frame.frameID;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Frame::GetTimestamp( VmbUint64_t &rnTimestamp ) const
|
||||
{
|
||||
rnTimestamp = m_pImpl->m_frame.timestamp;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
76
Vimba_6_0/VimbaCPP/Source/FrameHandler.cpp
Normal file
76
Vimba_6_0/VimbaCPP/Source/FrameHandler.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FrameHandler.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::FrameHandler.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 "VimbaCPP/Source/FrameHandler.h"
|
||||
|
||||
#include "VimbaCPP/Include/LoggerDefines.h"
|
||||
#include "VimbaCPP/Source/MutexGuard.h"
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
FrameHandler::FrameHandler( FramePtr pFrame, IFrameObserverPtr pFrameObserver )
|
||||
: m_pFrame( pFrame )
|
||||
, m_pObserver( pFrameObserver )
|
||||
, m_pMutex( new AVT::VmbAPI::Mutex() )
|
||||
{
|
||||
}
|
||||
|
||||
FramePtr FrameHandler::GetFrame() const
|
||||
{
|
||||
return m_pFrame;
|
||||
}
|
||||
|
||||
void VMB_CALL FrameHandler::FrameDoneCallback( const VmbHandle_t /*handle*/, VmbFrame_t *pVmbFrame )
|
||||
{
|
||||
if ( NULL != pVmbFrame )
|
||||
{
|
||||
FrameHandler* pFrameHandler = reinterpret_cast<FrameHandler*>( pVmbFrame->context[FRAME_HDL] );
|
||||
if ( NULL != pFrameHandler)
|
||||
{
|
||||
// Begin read lock frame handler
|
||||
MutexGuard local_lock( pFrameHandler->Mutex() );
|
||||
{
|
||||
IFrameObserverPtr pObs;
|
||||
if ( true == SP_ACCESS( pFrameHandler->m_pFrame )->GetObserver( pObs ))
|
||||
{
|
||||
SP_ACCESS( pObs )->FrameReceived( pFrameHandler->m_pFrame );
|
||||
}
|
||||
}// scope to destroy observer pointer before releasing the lock
|
||||
}
|
||||
else // No FrameHandler
|
||||
{
|
||||
LOG_FREE_TEXT( "No frame handler passed. Frame has been removed from the frame queue." )
|
||||
}
|
||||
}
|
||||
else // pVmbFrame == NULL (Just for safety)
|
||||
{
|
||||
LOG_FREE_TEXT( "Received callback for already freed frame." )
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
64
Vimba_6_0/VimbaCPP/Source/FrameHandler.h
Normal file
64
Vimba_6_0/VimbaCPP/Source/FrameHandler.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FrameHandler.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::FrameHandler.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_FRAMEHANDLER_H
|
||||
#define AVT_VMBAPI_FRAMEHANDLER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "VimbaC/Include/VmbCommonTypes.h"
|
||||
#include "VimbaCPP/Include/BasicLockable.h"
|
||||
#include "VimbaCPP/Include/SharedPointerDefines.h"
|
||||
#include "VimbaCPP/Include/Frame.h"
|
||||
#include "VimbaCPP/Include/IFrameObserver.h"
|
||||
#include "VimbaCPP/Include/Mutex.h"
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
enum { FRAME_HDL=0, };
|
||||
|
||||
class FrameHandler
|
||||
{
|
||||
public:
|
||||
static void VMB_CALL FrameDoneCallback( const VmbHandle_t handle, VmbFrame_t *pFrame );
|
||||
|
||||
FrameHandler( FramePtr pFrame, IFrameObserverPtr pFrameObserver );
|
||||
|
||||
FramePtr GetFrame() const;
|
||||
MutexPtr& Mutex() { return m_pMutex; }
|
||||
private:
|
||||
IFrameObserverPtr m_pObserver;
|
||||
FramePtr m_pFrame;
|
||||
MutexPtr m_pMutex;
|
||||
};
|
||||
|
||||
typedef std::vector<FrameHandlerPtr> FrameHandlerPtrVector;
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
54
Vimba_6_0/VimbaCPP/Source/FrameImpl.h
Normal file
54
Vimba_6_0/VimbaCPP/Source/FrameImpl.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: FrameImpl.h
|
||||
|
||||
Description: Definition of pointer to implementation structure used by
|
||||
AVT::VmbAPI::Frame.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_FRAMEIMPL_H
|
||||
#define AVT_VMBAPI_FRAMEIMPL_H
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct Frame::Impl
|
||||
{
|
||||
VmbUchar_t *m_pBuffer;
|
||||
bool m_bIsSelfAllocatedBuffer;
|
||||
|
||||
VmbFrame_t m_frame;
|
||||
|
||||
IFrameObserverPtr m_pObserver;
|
||||
MutexPtr m_pObserverMutex;
|
||||
|
||||
bool m_bAlreadyAnnounced;
|
||||
bool m_bAlreadyQueued;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
55
Vimba_6_0/VimbaCPP/Source/Helper.h
Normal file
55
Vimba_6_0/VimbaCPP/Source/Helper.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Helper.h
|
||||
|
||||
Description: Definition of helper classes (types)
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_HELPER_H
|
||||
#define AVT_VMBAPI_HELPER_H
|
||||
|
||||
#include <VimbaCPP/Include/BasicLockable.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
template <class T>
|
||||
class LockableVector : public virtual BasicLockable
|
||||
{
|
||||
public:
|
||||
std::vector<T> Vector;
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
class LockableMap : public virtual BasicLockable
|
||||
{
|
||||
public:
|
||||
std::map<T1, T2> Map;
|
||||
};
|
||||
|
||||
char const * const AVT_IP_OR_MAC_ADDRESS = "IP_OR_MAC@";
|
||||
|
||||
}} // AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
85
Vimba_6_0/VimbaCPP/Source/IntFeature.cpp
Normal file
85
Vimba_6_0/VimbaCPP/Source/IntFeature.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: IntFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::IntFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/IntFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
IntFeature::IntFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
|
||||
: BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType IntFeature::GetValue( VmbInt64_t &rnValue ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureIntGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rnValue );
|
||||
}
|
||||
|
||||
VmbErrorType IntFeature::SetValue( const VmbInt64_t &rnValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureIntSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), rnValue );
|
||||
}
|
||||
|
||||
VmbErrorType IntFeature::GetRange( VmbInt64_t &rnMinimum, VmbInt64_t &rnMaximum ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureIntRangeQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rnMinimum, &rnMaximum );
|
||||
}
|
||||
|
||||
VmbErrorType IntFeature::HasIncrement( VmbBool_t & incrementSupported) const
|
||||
{
|
||||
incrementSupported = VmbBoolTrue;
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
VmbErrorType IntFeature::GetIncrement( VmbInt64_t &rnIncrement ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureIntIncrementQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rnIncrement );
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
58
Vimba_6_0/VimbaCPP/Source/IntFeature.h
Normal file
58
Vimba_6_0/VimbaCPP/Source/IntFeature.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: IntFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::IntFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_INTFEATURE_H
|
||||
#define AVT_VMBAPI_INTFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class IntFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
IntFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetValue( VmbInt64_t &value ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbInt64_t &value );
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetRange( VmbInt64_t &minimum, VmbInt64_t &maximum ) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType HasIncrement( VmbBool_t &incrementSupported) const;
|
||||
|
||||
IMEXPORT virtual VmbErrorType GetIncrement( VmbInt64_t &increment ) const;
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
200
Vimba_6_0/VimbaCPP/Source/Interface.cpp
Normal file
200
Vimba_6_0/VimbaCPP/Source/Interface.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Interface.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::Interface.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
=============================================================================*/
|
||||
#pragma warning(disable:4996)
|
||||
#include <map>
|
||||
#pragma warning(default:4996)
|
||||
|
||||
#include <VimbaCPP/Include/Interface.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
struct Interface::Impl
|
||||
{
|
||||
// Copy of interface infos
|
||||
struct InterfaceInfo
|
||||
{
|
||||
std::string interfaceIdString; // Unique identifier for each interface
|
||||
VmbInterface_t interfaceType; // Interface type
|
||||
std::string interfaceName; // Interface name, given by the transport layer
|
||||
std::string serialString; // Serial number
|
||||
VmbAccessMode_t permittedAccess; // Used access mode, see VmbAccessMode_t
|
||||
} m_interfaceInfo;
|
||||
};
|
||||
|
||||
Interface::Interface()
|
||||
{
|
||||
// No default ctor
|
||||
}
|
||||
|
||||
Interface::Interface( const Interface& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
Interface& Interface::operator=( const Interface& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
Interface::Interface(const VmbInterfaceInfo_t *pInterfaceInfo)
|
||||
: m_pImpl( new Impl() )
|
||||
{
|
||||
m_pImpl->m_interfaceInfo.interfaceIdString.assign( pInterfaceInfo->interfaceIdString ? pInterfaceInfo->interfaceIdString : "" );
|
||||
m_pImpl->m_interfaceInfo.interfaceName.assign( pInterfaceInfo->interfaceName ? pInterfaceInfo->interfaceName : "" );
|
||||
m_pImpl->m_interfaceInfo.interfaceType = pInterfaceInfo->interfaceType;
|
||||
m_pImpl->m_interfaceInfo.permittedAccess = pInterfaceInfo->permittedAccess;
|
||||
m_pImpl->m_interfaceInfo.serialString.assign( pInterfaceInfo->serialString ? pInterfaceInfo->serialString : "" );
|
||||
}
|
||||
|
||||
VmbErrorType Interface::Open()
|
||||
{
|
||||
VmbError_t res;
|
||||
VmbHandle_t hHandle;
|
||||
|
||||
res = VmbInterfaceOpen( m_pImpl->m_interfaceInfo.interfaceIdString.c_str(), &hHandle );
|
||||
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
SetHandle( hHandle );
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
Interface::~Interface()
|
||||
{
|
||||
Close();
|
||||
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::Close()
|
||||
{
|
||||
VmbError_t res = VmbErrorSuccess;
|
||||
|
||||
if ( NULL != GetHandle() )
|
||||
{
|
||||
Reset();
|
||||
|
||||
res = VmbInterfaceClose( GetHandle() );
|
||||
|
||||
RevokeHandle();
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::GetID( char * const pStrID, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrID )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceIdString.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_pImpl->m_interfaceInfo.interfaceIdString.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_pImpl->m_interfaceInfo.interfaceIdString.begin(), m_pImpl->m_interfaceInfo.interfaceIdString.end(), pStrID );
|
||||
pStrID[m_pImpl->m_interfaceInfo.interfaceIdString.length()] = '\0';
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceIdString.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::GetType( VmbInterfaceType &reType ) const
|
||||
{
|
||||
reType = (VmbInterfaceType)m_pImpl->m_interfaceInfo.interfaceType;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrName )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_pImpl->m_interfaceInfo.interfaceName.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_pImpl->m_interfaceInfo.interfaceName.begin(), m_pImpl->m_interfaceInfo.interfaceName.end(), pStrName );
|
||||
pStrName[m_pImpl->m_interfaceInfo.interfaceName.length()] = '\0';
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.interfaceName.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::GetSerialNumber( char * const pStrSerial, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
VmbErrorType res;
|
||||
|
||||
if ( NULL == pStrSerial )
|
||||
{
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else if ( m_pImpl->m_interfaceInfo.serialString.length() <= rnLength )
|
||||
{
|
||||
std::copy( m_pImpl->m_interfaceInfo.serialString.begin(), m_pImpl->m_interfaceInfo.serialString.end(), pStrSerial );
|
||||
pStrSerial[m_pImpl->m_interfaceInfo.serialString.length()] = '\0';
|
||||
rnLength = (VmbUint32_t)m_pImpl->m_interfaceInfo.serialString.length();
|
||||
res = VmbErrorSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = VmbErrorMoreData;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
VmbErrorType Interface::GetPermittedAccess( VmbAccessModeType &reAccessMode ) const
|
||||
{
|
||||
reAccessMode = (VmbAccessModeType)m_pImpl->m_interfaceInfo.permittedAccess;
|
||||
|
||||
return VmbErrorSuccess;
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
96
Vimba_6_0/VimbaCPP/Source/Mutex.cpp
Normal file
96
Vimba_6_0/VimbaCPP/Source/Mutex.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Mutex.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::Mutex.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <math.h>
|
||||
|
||||
#include <VimbaCPP/Include/Mutex.h>
|
||||
#include <VimbaCPP/Include/LoggerDefines.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Mutex::Mutex( bool bInitLock )
|
||||
#ifdef WIN32
|
||||
: m_hMutex( NULL )
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
m_hMutex = CreateMutex( NULL, FALSE, NULL );
|
||||
if( NULL == m_hMutex )
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not create mutex." );
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
#else
|
||||
pthread_mutex_init(&m_Mutex, NULL);
|
||||
#endif
|
||||
|
||||
if( true == bInitLock )
|
||||
{
|
||||
Lock();
|
||||
}
|
||||
}
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
#ifdef WIN32
|
||||
CloseHandle( m_hMutex );
|
||||
#else
|
||||
pthread_mutex_destroy(&m_Mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
Mutex::Mutex( const Mutex& )
|
||||
{
|
||||
// No copy ctor
|
||||
}
|
||||
|
||||
Mutex& Mutex::operator=( const Mutex& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Mutex::Lock()
|
||||
{
|
||||
#ifdef WIN32
|
||||
WaitForSingleObject( m_hMutex, INFINITE );
|
||||
#else
|
||||
pthread_mutex_lock( &m_Mutex );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mutex::Unlock()
|
||||
{
|
||||
#ifdef WIN32
|
||||
ReleaseMutex( m_hMutex );
|
||||
#else
|
||||
pthread_mutex_unlock( &m_Mutex );
|
||||
#endif
|
||||
}
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
102
Vimba_6_0/VimbaCPP/Source/MutexGuard.cpp
Normal file
102
Vimba_6_0/VimbaCPP/Source/MutexGuard.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: MutexGuard.cpp
|
||||
|
||||
Description: Implementation of a mutex helper class for locking and unlocking.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/MutexGuard.h>
|
||||
|
||||
#include <VimbaCPP/Include/VimbaSystem.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
MutexGuard::MutexGuard()
|
||||
: m_pMutex( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
MutexGuard::MutexGuard( MutexPtr &pMutex )
|
||||
{
|
||||
if ( SP_ISNULL( pMutex ))
|
||||
{
|
||||
LOG_FREE_TEXT( "No mutex passed." );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pMutex = SP_ACCESS(pMutex );
|
||||
Protect( );
|
||||
}
|
||||
}
|
||||
|
||||
MutexGuard::MutexGuard( BasicLockablePtr pLockable )
|
||||
{
|
||||
if ( SP_ISNULL( pLockable ))
|
||||
{
|
||||
LOG_FREE_TEXT( "No mutex passed." );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pMutex = SP_ACCESS(SP_ACCESS(pLockable)->GetMutex());
|
||||
Protect( );
|
||||
}
|
||||
}
|
||||
|
||||
MutexGuard::MutexGuard( const BasicLockable &rLockable )
|
||||
{
|
||||
m_pMutex = SP_ACCESS(rLockable.GetMutex() );
|
||||
Protect( );
|
||||
}
|
||||
|
||||
MutexGuard::~MutexGuard()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
void MutexGuard::Protect( )
|
||||
{
|
||||
if( m_pMutex == NULL )
|
||||
{
|
||||
LOG_FREE_TEXT( "No mutex passed." );
|
||||
return;
|
||||
}
|
||||
m_pMutex->Lock();
|
||||
}
|
||||
|
||||
|
||||
bool MutexGuard::Release()
|
||||
{
|
||||
if( m_pMutex == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pMutex ->Unlock();
|
||||
m_pMutex = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
59
Vimba_6_0/VimbaCPP/Source/MutexGuard.h
Normal file
59
Vimba_6_0/VimbaCPP/Source/MutexGuard.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: MutexGuard.h
|
||||
|
||||
Description: Definition of a mutex helper class for locking and unlocking.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_MUTEXGUARD
|
||||
#define AVT_VMBAPI_MUTEXGUARD
|
||||
|
||||
#include <VimbaCPP/Include/Mutex.h>
|
||||
#include <VimbaCPP/Include/BasicLockable.h>
|
||||
|
||||
namespace AVT
|
||||
{
|
||||
namespace VmbAPI
|
||||
{
|
||||
|
||||
class MutexGuard
|
||||
{
|
||||
public:
|
||||
MutexGuard();
|
||||
MutexGuard( MutexPtr &pMutex );
|
||||
MutexGuard( BasicLockablePtr pLockable );
|
||||
MutexGuard( const BasicLockable &rLockable );
|
||||
~MutexGuard();
|
||||
|
||||
void Protect();
|
||||
bool Release();
|
||||
|
||||
protected:
|
||||
Mutex *m_pMutex;
|
||||
};
|
||||
|
||||
} //namespace VmbAPI
|
||||
} //namespace AVT
|
||||
|
||||
#endif //AVT_VMBAPI_MUTEXGUARD
|
||||
86
Vimba_6_0/VimbaCPP/Source/RawFeature.cpp
Normal file
86
Vimba_6_0/VimbaCPP/Source/RawFeature.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: RawFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::RawFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/RawFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
RawFeature::RawFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer *pFeatureContainer )
|
||||
: BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType RawFeature::GetValue( VmbUchar_t *pValue, VmbUint32_t &rnSize, VmbUint32_t &rnSizeFilled ) const
|
||||
{
|
||||
VmbError_t res;
|
||||
VmbUint32_t nSize;
|
||||
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
res = VmbFeatureRawLengthQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &nSize );
|
||||
|
||||
if ( NULL != pValue )
|
||||
{
|
||||
if ( rnSize < nSize )
|
||||
{
|
||||
return VmbErrorMoreData;
|
||||
}
|
||||
|
||||
if ( VmbErrorSuccess == res )
|
||||
{
|
||||
res = VmbFeatureRawGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), (char*)pValue, rnSize, &rnSizeFilled );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rnSize = nSize;
|
||||
}
|
||||
|
||||
return (VmbErrorType)res;
|
||||
}
|
||||
|
||||
VmbErrorType RawFeature::SetValue( const VmbUchar_t *pValue, VmbUint32_t nSize )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
if ( NULL == pValue )
|
||||
{
|
||||
return VmbErrorBadParameter;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureRawSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), (const char*)pValue, nSize );
|
||||
}
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
53
Vimba_6_0/VimbaCPP/Source/RawFeature.h
Normal file
53
Vimba_6_0/VimbaCPP/Source/RawFeature.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: RawFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::RawFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_RAWFEATURE_H
|
||||
#define AVT_VMBAPI_RAWFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class RawFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
RawFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer *pFeatureContainer );
|
||||
|
||||
private:
|
||||
// Array functions to pass data across DLL boundaries
|
||||
IMEXPORT virtual VmbErrorType GetValue( VmbUchar_t *pValue, VmbUint32_t &size, VmbUint32_t &sizeFilled ) const;
|
||||
IMEXPORT virtual VmbErrorType SetValue( const VmbUchar_t *pValue, VmbUint32_t size );
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
93
Vimba_6_0/VimbaCPP/Source/Semaphore.cpp
Normal file
93
Vimba_6_0/VimbaCPP/Source/Semaphore.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Semaphore.cpp
|
||||
|
||||
Description: Implementation of an semaphore class.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <math.h>
|
||||
|
||||
#include <VimbaCPP/Source/Semaphore.h>
|
||||
#include <VimbaCPP/Include/LoggerDefines.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
Semaphore::Semaphore( int nInit, int nMax )
|
||||
#ifdef WIN32
|
||||
: m_hSemaphore( NULL )
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
m_hSemaphore = CreateSemaphore( NULL, nInit, nMax, NULL );
|
||||
if( NULL == m_hSemaphore )
|
||||
{
|
||||
LOG_FREE_TEXT( "Could not create semaphore." );
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
#else
|
||||
sem_init( &m_Semaphore, false, (unsigned int)nInit );
|
||||
#endif
|
||||
}
|
||||
|
||||
Semaphore::Semaphore( const Semaphore& )
|
||||
{
|
||||
// No compiler generated copy ctor
|
||||
}
|
||||
|
||||
Semaphore& Semaphore::operator=( const Semaphore& )
|
||||
{
|
||||
// No assignment operator
|
||||
return *this;
|
||||
}
|
||||
|
||||
Semaphore::~Semaphore()
|
||||
{
|
||||
#ifdef WIN32
|
||||
CloseHandle( m_hSemaphore );
|
||||
#else
|
||||
sem_destroy( &m_Semaphore );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Semaphore::Acquire()
|
||||
{
|
||||
#ifdef WIN32
|
||||
WaitForSingleObject( m_hSemaphore, INFINITE );
|
||||
#else
|
||||
sem_wait( &m_Semaphore );
|
||||
#endif
|
||||
}
|
||||
|
||||
void Semaphore::Release()
|
||||
{
|
||||
#ifdef WIN32
|
||||
ReleaseSemaphore( m_hSemaphore, 1, NULL );
|
||||
#else
|
||||
sem_post( &m_Semaphore );
|
||||
#endif
|
||||
}
|
||||
|
||||
} //namespace VmbAPI
|
||||
} //namespace AVT
|
||||
67
Vimba_6_0/VimbaCPP/Source/Semaphore.h
Normal file
67
Vimba_6_0/VimbaCPP/Source/Semaphore.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: Semaphore.h
|
||||
|
||||
Description: Definition of an semaphore class.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_SEMAPHORE
|
||||
#define AVT_VMBAPI_SEMAPHORE
|
||||
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class Semaphore
|
||||
{
|
||||
public:
|
||||
Semaphore( int nInit = 0, int nMax = 1 );
|
||||
~Semaphore();
|
||||
|
||||
void Acquire();
|
||||
void Release();
|
||||
|
||||
private:
|
||||
// No copy ctor
|
||||
Semaphore( const Semaphore &rSemaphore );
|
||||
// No assignment
|
||||
Semaphore& operator=( const Semaphore& );
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE m_hSemaphore;
|
||||
#else
|
||||
sem_t m_Semaphore;
|
||||
#endif
|
||||
};
|
||||
|
||||
}} //namespace AVT::VmbAPI
|
||||
|
||||
#endif //AVT_VMBAPI_MUTEX
|
||||
67
Vimba_6_0/VimbaCPP/Source/StringFeature.cpp
Normal file
67
Vimba_6_0/VimbaCPP/Source/StringFeature.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: StringFeature.cpp
|
||||
|
||||
Description: Implementation of class AVT::VmbAPI::StringFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 <VimbaCPP/Source/StringFeature.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
StringFeature::StringFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer )
|
||||
: BaseFeature( featureInfo, pFeatureContainer )
|
||||
{
|
||||
}
|
||||
|
||||
VmbErrorType StringFeature::GetValue( char * const pStrValue, VmbUint32_t &rnLength ) const
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
if ( NULL == pStrValue )
|
||||
{
|
||||
return (VmbErrorType)VmbFeatureStringMaxlengthQuery( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), &rnLength );
|
||||
}
|
||||
else
|
||||
{
|
||||
return (VmbErrorType)VmbFeatureStringGet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrValue, rnLength, &rnLength );
|
||||
}
|
||||
}
|
||||
|
||||
VmbErrorType StringFeature::SetValue( const char *pStrValue )
|
||||
{
|
||||
if ( NULL == m_pFeatureContainer )
|
||||
{
|
||||
return VmbErrorDeviceNotOpen;
|
||||
}
|
||||
|
||||
return (VmbErrorType)VmbFeatureStringSet( m_pFeatureContainer->GetHandle(), m_featureInfo.name.c_str(), pStrValue );
|
||||
}
|
||||
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
54
Vimba_6_0/VimbaCPP/Source/StringFeature.h
Normal file
54
Vimba_6_0/VimbaCPP/Source/StringFeature.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*=============================================================================
|
||||
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
|
||||
|
||||
Redistribution of this file, in original or modified form, without
|
||||
prior written consent of Allied Vision Technologies is prohibited.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
File: StringFeature.h
|
||||
|
||||
Description: Definition of class AVT::VmbAPI::StringFeature.
|
||||
Intended for use in the implementation of Vimba CPP API.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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 AVT_VMBAPI_STRINGFEATURE_H
|
||||
#define AVT_VMBAPI_STRINGFEATURE_H
|
||||
|
||||
#include <VimbaC/Include/VimbaC.h>
|
||||
#include <VimbaCPP/Include/VimbaCPPCommon.h>
|
||||
#include <VimbaCPP/Source/BaseFeature.h>
|
||||
#include <VimbaCPP/Include/FeatureContainer.h>
|
||||
|
||||
namespace AVT {
|
||||
namespace VmbAPI {
|
||||
|
||||
class StringFeature : public BaseFeature
|
||||
{
|
||||
public:
|
||||
StringFeature( const VmbFeatureInfo_t *featureInfo, FeatureContainer* const pFeatureContainer );
|
||||
|
||||
IMEXPORT virtual VmbErrorType SetValue( const char *pValue );
|
||||
|
||||
private:
|
||||
// Array functions to pass data across DLL boundaries
|
||||
IMEXPORT virtual VmbErrorType GetValue( char * const pValue, VmbUint32_t &length ) const;
|
||||
};
|
||||
|
||||
}} // namespace AVT::VmbAPI
|
||||
|
||||
#endif
|
||||
8
Vimba_6_0/VimbaCPP/Source/Version.h
Normal file
8
Vimba_6_0/VimbaCPP/Source/Version.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef AVT_VMBAPI_VERSION_H
|
||||
#define AVT_VMBAPI_VERSION_H
|
||||
|
||||
#define VIMBACPP_VERSION_MAJOR 1
|
||||
#define VIMBACPP_VERSION_MINOR 9
|
||||
#define VIMBACPP_VERSION_PATCH 0
|
||||
|
||||
#endif //AVT_VMBAPI_VERSION_H
|
||||
1293
Vimba_6_0/VimbaCPP/Source/VimbaSystem.cpp
Normal file
1293
Vimba_6_0/VimbaCPP/Source/VimbaSystem.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user