OkoLib
library for accessing Okolab devices
okolib.h
Go to the documentation of this file.
1 
311 #ifndef _OKOLIB_H_
312 #define _OKOLIB_H_
313 
314 #ifdef _MSC_VER
315  #if _MSC_VER >= 1600
316  #include <stdint.h>
317  #else
318  typedef __int8 int8_t;
319  typedef __int16 int16_t;
320  typedef __int32 int32_t;
321  typedef __int64 int64_t;
322  typedef unsigned __int8 uint8_t;
323  typedef unsigned __int16 uint16_t;
324  typedef unsigned __int32 uint32_t;
325  typedef unsigned __int64 uint64_t;
326  #endif
327 #elif __GNUC__ >= 3
328  #include <stdint.h>
329 #endif
330 
331 
332 
333 
334 #ifdef __cplusplus
335 extern "C" {
336 #endif
337 
338 #ifdef _WIN32
339 
340 #if defined(OKO_NO_DLL) /* Static import */
341 # define OKO_API
342 #elif defined(OKO_BUILDING_DLL) /* DLL export */
343 # define OKO_API __declspec (dllexport)
344 #else /* DLL import */
345 # define OKO_API __declspec (dllimport)
346 #endif /* Not BUILDING_DLL */
347 
348 /* Define calling convention in one place, for convenience. */
349 #define OKO_EXPORT __cdecl
350 
351 /* Microsoft VBA */
352 #ifdef OKO_VBA
353 #undef OKO_EXPORT
354 #define OKO_EXPORT __stdcall
355 #endif
356 
357 #else /* _WIN32 not defined. */
358 
359 /* Define with no value on non-Windows OSes. */
360 #define OKO_API
361 #define OKO_EXPORT
362 
363 #endif
364 
371 typedef enum _oko_res_type
372 {
373  OKO_OK = 0,
375  OKO_ERR_ARG = -2,
386  OKO_ERR_COMM = -13,
393  OKO_ERR_UNDEF = -999,
394 } oko_res_type;
395 
409 OKO_API oko_res_type OKO_EXPORT
410 oko_LibInit(const char *db_path);
411 
416 OKO_API oko_res_type OKO_EXPORT
418 
424 OKO_API oko_res_type OKO_EXPORT
425 oko_LibGetVersion(char *version);
426 
434 OKO_API oko_res_type OKO_EXPORT
435 oko_LibGetLastError(char *errmsg, unsigned int maxsize);
436 
437 
443 OKO_API oko_res_type OKO_EXPORT
445 
446 
452 OKO_API oko_res_type OKO_EXPORT
453 oko_LibGetSuggestedUSBOnly(bool *use);
454 
455 
456 
457 
467 typedef enum _oko_module_type
468 {
475 
476 
484 OKO_API oko_res_type OKO_EXPORT
485 oko_ModulesDetect(uint32_t max_num, oko_module_type *modules, uint32_t *detected_num);
486 
496 OKO_API oko_res_type OKO_EXPORT
497 oko_ModulesDetectSelected(const oko_module_type *selected_modules,
498  uint32_t selected_modules_num, oko_module_type *modules, uint32_t *detected_num);
499 
509 OKO_API oko_res_type OKO_EXPORT
510 oko_ModuleGetDetails(oko_module_type module, char *name, char *dim_unit, bool *can_disable);
511 
518 OKO_API oko_res_type OKO_EXPORT
519 oko_ModuleGetCurrentValue(oko_module_type module, double *current_value);
520 
527 OKO_API oko_res_type OKO_EXPORT
528 oko_ModuleGetSetpointValue(oko_module_type module, double *setpoint_value);
529 
537 OKO_API oko_res_type OKO_EXPORT
538 oko_ModuleGetLimits(oko_module_type module, double *min_value, double *max_value);
539 
546 OKO_API oko_res_type OKO_EXPORT
547 oko_ModuleSetSetpointValue(oko_module_type module, double setpoint_value);
548 
557 OKO_API oko_res_type OKO_EXPORT
558 oko_ModuleGetEnabled(oko_module_type module, bool *enabled);
559 
582 OKO_API oko_res_type OKO_EXPORT
583 oko_ModuleSetEnabled(oko_module_type module, bool enabled);
584 
596 OKO_API oko_res_type OKO_EXPORT
597 oko_LibGetNumberOfPorts(uint32_t *count);
598 
604 OKO_API oko_res_type OKO_EXPORT
605 oko_LibGetPortNames(char **names);
606 
615 OKO_API oko_res_type OKO_EXPORT
616 oko_LibGetPortName(uint32_t portidx, char *portname);
617 
624 OKO_API oko_res_type OKO_EXPORT
625 oko_DeviceOpen(const char *port, uint32_t *deviceh);
626 
634 OKO_API oko_res_type OKO_EXPORT
635 oko_DevicesDetect(uint32_t max_num, uint32_t *devicesh, uint32_t *detected_num);
636 
637 
646 OKO_API oko_res_type OKO_EXPORT
647 oko_DevicesDetectByName(uint32_t max_num, uint32_t *devicesh, char *name_filter, uint32_t *detected_num);
648 
649 
655 OKO_API oko_res_type OKO_EXPORT
656 oko_DeviceDetectSingle(uint32_t *deviceh);
657 
658 
665 OKO_API oko_res_type OKO_EXPORT
666 oko_DeviceDetectSingleByName(uint32_t *deviceh, char *name_filter);
667 
668 
674 OKO_API oko_res_type OKO_EXPORT
675 oko_DeviceClose(uint32_t deviceh);
676 
685 OKO_API oko_res_type OKO_EXPORT
686 oko_DeviceGetLastError(uint32_t deviceh, char *errmsg, unsigned int maxsize);
687 
692 OKO_API oko_res_type OKO_EXPORT
693 oko_DevicesCloseAll(void);
694 
706 OKO_API oko_res_type OKO_EXPORT
707 oko_DeviceGetPortName(uint32_t deviceh, char *port);
708 
709 
716 OKO_API oko_res_type OKO_EXPORT
717 oko_DeviceConnectionStatus(uint32_t deviceh, uint32_t *conn);
718 
719 
726 OKO_API oko_res_type OKO_EXPORT
727 oko_DeviceSetChecksumUsage(uint32_t deviceh, bool use_checksum);
728 
729 
736 OKO_API oko_res_type OKO_EXPORT
737 oko_DeviceGetChecksumUsage(uint32_t deviceh, bool *use_checksum);
738 
746 OKO_API oko_res_type OKO_EXPORT
747 oko_DeviceGetChecksumAvailable(uint32_t deviceh, bool *checksum);
748 
761 OKO_API oko_res_type OKO_EXPORT
762 oko_PropertiesGetNumber(uint32_t deviceh, uint32_t *num);
763 
773 OKO_API oko_res_type OKO_EXPORT
774 oko_PropertyGetName(uint32_t deviceh, uint32_t index, char *name);
775 
779 typedef enum _oko_prop_type
780 {
786 } oko_prop_type;
787 
788 
796 OKO_API oko_res_type OKO_EXPORT
797 oko_PropertyGetType(uint32_t deviceh, const char *name, oko_prop_type *prop_type);
798 
799 
807 OKO_API oko_res_type OKO_EXPORT
808 oko_PropertyGetEnumNumber(uint32_t deviceh, const char *name, unsigned int *num);
809 
810 
811 
820 OKO_API oko_res_type OKO_EXPORT
821 oko_PropertyGetEnumName(uint32_t deviceh, const char *name, uint32_t enumh, char *enumname);
822 
823 
824 
832 OKO_API oko_res_type OKO_EXPORT
833 oko_PropertyGetUnit(uint32_t deviceh, const char *name, char *unit);
834 
842 OKO_API oko_res_type OKO_EXPORT
843 oko_PropertyGetDescription(uint32_t deviceh, const char *name, char *desc);
844 
852 OKO_API oko_res_type OKO_EXPORT
853 oko_PropertyGetReadOnly(uint32_t deviceh, const char *name, bool *read_only);
854 
858 typedef enum _oko_write_type
859 {
865 
866 
874 OKO_API oko_res_type OKO_EXPORT
875 oko_PropertyGetWriteOnly(uint32_t deviceh, const char *name, bool *write_only);
876 
884 OKO_API oko_res_type OKO_EXPORT
885 oko_PropertyGetWriteType(uint32_t deviceh, const char *name, oko_write_type *write_type);
886 
887 
897 OKO_API oko_res_type OKO_EXPORT
898 oko_PropertyHasLimits(uint32_t deviceh, const char *name, bool *has_limits);
899 
909 OKO_API oko_res_type OKO_EXPORT
910 oko_PropertyGetLimits(uint32_t deviceh, const char *name, double *min, double *max);
911 
919 OKO_API oko_res_type OKO_EXPORT
920 oko_PropertyIsMain(uint32_t deviceh, const char *name, bool *is_main);
921 
931 OKO_API oko_res_type OKO_EXPORT
932 oko_PropertyIsAdvanced(uint32_t deviceh, const char *name, bool *is_adv);
933 
949 OKO_API oko_res_type OKO_EXPORT
950 oko_PropertyReadString(uint32_t deviceh, const char *name, char *val);
951 
960 OKO_API oko_res_type OKO_EXPORT
961 oko_PropertyReadInt(uint32_t deviceh, const char *name, int32_t *val);
962 
971 OKO_API oko_res_type OKO_EXPORT
972 oko_PropertyReadDouble(uint32_t deviceh, const char *name, double *val);
973 
980 OKO_API oko_res_type OKO_EXPORT
981 oko_PropertyUpdate(uint32_t deviceh, const char *name); // refresh, read ?
982 
998 OKO_API oko_res_type OKO_EXPORT
999 oko_PropertyWriteString(uint32_t deviceh, const char *name, const char *val, bool async);
1000 
1010 OKO_API oko_res_type OKO_EXPORT
1011 oko_PropertyWriteInt(uint32_t deviceh, const char *name, int32_t val, char async);
1012 
1022 OKO_API oko_res_type OKO_EXPORT
1023 oko_PropertyWriteDouble(uint32_t deviceh, const char *name, double val, char async);
1024 
1034 OKO_API oko_res_type OKO_EXPORT
1035 oko_PropertyWriteVolatileString(uint32_t deviceh, const char *name, const char *val, bool async);
1036 
1046 OKO_API oko_res_type OKO_EXPORT
1047 oko_PropertyWriteVolatileInt(uint32_t deviceh, const char *name, int32_t val, char async);
1048 
1058 OKO_API oko_res_type OKO_EXPORT
1059 oko_PropertyWriteVolatileDouble(uint32_t deviceh, const char *name, double val, char async);
1060 
1074 OKO_API oko_res_type OKO_EXPORT
1075 oko_PropertyAutoUpdate(uint32_t deviceh, const char *name, uint32_t freq_ms);
1076 
1090 OKO_API oko_res_type OKO_EXPORT
1091 oko_StartPropertyLogging(uint32_t deviceh, const char *filename, uint32_t freq_ms);
1092 
1098 OKO_API oko_res_type OKO_EXPORT
1099 oko_StopPropertyLogging(uint32_t deviceh);
1100 
1107 OKO_API oko_res_type OKO_EXPORT
1108 oko_PropertyLoggingGetFileName(uint32_t deviceh, char *filename);
1109 
1122 OKO_API oko_res_type OKO_EXPORT
1123 oko_StartPlayback(uint32_t deviceh, const char *filename);
1124 
1130 OKO_API oko_res_type OKO_EXPORT
1131 oko_StopPlayback(uint32_t deviceh);
1132 
1139 OKO_API oko_res_type OKO_EXPORT
1140 oko_PlaybakGetFileName(uint32_t deviceh, char *filename);
1141 
1155 OKO_API oko_res_type OKO_EXPORT
1156 oko_CommandExecute(uint32_t deviceh, const char *name);
1157 
1158 
1160 OKO_API oko_res_type OKO_EXPORT
1161 oko_OkolabSetDebugPropertiesUsage(bool debug_properties);
1162 
1163 OKO_API oko_res_type OKO_EXPORT
1164 oko_OkolabGetLastProtocolError(uint32_t deviceh, const char *name, int *err);
1171 #ifdef __cplusplus
1172 }
1173 #endif
1174 
1175 #endif /* _OKOLIB_H_ */
1176 
Library not initialized yet.
Definition: okolib.h:374
Undefined error.
Definition: okolib.h:393
Operation completed successfully.
Definition: okolib.h:373
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:381
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:386
Device not found.
Definition: okolib.h:385
Property not found.
Definition: okolib.h:384
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:860
Undefined property type.
Definition: okolib.h:781
oko_res_type oko_LibGetPortNames(char **names)
Refresh available ports and return their names.
Module specified not found.
Definition: okolib.h:388
Enum of the Property not found.
Definition: okolib.h:387
Slave device.
Definition: okolib.h:389
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:377
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:779
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:862
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:467
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:383
The specified device is not connected.
Definition: okolib.h:379
Serial port busy.
Definition: okolib.h:380
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:782
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:861
_oko_write_type
Specifies the available write types.
Definition: okolib.h:858
The specified device is not opened.
Definition: okolib.h:378
CO2 module.
Definition: okolib.h:470
Temperature module.
Definition: okolib.h:469
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:863
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:375
O2 module.
Definition: okolib.h:471
oko_res_type oko_DeviceGetPortName(uint32_t deviceh, char *port)
Get the Port Name of the specified device.
Timeout error.
Definition: okolib.h:392
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:382
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:390
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:784
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:473
Enum property type.
Definition: okolib.h:785
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:376
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:391
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:371
Humidity module.
Definition: okolib.h:472
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:783