VimbaSystem.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*=============================================================================
  2. Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
  3. Redistribution of this file, in original or modified form, without
  4. prior written consent of Allied Vision Technologies is prohibited.
  5. -------------------------------------------------------------------------------
  6. File: VimbaSystem.h
  7. Description: Definition of class AVT::VmbAPI::VimbaSystem.
  8. -------------------------------------------------------------------------------
  9. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  10. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  11. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  12. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  13. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  16. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. =============================================================================*/
  20. #ifndef AVT_VMBAPI_SYSTEM_H
  21. #define AVT_VMBAPI_SYSTEM_H
  22. #include <vector>
  23. #include <VimbaC/Include/VimbaC.h>
  24. #include <VimbaCPP/Include/VimbaCPPCommon.h>
  25. #include <VimbaCPP/Include/LoggerDefines.h>
  26. #include <VimbaCPP/Include/SharedPointerDefines.h>
  27. #include <VimbaCPP/Include/Interface.h>
  28. #include <VimbaCPP/Include/Camera.h>
  29. #include <VimbaCPP/Include/ICameraFactory.h>
  30. #include <VimbaCPP/Include/ICameraListObserver.h>
  31. #include <VimbaCPP/Include/IInterfaceListObserver.h>
  32. namespace AVT {
  33. namespace VmbAPI {
  34. typedef std::vector<InterfacePtr> InterfacePtrVector;
  35. class VimbaSystem : public FeatureContainer
  36. {
  37. public:
  38. //
  39. // Method: GetInstance()
  40. //
  41. // Purpose: Returns a reference to the System singleton.
  42. //
  43. // Parameters: none
  44. //
  45. // Returns:
  46. //
  47. // - VimbaSystem&
  48. //
  49. IMEXPORT static VimbaSystem& GetInstance();
  50. //
  51. // Method: QueryVersion()
  52. //
  53. // Purpose: Retrieve the version number of VmbAPI.
  54. //
  55. // Parameters:
  56. //
  57. // [out] VmbVersionInfo_t& version Reference to the struct where version information
  58. // is copied
  59. //
  60. // Returns:
  61. //
  62. // - VmbErrorSuccess: always returned
  63. //
  64. // Details: This function can be called at any time, even before the API is
  65. // initialized. All other version numbers may be queried via feature access
  66. //
  67. IMEXPORT VmbErrorType QueryVersion( VmbVersionInfo_t &version );
  68. //
  69. // Method: Startup()
  70. //
  71. // Purpose: Initialize the VmbAPI module.
  72. //
  73. // Parameters: none
  74. //
  75. // Returns:
  76. //
  77. // - VmbErrorSuccess: If no error
  78. // - VmbErrorInternalFault: An internal fault occurred
  79. //
  80. // Details: On successful return, the API is initialized; this is a necessary call.
  81. // This method must be called before any other VmbAPI function is run.
  82. //
  83. IMEXPORT VmbErrorType Startup();
  84. //
  85. // Method: Shutdown()
  86. //
  87. // Purpose: Perform a shutdown on the API module.
  88. //
  89. // Parameters: none
  90. //
  91. // Returns:
  92. //
  93. // - VmbErrorSuccess: always returned
  94. //
  95. // Details: This will free some resources and deallocate all physical resources if applicable.
  96. //
  97. IMEXPORT VmbErrorType Shutdown();
  98. //
  99. // Method: GetInterfaces()
  100. //
  101. // Purpose: List all the interfaces currently visible to VmbAPI.
  102. //
  103. // Parameters:
  104. //
  105. // [out] InterfacePtrVector& interfaces Vector of shared pointer to Interface object
  106. //
  107. // Returns:
  108. //
  109. // - VmbErrorSuccess: If no error
  110. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  111. // - VmbErrorStructSize: The given struct size is not valid for this API version
  112. // - VmbErrorMoreData: More data were returned than space was provided
  113. // - VmbErrorInternalFault: An internal fault occurred
  114. //
  115. // Details: All the interfaces known via a GenTL are listed by this command and filled into the vector provided.
  116. // If the vector is not empty, new elements will be appended.
  117. // Interfaces can be adapter cards or frame grabber cards, for instance.
  118. //
  119. VmbErrorType GetInterfaces( InterfacePtrVector &interfaces );
  120. //
  121. // Method: GetInterfaceByID()
  122. //
  123. // Purpose: Gets a specific interface identified by an ID.
  124. //
  125. // Parameters:
  126. //
  127. // [in ] const char* pID The ID of the interface to get (returned by GetInterfaces())
  128. // [out] InterfacePtr& pInterface Shared pointer to Interface object
  129. //
  130. // Returns:
  131. //
  132. // - VmbErrorSuccess: If no error
  133. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  134. // - VmbErrorBadParameter: "pID" is NULL.
  135. // - VmbErrorStructSize: The given struct size is not valid for this API version
  136. // - VmbErrorMoreData: More data were returned than space was provided
  137. //
  138. // Details: An interface known via a GenTL is listed by this command and filled into the pointer provided.
  139. // Interface can be an adapter card or a frame grabber card, for instance.
  140. //
  141. IMEXPORT VmbErrorType GetInterfaceByID( const char *pID, InterfacePtr &pInterface );
  142. //
  143. // Method: OpenInterfaceByID()
  144. //
  145. // Purpose: Open an interface for feature access.
  146. //
  147. // Parameters:
  148. //
  149. // [in ] const char* pID The ID of the interface to open (returned by GetInterfaces())
  150. // [out] InterfacePtr& pInterface A shared pointer to the interface
  151. //
  152. // Returns:
  153. //
  154. // - VmbErrorSuccess: If no error
  155. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  156. // - VmbErrorNotFound: The designated interface cannot be found
  157. // - VmbErrorBadParameter: "pID" is NULL.
  158. //
  159. //
  160. // Details: An interface can be opened if interface-specific control is required, such as I/O pins
  161. // on a frame grabber card. Control is then possible via feature access methods.
  162. //
  163. IMEXPORT VmbErrorType OpenInterfaceByID( const char *pID, InterfacePtr &pInterface );
  164. //
  165. // Method: GetCameras()
  166. //
  167. // Purpose: Retrieve a list of all cameras.
  168. //
  169. // Parameters:
  170. //
  171. // [out] CameraPtrVector& cameras Vector of shared pointer to Camera object
  172. //
  173. // Returns:
  174. //
  175. // - VmbErrorSuccess: If no error
  176. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  177. // - VmbErrorStructSize: The given struct size is not valid for this API version
  178. // - VmbErrorMoreData: More data were returned than space was provided
  179. //
  180. // Details: A camera known via a GenTL is listed by this command and filled into the pointer provided.
  181. //
  182. VmbErrorType GetCameras( CameraPtrVector &cameras );
  183. //
  184. // Method: GetCameraByID()
  185. //
  186. // Purpose: Gets a specific camera identified by an ID. The returned camera is still closed.
  187. //
  188. // Parameters:
  189. //
  190. // [in ] const char* pID The ID of the camera to get
  191. // [out] CameraPtr& pCamera Shared pointer to camera object
  192. //
  193. // Returns:
  194. //
  195. // - VmbErrorSuccess: If no error
  196. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  197. // - VmbErrorBadParameter: "pID" is NULL.
  198. // - VmbErrorStructSize: The given struct size is not valid for this API version
  199. // - VmbErrorMoreData: More data were returned than space was provided
  200. //
  201. // Details: A camera known via a GenTL is listed by this command and filled into the pointer provided.
  202. // Only static properties of the camera can be fetched until the camera has been opened.
  203. // "pID" might be one of the following:
  204. // "169.254.12.13" for an IP address,
  205. // "000F314C4BE5" for a MAC address or
  206. // "DEV_1234567890" for an ID as reported by Vimba
  207. //
  208. IMEXPORT VmbErrorType GetCameraByID( const char *pID, CameraPtr &pCamera );
  209. //
  210. // Method: OpenCameraByID()
  211. //
  212. // Purpose: Gets a specific camera identified by an ID. The returned camera is already open.
  213. //
  214. // Parameters:
  215. //
  216. // [in ] const char* pID The unique ID of the camera to get
  217. // [in ] VmbAccessModeType eAccessMode The requested access mode
  218. // [out] CameraPtr& pCamera A shared pointer to the camera
  219. //
  220. // Returns:
  221. //
  222. // - VmbErrorSuccess: If no error
  223. // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
  224. // - VmbErrorNotFound: The designated interface cannot be found
  225. // - VmbErrorBadParameter: "pID" is NULL.
  226. //
  227. // Details: A camera can be opened if camera-specific control is required, such as I/O pins
  228. // on a frame grabber card. Control is then possible via feature access methods.
  229. // "pID" might be one of the following:
  230. // "169.254.12.13" for an IP address,
  231. // "000F314C4BE5" for a MAC address or
  232. // "DEV_1234567890" for an ID as reported by Vimba
  233. //
  234. IMEXPORT VmbErrorType OpenCameraByID( const char *pID, VmbAccessModeType eAccessMode, CameraPtr &pCamera );
  235. //
  236. // Method: RegisterCameraListObserver()
  237. //
  238. // Purpose: Registers an instance of camera observer whose CameraListChanged() method gets called
  239. // as soon as a camera is plugged in, plugged out, or changes its access status
  240. //
  241. // Parameters:
  242. //
  243. // [in ] const ICameraListObserverPtr& pObserver A shared pointer to an object derived from ICameraListObserver
  244. //
  245. // Returns:
  246. //
  247. // - VmbErrorSuccess: If no error
  248. // - VmbErrorBadParameter: "pObserver" is NULL.
  249. // - VmbErrorInvalidCall: If the very same observer is already registered
  250. //
  251. IMEXPORT VmbErrorType RegisterCameraListObserver( const ICameraListObserverPtr &pObserver );
  252. //
  253. // Method: UnregisterCameraListObserver()
  254. //
  255. // Purpose: Unregisters a camera observer
  256. //
  257. // Parameters:
  258. //
  259. // [in ] const ICameraListObserverPtr& pObserver A shared pointer to an object derived from ICameraListObserver
  260. //
  261. // Returns:
  262. //
  263. // - VmbErrorSuccess: If no error
  264. // - VmbErrorNotFound: If the observer is not registered
  265. // - VmbErrorBadParameter: "pObserver" is NULL.
  266. //
  267. IMEXPORT VmbErrorType UnregisterCameraListObserver( const ICameraListObserverPtr &pObserver );
  268. //
  269. // Method: RegisterInterfaceListObserver()
  270. //
  271. // Purpose: Registers an instance of interface observer whose InterfaceListChanged() method gets called
  272. // as soon as an interface is plugged in, plugged out, or changes its access status
  273. //
  274. // Parameters:
  275. //
  276. // [in ] const IInterfaceListObserverPtr& pObserver A shared pointer to an object derived from IInterfaceListObserver
  277. //
  278. // Returns:
  279. //
  280. // - VmbErrorSuccess: If no error
  281. // - VmbErrorBadParameter: "pObserver" is NULL.
  282. // - VmbErrorInvalidCall: If the very same observer is already registered
  283. //
  284. IMEXPORT VmbErrorType RegisterInterfaceListObserver( const IInterfaceListObserverPtr &pObserver );
  285. //
  286. // Method: UnregisterInterfaceListObserver()
  287. //
  288. // Purpose: Unregisters an interface observer
  289. //
  290. // Parameters:
  291. //
  292. // [in ] const IInterfaceListObserverPtr& pObserver A shared pointer to an object derived from IInterfaceListObserver
  293. //
  294. // Returns:
  295. //
  296. // - VmbErrorSuccess: If no error
  297. // - VmbErrorNotFound: If the observer is not registered
  298. // - VmbErrorBadParameter: "pObserver" is NULL.
  299. //
  300. IMEXPORT VmbErrorType UnregisterInterfaceListObserver( const IInterfaceListObserverPtr &pObserver );
  301. //
  302. // Method: RegisterCameraFactory()
  303. //
  304. // Purpose: Registers an instance of camera factory. When a custom camera factory is registered, all instances of type camera
  305. // will be set up accordingly.
  306. //
  307. // Parameters:
  308. //
  309. // [in ] const ICameraFactoryPtr& pCameraFactory A shared pointer to an object derived from ICameraFactory
  310. //
  311. // Returns:
  312. //
  313. // - VmbErrorSuccess: If no error
  314. // - VmbErrorBadParameter: "pCameraFactory" is NULL.
  315. //
  316. IMEXPORT VmbErrorType RegisterCameraFactory( const ICameraFactoryPtr &pCameraFactory );
  317. //
  318. // Method: UnregisterCameraFactory()
  319. //
  320. // Purpose: Unregisters the camera factory. After unregistering the default camera class is used.
  321. //
  322. // Returns:
  323. //
  324. // - VmbErrorSuccess: If no error
  325. //
  326. IMEXPORT VmbErrorType UnregisterCameraFactory();
  327. // Mapping of handle to CameraPtr
  328. CameraPtr GetCameraPtrByHandle( const VmbHandle_t handle ) const;
  329. Logger GetLogger() const;
  330. private:
  331. // Singleton.
  332. static VimbaSystem _instance;
  333. VimbaSystem();
  334. VimbaSystem( const VimbaSystem& );
  335. ~VimbaSystem();
  336. VimbaSystem& operator=( const VimbaSystem& system );
  337. struct Impl;
  338. Impl *m_pImpl;
  339. IMEXPORT VmbErrorType GetCameras( CameraPtr *pCameras, VmbUint32_t &size );
  340. IMEXPORT VmbErrorType GetInterfaces( InterfacePtr *pInterfaces, VmbUint32_t &size );
  341. };
  342. #include <VimbaCPP/Include/VimbaSystem.hpp>
  343. }} // namespace AVT::VmbAPI
  344. #endif