DeviceFactory.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2006-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: AH
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Definition of the IDeviceFactory interface
  10. */
  11. #ifndef __DEVICEFACTORY_H__
  12. #define __DEVICEFACTORY_H__
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #include <pylon/Platform.h>
  17. #ifdef _MSC_VER
  18. # pragma pack(push, PYLON_PACKING)
  19. #endif /* _MSC_VER */
  20. #include <pylon/stdinclude.h>
  21. #include <pylon/DeviceInfo.h>
  22. #include <pylon/Container.h>
  23. #include <pylon/DeviceAccessMode.h>
  24. namespace Pylon
  25. {
  26. interface IPylonDevice;
  27. // --------------------------------------------------------------------------
  28. // enum EDeviceAccessiblityInfo
  29. // --------------------------------------------------------------------------
  30. /// Information about the accessibility of a device
  31. /*!
  32. \ingroup Pylon_TransportLayer
  33. */
  34. enum EDeviceAccessiblityInfo
  35. {
  36. Accessibility_Unknown = 0, //!< The accessibility could not be determined. The state of accessibility is unknown.
  37. Accessibility_Ok = 1, //!< The device could be opened.
  38. Accessibility_Opened = 2, //!< The device is reachable, but can be opened in read only mode only.
  39. Accessibility_OpenedExclusively = 3, //!< The device is reachable, but currently opened exclusively by another application.
  40. Accessibility_NotReachable = 4, //!< The device could not be reached or does not exist. No connection to the device is possible.
  41. };
  42. /*!
  43. \interface IDeviceFactory
  44. \brief Interface to be implemented by device factories used to create devices.
  45. Each transport layer object is a device factory. These device factories must implement
  46. the IDeviceFactory interface.
  47. \ingroup Pylon_TransportLayer
  48. */
  49. interface PUBLIC_INTERFACE IDeviceFactory
  50. {
  51. /// Retrieves a list of available devices.
  52. /**
  53. The list contains Pylon::CDeviceInfo objects used for the device creation and is ordered by device class and serial number using the operator Pylon::CDeviceInfo::operator<().
  54. By default, the list will be cleared before the device discovery is started.
  55. \param list List to be filled with device info objects.
  56. \param addToList If true, the devices found will be appended to the list instead of deleting the list. Only newly discovered devices are sorted and not the entire list.
  57. \return Number of devices found.
  58. */
  59. virtual int EnumerateDevices( DeviceInfoList_t& list, bool addToList = false ) = 0;
  60. /// Retrieves a list of available devices filtered by given properties, usable for looking for specific devices.
  61. /**
  62. The list contains Pylon::CDeviceInfo objects used for the device creation and is ordered by device class and serial number using the operator Pylon::CDeviceInfo::operator<().
  63. By default, the list will be cleared before the device discovery is started.
  64. The filter list can contain a list of device info objects containing properties a device must have, e.g.,
  65. the user-provided name or the serial number. A device is returned if it matches the properties of any of the
  66. device info objects on the filter list.
  67. If the device class property is set in the filter device info objects, the search is
  68. limited to the required transport layers.
  69. \param list List to be filled with device info objects.
  70. \param filter A list of device info objects with user-provided properties that a device can match.
  71. \param addToList If true, the devices found will be appended to the list instead of deleting the list. Only newly discovered devices are sorted and not the entire list.
  72. \return Number of devices found.
  73. */
  74. virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false ) = 0;
  75. /// Creates a camera object from a device info object.
  76. /**
  77. This method accepts either a device info object from a device enumeration or a user-provided device info object.
  78. User-provided device info objects can be preset with properties required for a device, e.g.
  79. the user-provided name or the serial number. The implementation tries to find a matching camera by using device
  80. enumeration.
  81. When the device class property is set, the search is limited to the required transport layer.
  82. If the device creation fails, a GenApi::GenericException will be thrown.
  83. \param di Device info object containing all information needed to identify exactly one device.
  84. */
  85. virtual IPylonDevice* CreateDevice( const CDeviceInfo& di ) = 0;
  86. /// If multiple devices match the provided properties, the first device found is created.
  87. /// The order in which the devices are found can vary from call to call.
  88. virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() ) = 0;
  89. /// Creates a camera object from a device info object, injecting additional GenICam XML definition strings.
  90. /// Currently only one injected xml string is supported.
  91. virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) = 0;
  92. /// Creates the first found camera device matching the provided properties, injecting additional GenICam XML definition strings.
  93. /// Currently only one injected xml string is supported.
  94. virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) = 0;
  95. /// This method is deprecated. Use CreateDevice and pass a CDeviceInfo object containing the full name as a property.
  96. /// Example: IPylonDevice* device = TlFactory.CreateDevice( CDeviceInfo().SetFullName( fullname));
  97. /// creates a device that matches its full name (i.e., as returned by CDeviceInfo::GetFullName).
  98. virtual IPylonDevice* CreateDevice( const String_t& ) = 0;
  99. /// Destroys a device.
  100. /** \note Never try to delete a pointer to a camera device by calling free or delete.
  101. Always use the DestroyDevice method.
  102. */
  103. virtual void DestroyDevice( IPylonDevice* ) = 0;
  104. /*!
  105. \brief This method can be used to check if a camera device can be created and opened.
  106. This method accepts either a device info object from a device enumeration or a user-provided device info object.
  107. User-provided device info objects can be preset with properties required for a device, e.g.
  108. the user-provided name or the serial number. The implementation tries to find a matching camera by using device
  109. enumeration. When the device class property is set, see \ref DeviceClass.h header file, the search is limited to the required transport layer.
  110. For more information, see \ref UsingEnumeraionWithFilter "Applying a Filter when Enumerating Cameras".
  111. \param[in] deviceInfo Properties to find/identify the camera device to check.
  112. \param[in] mode Used for defining how a device is accessed.
  113. The use of the mode information is transport layer-specific.
  114. - For \ref Pylon::BaslerBconDeviceClass "BCON", \ref Pylon::BaslerCameraLinkDeviceClass "CameraLink",
  115. and \ref Pylon::BaslerUsbDeviceClass "USB" devices, the mode information is ignored.
  116. - For \ref Pylon::BaslerGigEDeviceClass "GigE" devices, the \c Exclusive and \c Control flags are used for defining how a device is accessed. Other mode information is ignored.
  117. - For devices of any type that are accessed via the \ref Pylon::BaslerGenTlDeviceClassPrefix "GenICam GenTL" transport layer, the mode is ignored.
  118. \param[out] pAccessibilityInfo Optional parameter that provides more information about whether a device is accessible or not.
  119. \return True if device can be opened with provided access mode.
  120. \pre The \c deviceInfo object properties specify exactly one device.
  121. This is the case when the device info object has been obtained using device enumeration.
  122. \error
  123. Throws a C++ exception, if the preconditions are not met.
  124. */
  125. virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL ) = 0;
  126. };
  127. } // namespace PYLON
  128. #ifdef _MSC_VER
  129. # pragma pack(pop)
  130. #endif /* _MSC_VER */
  131. #endif