Skip to content

pylon/BaslerUniversalInstantCamera.h#

pylon universal instant camera class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
struct Pylon::CBaslerUniversalInstantCameraTraits
Lists all the types used by the universal instant camera class.
class Pylon::CBaslerUniversalInstantCamera
Extends the CInstantCamera by universal parameter interface classes combining all interface types.

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2010-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  Andreas Gau
//-----------------------------------------------------------------------------
#ifndef INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H
#define INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H

#pragma once

#include <pylon/_BaslerUniversalCameraParams.h>
#include <pylon/_BaslerUniversalStreamParams.h>
#include <pylon/_BaslerUniversalEventParams.h>
#include <pylon/_BaslerUniversalTLParams.h>
#include <pylon/BaslerUniversalConfigurationEventHandler.h>
#include <pylon/BaslerUniversalImageEventHandler.h>
#include <pylon/BaslerUniversalCameraEventHandler.h>
#include <pylon/BaslerUniversalGrabResultPtr.h>
#include <pylon/private/DeviceSpecificInstantCamera.h>
#include <pylon/gige/PylonGigEDevice.h>
#include <pylon/DeviceClass.h>
#include <pylon/NodeMapProxy.h>
#include <Base/GCException.h>

namespace Pylon
{
    class CBaslerUniversalInstantCamera;

    struct CBaslerUniversalInstantCameraTraits
    {
        typedef CBaslerUniversalInstantCamera InstantCamera_t;
        typedef Basler_UniversalCameraParams::CUniversalCameraParams_Params CameraParams_t;
        typedef IPylonDevice IPylonDevice_t;
        typedef Pylon::CDeviceInfo DeviceInfo_t;
        typedef CNodeMapProxyT<Basler_UniversalTLParams::CUniversalTLParams_Params> TlParams_t;
        typedef CNodeMapProxyT<Basler_UniversalStreamParams::CUniversalStreamParams_Params> StreamGrabberParams_t;
        typedef CNodeMapProxyT<Basler_UniversalEventParams::CUniversalEventParams_Params> EventGrabberParams_t;
        typedef CBaslerUniversalConfigurationEventHandler ConfigurationEventHandler_t;
        typedef CBaslerUniversalImageEventHandler ImageEventHandler_t;
        typedef CBaslerUniversalCameraEventHandler CameraEventHandler_t;
        typedef CBaslerUniversalGrabResultData GrabResultData_t;
        typedef CBaslerUniversalGrabResultPtr GrabResultPtr_t;

        static bool HasSpecificDeviceClass()
        {
            return false;
        }
        static String_t DeviceClass()
        {
            throw LOGICAL_ERROR_EXCEPTION( "The CBaslerUniversalInstantCamera has no specific device class. The method DeviceClass() cannot be used." );
        }

    };
    class CBaslerUniversalInstantCamera : public CDeviceSpecificInstantCameraT<CBaslerUniversalInstantCameraTraits>
    {
    public:
        CBaslerUniversalInstantCamera()
        {
        }

        CBaslerUniversalInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete )
            : CDeviceSpecificInstantCameraT<CBaslerUniversalInstantCameraTraits>( pDevice, cleanupProcedure )
        {
        }

        ~CBaslerUniversalInstantCamera()
        {
            Attach( NULL );
            InternalShutdownEventHandlers();
        }

        void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp )
        {
            AutoLock lock( CInstantCamera::GetLock() );
            GetGigEDevice()->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp );
        }

        void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway )
        {
            AutoLock lock( CInstantCamera::GetLock() );
            GetGigEDevice()->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
        }

        void SetPersistentIpAddress( const String_t& IpAddress,
                                     const String_t& SubnetMask,
                                     const String_t& DefaultGateway )

        {
            AutoLock lock( CInstantCamera::GetLock() );
            GetGigEDevice()->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway );
        }

    protected:
        //Get the pointer for the Universal device.
        virtual IPylonGigEDevice* GetGigEDevice()
        {
            IPylonDevice* pDevice = CInstantCamera::GetDevice();
            IPylonGigEDevice* pGigEDevice = dynamic_cast<IPylonGigEDevice*>(pDevice);

            // Check whether device type matches camera type.
            if (!pGigEDevice)
            {
                throw LOGICAL_ERROR_EXCEPTION( "The attached pylon device type must be a GigE device." );
            }

            return pGigEDevice;
        }

        //Create device grab result data. Is subject to change without notice.
        virtual CGrabResultData* CreateDeviceSpecificGrabResultData()
        {
            return new GrabResultData_t();
        }
    };

} // namespace Pylon

#endif /* INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H */

Updated on 5 July 2022 at 15:30:01