OkoLib
library for accessing Okolab devices
okolib.h
Go to the documentation of this file.
1 
305 #ifndef _OKOLIB_H_
306 #define _OKOLIB_H_
307 
308 #ifdef _MSC_VER
309  #if _MSC_VER >= 1600
310  #include <stdint.h>
311  #else
312  typedef __int8 int8_t;
313  typedef __int16 int16_t;
314  typedef __int32 int32_t;
315  typedef __int64 int64_t;
316  typedef unsigned __int8 uint8_t;
317  typedef unsigned __int16 uint16_t;
318  typedef unsigned __int32 uint32_t;
319  typedef unsigned __int64 uint64_t;
320  #endif
321 #elif __GNUC__ >= 3
322  #include <stdint.h>
323 #endif
324 
325 
326 
327 
328 #ifdef __cplusplus
329 extern "C" {
330 #endif
331 
332 #ifdef _WIN32
333 
334 #if defined(OKO_NO_DLL) /* Static import */
335 # define OKO_API
336 #elif defined(OKO_BUILDING_DLL) /* DLL export */
337 # define OKO_API __declspec (dllexport)
338 #else /* DLL import */
339 # define OKO_API __declspec (dllimport)
340 #endif /* Not BUILDING_DLL */
341 
342 /* Define calling convention in one place, for convenience. */
343 #define OKO_EXPORT __cdecl
344 
345 /* Microsoft VBA */
346 #ifdef OKO_VBA
347 #undef OKO_EXPORT
348 #define OKO_EXPORT __stdcall
349 #endif
350 
351 #else /* _WIN32 not defined. */
352 
353 /* Define with no value on non-Windows OSes. */
354 #define OKO_API
355 #define OKO_EXPORT
356 
357 #endif
358 
365 typedef enum _oko_res_type
366 {
367  OKO_OK = 0,
369  OKO_ERR_ARG = -2,
380  OKO_ERR_COMM = -13,
387  OKO_ERR_UNDEF = -999,
388 } oko_res_type;
389 
403 OKO_API oko_res_type OKO_EXPORT
404 oko_LibInit(const char *db_path);
405 
410 OKO_API oko_res_type OKO_EXPORT
412 
418 OKO_API oko_res_type OKO_EXPORT
419 oko_LibGetVersion(char *version);
420 
428 OKO_API oko_res_type OKO_EXPORT
429 oko_LibGetLastError(char *errmsg, unsigned int maxsize);
430 
431 
437 OKO_API oko_res_type OKO_EXPORT
439 
440 
446 OKO_API oko_res_type OKO_EXPORT
447 oko_LibGetSuggestedUSBOnly(bool *use);
448 
449 
450 
451 
461 typedef enum _oko_module_type
462 {
469 
470 
478 OKO_API oko_res_type OKO_EXPORT
479 oko_ModulesDetect(uint32_t max_num, oko_module_type *modules, uint32_t *detected_num);
480 
490 OKO_API oko_res_type OKO_EXPORT
491 oko_ModulesDetectSelected(const oko_module_type *selected_modules,
492  uint32_t selected_modules_num, oko_module_type *modules, uint32_t *detected_num);
493 
503 OKO_API oko_res_type OKO_EXPORT
504 oko_ModuleGetDetails(oko_module_type module, char *name, char *dim_unit, bool *can_disable);
505 
512 OKO_API oko_res_type OKO_EXPORT
513 oko_ModuleGetCurrentValue(oko_module_type module, double *current_value);
514 
521 OKO_API oko_res_type OKO_EXPORT
522 oko_ModuleGetSetpointValue(oko_module_type module, double *setpoint_value);
523 
531 OKO_API oko_res_type OKO_EXPORT
532 oko_ModuleGetLimits(oko_module_type module, double *min_value, double *max_value);
533 
540 OKO_API oko_res_type OKO_EXPORT
541 oko_ModuleSetSetpointValue(oko_module_type module, double setpoint_value);
542 
551 OKO_API oko_res_type OKO_EXPORT
552 oko_ModuleGetEnabled(oko_module_type module, bool *enabled);
553 
576 OKO_API oko_res_type OKO_EXPORT
577 oko_ModuleSetEnabled(oko_module_type module, bool enabled);
578 
590 OKO_API oko_res_type OKO_EXPORT
591 oko_LibGetNumberOfPorts(uint32_t *count);
592 
598 OKO_API oko_res_type OKO_EXPORT
599 oko_LibGetPortNames(char **names);
600 
609 OKO_API oko_res_type OKO_EXPORT
610 oko_LibGetPortName(uint32_t portidx, char *portname);
611 
618 OKO_API oko_res_type OKO_EXPORT
619 oko_DeviceOpen(const char *port, uint32_t *deviceh);
620 
628 OKO_API oko_res_type OKO_EXPORT
629 oko_DevicesDetect(uint32_t max_num, uint32_t *devicesh, uint32_t *detected_num);
630 
631 
640 OKO_API oko_res_type OKO_EXPORT
641 oko_DevicesDetectByName(uint32_t max_num, uint32_t *devicesh, char *name_filter, uint32_t *detected_num);
642 
643 
649 OKO_API oko_res_type OKO_EXPORT
650 oko_DeviceDetectSingle(uint32_t *deviceh);
651 
652 
659 OKO_API oko_res_type OKO_EXPORT
660 oko_DeviceDetectSingleByName(uint32_t *deviceh, char *name_filter);
661 
662 
668 OKO_API oko_res_type OKO_EXPORT
669 oko_DeviceClose(uint32_t deviceh);
670 
679 OKO_API oko_res_type OKO_EXPORT
680 oko_DeviceGetLastError(uint32_t deviceh, char *errmsg, unsigned int maxsize);
681 
686 OKO_API oko_res_type OKO_EXPORT
687 oko_DevicesCloseAll(void);
688 
700 OKO_API oko_res_type OKO_EXPORT
701 oko_DeviceGetPortName(uint32_t deviceh, char *port);
702 
703 
710 OKO_API oko_res_type OKO_EXPORT
711 oko_DeviceConnectionStatus(uint32_t deviceh, uint32_t *conn);
712 
713 
720 OKO_API oko_res_type OKO_EXPORT
721 oko_DeviceSetChecksumUsage(uint32_t deviceh, bool use_checksum);
722 
723 
730 OKO_API oko_res_type OKO_EXPORT
731 oko_DeviceGetChecksumUsage(uint32_t deviceh, bool *use_checksum);
732 
740 OKO_API oko_res_type OKO_EXPORT
741 oko_DeviceGetChecksumAvailable(uint32_t deviceh, bool *checksum);
742 
755 OKO_API oko_res_type OKO_EXPORT
756 oko_PropertiesGetNumber(uint32_t deviceh, uint32_t *num);
757 
767 OKO_API oko_res_type OKO_EXPORT
768 oko_PropertyGetName(uint32_t deviceh, uint32_t index, char *name);
769 
773 typedef enum _oko_prop_type
774 {
780 } oko_prop_type;
781 
782 
790 OKO_API oko_res_type OKO_EXPORT
791 oko_PropertyGetType(uint32_t deviceh, const char *name, oko_prop_type *prop_type);
792 
793 
801 OKO_API oko_res_type OKO_EXPORT
802 oko_PropertyGetEnumNumber(uint32_t deviceh, const char *name, unsigned int *num);
803 
804 
805 
814 OKO_API oko_res_type OKO_EXPORT
815 oko_PropertyGetEnumName(uint32_t deviceh, const char *name, uint32_t enumh, char *enumname);
816 
817 
818 
826 OKO_API oko_res_type OKO_EXPORT
827 oko_PropertyGetUnit(uint32_t deviceh, const char *name, char *unit);
828 
836 OKO_API oko_res_type OKO_EXPORT
837 oko_PropertyGetDescription(uint32_t deviceh, const char *name, char *desc);
838 
846 OKO_API oko_res_type OKO_EXPORT
847 oko_PropertyGetReadOnly(uint32_t deviceh, const char *name, bool *read_only);
848 
852 typedef enum _oko_write_type
853 {
859 
860 
868 OKO_API oko_res_type OKO_EXPORT
869 oko_PropertyGetWriteOnly(uint32_t deviceh, const char *name, bool *write_only);
870 
878 OKO_API oko_res_type OKO_EXPORT
879 oko_PropertyGetWriteType(uint32_t deviceh, const char *name, oko_write_type *write_type);
880 
881 
891 OKO_API oko_res_type OKO_EXPORT
892 oko_PropertyHasLimits(uint32_t deviceh, const char *name, bool *has_limits);
893 
903 OKO_API oko_res_type OKO_EXPORT
904 oko_PropertyGetLimits(uint32_t deviceh, const char *name, double *min, double *max);
905 
913 OKO_API oko_res_type OKO_EXPORT
914 oko_PropertyIsMain(uint32_t deviceh, const char *name, bool *is_main);
915 
925 OKO_API oko_res_type OKO_EXPORT
926 oko_PropertyIsAdvanced(uint32_t deviceh, const char *name, bool *is_adv);
927 
943 OKO_API oko_res_type OKO_EXPORT
944 oko_PropertyReadString(uint32_t deviceh, const char *name, char *val);
945 
954 OKO_API oko_res_type OKO_EXPORT
955 oko_PropertyReadInt(uint32_t deviceh, const char *name, int32_t *val);
956 
965 OKO_API oko_res_type OKO_EXPORT
966 oko_PropertyReadDouble(uint32_t deviceh, const char *name, double *val);
967 
974 OKO_API oko_res_type OKO_EXPORT
975 oko_PropertyUpdate(uint32_t deviceh, const char *name); // refresh, read ?
976 
992 OKO_API oko_res_type OKO_EXPORT
993 oko_PropertyWriteString(uint32_t deviceh, const char *name, const char *val, bool async);
994 
1004 OKO_API oko_res_type OKO_EXPORT
1005 oko_PropertyWriteInt(uint32_t deviceh, const char *name, int32_t val, char async);
1006 
1016 OKO_API oko_res_type OKO_EXPORT
1017 oko_PropertyWriteDouble(uint32_t deviceh, const char *name, double val, char async);
1018 
1028 OKO_API oko_res_type OKO_EXPORT
1029 oko_PropertyWriteVolatileString(uint32_t deviceh, const char *name, const char *val, bool async);
1030 
1040 OKO_API oko_res_type OKO_EXPORT
1041 oko_PropertyWriteVolatileInt(uint32_t deviceh, const char *name, int32_t val, char async);
1042 
1052 OKO_API oko_res_type OKO_EXPORT
1053 oko_PropertyWriteVolatileDouble(uint32_t deviceh, const char *name, double val, char async);
1054 
1068 OKO_API oko_res_type OKO_EXPORT
1069 oko_PropertyAutoUpdate(uint32_t deviceh, const char *name, uint32_t freq_ms);
1070 
1084 OKO_API oko_res_type OKO_EXPORT
1085 oko_StartPropertyLogging(uint32_t deviceh, const char *filename, uint32_t freq_ms);
1086 
1092 OKO_API oko_res_type OKO_EXPORT
1093 oko_StopPropertyLogging(uint32_t deviceh);
1094 
1101 OKO_API oko_res_type OKO_EXPORT
1102 oko_PropertyLoggingGetFileName(uint32_t deviceh, char *filename);
1103 
1116 OKO_API oko_res_type OKO_EXPORT
1117 oko_StartPlayback(uint32_t deviceh, const char *filename);
1118 
1124 OKO_API oko_res_type OKO_EXPORT
1125 oko_StopPlayback(uint32_t deviceh);
1126 
1133 OKO_API oko_res_type OKO_EXPORT
1134 oko_PlaybakGetFileName(uint32_t deviceh, char *filename);
1135 
1149 OKO_API oko_res_type OKO_EXPORT
1150 oko_CommandExecute(uint32_t deviceh, const char *name);
1151 
1152 
1154 OKO_API oko_res_type OKO_EXPORT
1155 oko_OkolabSetDebugPropertiesUsage(bool debug_properties);
1156 
1157 OKO_API oko_res_type OKO_EXPORT
1158 oko_OkolabGetLastProtocolError(uint32_t deviceh, const char *name, int *err);
1165 #ifdef __cplusplus
1166 }
1167 #endif
1168 
1169 #endif /* _OKOLIB_H_ */
1170 
Library not initialized yet.
Definition: okolib.h:368
Undefined error.
Definition: okolib.h:387
Operation completed successfully.
Definition: okolib.h:367
oko_res_type oko_DeviceDetectSingle(uint32_t *deviceh)
Detect the first available device and open it, returning a handle for it.
oko_res_type oko_ModulesDetectSelected(const oko_module_type *selected_modules, uint32_t selected_modules_num, oko_module_type *modules, uint32_t *detected_num)
Detect available modules and open them, returning the type for each module.
oko_res_type oko_ModulesDetect(uint32_t max_num, oko_module_type *modules, uint32_t *detected_num)
Detect available modules and open them, returning the type for each module.
enum _oko_write_type oko_write_type
Specifies the available write types.
Port configuration failed.
Definition: okolib.h:375
oko_res_type oko_PropertyGetReadOnly(uint32_t deviceh, const char *name, bool *read_only)
Verify if the specified property is read-only.
Communication error.
Definition: okolib.h:380
Device not found.
Definition: okolib.h:379
Property not found.
Definition: okolib.h:378
oko_res_type oko_LibGetSuggestedUSBOnly(bool *use)
Get the usage status of the USB serial ports filter.
oko_res_type oko_LibSetSuggestedUSBOnly(bool use)
Turn on/off the filter on the USB serial ports.
oko_res_type oko_PropertyIsMain(uint32_t deviceh, const char *name, bool *is_main)
Verify if the specified property is a main feature of the device.
No write available (read-only)
Definition: okolib.h:854
Undefined property type.
Definition: okolib.h:775
oko_res_type oko_LibGetPortNames(char **names)
Refresh available ports and return their names.
Module specified not found.
Definition: okolib.h:382
Enum of the Property not found.
Definition: okolib.h:381
Slave device.
Definition: okolib.h:383
oko_res_type oko_LibGetVersion(char *version)
Print the version of Okolib library on a string passed by reference.
oko_res_type oko_PropertyGetEnumNumber(uint32_t deviceh, const char *name, unsigned int *num)
Get the number of availables enum values of the specified property.
oko_res_type oko_PropertyLoggingGetFileName(uint32_t deviceh, char *filename)
Get the file path used to log the specified device.
The requested operation is not supported by this system or device.
Definition: okolib.h:371
oko_res_type oko_PropertyGetType(uint32_t deviceh, const char *name, oko_prop_type *prop_type)
Get the type of the specified property.
oko_res_type oko_DeviceOpen(const char *port, uint32_t *deviceh)
Open the specified device, returning a handle for it.
_oko_prop_type
Specifies the available property types.
Definition: okolib.h:773
oko_res_type oko_DevicesDetect(uint32_t max_num, uint32_t *devicesh, uint32_t *detected_num)
Detect available devices and open them, returning an handle for each device.
oko_res_type oko_PropertyWriteVolatileString(uint32_t deviceh, const char *name, const char *val, bool async)
Change the current value of the specified string property in the volatile memory. ...
oko_res_type oko_PropertyWriteInt(uint32_t deviceh, const char *name, int32_t val, char async)
Change the current value of the specified integer property.
Only volatile write is available.
Definition: okolib.h:856
oko_res_type oko_DeviceSetChecksumUsage(uint32_t deviceh, bool use_checksum)
Set the checksum usage flag of the current device.
oko_res_type oko_PropertyWriteVolatileInt(uint32_t deviceh, const char *name, int32_t val, char async)
Change the current value of the specified integer property in the volatile memory.
enum _oko_prop_type oko_prop_type
Specifies the available property types.
oko_res_type oko_PlaybakGetFileName(uint32_t deviceh, char *filename)
Get the file path used to playback the specified device.
oko_res_type oko_LibInit(const char *db_path)
Initialize the library.
_oko_module_type
Specifies the available modules types.
Definition: okolib.h:461
oko_res_type oko_ModuleGetCurrentValue(oko_module_type module, double *current_value)
Returns current value of the specified module.
oko_res_type oko_DeviceGetChecksumUsage(uint32_t deviceh, bool *use_checksum)
Get the checksum usage flag of the current device.
oko_res_type oko_DeviceGetLastError(uint32_t deviceh, char *errmsg, unsigned int maxsize)
Return a text message that describes the error for the most recent failed call on a specified device...
oko_res_type oko_StopPropertyLogging(uint32_t deviceh)
Stop the property logging feature for the specified device.
Database error on open.
Definition: okolib.h:377
The specified device is not connected.
Definition: okolib.h:373
Serial port busy.
Definition: okolib.h:374
oko_res_type oko_PropertyGetWriteType(uint32_t deviceh, const char *name, oko_write_type *write_type)
Get the write type of the specified property.
oko_res_type oko_PropertyIsAdvanced(uint32_t deviceh, const char *name, bool *is_adv)
Verify if the specified property is an advanced feature of the device.
String property type.
Definition: okolib.h:776
oko_res_type oko_DevicesDetectByName(uint32_t max_num, uint32_t *devicesh, char *name_filter, uint32_t *detected_num)
Detect the first available device matching the filter name and open it, returning a handle for it...
oko_res_type oko_PropertyUpdate(uint32_t deviceh, const char *name)
Update the specified property value, reading it from the current device.
oko_res_type oko_StartPlayback(uint32_t deviceh, const char *filename)
Start the playback feature for the specified device.
oko_res_type oko_PropertyReadString(uint32_t deviceh, const char *name, char *val)
Get the current value of a string property.
Only standard write is available.
Definition: okolib.h:855
_oko_write_type
Specifies the available write types.
Definition: okolib.h:852
The specified device is not opened.
Definition: okolib.h:372
CO2 module.
Definition: okolib.h:464
Temperature module.
Definition: okolib.h:463
oko_res_type oko_LibGetLastError(char *errmsg, unsigned int maxsize)
Return a text message that describes the error for the most recent failed call on general library fun...
enum _oko_res_type oko_res_type
Specifies the return values.
oko_res_type oko_PropertyWriteDouble(uint32_t deviceh, const char *name, double val, char async)
Change the current value of the specified double property.
oko_res_type oko_PropertiesGetNumber(uint32_t deviceh, uint32_t *num)
Get the number of available properties of the current device.
Standard and volatile write types are available.
Definition: okolib.h:857
oko_res_type oko_PropertyWriteVolatileDouble(uint32_t deviceh, const char *name, double val, char async)
Change the current value of the specified double property in the volatile memory. ...
oko_res_type oko_PropertyGetUnit(uint32_t deviceh, const char *name, char *unit)
Get the measure unit of the specified property.
oko_res_type oko_ModuleGetDetails(oko_module_type module, char *name, char *dim_unit, bool *can_disable)
Returns all information about of the specified module of this device, which is not changing during ap...
oko_res_type oko_ModuleGetLimits(oko_module_type module, double *min_value, double *max_value)
Returns setpoint limits of the specified module of this device.
oko_res_type oko_PropertyGetName(uint32_t deviceh, uint32_t index, char *name)
Get the name of the specified property, using its index.
oko_res_type oko_PropertyWriteString(uint32_t deviceh, const char *name, const char *val, bool async)
Change the current value of the specified string property.
oko_res_type oko_DevicesCloseAll(void)
Close all the opened devices.
Invalid arguments were passed to the function.
Definition: okolib.h:369
O2 module.
Definition: okolib.h:465
oko_res_type oko_DeviceGetPortName(uint32_t deviceh, char *port)
Get the Port Name of the specified device.
Timeout error.
Definition: okolib.h:386
oko_res_type oko_CommandExecute(uint32_t deviceh, const char *name)
Execute a command.
oko_res_type oko_StopPlayback(uint32_t deviceh)
Start the playback feature for the specified device.
oko_res_type oko_PropertyAutoUpdate(uint32_t deviceh, const char *name, uint32_t freq_ms)
Set the update frequency to read the specified property value from the current device.
oko_res_type oko_PropertyGetWriteOnly(uint32_t deviceh, const char *name, bool *write_only)
Verify if the specified property is write-only.
oko_res_type oko_DeviceClose(uint32_t deviceh)
Close the specified device.
oko_res_type oko_PropertyGetDescription(uint32_t deviceh, const char *name, char *desc)
Get the description of the specified property.
Port not valid.
Definition: okolib.h:376
oko_res_type oko_DeviceGetChecksumAvailable(uint32_t deviceh, bool *checksum)
Check if the communication protocol of the specified device supports checksum.
Device not running.
Definition: okolib.h:384
oko_res_type oko_PropertyGetEnumName(uint32_t deviceh, const char *name, uint32_t enumh, char *enumname)
Get the name of the specified enum field of the specified property.
oko_res_type oko_ModuleSetSetpointValue(oko_module_type module, double setpoint_value)
Set setpoint of the specified module of this device.
enum _oko_module_type oko_module_type
Specifies the available modules types.
Double property type.
Definition: okolib.h:778
oko_res_type oko_PropertyReadDouble(uint32_t deviceh, const char *name, double *val)
Get the current value of a double property.
oko_res_type oko_LibShutDown()
Deallocates any resource that were allocated by oko_LibInitialize.
oko_res_type oko_StartPropertyLogging(uint32_t deviceh, const char *filename, uint32_t freq_ms)
Start the property logging feature for the specified device.
oko_res_type oko_LibGetPortName(uint32_t portidx, char *portname)
Get the name of the specified port, using the ports refreshed by oko_LibGetNumberOfPorts.
oko_res_type oko_PropertyHasLimits(uint32_t deviceh, const char *name, bool *has_limits)
Verify if the specified property has readable limits.
Number of available modules.
Definition: okolib.h:467
Enum property type.
Definition: okolib.h:779
oko_res_type oko_DeviceDetectSingleByName(uint32_t *deviceh, char *name_filter)
Detect the first available device matching the filter name and open it, returning a handle for it...
A system error occurred while executing the operation.
Definition: okolib.h:370
oko_res_type oko_LibGetNumberOfPorts(uint32_t *count)
Refresh available ports and return the number of them.
oko_res_type oko_PropertyGetLimits(uint32_t deviceh, const char *name, double *min, double *max)
Get the minimum and maximum value that can be set for the specified property.
oko_res_type oko_ModuleSetEnabled(oko_module_type module, bool enabled)
Set enable status of the specified module of this device.
oko_res_type oko_ModuleGetEnabled(oko_module_type module, bool *enabled)
Returns enable status of the specified module of this device.
oko_res_type oko_DeviceConnectionStatus(uint32_t deviceh, uint32_t *conn)
Get the connection status of the current device.
Memory allocation failed.
Definition: okolib.h:385
oko_res_type oko_PropertyReadInt(uint32_t deviceh, const char *name, int32_t *val)
Get the current value of a integer property.
_oko_res_type
Specifies the return values.
Definition: okolib.h:365
Humidity module.
Definition: okolib.h:466
oko_res_type oko_ModuleGetSetpointValue(oko_module_type module, double *setpoint_value)
Returns setpoint value of the specified module of this device.
Integer (long) property type.
Definition: okolib.h:777