All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CLAllAdapter.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2009 by DALSA
3 // Section: Digital Imaging
4 // Project: CLProtocol
5 // Author: Eric Bourbonnais
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
30 #ifndef CLPROTOCOL_CLALLADAPTER_H
31 #define CLPROTOCOL_CLALLADAPTER_H
32 
33 #include <Base/GCBase.h>
34 #include <CLProtocol/ClAllSerial.h>
35 #include <CLProtocol/CLException.h>
36 #include <CLProtocol/CLProtocol.h>
38 #include <map>
39 
40 #if defined(_WIN32)
41 #include <windows.h>
42 #else
43 #include <dlfcn.h>
44 #include <errno.h>
45 #endif
46 
47 #if defined (_WIN32)
48 typedef HMODULE lib_handle_t;
49 #else
50 typedef void * lib_handle_t;
51 #endif
52 
53 // manufacturer shared libraries are defined with __cdecl ...; taken from DLLLoad.h
54 #if defined (_MSC_VER)
55 // nothing
56 #else
57 # if !defined(__x86_64) && !defined(__arm__) && !defined(__aarch64__) && !defined(VXWORKS)
58 # define __cdecl __attribute__((cdecl))
59 # else
60 # define __cdecl /* use default calling convention */
61 # endif
62 #endif
63 
64 namespace CLProtocol
65 {
67  typedef std::map<GENICAM_NAMESPACE::gcstring, ISerialAdapter *> SerialPortMap;
68 
71  {
72  public:
73 
75  static void Destroy( ISerialAdapter * pAdapter );
76 
78 
83  virtual CLINT32 SerialInit( void);
84  virtual void SerialClose( void);
85  virtual void CheckError( CLINT32 ErrorCode );
87 
89  static void GetPortIDs(GENICAM_NAMESPACE::gcstring_vector &TheVector);
91  static ISerialAdapter *GetSerialAdapter(GENICAM_NAMESPACE::gcstring PortID);
92 
93  private:
94  /*------------------------------------------------*/
95  // functions of the CLAllSerial DLL
96  /*------------------------------------------------*/
97  struct CLAllProxy
98  {
100  CLINT32 (CLALLSERIALCC *m_clGetErrorText)( const CLINT8*, CLINT32, CLINT8*, CLUINT32*);
102  CLINT32 (CLALLSERIALCC *m_clGetNumPorts) ( CLUINT32* Ports);
104  CLINT32 (CLALLSERIALCC *m_clGetPortInfo ) ( CLUINT32 serialIndex, CLINT8* manufacturerName, CLUINT32* nameBytes, CLINT8* portID, CLUINT32* IDBytes, CLUINT32* version);
106  CLINT32 (CLALLSERIALCC *m_clGetSupportedBaudRates) ( hSerRef serialRef, CLUINT32* baudRates);
108  void (CLALLSERIALCC *m_clSerialClose) ( hSerRef serialRef);
110  CLINT32 (CLALLSERIALCC *m_clSerialInit) ( CLUINT32 serialIndex, hSerRef* serialRefPtr);
112  CLINT32 (CLALLSERIALCC *m_clSerialRead) ( hSerRef serialRef, CLINT8* buffer, CLUINT32* bufferSize, CLUINT32 serialTimeout);
114  CLINT32 (CLALLSERIALCC *m_clSerialWrite) ( hSerRef serialRef, CLINT8* buffer, CLUINT32* bufferSize, CLUINT32 serialTimeout);
116  CLINT32 (CLALLSERIALCC *m_clSetBaudRate) ( hSerRef serialRef, CLUINT32 baudRate);
117  };
118 
119  static void CheckError( CLINT32 ErrorCode, CLUINT32 SerialIndex, CLAllProxy & );
120 
123 
125  virtual ~CCLAllAdapter();
126 
129 
130 #ifdef _DEBUG // Allow changing serial index to test error situations.
131  public:
132 #endif
133  CLUINT32 m_SerialIndex;
135 
136  private:
137 
139  static void InternalGetPortMap(SerialPortMap &);
140 
142 
145 
148 
151  };
152 
154  inline void GetPortMap(SerialPortMap &StdMap)
155  {
156  GENICAM_NAMESPACE::gcstring_vector PortIDs;
157  CCLAllAdapter::GetPortIDs(PortIDs);
158  for (GENICAM_NAMESPACE::gcstring_vector::iterator it = PortIDs.begin(); it != PortIDs.end(); it++)
159  {
160  StdMap[*it] = CCLAllAdapter::GetSerialAdapter(*it);
161  }
162  }
163 
164  inline void Destroy(SerialPortMap &portList)
165  {
166  for (SerialPortMap::iterator it = portList.begin(); it != portList.end(); it++)
167  CCLAllAdapter::Destroy(it->second);
168  }
169 
170 }
171 #endif //CLPROTOCOL_CLALLADAPTER_H
CLProtocol
Definition: CLAllAdapter.h:64
CLProtocol.h
Exported C functions for camera link protocol drivers.
CLProtocol::GetPortMap
void GetPortMap(SerialPortMap &StdMap)
retrieves the list of port mapped by PortID
Definition: CLAllAdapter.h:154
CLProtocol::CCLAllAdapter::CLAllProxy::CLINT32
CLINT32
Definition: CLAllAdapter.h:100
CLProtocol::CCLAllAdapter
Wraps the CLAllSerial.dll.
Definition: CLAllAdapter.h:70
CLProtocol::CCLAllAdapter::CLAllProxy::baudRates
CLUINT32 * baudRates
Definition: CLAllAdapter.h:106
CLINT8
char CLINT8
Definition: ClSerialTypes.h:126
CLProtocol::SerialPortMap
std::map< GENICAM_NAMESPACE::gcstring, ISerialAdapter * > SerialPortMap
A map holding the pointers to the serial adapters.
Definition: CLAllAdapter.h:67
CLUINT32
unsigned int CLUINT32
Definition: ClSerialTypes.h:105
GENICAM_NAMESPACE::gcstring
A string class which is a clone of std::string.
Definition: GCString.h:52
clSerialWrite
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialWrite(hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
CLProtocol::CCLAllAdapter::Destroy
static void Destroy(ISerialAdapter *pAdapter)
Destroy the factory and all its objects.
CLProtocol::CCLAllAdapter::GetPortIDs
static void GetPortIDs(GENICAM_NAMESPACE::gcstring_vector &TheVector)
used to copy the content of the SerialPort ma to a std::map
CLProtocol::CCLAllAdapter::CLAllProxy::version
CLINT8 CLUINT32 CLINT8 CLUINT32 CLUINT32 * version
Definition: CLAllAdapter.h:104
CLProtocol::CCLAllAdapter::CLAllProxy
Definition: CLAllAdapter.h:97
CLPROTOCOL_DECL
#define CLPROTOCOL_DECL
Definition: CLProtocol.h:64
CLProtocol::CCLAllAdapter::m_clallproxy
CLAllProxy m_clallproxy
CLALL functions pointers.
Definition: CLAllAdapter.h:147
clSetBaudRate
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSetBaudRate(hSerRef serialRef, CLUINT32 baudRate)
CLProtocol::CCLAllAdapter::m_SerialRef
hSerRef m_SerialRef
handle of the serial port
Definition: CLAllAdapter.h:128
CLProtocol::CCLAllAdapter::m_ClAlldllHandle
lib_handle_t m_ClAlldllHandle
handle to the loaded ClAllSerial DLL
Definition: CLAllAdapter.h:144
CLProtocol::CCLAllAdapter::m_PreviousBaudRate
CLUINT32 m_PreviousBaudRate
the previous baud rate as set via SetBaudRate; zero otherwise
Definition: CLAllAdapter.h:150
CLProtocol::CCLAllAdapter::GetSerialAdapter
static ISerialAdapter * GetSerialAdapter(GENICAM_NAMESPACE::gcstring PortID)
used to copy the content of the SerialPort ma to a std::map
CLALLSERIALCC
#define CLALLSERIALCC
Definition: ClAllSerial.h:81
clGetSupportedBaudRates
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clGetSupportedBaudRates(hSerRef serialRef, CLUINT32 *baudRates)
ClAllSerial.h
CLProtocol::Destroy
void Destroy(SerialPortMap &portList)
Definition: CLAllAdapter.h:164
GCBase.h
Common GenICam base include file.
CLProtocol::CCLAllAdapter::g_pSerialPortMap
static SerialPortMap * g_pSerialPortMap
Definition: CLAllAdapter.h:141
lib_handle_t
void * lib_handle_t
Definition: CLAllAdapter.h:50
clSerialRead
CLALLSERIALEXPORT CLINT32 CLALLSERIALCC clSerialRead(hSerRef serialRef, CLINT8 *buffer, CLUINT32 *bufferSize, CLUINT32 serialTimeout)
hSerRef
void * hSerRef
Definition: ClSerialTypes.h:95
ISerialAdapter.h
CLINT32
int CLINT32
Definition: ClSerialTypes.h:100
CLException.h
CLProtocol exception type.
CLProtocol::CCLAllAdapter::CLAllProxy::baudRate
CLUINT32 baudRate
Definition: CLAllAdapter.h:116
CLProtocol::CCLAllAdapter::CLAllProxy::serialTimeout
CLINT8 CLUINT32 CLUINT32 serialTimeout
Definition: CLAllAdapter.h:112
CLProtocol::CCLAllAdapter::CLAllProxy::serialRefPtr
hSerRef * serialRefPtr
Definition: CLAllAdapter.h:110
CLPROTOCOL
#define CLPROTOCOL
Definition: CLProtocol.h:73
CLProtocol::ISerialAdapter
Definition: ISerialAdapter.h:37


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11