3
* This is the replacement for camdll.h. It will provide the API for
4
* the property protocol only.
6
* This is (yet) work under construction.
10
#include "pftypes.h" // Photonfocus data types
15
* \mainpage PFLIB SDK Documentation
17
* \author Photonfocus AG
20
* \section intro Introduction
22
* The Photonfocus library 'PFLIB' enables an application programmer
23
* to control a Photonfocus Camera's features without direct access to
24
* the CameraLink (or other communication layer such as Gigabit Ethernet)
26
* The access, in order to work with most of the frame grabbers, is
27
* done by a separate COMDLL, which is a low level communication interface
28
* to the frame grabber's RS232 emulation. This may be frame grabber specific,
29
* and does not depend on the camera type.
31
* \note The API has changed from 0.x to 1.x. No 'old' function call
32
* is supported anymore. However, the 1.0 API is much simpler and
35
* \section api API Details
37
* The API interface uses the standard C convention (CDECL) interface.
38
* Support for Visual Basic is not available.
39
* The PFLIB is portable among different operating systems such as
40
* Microsoft Windows, Linux, QNX, and other Unix versions, however,
41
* this is not tested and we cannot give any support for an operating
42
* system other than Microsoft Windows.
44
* This 1.0 version API was designed as generic as possible for any
45
* device type. Therefore, we ask the reader not to be confused about
46
* abstract terms as 'devices' and 'properties'. For legacy reasons,
47
* the term 'camera' still appears here and there. We apologize for
50
* \subsection props Property concept
52
* The device property concept (so forth 'Property') of the previous 0.x PFLIB
53
* API has been refined such that all device properties are basically
54
* controlled via pfDevice_GetProperty() and pfDevice_SetProperty().
56
* New in this API is a tree hierarchy, that covers the following property
59
* \li Properties have more extended types such as structs and arrays and
60
* can contain other Property members
61
* \li Max and min values are encoded the same way in a parent/children
63
* \li Mode selections can be encoded in this tree concept as well
65
* \image html properties.png "Property hierarchy"
66
* \image latex properties.pdf "Property" width=15cm
69
* The architecture also allows to integrate user defined children types
70
* to a data type via structs that allow signalling events to a specific GUI
71
* element when Property was changed, etc.
73
* To keep the API and the library code as compact and efficient as possible,
74
* the Property access happens via tokens. The token is obtained by
75
* pfProperty_ParseName() via a given name, which is defined in the name
76
* space of a certain parent node. The top root node of a Property
77
* hierarchy is always the device node which is obtained by pfDevice_GetRoot().
79
* Value passing is done via a runtime data type information capable structure
80
* 'PFValue'. This structure contains a data union field and an associated
81
* data type. The value is retrieved from the PFValue struct according
82
* to the type field. The Property getter and setter functions of the library
83
* perform a type check and return an error (#PFERR_PROPERTY_TYPE_MATCH) in
86
* The following code sequence demonstrates how to set the exposure time
91
int setExposure(int port, float time)
95
TOKEN t_exp = pfProperty_ParseName(port, "ExposureTime"));
97
if (t_exp == INVALID_TOKEN) return PFERR_PROPERTY_UNKNOWN;
103
error = pfDevice_SetProperty(port, t_exp, &val);
112
* \subsection commonfunc Common function parameters
114
* Generally, the first parameter of a function whose name starts with
115
* 'pfDevice_' is the current camera device handle. The struct members of
116
* the camera object must NEVER be accessed directly, to preserve future
117
* binary compatibility.
119
* If not documented otherwise, the function's return value is
121
* \li == 0 on success
124
* Functions which set a value may return #PFWARN_PROPERTY_MODIFIED, meaning
125
* that the given parameter was not valid or not according to certain
126
* constraints. All 'Event' children of this property should be queried via
127
* pfProperty_Select(), because they may have changed.
128
* In this case, the user should also read back the value that was passed
129
* to pfSetProperty() which was possibly modified 'in place'.
137
// This trick is used for easy function wrapping..
139
#define APIFUNC(retval, name, parms) \
140
CAMDLL_API retval APIDECL pf##name parms;
145
* \defgroup PortAccess Port Access, Device Initialization
147
* This module contains the initialization routines for the
154
* This example works with a HURRICANE-40 camera.
155
* For other cameras, check propertylist first and change code.\n
156
* Propertylist: Start PFRemote1.0, press F1 for help, menu Camera Properties, select camera
163
* A simple command line program to query and set properties.
167
<programname>\endverbatim
168
* Lists all top level properties of the device
171
<programname> <property_name> \endverbatim
173
* Query specified Property with name 'property'.
174
* Children are displayed as well as its value,
178
<programname> <property> <value> \endverbatim
180
* Set specified Property with name 'property'
181
* to value 'value'. Illegal values are caught.
188
* \addtogroup PortAccess
195
* Init of all camera ports. This has to be called as first
197
* \param numOfPorts Number of available camera ports
199
* \return 0: successful\n
203
APIFUNC(int, PortInit, (int *numOfPorts))
208
* Get information about a port (manufacturer, name, etc)
210
* \param port Port number of the camera
212
* \param manu Name of the manufacturer of this port
214
* \param mBytes Lenght of (manu+1)
216
* \param name Name of the manufacturer of this port
218
* \param nBytes Lenght of (name+1)
220
* \param version Version of CLALLSERIAL (0 if no ClAllSerial port)\n
221
* 1 : CL_DLL_VERSION_NO_VERSION Not a CL dll\n
222
* 2 : CL_DLL_VERSION_1_0 Oct 2000 compliant\n
223
* 3 : CL_DLL_VERSION_1_1 Oct 2001 compliant\n
225
* \param type Type of this port\n
226
* 0 : ClAllSerial port\n
227
* 1 : port with clser.dll at pfremote directory\n
231
* \return 0: successful\n
235
APIFUNC(int, PortInfo, (int port, char *manu, int *mBytes, char *name, int *nBytes, int *version, int *type))
239
* Check if required baud rate is possible. The camera port must be opened, before checking the required baud rate
241
* \param port Port number of the camera
243
* \param baudrate Baud rate to check (eg. 57600)
245
* \return 1: baud rate suporrted\n
246
* 0: baud rate not supported\n
249
APIFUNC(int, IsBaudRateSupported, (int port, int baudrate))
253
* Get current baud rate
255
* \param port Port number of the camera
257
* \param baudrate Baud rate
259
* \return 0: successful\n
262
APIFUNC(int, GetBaudRate, (int port, int *baudrate))
266
* Set baud rate. The camera port must be opened, before setting the baud rate
268
* \param port Port number of the camera
270
* \param baudrate Baud rate to set (eg. 57600)
272
* \return 0: successful\n
275
APIFUNC(int, SetBaudRate, (int port, int baudrate))
281
* \param port Port number of the camera
283
* \return 0: successful\n
285
* A value > 0 means, the device was opened, but
286
* some non blocking failure was detected (bad
287
* device identity, etc.). In this case, some int index
288
* device features may not be accessible, but the
289
* it can be normally fixed via an update.
291
APIFUNC(int, DeviceOpen, (int port))
295
* Close device communication.
296
* This should be called at the end of an application,
297
* when the device is no longer accessed.
299
* \param port Port number of the camera
301
* \return 0: success\n
304
APIFUNC(int, DeviceClose, (int port))
309
////////////////////////////////////////////////////////////////////////////
310
// Prototyping NEW API (1.0)
311
////////////////////////////////////////////////////////////////////////////
313
// DLL top level stuff
315
APIFUNC(const char *, DeviceGetDllVersion, (int port, int *major, int *minor))
317
////////////////////////////////////////////////////////////////////////////
321
* \defgroup PropControl Generic Device property control
323
* This contains the function set necessary to control arbitrary
329
* \addtogroup PropControl
335
* Get root namespace descriptor token of current device
337
* This function always returns a valid token.
339
* \param port Port number of the camera
341
* \return The root descriptor token
344
APIFUNC(TOKEN, Device_GetRoot, (int port))
348
* Select a property in the property and feature hierarchy.
350
* This function is used to query a property inside the property hierarchy
351
* which is organized in a tree. A property can have children and has always
352
* a parent, except if it is the root node.
354
* Quick overview: To select the first child of a node, use:
357
child = pfProperty_Select(port, node, node); \endcode
359
* To select the next children of that node:
362
next = pfProperty_Select(port, node, child); \endcode
364
* \param port Port number of the camera
365
* \param parent The parent node to be queried
366
* \param prev The node whose following (next) node shall be selected
367
* If the parent node is specified, its first children is
370
* \return The next or children token, if existing, INVALID_TOKEN
373
APIFUNC(TOKEN, Property_Select, (int port, TOKEN parent, TOKEN prev))
377
* Get a property handle (TOKEN) by name.
379
* \param port Port number of the camera *
380
* \param propname Pointer to a string containing the property name
382
* \return The TOKEN of the property. If not existing, INVALID_TOKEN.
385
APIFUNC(TOKEN, Property_ParseName, (int port, const char *propname))
389
* Get the name of a property by token
391
* \param port Port number of the camera
392
* \param p The token of the property whose name is to be
395
* \return Pointer to the constant property string
398
APIFUNC(const char *, Property_GetName, (int port, TOKEN p))
402
* Get the property data type by token
404
* \param port Port number of the camera
405
* \param p The property token whose type are to be queried
407
* \return The type of the property
410
APIFUNC(PropertyType, Property_GetType, (int port, TOKEN p))
414
* Get the property flags by token
416
* \param port Port number of the camera
417
* \param p The property token whose flags are to be queried
419
* \return The property flags
422
APIFUNC(unsigned long, Property_GetFlags, (int port, TOKEN p))
426
* Get the value of a property.
428
* By default, a property value is owned by the caller, i.e. in case of
429
* a dynamic string property, the caller is responsible for allocating the
430
* proper memory and initializing the PFValue pointer field.
431
* In case of a static string property, the string is owned by the
432
* library, so the PFValue does not need to be initialized. See also
433
* PFValue documentation.
435
* \param port Port number of the camera
436
* \param p The property token whose value is to be requested
437
* \param value Pointer to a PFValue which contains the property value
438
* after successful return of this function. Note that
439
* in case of a non static string property, the property
440
* value must be initialized first.
442
* \return A standard return code
445
APIFUNC(int, Device_GetProperty, (int port, TOKEN p, PFValue *value))
449
* Get the value of a property by string
452
* \param port Port number of the camera
453
* \param p The property token whose value is to be requested
454
* \param outs Pointer to a string which contains the property value
455
* string conversion after successful return of this function.
456
* The caller must reserve a string of the length of the
457
* expected value string.
458
* \param len Length of the string that was reserved by caller
460
* \note This function only applies to simple datatypes, resp.
461
* only displays debugging information about some
462
* complex data types.
464
* \return The standard return code
467
APIFUNC(int, Device_GetProperty_String, (int port, TOKEN p, char *outs, int len))
471
* Set the value of a property.
473
* \param port Port number of the camera
474
* \param p The property token whose value is to be requested
475
* \param value Pointer to a PFValue containing the value to be set.
477
* \return The standard return code
480
APIFUNC(int, Device_SetProperty, (int port, TOKEN p, PFValue *value))
484
* Set the value of a property by string.
486
* This function parses a string and tries to match it to the
487
* specified property.
489
* \param port Port number of the camera
490
* \param p The property token whose value is to be set
491
* \param string Pointer to a string containing the value to be set.
493
* \return The standard return code
496
APIFUNC(int, Device_SetProperty_String, (int port, TOKEN p, const char *string))
501
////////////////////////////////////////////////////////////////////////////
502
/* Non exposed low level burst read/write commands */
503
APIFUNC(int, Write, (int port, unsigned short addr, const unsigned char *buf, unsigned int size))
504
APIFUNC(int, Read, (int port, unsigned short addr, unsigned char *buf, int size))
507
* \defgroup Misc Auxiliary and miscellaneous functions/macros
509
* Auxiliary functions for handling & reporting errors.
514
* \defgroup ErrorHandling Error Handling
516
* Auxiliary functions for handling & reporting errors.
521
* \ingroup ErrorHandling
526
* Verbose error string query of an error code.
528
* \param error The error code returned by a function.
530
* \return Pointer to a constant string containing the error
531
* message to the specified error code.
534
APIFUNC(const char *, GetErrorString, (int error))
538
* \defgroup Aux Auxiliary functions
547
APIFUNC(int, Value_ToString, (PFValue *val, char *outs, int len))
551
* Sets camera feedback function
553
* The feedback function must return a value = 0, if the caller should
554
* proceed. For example, a GUI based feedback routine may allow the user
555
* to cancel the procedure by hitting the ESC key.
556
* If the procedure was cancelled, the caller returns #PFERR_CANCEL.
558
* \param func pointer to a feedback function of type FeedbackFuncP
559
* If equal 0, the default dummy routine (no feedback) is set.
560
* \return the previous feedback function pointer
562
APIFUNC(FeedbackFuncP, SetFeedback, (int port, FeedbackFuncP func))