00001 /*============================================================================= 00002 Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved. 00003 00004 Redistribution of this file, in original or modified form, without 00005 prior written consent of Allied Vision Technologies is prohibited. 00006 00007 ------------------------------------------------------------------------------- 00008 00009 File: VimbaSystem.h 00010 00011 Description: Definition of class AVT::VmbAPI::VimbaSystem. 00012 00013 ------------------------------------------------------------------------------- 00014 00015 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00016 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, 00017 NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00019 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00022 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 =============================================================================*/ 00027 00028 #ifndef AVT_VMBAPI_SYSTEM_H 00029 #define AVT_VMBAPI_SYSTEM_H 00030 00031 #include <vector> 00032 00033 #include <VimbaC/Include/VimbaC.h> 00034 #include <VimbaCPP/Include/VimbaCPPCommon.h> 00035 #include <VimbaCPP/Include/LoggerDefines.h> 00036 #include <VimbaCPP/Include/SharedPointerDefines.h> 00037 #include <VimbaCPP/Include/Interface.h> 00038 #include <VimbaCPP/Include/Camera.h> 00039 #include <VimbaCPP/Include/ICameraFactory.h> 00040 #include <VimbaCPP/Include/ICameraListObserver.h> 00041 #include <VimbaCPP/Include/IInterfaceListObserver.h> 00042 00043 namespace AVT { 00044 namespace VmbAPI { 00045 00046 typedef std::vector<InterfacePtr> InterfacePtrVector; 00047 00048 class VimbaSystem 00049 { 00050 public: 00051 // 00052 // Method: GetInstance() 00053 // 00054 // Purpose: Returns a reference to the System singleton. 00055 // 00056 // Parameters: none 00057 // 00058 // Returns: 00059 // 00060 // - VimbaSystem& 00061 // 00062 IMEXPORT static VimbaSystem& GetInstance(); 00063 00064 // 00065 // Method: QueryVersion() 00066 // 00067 // Purpose: Retrieve the version number of VmbAPI. 00068 // 00069 // Parameters: 00070 // 00071 // [out] VmbVersionInfo_t& version Reference to the struct where version information 00072 // is copied 00073 // 00074 // Returns: 00075 // 00076 // - VmbErrorSuccess: always returned 00077 // 00078 // Details: This function can be called at any time, even before the API is 00079 // initialized. All other version numbers may be queried via feature access 00080 // 00081 IMEXPORT VmbErrorType QueryVersion( VmbVersionInfo_t &version ); 00082 00083 // 00084 // Method: Startup() 00085 // 00086 // Purpose: Initialize the VmbAPI module. 00087 // 00088 // Parameters: none 00089 // 00090 // Returns: 00091 // 00092 // - VmbErrorSuccess: If no error 00093 // - VmbErrorInternalFault: An internal fault occurred 00094 // 00095 // Details: On successful return, the API is initialized; this is a necessary call. 00096 // This method must be called before any other VmbAPI function is run. 00097 // 00098 IMEXPORT VmbErrorType Startup(); 00099 00100 // 00101 // Method: Shutdown() 00102 // 00103 // Purpose: Perform a shutdown on the API module. 00104 // 00105 // Parameters: none 00106 // 00107 // Returns: 00108 // 00109 // - VmbErrorSuccess: always returned 00110 // 00111 // Details: This will free some resources and deallocate all physical resources if applicable. 00112 // 00113 IMEXPORT VmbErrorType Shutdown(); 00114 00115 // 00116 // Method: GetInterfaces() 00117 // 00118 // Purpose: List all the interfaces currently visible to VmbAPI. 00119 // 00120 // Parameters: 00121 // 00122 // [out] InterfacePtrVector& interfaces Vector of shared pointer to Interface object 00123 // 00124 // Returns: 00125 // 00126 // - VmbErrorSuccess: If no error 00127 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00128 // - VmbErrorStructSize: The given struct size is not valid for this API version 00129 // - VmbErrorMoreData: More data were returned than space was provided 00130 // - VmbErrorInternalFault: An internal fault occurred 00131 // 00132 // Details: All the interfaces known via a GenTL are listed by this command and filled into the vector provided. 00133 // If the vector is not empty, new elements will be appended. 00134 // Interfaces can be adapter cards or frame grabber cards, for instance. 00135 // 00136 VmbErrorType GetInterfaces( InterfacePtrVector &interfaces ); 00137 00138 // 00139 // Method: GetInterfaceByID() 00140 // 00141 // Purpose: Gets a specific interface identified by an ID. 00142 // 00143 // Parameters: 00144 // 00145 // [in ] const char* pID The ID of the interface to get (returned by GetInterfaces()) 00146 // [out] InterfacePtr& pInterface Shared pointer to Interface object 00147 // 00148 // Returns: 00149 // 00150 // - VmbErrorSuccess: If no error 00151 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00152 // - VmbErrorBadParameter: "pID" is NULL. 00153 // - VmbErrorStructSize: The given struct size is not valid for this API version 00154 // - VmbErrorMoreData: More data were returned than space was provided 00155 // 00156 // Details: An interface known via a GenTL is listed by this command and filled into the pointer provided. 00157 // Interface can be an adapter card or a frame grabber card, for instance. 00158 // 00159 IMEXPORT VmbErrorType GetInterfaceByID( const char *pID, InterfacePtr &pInterface ); 00160 00161 // 00162 // Method: OpenInterfaceByID() 00163 // 00164 // Purpose: Open an interface for feature access. 00165 // 00166 // Parameters: 00167 // 00168 // [in ] const char* pID The ID of the interface to open (returned by GetInterfaces()) 00169 // [out] InterfacePtr& pInterface A shared pointer to the interface 00170 // 00171 // Returns: 00172 // 00173 // - VmbErrorSuccess: If no error 00174 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00175 // - VmbErrorNotFound: The designated interface cannot be found 00176 // - VmbErrorBadParameter: "pID" is NULL. 00177 // 00178 // 00179 // Details: An interface can be opened if interface-specific control is required, such as I/O pins 00180 // on a frame grabber card. Control is then possible via feature access methods. 00181 // 00182 IMEXPORT VmbErrorType OpenInterfaceByID( const char *pID, InterfacePtr &pInterface ); 00183 00184 // 00185 // Method: GetCameras() 00186 // 00187 // Purpose: Retrieve a list of all cameras. 00188 // 00189 // Parameters: 00190 // 00191 // [out] CameraPtrVector& cameras Vector of shared pointer to Camera object 00192 // 00193 // Returns: 00194 // 00195 // - VmbErrorSuccess: If no error 00196 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00197 // - VmbErrorStructSize: The given struct size is not valid for this API version 00198 // - VmbErrorMoreData: More data were returned than space was provided 00199 // 00200 // Details: A camera known via a GenTL is listed by this command and filled into the pointer provided. 00201 // 00202 VmbErrorType GetCameras( CameraPtrVector &cameras ); 00203 00204 // 00205 // Method: GetCameraByID() 00206 // 00207 // Purpose: Gets a specific camera identified by an ID. The returned camera is still closed. 00208 // 00209 // Parameters: 00210 // 00211 // [in ] const char* pID The ID of the camera to get 00212 // [out] CameraPtr& pCamera Shared pointer to camera object 00213 // 00214 // Returns: 00215 // 00216 // - VmbErrorSuccess: If no error 00217 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00218 // - VmbErrorBadParameter: "pID" is NULL. 00219 // - VmbErrorStructSize: The given struct size is not valid for this API version 00220 // - VmbErrorMoreData: More data were returned than space was provided 00221 // 00222 // Details: A camera known via a GenTL is listed by this command and filled into the pointer provided. 00223 // Only static properties of the camera can be fetched until the camera has been opened. 00224 // "pID" might be one of the following: 00225 // "169.254.12.13" for an IP address, 00226 // "000F314C4BE5" for a MAC address or 00227 // "DEV_1234567890" for an ID as reported by Vimba 00228 // 00229 IMEXPORT VmbErrorType GetCameraByID( const char *pID, CameraPtr &pCamera ); 00230 00231 // 00232 // Method: OpenCameraByID() 00233 // 00234 // Purpose: Gets a specific camera identified by an ID. The returned camera is already open. 00235 // 00236 // Parameters: 00237 // 00238 // [in ] const char* pID The unique ID of the camera to get 00239 // [in ] VmbAccessModeType eAccessMode The requested access mode 00240 // [out] CameraPtr& pCamera A shared pointer to the camera 00241 // 00242 // Returns: 00243 // 00244 // - VmbErrorSuccess: If no error 00245 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command 00246 // - VmbErrorNotFound: The designated interface cannot be found 00247 // - VmbErrorBadParameter: "pID" is NULL. 00248 // 00249 // Details: A camera can be opened if camera-specific control is required, such as I/O pins 00250 // on a frame grabber card. Control is then possible via feature access methods. 00251 // "pID" might be one of the following: 00252 // "169.254.12.13" for an IP address, 00253 // "000F314C4BE5" for a MAC address or 00254 // "DEV_1234567890" for an ID as reported by Vimba 00255 // 00256 IMEXPORT VmbErrorType OpenCameraByID( const char *pID, VmbAccessModeType eAccessMode, CameraPtr &pCamera ); 00257 00258 // 00259 // Method: RegisterCameraListObserver() 00260 // 00261 // Purpose: Registers an instance of camera observer whose CameraListChanged() method gets called 00262 // as soon as a camera is plugged in, plugged out, or changes its access status 00263 // 00264 // Parameters: 00265 // 00266 // [in ] const ICameraListObserverPtr& pObserver A shared pointer to an object derived from ICameraListObserver 00267 // 00268 // Returns: 00269 // 00270 // - VmbErrorSuccess: If no error 00271 // - VmbErrorBadParameter: "pObserver" is NULL. 00272 // - VmbErrorInvalidCall: If the very same observer is already registered 00273 // 00274 IMEXPORT VmbErrorType RegisterCameraListObserver( const ICameraListObserverPtr &pObserver ); 00275 00276 // 00277 // Method: UnregisterCameraListObserver() 00278 // 00279 // Purpose: Unregisters a camera observer 00280 // 00281 // Parameters: 00282 // 00283 // [in ] const ICameraListObserverPtr& pObserver A shared pointer to an object derived from ICameraListObserver 00284 // 00285 // Returns: 00286 // 00287 // - VmbErrorSuccess: If no error 00288 // - VmbErrorNotFound: If the observer is not registered 00289 // - VmbErrorBadParameter: "pObserver" is NULL. 00290 // 00291 IMEXPORT VmbErrorType UnregisterCameraListObserver( const ICameraListObserverPtr &pObserver ); 00292 00293 // 00294 // Method: RegisterInterfaceListObserver() 00295 // 00296 // Purpose: Registers an instance of interface observer whose InterfaceListChanged() method gets called 00297 // as soon as an interface is plugged in, plugged out, or changes its access status 00298 // 00299 // Parameters: 00300 // 00301 // [in ] const IInterfaceListObserverPtr& pObserver A shared pointer to an object derived from IInterfaceListObserver 00302 // 00303 // Returns: 00304 // 00305 // - VmbErrorSuccess: If no error 00306 // - VmbErrorBadParameter: "pObserver" is NULL. 00307 // - VmbErrorInvalidCall: If the very same observer is already registered 00308 // 00309 IMEXPORT VmbErrorType RegisterInterfaceListObserver( const IInterfaceListObserverPtr &pObserver ); 00310 00311 // 00312 // Method: UnregisterInterfaceListObserver() 00313 // 00314 // Purpose: Unregisters an interface observer 00315 // 00316 // Parameters: 00317 // 00318 // [in ] const IInterfaceListObserverPtr& pObserver A shared pointer to an object derived from IInterfaceListObserver 00319 // 00320 // Returns: 00321 // 00322 // - VmbErrorSuccess: If no error 00323 // - VmbErrorNotFound: If the observer is not registered 00324 // - VmbErrorBadParameter: "pObserver" is NULL. 00325 // 00326 IMEXPORT VmbErrorType UnregisterInterfaceListObserver( const IInterfaceListObserverPtr &pObserver ); 00327 00328 // 00329 // Method: RegisterCameraFactory() 00330 // 00331 // Purpose: Registers an instance of camera factory. When a custom camera factory is registered, all instances of type camera 00332 // will be set up accordingly. 00333 // 00334 // Parameters: 00335 // 00336 // [in ] const ICameraFactoryPtr& pCameraFactory A shared pointer to an object derived from ICameraFactory 00337 // 00338 // Returns: 00339 // 00340 // - VmbErrorSuccess: If no error 00341 // - VmbErrorBadParameter: "pCameraFactory" is NULL. 00342 // 00343 IMEXPORT VmbErrorType RegisterCameraFactory( const ICameraFactoryPtr &pCameraFactory ); 00344 00345 // 00346 // Method: UnregisterCameraFactory() 00347 // 00348 // Purpose: Unregisters the camera factory. After unregistering the default camera class is used. 00349 // 00350 // Returns: 00351 // 00352 // - VmbErrorSuccess: If no error 00353 // 00354 IMEXPORT VmbErrorType UnregisterCameraFactory(); 00355 00356 // Mapping of handle to CameraPtr 00357 CameraPtr GetCameraPtrByHandle( const VmbHandle_t handle ) const; 00358 00359 Logger GetLogger() const; 00360 00361 private: 00362 // Singleton. 00363 static VimbaSystem _instance; 00364 VimbaSystem(); 00365 VimbaSystem( const VimbaSystem& ); 00366 ~VimbaSystem(); 00367 VimbaSystem& operator=( const VimbaSystem& system ); 00368 00369 struct Impl; 00370 Impl *m_pImpl; 00371 00372 IMEXPORT VmbErrorType GetCameras( CameraPtr *pCameras, VmbUint32_t &size ); 00373 IMEXPORT VmbErrorType GetInterfaces( InterfacePtr *pInterfaces, VmbUint32_t &size ); 00374 }; 00375 00376 #include <VimbaCPP/Include/VimbaSystem.hpp> 00377 00378 }} // namespace AVT::VmbAPI 00379 #endif