From 0887df6f90a4d7968081cff11b2d5afc92580a81 Mon Sep 17 00:00:00 2001 From: di93coc Date: Mon, 24 Mar 2025 15:57:55 +0000 Subject: [PATCH 01/61] =?UTF-8?q?=E2=9C=A8=20Initial=20QDMI=20Environment?= =?UTF-8?q?=20impl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/prefix_defs.txt | 2 + examples/device/c/device.c | 14 ++++++- include/qdmi/constants.h | 75 +++++++++++++++++++++++++++++++++++++- include/qdmi/device.h | 26 +++++++++++++ include/qdmi/types.h | 5 +++ 5 files changed, 119 insertions(+), 3 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index ccda2f6b..92497be7 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -23,3 +23,5 @@ QDMI_Site QDMI_Site_impl_d QDMI_Operation QDMI_Operation_impl_d +QDMI_Environment +QDMI_Environment_impl_d diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 3dee4c51..b9c31e59 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -57,6 +57,13 @@ typedef struct C_QDMI_Operation_impl_d { char *name; } C_QDMI_Operation_impl_t; +typedef struct C_QDMI_Environment_impl_d { + char *id; + int factor; + char *unit; + int duration; +} C_QDMI_Environment_impl_t; + /** * @brief Static function to maintain the device status. * @return a pointer to the device status. @@ -87,6 +94,9 @@ void C_QDMI_set_device_status(QDMI_Device_Status status) { QDMI_Device_Status C_QDMI_read_device_status(void) { return *C_QDMI_get_device_status(); } +const C_QDMI_Environment DEVICE_ENVIROMENT_PROPERTY[] = { + &(C_QDMI_Environment_impl_t){"t4k", 100, "K", 60}, +}; const C_QDMI_Site C_DEVICE_SITES[] = { &(C_QDMI_Site_impl_t){0}, &(C_QDMI_Site_impl_t){1}, @@ -122,8 +132,8 @@ const C_QDMI_Operation C_DEVICE_OPERATIONS[] = { if ((size) < strlen(prop_value) + 1) { \ return QDMI_ERROR_INVALIDARGUMENT; \ } \ - strncpy((char *)(value), prop_value, (size) - 1); \ - ((char *)(value))[(size) - 1] = '\0'; \ + strncpy((char *)(value), prop_value, (size)-1); \ + ((char *)(value))[(size)-1] = '\0'; \ } \ if ((size_ret) != NULL) { \ *(size_ret) = strlen(prop_value) + 1; \ diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index a70f9017..9ffe18b9 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -218,6 +218,10 @@ enum QDMI_DEVICE_PROPERTY_T { * QDMI_PROGRAM_FORMAT_CALIBRATION. */ QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION = 8, + /* + * TODO + */ + QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 9, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -226,7 +230,7 @@ enum QDMI_DEVICE_PROPERTY_T { * @attention This value must remain the last regular member of the enum * besides the custom members and must be updated when new members are added. */ - QDMI_DEVICE_PROPERTY_MAX = 9, + QDMI_DEVICE_PROPERTY_MAX = 10, /** * @brief This enum value is reserved for a custom property. * @details The device defines the meaning and the type of this property. @@ -643,6 +647,75 @@ enum QDMI_JOB_RESULT_T { /// Job result type. typedef enum QDMI_JOB_RESULT_T QDMI_Job_Result; +/* + * + * TODO + */ +enum QDMI_ENVIRONMENT_PROPERTY_T { + + QDMI_ENVIRONMENT_PROPERTY_ID = 0, + + QDMI_ENVIRONMENT_PROPERTY_MAX = 1, + + QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 = 999999995, + + QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 = 999999996, + + QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 = 999999997, + + QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 = 999999998, + + QDMI_ENVIRONMENT_PROPERTY_CUSTOM5 = 999999999 +}; + +typedef enum QDMI_ENVIRONMENT_PROPERTY_T QDMI_Environment_Property; + +enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { + + QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX = 2, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM1 = 999999995, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM2 = 999999996, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM3 = 999999997, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM4 = 999999998, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM5 = 999999999 +}; + +typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T + QDMI_Environment_Query_Parameter; + +enum QDMI_ENVIRONMENT_QUERY_RESULT_T { + + QDMI_ENVIRONMENT_QUERY_RESULT_START_TIME = 0, + + QDMI_ENVIRONMENT_QUERY_RESULT_END_TIME = 1, + + QDMI_ENVIRONMENT_QUERY_RESULT_VALUE = 2, + + QDMI_ENVIRONMENT_QUERY_RESULT_MAX = 3, + + QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 = 999999995, + + QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 = 999999996, + + QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 = 999999997, + + QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 = 999999998, + + QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5 = 999999999 +}; + +/// Job result type. +typedef enum QDMI_ENVIRONMENT_QUERY_RESULT_T QDMI_Environment_Query_Result; + // NOLINTEND(performance-enum-size, modernize-use-using) #ifdef __cplusplus diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 7282b27e..bf9c5e12 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -351,6 +351,13 @@ int QDMI_device_session_query_operation_property( QDMI_Device_Session session, QDMI_Operation operation, size_t num_sites, const QDMI_Site *sites, size_t num_params, const double *params, QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); +/* + * TODO + */ + +int QDMI_device_session_query_enviroment_property( + QDMI_Device_Session session, QDMI_Environment environment, + QDMI_Environment_Property prop, size_t size, void *value, size_t *size_ret); /** @} */ // end of device_query_interface @@ -549,6 +556,25 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @} */ // end of device_job_interface +/* + * TODO Documentation + * + */ +typedef struct QDMI_Enviroment_Query_impl_d *QDMI_Enviroment_Query; + +int QDMI_device_session_create_enviroment_query(QDMI_Device_Session session, + QDMI_Enviroment_Query *query); + +int QDMI_enviroment_query_set_parameter(QDMI_Enviroment_Query query, + QDMI_Environment_Query_Parameter param, + size_t size, const void *value); + +int QDMI_enviroment_query_submit(QDMI_Enviroment_Query query); + +int QDMI_enviroment_query_get_results(QDMI_Enviroment_Query query, + QDMI_Environment_Query_Result result, + size_t size, void *data, + size_t *size_ret); /** @} */ // end of device_interface // NOLINTEND(performance-enum-size,modernize-use-using,modernize-redundant-void-arg) diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 5bdd1c9b..f09c64be 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -71,6 +71,11 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; */ typedef struct QDMI_Operation_impl_d *QDMI_Operation; +/* +* TODO +*/ +typedef struct QDMI_Environment_impl_d *QDMI_Environment; + // NOLINTEND(modernize-use-using) #ifdef __cplusplus From 302c416f0319191c13304217024eb25b4e4a641c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:32:50 +0000 Subject: [PATCH 02/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 6 +++--- include/qdmi/device.h | 24 ++++++++++++------------ include/qdmi/types.h | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index b9c31e59..e38b19f9 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -94,7 +94,7 @@ void C_QDMI_set_device_status(QDMI_Device_Status status) { QDMI_Device_Status C_QDMI_read_device_status(void) { return *C_QDMI_get_device_status(); } -const C_QDMI_Environment DEVICE_ENVIROMENT_PROPERTY[] = { +const C_QDMI_Environment DEVICE_ENVIRONMENT_PROPERTY[] = { &(C_QDMI_Environment_impl_t){"t4k", 100, "K", 60}, }; @@ -132,8 +132,8 @@ const C_QDMI_Operation C_DEVICE_OPERATIONS[] = { if ((size) < strlen(prop_value) + 1) { \ return QDMI_ERROR_INVALIDARGUMENT; \ } \ - strncpy((char *)(value), prop_value, (size)-1); \ - ((char *)(value))[(size)-1] = '\0'; \ + strncpy((char *)(value), prop_value, (size) - 1); \ + ((char *)(value))[(size) - 1] = '\0'; \ } \ if ((size_ret) != NULL) { \ *(size_ret) = strlen(prop_value) + 1; \ diff --git a/include/qdmi/device.h b/include/qdmi/device.h index bf9c5e12..adfc634a 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -355,7 +355,7 @@ int QDMI_device_session_query_operation_property( * TODO */ -int QDMI_device_session_query_enviroment_property( +int QDMI_device_session_query_environment_property( QDMI_Device_Session session, QDMI_Environment environment, QDMI_Environment_Property prop, size_t size, void *value, size_t *size_ret); @@ -560,21 +560,21 @@ void QDMI_device_job_free(QDMI_Device_Job job); * TODO Documentation * */ -typedef struct QDMI_Enviroment_Query_impl_d *QDMI_Enviroment_Query; +typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; -int QDMI_device_session_create_enviroment_query(QDMI_Device_Session session, - QDMI_Enviroment_Query *query); +int QDMI_device_session_create_environment_query(QDMI_Device_Session session, + QDMI_Environment_Query *query); -int QDMI_enviroment_query_set_parameter(QDMI_Enviroment_Query query, - QDMI_Environment_Query_Parameter param, - size_t size, const void *value); +int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, + QDMI_Environment_Query_Parameter param, + size_t size, const void *value); -int QDMI_enviroment_query_submit(QDMI_Enviroment_Query query); +int QDMI_environment_query_submit(QDMI_Environment_Query query); -int QDMI_enviroment_query_get_results(QDMI_Enviroment_Query query, - QDMI_Environment_Query_Result result, - size_t size, void *data, - size_t *size_ret); +int QDMI_environment_query_get_results(QDMI_Environment_Query query, + QDMI_Environment_Query_Result result, + size_t size, void *data, + size_t *size_ret); /** @} */ // end of device_interface // NOLINTEND(performance-enum-size,modernize-use-using,modernize-redundant-void-arg) diff --git a/include/qdmi/types.h b/include/qdmi/types.h index f09c64be..7f168541 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,8 +72,8 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /* -* TODO -*/ + * TODO + */ typedef struct QDMI_Environment_impl_d *QDMI_Environment; // NOLINTEND(modernize-use-using) From 3aab49ef5199b2f7c57e2b74d9fb02e527c80697 Mon Sep 17 00:00:00 2001 From: di93coc Date: Fri, 4 Apr 2025 16:09:46 +0000 Subject: [PATCH 03/61] =?UTF-8?q?=F0=9F=8E=A8=20renaming=20definitions=20f?= =?UTF-8?q?or=20qdmi=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/prefix_defs.txt | 7 +++++++ include/qdmi/client.h | 45 ++++++++++++++++++++++++++++++++++++++++ include/qdmi/constants.h | 40 +++++++++++++++++++---------------- include/qdmi/device.h | 16 +++++++------- 4 files changed, 83 insertions(+), 25 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index 92497be7..019a54e7 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -25,3 +25,10 @@ QDMI_Operation QDMI_Operation_impl_d QDMI_Environment QDMI_Environment_impl_d +QDMI_Device_Environment_Query +QDMI_Device_Environment_Query_impl_d +QDMI_device_session_query_environment_property +QDMI_device_session_create_environment_query +QDMI_device_environment_query_set_parameter +QDMI_device_environment_query_submit +QDMI_device_environment_query_get_results diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 956253b4..3dfac2d7 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -543,6 +543,13 @@ int QDMI_device_query_operation_property( const QDMI_Site *sites, size_t num_params, const double *params, QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); + +int QDMI_device_query_environment_property(QDMI_Device device, + QDMI_Environment enviroment, + QDMI_Environment_Property prop, + const size_t size, void *value, + size_t *size_ret); + /** @} */ // end of client_query_interface /** @defgroup client_job_interface QDMI Client Job Interface @@ -827,6 +834,44 @@ int QDMI_job_get_results(QDMI_Job job, QDMI_Job_Result result, size_t size, void QDMI_job_free(QDMI_Job job); /** @} */ // end of client_job_interface +enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { + + QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, + + QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 +}; + +typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T + QDMI_Environment_Query_Parameter; + +typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; + +int QDMI_device_create_environment_query(QDMI_Device dev, QDMI_Environment_Query *query); + +int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, + QDMI_Environment_Query_Parameter param, + size_t size, const void *value); + +int QDMI_environment_query_submit(QDMI_Environment_Query query); + +int QDMI_environment_query_get_results(QDMI_Environment_Query query, + QDMI_Environment_Query_Result result, + size_t size, void *data, + size_t *size_ret); /** @} */ // end of client_interface diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 9ffe18b9..364bec0f 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -221,7 +221,7 @@ enum QDMI_DEVICE_PROPERTY_T { /* * TODO */ - QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 9, + QDMI_DEVICE_PROPERTY_ENVIRONMENTS = 9, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -655,7 +655,11 @@ enum QDMI_ENVIRONMENT_PROPERTY_T { QDMI_ENVIRONMENT_PROPERTY_ID = 0, - QDMI_ENVIRONMENT_PROPERTY_MAX = 1, + QDMI_ENVIRONMENT_PROPERTY_UNIT = 1, + + QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE = 2, + + QDMI_ENVIRONMENT_PROPERTY_MAX = 3, QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 = 999999995, @@ -670,37 +674,37 @@ enum QDMI_ENVIRONMENT_PROPERTY_T { typedef enum QDMI_ENVIRONMENT_PROPERTY_T QDMI_Environment_Property; -enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { +enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T { - QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, - QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX = 2, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM1 = 999999995, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM2 = 999999996, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM3 = 999999997, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM4 = 999999998, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX_CUSTOM5 = 999999999 + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, + + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 }; -typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T - QDMI_Environment_Query_Parameter; +typedef enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T + QDMI_Device_Environment_Query_Parameter; enum QDMI_ENVIRONMENT_QUERY_RESULT_T { - QDMI_ENVIRONMENT_QUERY_RESULT_START_TIME = 0, - - QDMI_ENVIRONMENT_QUERY_RESULT_END_TIME = 1, + QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS = 0, - QDMI_ENVIRONMENT_QUERY_RESULT_VALUE = 2, + QDMI_ENVIRONMENT_QUERY_RESULT_VALUES = 1, - QDMI_ENVIRONMENT_QUERY_RESULT_MAX = 3, + QDMI_ENVIRONMENT_QUERY_RESULT_MAX = 2, QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 = 999999995, diff --git a/include/qdmi/device.h b/include/qdmi/device.h index adfc634a..47c20140 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -560,18 +560,20 @@ void QDMI_device_job_free(QDMI_Device_Job job); * TODO Documentation * */ -typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; -int QDMI_device_session_create_environment_query(QDMI_Device_Session session, - QDMI_Environment_Query *query); +typedef struct QDMI_Device_Environment_Query_impl_d + *QDMI_Device_Environment_Query; -int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, - QDMI_Environment_Query_Parameter param, +int QDMI_device_session_create_environment_query( + QDMI_Device_Session session, QDMI_Device_Environment_Query *query); + +int QDMI_device_environment_query_set_parameter(QDMI_Device_Environment_Query query, + QDMI_Device_Environment_Query_Parameter param, size_t size, const void *value); -int QDMI_environment_query_submit(QDMI_Environment_Query query); +int QDMI_device_environment_query_submit(QDMI_Device_Environment_Query query); -int QDMI_environment_query_get_results(QDMI_Environment_Query query, +int QDMI_device_environment_query_get_results(QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, size_t size, void *data, size_t *size_ret); From 52bd8d7667589390b7fde267b9ce5249507ec3c8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:10:07 +0000 Subject: [PATCH 04/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 6 +++--- include/qdmi/device.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 3dfac2d7..375edc97 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -543,9 +543,8 @@ int QDMI_device_query_operation_property( const QDMI_Site *sites, size_t num_params, const double *params, QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); - int QDMI_device_query_environment_property(QDMI_Device device, - QDMI_Environment enviroment, + QDMI_Environment environment, QDMI_Environment_Property prop, const size_t size, void *value, size_t *size_ret); @@ -860,7 +859,8 @@ typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; -int QDMI_device_create_environment_query(QDMI_Device dev, QDMI_Environment_Query *query); +int QDMI_device_create_environment_query(QDMI_Device dev, + QDMI_Environment_Query *query); int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, QDMI_Environment_Query_Parameter param, diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 47c20140..bed16765 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -567,16 +567,16 @@ typedef struct QDMI_Device_Environment_Query_impl_d int QDMI_device_session_create_environment_query( QDMI_Device_Session session, QDMI_Device_Environment_Query *query); -int QDMI_device_environment_query_set_parameter(QDMI_Device_Environment_Query query, - QDMI_Device_Environment_Query_Parameter param, - size_t size, const void *value); +int QDMI_device_environment_query_set_parameter( + QDMI_Device_Environment_Query query, + QDMI_Device_Environment_Query_Parameter param, size_t size, + const void *value); int QDMI_device_environment_query_submit(QDMI_Device_Environment_Query query); -int QDMI_device_environment_query_get_results(QDMI_Device_Environment_Query query, - QDMI_Environment_Query_Result result, - size_t size, void *data, - size_t *size_ret); +int QDMI_device_environment_query_get_results( + QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, + size_t size, void *data, size_t *size_ret); /** @} */ // end of device_interface // NOLINTEND(performance-enum-size,modernize-use-using,modernize-redundant-void-arg) From 49cc0bf48c39cba3bac309773657ed39b24fcbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Tue, 8 Apr 2025 15:54:49 +0200 Subject: [PATCH 05/61] =?UTF-8?q?=F0=9F=9A=9A=20rename=20environment=20to?= =?UTF-8?q?=20environmentvariable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/constants.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 364bec0f..c8a43ad7 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -221,7 +221,7 @@ enum QDMI_DEVICE_PROPERTY_T { /* * TODO */ - QDMI_DEVICE_PROPERTY_ENVIRONMENTS = 9, + QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES = 9, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -680,7 +680,7 @@ enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T { QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES = 2, QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, From 3ba8a9247eeeccf27f2833be22009ddfc73c6792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Tue, 8 Apr 2025 16:08:28 +0200 Subject: [PATCH 06/61] =?UTF-8?q?=E2=9C=A8=20Implemention=20of=20QDMI=20En?= =?UTF-8?q?viroment=20functions=20in=20example=20C=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 166 ++++++++++++++++++++++++++++++++++++- 1 file changed, 162 insertions(+), 4 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index e38b19f9..740ff502 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -28,6 +28,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include enum C_QDMI_DEVICE_SESSION_STATUS { ALLOCATED, INITIALIZED }; @@ -59,11 +60,19 @@ typedef struct C_QDMI_Operation_impl_d { typedef struct C_QDMI_Environment_impl_d { char *id; - int factor; char *unit; - int duration; + int sampling_rate; // in seconds } C_QDMI_Environment_impl_t; +typedef struct C_QDMI_Device_Environment_Query_impl_d { + time_t start_time; + time_t end_time; + C_QDMI_Environment enviroment; + time_t *result_timestamps; + float *result_values; + size_t result_length; +} C_QDMI_Device_Environment_Query_impl_t; + /** * @brief Static function to maintain the device status. * @return a pointer to the device status. @@ -94,8 +103,8 @@ void C_QDMI_set_device_status(QDMI_Device_Status status) { QDMI_Device_Status C_QDMI_read_device_status(void) { return *C_QDMI_get_device_status(); } -const C_QDMI_Environment DEVICE_ENVIRONMENT_PROPERTY[] = { - &(C_QDMI_Environment_impl_t){"t4k", 100, "K", 60}, +const C_QDMI_Environment C_DEVICE_ENVIRONMENTS[] = { + &(C_QDMI_Environment_impl_t){"t4k", "K", 60}, }; const C_QDMI_Site C_DEVICE_SITES[] = { @@ -706,6 +715,8 @@ int C_QDMI_device_session_query_device_property(C_QDMI_Device_Session session, // The example device never requires calibration ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, C_QDMI_Environment, + C_DEVICE_ENVIRONMENTS, 1, prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] @@ -824,3 +835,150 @@ int C_QDMI_device_session_query_operation_property( } return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] + +int C_QDMI_device_session_query_environment_property( + C_QDMI_Device_Session session, C_QDMI_Environment environment, + QDMI_Environment_Property prop, size_t size, void *value, + size_t *size_ret) { + if (session == NULL || environment == NULL || (value != NULL && size == 0) || + (prop >= QDMI_ENVIRONMENT_PROPERTY_MAX && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_ID, environment->id, prop, size, + value, size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_UNIT, environment->unit, prop, + size, value, size_ret) + ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, int, + environment->sampling_rate, prop, size, value, + size_ret) + return QDMI_ERROR_NOTSUPPORTED; +} + +int C_QDMI_device_session_create_environment_query( + C_QDMI_Device_Session session, C_QDMI_Device_Environment_Query *query) { + + if (session == NULL || query == NULL) { + return QDMI_ERROR_INVALIDARGUMENT; + } + if (session->status != INITIALIZED) { + return QDMI_ERROR_BADSTATE; + } + *query = malloc(sizeof(C_QDMI_Device_Environment_Query_impl_t)); + (*query)->enviroment = malloc(sizeof(C_QDMI_Environment)); + (*query)->start_time = time(NULL); + (*query)->end_time = time(NULL); + + return QDMI_SUCCESS; +} + +int C_QDMI_device_environment_query_set_parameter( + C_QDMI_Device_Environment_Query query, + QDMI_Device_Environment_Query_Parameter param, size_t size, + const void *value) { + + if (query == NULL || (value != NULL && size == 0) || + (param >= QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + switch (param) { + + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME: + query->start_time = *(time_t *)(value); + return QDMI_SUCCESS; + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME: + query->end_time = *(time_t *)(value); + return QDMI_SUCCESS; + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: + query->enviroment = *(C_QDMI_Environment *)(value); + return QDMI_SUCCESS; + default: + return QDMI_ERROR_NOTSUPPORTED; + } +} + +int C_QDMI_device_environment_query_submit( + C_QDMI_Device_Environment_Query query) { + + if (query == NULL || query->enviroment == NULL) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + // here, the actual submittion. + + // for demonstration purposes + long time_difference = query->end_time - query->start_time; + int sampling_rate = query->enviroment->sampling_rate; + + size_t result_length = (size_t)(time_difference / sampling_rate); + + query->result_timestamps = malloc(sizeof(time_t) * result_length); + query->result_values = malloc(sizeof(time_t) * result_length); + query->result_length = result_length; + + for (size_t i = 0; i < result_length; i++) { + query->result_timestamps[i] = query->start_time + sampling_rate * (long)i; + query->result_values[i] = ((float)rand() / (float)(RAND_MAX)) * 100; + } + + return QDMI_SUCCESS; +} + +int C_QDMI_device_environment_query_get_results( + C_QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, + size_t size, void *data, size_t *size_ret) { + + if (query == NULL || (data != NULL && size == 0) || + (result >= QDMI_ENVIRONMENT_QUERY_RESULT_MAX && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + size_t req_size = query->result_length; + switch (result) { + case QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS: + req_size *= sizeof(time_t); + if (data != NULL) { + if (size < req_size) { + return QDMI_ERROR_INVALIDARGUMENT; + } + memcpy(data, query->result_timestamps, req_size); + } + + if ((size_ret) != NULL) { + *(size_ret) = req_size; + } + return QDMI_SUCCESS; + case QDMI_ENVIRONMENT_QUERY_RESULT_VALUES: + + req_size *= sizeof(float); + if (data != NULL) { + if (size < req_size) { + return QDMI_ERROR_INVALIDARGUMENT; + } + memcpy(data, (query->result_values), req_size); + } + if ((size_ret) != NULL) { + *(size_ret) = req_size; + } + return QDMI_SUCCESS; + + default: + return QDMI_ERROR_NOTSUPPORTED; + } + + return QDMI_SUCCESS; +} From 6f658f677494f41bef870a039bbfeb458c679577 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:08:41 +0000 Subject: [PATCH 07/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 740ff502..ed9e50dc 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -67,7 +67,7 @@ typedef struct C_QDMI_Environment_impl_d { typedef struct C_QDMI_Device_Environment_Query_impl_d { time_t start_time; time_t end_time; - C_QDMI_Environment enviroment; + C_QDMI_Environment environment; time_t *result_timestamps; float *result_values; size_t result_length; @@ -715,8 +715,9 @@ int C_QDMI_device_session_query_device_property(C_QDMI_Device_Session session, // The example device never requires calibration ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) - ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, C_QDMI_Environment, - C_DEVICE_ENVIRONMENTS, 1, prop, size, value, size_ret) + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, + C_QDMI_Environment, C_DEVICE_ENVIRONMENTS, 1, prop, size, + value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] @@ -870,7 +871,7 @@ int C_QDMI_device_session_create_environment_query( return QDMI_ERROR_BADSTATE; } *query = malloc(sizeof(C_QDMI_Device_Environment_Query_impl_t)); - (*query)->enviroment = malloc(sizeof(C_QDMI_Environment)); + (*query)->environment = malloc(sizeof(C_QDMI_Environment)); (*query)->start_time = time(NULL); (*query)->end_time = time(NULL); @@ -900,7 +901,7 @@ int C_QDMI_device_environment_query_set_parameter( query->end_time = *(time_t *)(value); return QDMI_SUCCESS; case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: - query->enviroment = *(C_QDMI_Environment *)(value); + query->environment = *(C_QDMI_Environment *)(value); return QDMI_SUCCESS; default: return QDMI_ERROR_NOTSUPPORTED; @@ -910,7 +911,7 @@ int C_QDMI_device_environment_query_set_parameter( int C_QDMI_device_environment_query_submit( C_QDMI_Device_Environment_Query query) { - if (query == NULL || query->enviroment == NULL) { + if (query == NULL || query->environment == NULL) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -918,7 +919,7 @@ int C_QDMI_device_environment_query_submit( // for demonstration purposes long time_difference = query->end_time - query->start_time; - int sampling_rate = query->enviroment->sampling_rate; + int sampling_rate = query->environment->sampling_rate; size_t result_length = (size_t)(time_difference / sampling_rate); From 25abdd4d43c463e5ad35f8711d95a9a865d1740d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Tue, 8 Apr 2025 16:19:38 +0200 Subject: [PATCH 08/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20fix=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index ed9e50dc..80506bd9 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -915,7 +915,7 @@ int C_QDMI_device_environment_query_submit( return QDMI_ERROR_INVALIDARGUMENT; } - // here, the actual submittion. + // here, the actual submission. // for demonstration purposes long time_difference = query->end_time - query->start_time; From 98971bad08c9713cdcd1635b7f3d2a05b64eab21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Wed, 9 Apr 2025 13:47:03 +0200 Subject: [PATCH 09/61] =?UTF-8?q?=E2=9C=A8=20additional=20functions=20and?= =?UTF-8?q?=20their=20implementations=20in=20example=20c=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/prefix_defs.txt | 4 +++ examples/device/c/device.c | 61 ++++++++++++++++++++++++++++++++++++-- include/qdmi/constants.h | 19 ++++++++++++ include/qdmi/device.h | 9 ++++++ 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index 019a54e7..8562b9f8 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -32,3 +32,7 @@ QDMI_device_session_create_environment_query QDMI_device_environment_query_set_parameter QDMI_device_environment_query_submit QDMI_device_environment_query_get_results +QDMI_device_environment_query_check_status +QDMI_device_environment_query_wait +QDMI_device_environment_query_cancel +QDMI_device_environment_query_free diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 80506bd9..243c045b 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -71,6 +71,7 @@ typedef struct C_QDMI_Device_Environment_Query_impl_d { time_t *result_timestamps; float *result_values; size_t result_length; + QDMI_Environment_Query_Status status; } C_QDMI_Device_Environment_Query_impl_t; /** @@ -915,16 +916,19 @@ int C_QDMI_device_environment_query_submit( return QDMI_ERROR_INVALIDARGUMENT; } + long time_difference = query->end_time - query->start_time; + if (time_difference <= 0) { + return QDMI_ERROR_INVALIDARGUMENT; + } // here, the actual submission. // for demonstration purposes - long time_difference = query->end_time - query->start_time; int sampling_rate = query->environment->sampling_rate; size_t result_length = (size_t)(time_difference / sampling_rate); query->result_timestamps = malloc(sizeof(time_t) * result_length); - query->result_values = malloc(sizeof(time_t) * result_length); + query->result_values = malloc(sizeof(float) * result_length); query->result_length = result_length; for (size_t i = 0; i < result_length; i++) { @@ -983,3 +987,56 @@ int C_QDMI_device_environment_query_get_results( return QDMI_SUCCESS; } + +int C_QDMI_device_environment_query_check_status( + C_QDMI_Device_Environment_Query query, + QDMI_Environment_Query_Status *status) { + if (query == NULL || status == NULL) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + // randomly decide whether job is done or not + if (query->status == QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING && + rand() % 2 == 0) { + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + } + + *status = query->status; + return QDMI_SUCCESS; +} + +int C_QDMI_device_environment_query_wait( + C_QDMI_Device_Environment_Query query) { + + if (query == NULL) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + return QDMI_SUCCESS; +} + +int C_QDMI_device_environment_query_cancel( + C_QDMI_Device_Environment_Query query) { + + if (query == NULL || query->status == QDMI_ENVIRONMENT_QUERY_STATUS_DONE) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED; + + return QDMI_SUCCESS; +} + +void C_QDMI_device_environment_query_free( + C_QDMI_Device_Environment_Query query) { + + free(query->result_timestamps); + query->result_timestamps = NULL; + + free(query->result_values); + query->result_values = NULL; + + free(query->environment); + query->environment = NULL; +} diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index c8a43ad7..0d51bbe1 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -720,6 +720,25 @@ enum QDMI_ENVIRONMENT_QUERY_RESULT_T { /// Job result type. typedef enum QDMI_ENVIRONMENT_QUERY_RESULT_T QDMI_Environment_Query_Result; +enum QDMI_ENVIRONMENT_QUERY_STATUS_T { + /** + * @brief The job was created and can be configured via @ref + * QDMI_job_set_parameter. + */ + QDMI_ENVIRONMENT_QUERY_STATUS_CREATED = 0, + /// The job was submitted and is waiting to be executed. + QDMI_ENVIRONMENT_QUERY_STATUS_SUBMITTED = 1, + /// The job is done, and the result can be retrieved. + QDMI_ENVIRONMENT_QUERY_STATUS_DONE = 2, + /// The job is running, and the result is not yet available. + QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING = 3, + /// The job was canceled, and the result is not available. + QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED = 4 +}; + +/// Job status type. +typedef enum QDMI_ENVIRONMENT_QUERY_STATUS_T QDMI_Environment_Query_Status; + // NOLINTEND(performance-enum-size, modernize-use-using) #ifdef __cplusplus diff --git a/include/qdmi/device.h b/include/qdmi/device.h index bed16765..6c74f7d6 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -577,6 +577,15 @@ int QDMI_device_environment_query_submit(QDMI_Device_Environment_Query query); int QDMI_device_environment_query_get_results( QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, size_t size, void *data, size_t *size_ret); + +int QDMI_device_environment_query_check_status(QDMI_Device_Environment_Query query, QDMI_Environment_Query_Status *status); + +int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); + +int QDMI_device_environment_query_cancel(QDMI_Device_Environment_Query query); + +void QDMI_device_environment_query_free(QDMI_Device_Environment_Query query); + /** @} */ // end of device_interface // NOLINTEND(performance-enum-size,modernize-use-using,modernize-redundant-void-arg) From 98a8659634a64d128be758ac2d8851616cadf77b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:48:16 +0000 Subject: [PATCH 10/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/device.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 6c74f7d6..f951e9c1 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -578,7 +578,8 @@ int QDMI_device_environment_query_get_results( QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, size_t size, void *data, size_t *size_ret); -int QDMI_device_environment_query_check_status(QDMI_Device_Environment_Query query, QDMI_Environment_Query_Status *status); +int QDMI_device_environment_query_check_status( + QDMI_Device_Environment_Query query, QDMI_Environment_Query_Status *status); int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); From c2b293591210b8bba102a17f1e1f9687066f0d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Wed, 9 Apr 2025 14:23:57 +0200 Subject: [PATCH 11/61] =?UTF-8?q?=E2=9C=A8=20additional=20definations=20in?= =?UTF-8?q?=20the=20client=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 375edc97..daab3ad2 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -873,6 +873,15 @@ int QDMI_environment_query_get_results(QDMI_Environment_Query query, size_t size, void *data, size_t *size_ret); +int QDMI_environment_query_check_status( + QDMI_Environment_Query query, QDMI_Environment_Query_Status *status); + +int QDMI_environment_query_wait(QDMI_Environment_Query query); + +int QDMI_environment_query_cancel(QDMI_Environment_Query query); + +void QDMI_environment_query_free(QDMI_Environment_Query query); + /** @} */ // end of client_interface // NOLINTEND(performance-enum-size, modernize-use-using) From f88b60cfc6d55b14b713e713b8b659009bc34c7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 12:24:34 +0000 Subject: [PATCH 12/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index daab3ad2..bc33bd37 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -873,8 +873,8 @@ int QDMI_environment_query_get_results(QDMI_Environment_Query query, size_t size, void *data, size_t *size_ret); -int QDMI_environment_query_check_status( - QDMI_Environment_Query query, QDMI_Environment_Query_Status *status); +int QDMI_environment_query_check_status(QDMI_Environment_Query query, + QDMI_Environment_Query_Status *status); int QDMI_environment_query_wait(QDMI_Environment_Query query); From c1591fe2c6a7193c6eba77a97cfdd3641a23a783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Wed, 9 Apr 2025 14:48:51 +0200 Subject: [PATCH 13/61] =?UTF-8?q?=E2=9C=A8=20Implemention=20of=20QDMI=20En?= =?UTF-8?q?viroment=20functions=20in=20example=20CXX=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 248 +++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index 2668ce67..a901883e 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -26,10 +26,12 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include +#include #include #include #include #include +#include #include #include #include @@ -78,6 +80,23 @@ struct CXX_QDMI_Operation_impl_d { std::string name; }; +struct CXX_QDMI_Environment_impl_d { + std::string id; + std::string unit; + std::chrono::duration sampling_rate{}; // in seconds +}; + +struct CXX_QDMI_Device_Environment_Query_impl_d { + std::chrono::time_point start_time{}; + std::chrono::time_point end_time{}; + CXX_QDMI_Environment enviroment{}; + std::vector> + result_timestamps; + std::vector result_values; + size_t result_length{}; + QDMI_Environment_Query_Status status{}; +}; + namespace { /** * @brief Static function to maintain the device state. @@ -160,6 +179,12 @@ constexpr CXX_QDMI_Site_impl_d SITE4{4}; constexpr std::array CXX_DEVICE_SITES = { &SITE0, &SITE1, &SITE2, &SITE3, &SITE4}; +const CXX_QDMI_Environment_impl_d ENV0{"t4k", "K", + std::chrono::duration{60}}; + +constexpr std::array + CXX_DEVICE_ENVIRONMENTS{&ENV0}; + constexpr std::array // clang-format off DEVICE_COUPLING_MAP = { @@ -749,6 +774,10 @@ int CXX_QDMI_device_session_query_device_property( ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, + CXX_QDMI_Environment, CXX_DEVICE_ENVIRONMENTS, prop, size, + value, size_ret) + return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] @@ -844,3 +873,222 @@ int CXX_QDMI_device_session_query_operation_property( } return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] + +int CXX_QDMI_device_session_query_environment_property( + CXX_QDMI_Device_Session session, CXX_QDMI_Environment environment, + QDMI_Environment_Property prop, size_t size, void *value, + size_t *size_ret) { + if (session == nullptr || environment == nullptr || + (value != nullptr && size == 0) || + (prop >= QDMI_ENVIRONMENT_PROPERTY_MAX && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 && + prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_ID, environment->id.c_str(), + prop, size, value, size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_UNIT, environment->unit.c_str(), + prop, size, value, size_ret) + ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, int, + environment->sampling_rate.count(), prop, size, + value, size_ret) + return QDMI_ERROR_NOTSUPPORTED; +} + +int CXX_QDMI_device_session_create_environment_query( + CXX_QDMI_Device_Session session, CXX_QDMI_Device_Environment_Query *query) { + + if (session == nullptr || query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + if (session->status != CXX_QDMI_DEVICE_SESSION_STATUS::INITIALIZED) { + return QDMI_ERROR_BADSTATE; + } + *query = new CXX_QDMI_Device_Environment_Query_impl_d(); + (*query)->enviroment = new CXX_QDMI_Environment_impl_d(); + (*query)->start_time = std::chrono::system_clock::now(); + (*query)->end_time = std::chrono::system_clock::now(); + + return QDMI_SUCCESS; +} + +int CXX_QDMI_device_environment_query_set_parameter( + CXX_QDMI_Device_Environment_Query query, + QDMI_Device_Environment_Query_Parameter param, size_t size, + const void *value) { + + if (query == nullptr || (value != nullptr && size == 0) || + (param >= QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 && + param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + switch (param) { + + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME: { + const auto *c_start_time_ptr = static_cast(value); + query->start_time = + std::chrono::system_clock::from_time_t(*c_start_time_ptr); + return QDMI_SUCCESS; + } + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME: { + + const auto *c_end_time_ptr = static_cast(value); + query->end_time = std::chrono::system_clock::from_time_t(*c_end_time_ptr); + return QDMI_SUCCESS; + } + + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: { + const auto *enviroment_ptr = + static_cast(value); + query->enviroment = *enviroment_ptr; + return QDMI_SUCCESS; + } + default: + return QDMI_ERROR_NOTSUPPORTED; + } +} + +int CXX_QDMI_device_environment_query_submit( + CXX_QDMI_Device_Environment_Query query) { + + if (query == nullptr || query->enviroment == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + // here, the actual submission. + + // for demonstration purposes + auto time_difference = std::chrono::round( + query->end_time - query->start_time); + + auto sampling_rate = query->enviroment->sampling_rate; + + auto result_length = + static_cast(time_difference.count() / sampling_rate.count()); + + query->result_timestamps.clear(); + query->result_timestamps.reserve(result_length); + + query->result_values.clear(); + query->result_values.reserve(result_length); + + query->result_length = result_length; + + for (unsigned int i = 0; i < result_length; i++) { + auto duration_to_add = + std::chrono::duration_cast( + query->enviroment->sampling_rate * i); + auto next_time = query->start_time + duration_to_add; + query->result_timestamps.emplace_back(next_time); + query->result_values[i] = + static_cast(rand()) / (static_cast(RAND_MAX / 100)); + } + + return QDMI_SUCCESS; +} + +int CXX_QDMI_device_environment_query_get_results( + CXX_QDMI_Device_Environment_Query query, + QDMI_Environment_Query_Result result, size_t size, void *data, + size_t *size_ret) { + + if (query == nullptr || (data != nullptr && size == 0) || + (result >= QDMI_ENVIRONMENT_QUERY_RESULT_MAX && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 && + result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + size_t req_size = query->result_length; + switch (result) { + case QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS: + req_size *= sizeof(time_t); + if (data != nullptr) { + if (size < req_size) { + return QDMI_ERROR_INVALIDARGUMENT; + } + auto *data_ptr = static_cast(data); + for (size_t i = 0; i < query->result_length; i++) { + data_ptr[i] = + std::chrono::system_clock::to_time_t(query->result_timestamps[i]); + } + } + + if ((size_ret) != nullptr) { + *(size_ret) = req_size; + } + return QDMI_SUCCESS; + case QDMI_ENVIRONMENT_QUERY_RESULT_VALUES: + + req_size *= sizeof(float); + if (data != nullptr) { + if (size < req_size) { + return QDMI_ERROR_INVALIDARGUMENT; + } + memcpy(data, query->result_values.data(), req_size); + } + if ((size_ret) != nullptr) { + *(size_ret) = req_size; + } + return QDMI_SUCCESS; + + default: + return QDMI_ERROR_NOTSUPPORTED; + } + + return QDMI_SUCCESS; +} + +int CXX_QDMI_device_environment_query_check_status( + CXX_QDMI_Device_Environment_Query query, + QDMI_Environment_Query_Status *status) { + if (query == nullptr || status == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + // randomly decide whether job is done or not + if (query->status == QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING && + CXX_QDMI_generate_bit()) { + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + } + + *status = query->status; + return QDMI_SUCCESS; +} + +int CXX_QDMI_device_environment_query_wait( + CXX_QDMI_Device_Environment_Query query) { + + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + return QDMI_SUCCESS; +} + +int CXX_QDMI_device_environment_query_cancel( + CXX_QDMI_Device_Environment_Query query) { + + if (query == nullptr || query->status == QDMI_ENVIRONMENT_QUERY_STATUS_DONE) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + query->status = QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED; + + return QDMI_SUCCESS; +} + +void CXX_QDMI_device_environment_query_free( + CXX_QDMI_Device_Environment_Query query) { + delete query; +} From 4e7b8f817e2420c443d5b18871d68437c4924d89 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 12:51:19 +0000 Subject: [PATCH 14/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index a901883e..116d9b91 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -89,7 +89,7 @@ struct CXX_QDMI_Environment_impl_d { struct CXX_QDMI_Device_Environment_Query_impl_d { std::chrono::time_point start_time{}; std::chrono::time_point end_time{}; - CXX_QDMI_Environment enviroment{}; + CXX_QDMI_Environment environment{}; std::vector> result_timestamps; std::vector result_values; @@ -908,7 +908,7 @@ int CXX_QDMI_device_session_create_environment_query( return QDMI_ERROR_BADSTATE; } *query = new CXX_QDMI_Device_Environment_Query_impl_d(); - (*query)->enviroment = new CXX_QDMI_Environment_impl_d(); + (*query)->environment = new CXX_QDMI_Environment_impl_d(); (*query)->start_time = std::chrono::system_clock::now(); (*query)->end_time = std::chrono::system_clock::now(); @@ -945,9 +945,9 @@ int CXX_QDMI_device_environment_query_set_parameter( } case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: { - const auto *enviroment_ptr = + const auto *environment_ptr = static_cast(value); - query->enviroment = *enviroment_ptr; + query->environment = *environment_ptr; return QDMI_SUCCESS; } default: @@ -958,7 +958,7 @@ int CXX_QDMI_device_environment_query_set_parameter( int CXX_QDMI_device_environment_query_submit( CXX_QDMI_Device_Environment_Query query) { - if (query == nullptr || query->enviroment == nullptr) { + if (query == nullptr || query->environment == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -968,7 +968,7 @@ int CXX_QDMI_device_environment_query_submit( auto time_difference = std::chrono::round( query->end_time - query->start_time); - auto sampling_rate = query->enviroment->sampling_rate; + auto sampling_rate = query->environment->sampling_rate; auto result_length = static_cast(time_difference.count() / sampling_rate.count()); @@ -984,7 +984,7 @@ int CXX_QDMI_device_environment_query_submit( for (unsigned int i = 0; i < result_length; i++) { auto duration_to_add = std::chrono::duration_cast( - query->enviroment->sampling_rate * i); + query->environment->sampling_rate * i); auto next_time = query->start_time + duration_to_add; query->result_timestamps.emplace_back(next_time); query->result_values[i] = From bd849ae858e3023fdded3b1da4a1b41ba9300a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Wed, 9 Apr 2025 16:32:26 +0200 Subject: [PATCH 15/61] =?UTF-8?q?=E2=9C=A8=20implementation=20of=20qdmi=20?= =?UTF-8?q?environment=20function=20in=20example=20driver,=20fomac=20and?= =?UTF-8?q?=20their=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/driver/qdmi_example_driver.cpp | 132 ++++++++++++++++++++++++ examples/fomac/example_fomac.cpp | 59 +++++++++++ examples/fomac/example_fomac.hpp | 13 +++ test/test_qdmi.cpp | 83 +++++++++++++++ 4 files changed, 287 insertions(+) diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 5757217e..388c30da 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -101,6 +101,31 @@ struct QDMI_Library { decltype(QDMI_device_session_query_operation_property) *device_session_query_operation_property{}; + decltype(QDMI_device_session_query_environment_property) + *device_session_query_environment_property{}; + + decltype(QDMI_device_environment_query_set_parameter) + *device_environment_query_set_parameter{}; + + decltype(QDMI_device_session_create_environment_query) + *device_session_create_environment_query{}; + + decltype(QDMI_device_environment_query_submit) + *device_environment_query_submit{}; + + decltype(QDMI_device_environment_query_get_results) + *device_environment_query_get_results{}; + + decltype(QDMI_device_environment_query_check_status) + *device_environment_query_check_status{}; + + decltype(QDMI_device_environment_query_wait) *device_environment_query_wait{}; + + decltype(QDMI_device_environment_query_cancel) + *device_environment_query_cancel{}; + + decltype(QDMI_device_environment_query_free) *device_environment_query_free{}; + // default constructor QDMI_Library() = default; @@ -156,6 +181,11 @@ struct QDMI_Driver_State { std::unordered_set sessions; }; +struct QDMI_Environment_Query_impl_d { + QDMI_Device device = nullptr; + QDMI_Device_Environment_Query env_query = nullptr; +}; + namespace { /** * @brief Returns a pointer to the global driver state. @@ -216,6 +246,16 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_device_property) LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) + LOAD_SYMBOL(library, prefix, device_session_query_environment_property) + // device qnvironment interface + LOAD_SYMBOL(library, prefix, device_session_create_environment_query) + LOAD_SYMBOL(library, prefix, device_environment_query_set_parameter) + LOAD_SYMBOL(library, prefix, device_environment_query_submit) + LOAD_SYMBOL(library, prefix, device_environment_query_get_results) + LOAD_SYMBOL(library, prefix, device_environment_query_check_status) + LOAD_SYMBOL(library, prefix, device_environment_query_wait) + LOAD_SYMBOL(library, prefix, device_environment_query_cancel) + LOAD_SYMBOL(library, prefix, device_environment_query_free) // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) } catch (const std::exception &) { @@ -515,3 +555,95 @@ int QDMI_device_query_operation_property( device->device_session, operation, num_sites, sites, num_params, params, prop, size, value, size_ret); } + +int QDMI_device_query_environment_property(QDMI_Device device, + QDMI_Environment environment, + QDMI_Environment_Property prop, + const size_t size, void *value, + size_t *size_ret) { + if (device == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return device->library->device_session_query_environment_property( + device->device_session, environment, prop, size, value, size_ret); +} + +int QDMI_device_create_environment_query(QDMI_Device dev, + QDMI_Environment_Query *query) { + if (dev == nullptr || query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + + if ((dev->session->mode & QDMI_SESSION_MODE_READWRITE) == 0) { + return QDMI_ERROR_PERMISSIONDENIED; + } + + *query = new QDMI_Environment_Query_impl_d(); + (*query)->device = dev; + return dev->library->device_session_create_environment_query( + dev->device_session, &(*query)->env_query); +} + +int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, + QDMI_Environment_Query_Parameter param, + size_t size, const void *value) { + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_set_parameter( + query->env_query, + static_cast(param), size, value); +} + +int QDMI_environment_query_submit(QDMI_Environment_Query query) { + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_submit( + query->env_query); +} + +int QDMI_environment_query_get_results(QDMI_Environment_Query query, + QDMI_Environment_Query_Result result, + size_t size, void *data, + size_t *size_ret) { + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_get_results( + query->env_query, result, size, data, size_ret); +} + +int QDMI_environment_query_check_status(QDMI_Environment_Query query, + QDMI_Environment_Query_Status *status) { + + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_check_status( + query->env_query, status); +} + +int QDMI_environment_query_wait(QDMI_Environment_Query query) { + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_wait( + query->env_query); +} + +int QDMI_environment_query_cancel(QDMI_Environment_Query query) { + + if (query == nullptr) { + return QDMI_ERROR_INVALIDARGUMENT; + } + return query->device->library->device_environment_query_cancel( + query->env_query); +} + +void QDMI_environment_query_free(QDMI_Environment_Query query) { + if (query != nullptr) { + query->device->library->device_environment_query_free(query->env_query); + delete query; + } +} \ No newline at end of file diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 5c679182..e99af470 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -25,6 +25,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "example_fomac.hpp" #include "qdmi/client.h" +#include "qdmi/constants.h" #include #include @@ -198,3 +199,61 @@ auto FoMaC::get_parameters_num(const QDMI_Operation &op) const -> size_t { throw_if_error(ret, "Failed to query the parameter number"); return parameters_num; } + +auto FoMaC::get_environment_variables() const -> std::vector { + size_t environments_size = 0; + int ret = QDMI_device_query_device_property( + device, QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, 0, nullptr, + &environments_size); + throw_if_error(ret, "Failed to get the environment variable list size."); + std::vector environments(environments_size / + sizeof(QDMI_Site)); + ret = QDMI_device_query_device_property( + device, QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, environments_size, + static_cast(environments.data()), nullptr); + throw_if_error(ret, "Failed to get the environment variables."); + return environments; +} + +auto FoMaC::get_environment_id(QDMI_Environment environment) const -> std::string { + size_t environment_id_size = 0; + + int ret = QDMI_device_query_environment_property( + device, environment, QDMI_ENVIRONMENT_PROPERTY_ID, 0, nullptr, + &environment_id_size); + throw_if_error(ret, "Failed to query the size for environment ID"); + std::string environment_id(environment_id_size - 1, '\0'); + ret = QDMI_device_query_environment_property( + device, environment, QDMI_ENVIRONMENT_PROPERTY_ID, + environment_id.size() + 1, environment_id.data(), nullptr); + throw_if_error(ret, "Failed to query the environment ID"); + + return environment_id; +} + +auto FoMaC::get_environment_unit(QDMI_Environment environment) const -> std::string { + size_t environment_unit_size = 0; + + int ret = QDMI_device_query_environment_property( + device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, + &environment_unit_size); + throw_if_error(ret, "Failed to query the size for environment unit"); + + std::string environment_unit(environment_unit_size - 1, '\0'); + ret = QDMI_device_query_environment_property( + device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, + environment_unit.size() + 1, environment_unit.data(), nullptr); + throw_if_error(ret, "Failed to query the environment unit"); + + return environment_unit; +} + +auto FoMaC::get_environment_sampling_rate(QDMI_Environment environment) const -> int { + int sampling_rate = 0; + const int ret = QDMI_device_query_environment_property( + device, environment, QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, + sizeof(int), &sampling_rate, nullptr); + throw_if_error(ret, "Failed to query the sampling rate"); + + return sampling_rate; +} \ No newline at end of file diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index c97885b6..e11d5a63 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -63,4 +63,17 @@ class FoMaC { [[nodiscard]] auto get_parameters_num(const QDMI_Operation &op) const -> size_t; + + [[nodiscard]] auto get_environment_variables() const + -> std::vector; + + [[nodiscard]] auto get_environment_id(QDMI_Environment environment) const + -> std::string; + + [[nodiscard]] auto get_environment_unit(QDMI_Environment environment) const + -> std::string; + + [[nodiscard]] auto + get_environment_sampling_rate(QDMI_Environment environment) const -> int; + }; diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index e00956e9..da061323 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -28,6 +28,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include #include @@ -952,3 +953,85 @@ TEST_P(QDMIImplementationTest, NeedsCalibration) { EXPECT_EQ(ret, QDMI_SUCCESS); EXPECT_EQ(needs_calibration, 0); } + +TEST_P(QDMIImplementationTest, QueryEveryEnviromentProperties) { + + const auto fomac = FoMaC(device); + + auto environments = fomac.get_environment_variables(); + + ASSERT_GT(environments.size(), 0); + + for (const auto &environment : environments) { + + auto environment_id = fomac.get_environment_id(environment); + EXPECT_STRNE(environment_id.c_str(), ""); + + auto environment_unit = fomac.get_environment_unit(environment); + EXPECT_STRNE(environment_unit.c_str(), ""); + + auto sampling_rate = fomac.get_environment_sampling_rate(environment); + EXPECT_GT(sampling_rate, 0); + } +} + +TEST_P(QDMIImplementationTest, EnviromentQuery) { + if (mode == TEST_SESSION_MODE::READONLY) { + GTEST_SKIP() << "Skipping test for read-only session"; + } + + const auto fomac = FoMaC(device); + + auto environments = fomac.get_environment_variables(); + + ASSERT_GT(environments.size(), 0); + + for (const auto &environment : environments) { + QDMI_Environment_Query query = nullptr; + time_t start_time = time(&start_time); + time_t end_time = time(&end_time) + 600; + + EXPECT_EQ(QDMI_device_create_environment_query(device, &query), + QDMI_SUCCESS); + + EXPECT_EQ(QDMI_environment_query_set_parameter( + query, QDMI_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT, + sizeof(QDMI_Environment), &environment), + QDMI_SUCCESS); + + EXPECT_EQ(QDMI_environment_query_set_parameter( + query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, + sizeof(time_t), &start_time), + QDMI_SUCCESS); + + EXPECT_EQ(QDMI_environment_query_set_parameter( + query, QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME, + sizeof(time_t), &end_time), + QDMI_SUCCESS); + + EXPECT_EQ(QDMI_environment_query_submit(query), QDMI_SUCCESS); + + size_t timestamps_size = 0; + QDMI_environment_query_get_results(query, + QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, + 0, nullptr, ×tamps_size); + + std::vector timestamps; + timestamps.reserve(timestamps_size); + + QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, timestamps_size, + timestamps.data(), nullptr); + + size_t size_values = 0; + QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, &size_values); + + std::vector values; + values.reserve(size_values); + + QDMI_environment_query_get_results(query, + QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, + size_values, values.data(), nullptr); + } +} From 385856356c5de52706135ff79355af68fbaad24e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:32:43 +0000 Subject: [PATCH 16/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/driver/qdmi_example_driver.cpp | 2 +- examples/fomac/example_fomac.cpp | 15 +++++++++------ examples/fomac/example_fomac.hpp | 1 - test/test_qdmi.cpp | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 388c30da..6f4f3e60 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -646,4 +646,4 @@ void QDMI_environment_query_free(QDMI_Environment_Query query) { query->device->library->device_environment_query_free(query->env_query); delete query; } -} \ No newline at end of file +} diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index e99af470..0136bc34 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -215,7 +215,8 @@ auto FoMaC::get_environment_variables() const -> std::vector { return environments; } -auto FoMaC::get_environment_id(QDMI_Environment environment) const -> std::string { +auto FoMaC::get_environment_id(QDMI_Environment environment) const + -> std::string { size_t environment_id_size = 0; int ret = QDMI_device_query_environment_property( @@ -231,7 +232,8 @@ auto FoMaC::get_environment_id(QDMI_Environment environment) const -> std::strin return environment_id; } -auto FoMaC::get_environment_unit(QDMI_Environment environment) const -> std::string { +auto FoMaC::get_environment_unit(QDMI_Environment environment) const + -> std::string { size_t environment_unit_size = 0; int ret = QDMI_device_query_environment_property( @@ -248,12 +250,13 @@ auto FoMaC::get_environment_unit(QDMI_Environment environment) const -> std::str return environment_unit; } -auto FoMaC::get_environment_sampling_rate(QDMI_Environment environment) const -> int { +auto FoMaC::get_environment_sampling_rate(QDMI_Environment environment) const + -> int { int sampling_rate = 0; const int ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, - sizeof(int), &sampling_rate, nullptr); + device, environment, QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, sizeof(int), + &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); return sampling_rate; -} \ No newline at end of file +} diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index e11d5a63..68b6291a 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -75,5 +75,4 @@ class FoMaC { [[nodiscard]] auto get_environment_sampling_rate(QDMI_Environment environment) const -> int; - }; diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index da061323..77a16516 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -954,7 +954,7 @@ TEST_P(QDMIImplementationTest, NeedsCalibration) { EXPECT_EQ(needs_calibration, 0); } -TEST_P(QDMIImplementationTest, QueryEveryEnviromentProperties) { +TEST_P(QDMIImplementationTest, QueryEveryEnvironmentProperties) { const auto fomac = FoMaC(device); @@ -975,7 +975,7 @@ TEST_P(QDMIImplementationTest, QueryEveryEnviromentProperties) { } } -TEST_P(QDMIImplementationTest, EnviromentQuery) { +TEST_P(QDMIImplementationTest, EnvironmentQuery) { if (mode == TEST_SESSION_MODE::READONLY) { GTEST_SKIP() << "Skipping test for read-only session"; } From 3929d0a41e506158624582e4da552cc34b3f1ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Wed, 9 Apr 2025 17:12:37 +0200 Subject: [PATCH 17/61] =?UTF-8?q?=F0=9F=8E=A8=20minor=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 5 ++--- test/test_qdmi.cpp | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 243c045b..90818a8b 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -1030,13 +1030,12 @@ int C_QDMI_device_environment_query_cancel( void C_QDMI_device_environment_query_free( C_QDMI_Device_Environment_Query query) { - free(query->result_timestamps); query->result_timestamps = NULL; free(query->result_values); query->result_values = NULL; - free(query->environment); - query->environment = NULL; + free(query); + } diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 77a16516..ad41ec5e 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -988,6 +988,7 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { for (const auto &environment : environments) { QDMI_Environment_Query query = nullptr; + QDMI_Environment_Query_Status status; time_t start_time = time(&start_time); time_t end_time = time(&end_time) + 600; @@ -1011,27 +1012,40 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { EXPECT_EQ(QDMI_environment_query_submit(query), QDMI_SUCCESS); + EXPECT_EQ(QDMI_environment_query_wait(query), QDMI_SUCCESS); + + EXPECT_EQ(QDMI_environment_query_check_status(query, &status), + QDMI_SUCCESS); + size_t timestamps_size = 0; - QDMI_environment_query_get_results(query, - QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, - 0, nullptr, ×tamps_size); + EXPECT_EQ(QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, 0, nullptr, + ×tamps_size), + QDMI_SUCCESS); std::vector timestamps; timestamps.reserve(timestamps_size); - QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, timestamps_size, - timestamps.data(), nullptr); + EXPECT_EQ(QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, + timestamps_size, timestamps.data(), nullptr), + QDMI_SUCCESS); size_t size_values = 0; - QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, &size_values); + EXPECT_EQ(QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, + &size_values), + QDMI_SUCCESS); std::vector values; values.reserve(size_values); - QDMI_environment_query_get_results(query, - QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, - size_values, values.data(), nullptr); + EXPECT_EQ(QDMI_environment_query_get_results( + query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, size_values, + values.data(), nullptr), + QDMI_SUCCESS); + + + QDMI_environment_query_free(query); } } From 16afe773a9d0d5aa30615297c01373021e2eda3d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 15:12:49 +0000 Subject: [PATCH 18/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 1 - test/test_qdmi.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 90818a8b..7bdca935 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -1037,5 +1037,4 @@ void C_QDMI_device_environment_query_free( query->result_values = NULL; free(query); - } diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index ad41ec5e..e38c364b 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -1045,7 +1045,6 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { values.data(), nullptr), QDMI_SUCCESS); - QDMI_environment_query_free(query); } } From 7b3e8dfee288d45a44e23e10cd8bd61653ea9ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Fri, 9 May 2025 07:37:38 +0200 Subject: [PATCH 19/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20initial=20documentat?= =?UTF-8?q?ion=20for=20qdmi=5Fenvironment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 2 +- examples/device/cxx/device.cpp | 2 +- include/qdmi/client.h | 342 +++++++++++++++++++++++++++++++-- include/qdmi/constants.h | 139 ++++++++++---- include/qdmi/device.h | 255 ++++++++++++++++++++++-- include/qdmi/types.h | 19 +- 6 files changed, 686 insertions(+), 73 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 7bdca935..da10a591 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -901,7 +901,7 @@ int C_QDMI_device_environment_query_set_parameter( case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME: query->end_time = *(time_t *)(value); return QDMI_SUCCESS; - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT: query->environment = *(C_QDMI_Environment *)(value); return QDMI_SUCCESS; default: diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index 116d9b91..0d336d7e 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -944,7 +944,7 @@ int CXX_QDMI_device_environment_query_set_parameter( return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES: { + case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT: { const auto *environment_ptr = static_cast(value); query->environment = *environment_ptr; diff --git a/include/qdmi/client.h b/include/qdmi/client.h index bc33bd37..b6f730c4 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -50,6 +50,8 @@ extern "C" { * properties of devices. * - The @ref client_job_interface "client job interface" for submitting jobs * to devices. + * - The @ref client_environment_query_interface "client environment query + * interface" for querying environmental variables. * * @{ */ @@ -543,10 +545,71 @@ int QDMI_device_query_operation_property( const QDMI_Site *sites, size_t num_params, const double *params, QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); +/** + * @brief Query an environment property. + * @param[in] device The device to query. Must not be @c NULL. + * @param[in] environment The environment to query. Must not be @c NULL. + * @param[in] prop The property to query. Must be one of the values specified + * for @ref QDMI_Environment_Property. + * @param[in] size The size of the memory pointed to by @p value in bytes. Must + * be greater or equal to the size of the return type specified for @p prop, + * except when @p value is @c NULL, in which case it is ignored. + * @param[out] value A pointer to the memory location where the value of the + * property will be stored. If this is @c NULL, it is ignored. + * @param[out] size_ret The actual size of the data being queried in bytes. If + * this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the device supports the specified property and, + * when @p value is not @c NULL, the property was successfully retrieved. + * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the + * property. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p device or @p environment is @c NULL, + * - @p prop is invalid, or + * - @p value is not @c NULL and @p size is less than the size of the data + * being queried. + * @return @ref QDMI_ERROR_FATAL if an unexpected error occurred. + * + * @note By calling this function with @p value set to @c NULL, the function can + * be used to check if the environment supports the specified property without + * retrieving the property and without the need to provide a buffer for it. + * Additionally, the size of the buffer needed to retrieve the property is + * returned in @p size_ret if @p size_ret is not @c NULL. + * + * @note For example, to query the unit of an environment, the following code + pattern + * can be used: + * ``` + * // Check if the device supports the property. + * auto ret = QDMI_device_query_environment_property( + * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, nullptr); + * if (ret == QDMI_ERROR_NOTSUPPORTED) { + * // The device does not support the property. + * ... + * } + * + * // Query the size of the property and the property. + * size_t environment_unit_size = 0; + * auto ret = QDMI_device_query_environment_property( + * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, + * &environment_unit_size); + * if (ret != QDMI_SUCCESS) { + * // An error occured. + * ... + * } + * std::string environment_unit(environment_unit_size - 1, '\0'); + * ret = QDMI_device_query_environment_property( + * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, + * environment_unit.size() + 1, environment_unit.data(), nullptr); + * ``` + * + * @remark @ref QDMI_Environment handles may be queried via @ref + * QDMI_device_query_device_property with @ref + QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES. + */ int QDMI_device_query_environment_property(QDMI_Device device, QDMI_Environment environment, QDMI_Environment_Property prop, - const size_t size, void *value, + size_t size, void *value, size_t *size_ret); /** @} */ // end of client_query_interface @@ -833,55 +896,306 @@ int QDMI_job_get_results(QDMI_Job job, QDMI_Job_Result result, size_t size, void QDMI_job_free(QDMI_Job job); /** @} */ // end of client_job_interface + +/** @defgroup client_environment_query_interface QDMI Client Environment Query + * Interface + * @brief Provides functions to query environmental variables. + * @details An environment query is a task submitted by a client to a device + * for querying environmental variables, i.e. temperature or power. + * + * The typical workflow for a client environment query is as follows: + * - Create an environment query with @ref + * QDMI_device_create_environment_query. + * - Set parameters for the environment query with @ref + * QDMI_environment_query_set_parameter + * - Submit the environment query to the device with @ref + * QDMI_environment_query_submit. + * - Check the status of the environment query with @ref + * QDMI_environment_query_check_status. + * - Wait for the environment query to finish with @ref + * QDMI_environment_query_wait. + * - Retrieve the results of the environment query with @ref + * QDMI_environment_query_get_results. + * - Free the environment query with @ref QDMI_environment_query_free when it + * is no longer used. + * + * @{ + */ + +/** + * @brief A handle for a client-side environment query. + * @details An opaque pointer to a type defined by the driver that encapsulates + * all information about an environment query submitted to a device by a client. + * @remark Implementations of the underlying type will want to store the device + * handle used to create the environment query in the handle to be able to + * access the device when needed. + * @see QDMI_Device_Environment_Query for the device-side the environment query + * handle. + */ +typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; + +/** + * @brief Create an environment query. + * @details This is the main entry point for a client to submit an environment + * query to a device. The returned handle can be used throughout the @ref + * client_environment_query_interface "client environment query interface" to + * refer to the environment query. + * @param[in] device The device to create the environment query on. Must not be + * @c NULL. + * @param[out] query A pointer to a handle that will store the created + * environment query. Must not be @c NULL. The job must be freed by calling @ref + * QDMI_environment_query_free when it is no longer used. + * @return @ref QDMI_SUCCESS if the job was successfully created. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query creation failed due to + * a fatal error. + */ +int QDMI_device_create_environment_query(QDMI_Device device, + QDMI_Environment_Query *query); + +/** + * @brief Enum of the environment query parameters that can be set. + * @details If not noted otherwise, parameters are mandatory and drivers must + * require them to be set. + */ + enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { + /// The start time of the environment query interval. QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, + /// The end time of the environment query interval. QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, + /// The environment for the environment query. QDMI_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, + /// The maximum value of the enum. QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, + /** + * @brief This enum value is reserved for a custom parameter. + * @details The driver defines the meaning and the type of this parameter. + * @attention The value of this enum member must not be changed to maintain + * binary compatibility. + */ QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, + /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, + /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, + /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, + /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 }; +/// Environment query parameter type. typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T QDMI_Environment_Query_Parameter; - -typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; - -int QDMI_device_create_environment_query(QDMI_Device dev, - QDMI_Environment_Query *query); - +/** + * @brief Set a parameter for an environment. + * @param[in] query A handle to a job for which to set @p param. Must not be @c + * NULL. + * @param[in] param The parameter whose value will be set. Must be one of the + * values specified for @ref QDMI_Environment_Query_Parameter. + * @param[in] size The size of the data pointed to by @p value in bytes. Must + * not be zero, except when @p value is @c NULL, in which case it is ignored. + * @param[in] value A pointer to the memory location that contains the value of + * the parameter to be set. The data pointed to by @p value is copied and can be + * safely reused after this function returns. If this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the driver supports the specified @ref + * QDMI_Environment_Query_Parameter @p param and, when @p value is not @c NULL, + * the parameter was successfully set. + * @return @ref QDMI_ERROR_NOTSUPPORTED if the driver does not support the + * parameter or the value of the parameter. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p query is @c NULL, + * - @p param is invalid, or + * - @p value is not @c NULL and @p size is zero or not the expected size for + * the parameter (if specified by the @ref QDMI_Environment_Query_Parameter + * documentation). + * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the + * current state of the job, for example, because the query is already + * submitted. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal + * error. + * + * @note By calling this function with @p value set to @c NULL, the function can + * be used to check if the driver supports the specified parameter without + * setting the parameter and without the need to provide a value. + * + * @note For example, to check whether the device supports setting the start + * time for an envronment query, the following code pattern can be + * used: + * ``` + * // Check if the device supports setting the start time + * auto ret = QDMI_environment_query_set_parameter( + * query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, 0, nullptr); + * if (ret == QDMI_ERROR_NOTSUPPORTED) { + * // The device does not support setting the start time. + * ... + * } + * + * // Set the start time. + * uint64_t start_ts = 1744970400; + * QDMI_environment_query_set_parameter( + * query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), + * &start_ts); + * ``` + */ int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, QDMI_Environment_Query_Parameter param, size_t size, const void *value); - +/** + * @brief Submit an environment query to the device. + * @details This function can either be blocking until the environment query is + * finished or non-blocking and return while the environment query is running. + * In the latter case, the functions @ref QDMI_environment_query_check_status + * and @ref QDMI_environment_query_wait can be used to check the status and wait + * for the environment query to finish. + * @param[in] query The environment query to submit. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query was successfully + * submitted. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p environment query is @c NULL. + * @return @ref QDMI_ERROR_BADSTATE if the environment query is in an invalid + * state. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query submission failed. + */ int QDMI_environment_query_submit(QDMI_Environment_Query query); -int QDMI_environment_query_get_results(QDMI_Environment_Query query, - QDMI_Environment_Query_Result result, - size_t size, void *data, - size_t *size_ret); +/** + * @brief Cancel an already submitted environment query. + * @details Remove the environment query from the queue of waiting environment + * query. This changes the status of the environment query to @ref + * QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED. + * @param[in] query The environment query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query was successfully canceled. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the + * environment query already has the status @ref + * QDMI_ENVIRONMENT_QUERY_STATUS_DONE. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query could not be canceled. + */ +int QDMI_environment_query_cancel(QDMI_Environment_Query query); +/** + * @brief Check the status of an environment query. + * @details This function is non-blocking and returns immediately with the + * environment query status. It is not required to call this function before + * calling @ref QDMI_environment_query_get_results. + * @param[in] query The environment query to check the status of. Must not be @c + * NULL. + * @param[out] status The status of the environment query. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query status was successfully + * checked. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query status could not be + * checked. + */ int QDMI_environment_query_check_status(QDMI_Environment_Query query, QDMI_Environment_Query_Status *status); +/** + * @brief Wait for an environment query to finish. + * @details This function blocks until the environment query has either finished + * or has been canceled. + * @param[in] query The environment query to wait for. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query is finished or canceled. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query could not be waited + * for and this function returns before the environment query has finished or + * has been canceled. + */ int QDMI_environment_query_wait(QDMI_Environment_Query query); -int QDMI_environment_query_cancel(QDMI_Environment_Query query); - +/** + * @brief Retrieve the results of an environment query. + * @param[in] query The environment query to retrieve the results from. Must not + * be @c NULL. + * @param[in] result The result to retrieve. Must be one of the values specified + * for @ref QDMI_Environment_Query_Result. + * @param[in] size The size of the buffer pointed to by @p data in bytes. Must + * be greater or equal to the size of the return type specified for the @ref + * QDMI_Environment_Query_Result @p result, except when @p data is @c NULL, in + * which case it is ignored. + * @param[out] data A pointer to the memory location where the results will be + * stored. If this is @c NULL, it is ignored. + * @param[out] size_ret The actual size of the data being queried in bytes. If + * this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the device supports the specified result and, + * when @p data is not @c NULL, the results were successfully retrieved. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p query is @c NULL, + * - @p query has not finished, + * - @p query was canceled, + * - @p result is invalid, or + * - @p data is not @c NULL and @p size is smaller than the size of the data + * being queried. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using + * the @ref client_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. + * + * @note By calling this function with @p data set to @c NULL, the function can + * be used to check if the device supports the specified result without + * retrieving the result and without the need to provide a buffer for the + * result. + * Additionally, the size of the buffer needed to retrieve the result is + * returned in @p size_ret if @p size_ret is not @c NULL. + * + * @note For example, to query the results of a environment query, + * the following code pattern can be used: + * ``` + * // Query the size of the result. + * size_t size; + * auto ret = QDMI_environment_query_get_results( + * query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, &size); + * + * // Allocate memory for the result. + * std::vector values; + * values.reserve(size); + * + * // Query the result. + * QDMI_environment_query_get_results( + * query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, size, values.data(), nullptr); + * ``` + */ +int QDMI_environment_query_get_results(QDMI_Environment_Query query, + QDMI_Environment_Query_Result result, + size_t size, void *data, + size_t *size_ret); +/** + * @brief Free an environment query. + * @details Free the resources associated with a environment query. Using a + * environment query handle after it has been freed is undefined behavior. + * @param[in] query The environment query to free. + */ void QDMI_environment_query_free(QDMI_Environment_Query query); +/** @} */ // end of client_environment_query_interface + /** @} */ // end of client_interface // NOLINTEND(performance-enum-size, modernize-use-using) diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 0d51bbe1..fb359228 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -218,7 +218,7 @@ enum QDMI_DEVICE_PROPERTY_T { * QDMI_PROGRAM_FORMAT_CALIBRATION. */ QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION = 8, - /* + /** * TODO */ QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES = 9, @@ -647,96 +647,151 @@ enum QDMI_JOB_RESULT_T { /// Job result type. typedef enum QDMI_JOB_RESULT_T QDMI_Job_Result; -/* - * - * TODO - */ +/// Enum of the enviroment properties that can be queried via @ref +/// QDMI_device_session_query_environment_property as part of the @ref +/// device_interface "device interface" and via @ref +/// QDMI_device_query_environment_property as part of the @ref client_interface +/// "client interface". enum QDMI_ENVIRONMENT_PROPERTY_T { - + /// `char*` The ID of a environment. QDMI_ENVIRONMENT_PROPERTY_ID = 0, - + /// `char*` The unit of an environment, i.e., Kelvin. QDMI_ENVIRONMENT_PROPERTY_UNIT = 1, - + /// `unsigned int` The sampiling rate of an environment in seconds. QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE = 2, - + /** + * @brief The maximum value of the enum. + * @details It can be used by devices for bounds checking and validation of + * function parameters. + * + * @attention This value must remain the last regular member of the enum + * besides the custom members and must be updated when new members are added. + */ QDMI_ENVIRONMENT_PROPERTY_MAX = 3, - + /** + * @brief This enum value is reserved for a custom property. + * @details The device defines the meaning and the type of this property. + * @attention The value of this enum member must not be changed to maintain + * binary compatibility. + */ QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 = 999999995, - + /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 = 999999996, - + /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 = 999999997, - + /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 = 999999998, - + /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 QDMI_ENVIRONMENT_PROPERTY_CUSTOM5 = 999999999 }; +/// Environment property type. typedef enum QDMI_ENVIRONMENT_PROPERTY_T QDMI_Environment_Property; +/** + * @brief Enum of the device environment query parameters that can be set via + * @ref QDMI_device_environment_query_set_parameter. + * @details If not noted otherwise, parameters are mandatory and devices must + * require them to be set. + */ enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T { - + /// The start time of the environment query interval. QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, - + /// The end time of the environment query interval. QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, - - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENTVARIABLES = 2, - + /// The environment for the environment query. + QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, + /// The maximum value of the enum. QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, - + /** + * @brief This enum value is reserved for a custom parameter. + * @details The devices defines the meaning and the type of this parameter. + * @attention The value of this enum member must not be changed to maintain + * binary compatibility. + */ QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, - + /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, - + /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, - + /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, - + /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 }; +/// Device environment query parameter type. typedef enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T QDMI_Device_Environment_Query_Parameter; +/** + * @brief Enum of the formats the environment query results can be returned in. + */ enum QDMI_ENVIRONMENT_QUERY_RESULT_T { - + /** + * @brief `uint64_t*` (`unsigned 64 bit integer` list) The timestamps of the + * result + * @details The result of an environment query is represented as a key-value + * mapping. This mapping is returned as a list of keys and an equal-length + * list of values. The corresponding partners of the keys and values can be + * found at the same index in the lists + */ QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS = 0, - + /** + * @brief `float*` (`float` list) The values of the result. + * @see QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS + */ QDMI_ENVIRONMENT_QUERY_RESULT_VALUES = 1, - + /** + * @brief The maximum value of the enum. + * @details It can be used by devices for bounds checking and validation of + * function parameters. + * + * @attention This value must remain the last regular member of the enum + * besides the custom members and must be updated when new members are added. + */ QDMI_ENVIRONMENT_QUERY_RESULT_MAX = 2, - + /** + * @brief This enum value is reserved for a custom result. + * @details The device defines the meaning and the type of this result. + * @attention The value of this enum member must not be changed to maintain + * binary compatibility. + */ QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 = 999999995, - + /// @see QDMI_JOB_RESULT_CUSTOM1 QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 = 999999996, - + /// @see QDMI_JOB_RESULT_CUSTOM1 QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 = 999999997, - + /// @see QDMI_JOB_RESULT_CUSTOM1 QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 = 999999998, - + /// @see QDMI_JOB_RESULT_CUSTOM1 QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5 = 999999999 }; - -/// Job result type. +/// Environment query result type. typedef enum QDMI_ENVIRONMENT_QUERY_RESULT_T QDMI_Environment_Query_Result; +/** + * @brief Enum of the status Environment query can have. + * @details See also @ref client_environment_query_interface for a description + * of the environment query's lifecycle. + */ + enum QDMI_ENVIRONMENT_QUERY_STATUS_T { /** - * @brief The job was created and can be configured via @ref - * QDMI_job_set_parameter. + * @brief The environment query was created and can be configured via @ref + * QDMI_environment_query_set_parameter. */ QDMI_ENVIRONMENT_QUERY_STATUS_CREATED = 0, - /// The job was submitted and is waiting to be executed. + /// The environment query was submitted and is waiting to be executed. QDMI_ENVIRONMENT_QUERY_STATUS_SUBMITTED = 1, - /// The job is done, and the result can be retrieved. + /// The environment query is done, and the result can be retrieved. QDMI_ENVIRONMENT_QUERY_STATUS_DONE = 2, - /// The job is running, and the result is not yet available. + /// The environment query is running, and the result is not yet available. QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING = 3, - /// The job was canceled, and the result is not available. + /// The environment query was canceled, and the result is not available. QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED = 4 }; - -/// Job status type. +/// Environment query status type. typedef enum QDMI_ENVIRONMENT_QUERY_STATUS_T QDMI_Environment_Query_Status; // NOLINTEND(performance-enum-size, modernize-use-using) diff --git a/include/qdmi/device.h b/include/qdmi/device.h index f951e9c1..73ebe419 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -351,8 +351,44 @@ int QDMI_device_session_query_operation_property( QDMI_Device_Session session, QDMI_Operation operation, size_t num_sites, const QDMI_Site *sites, size_t num_params, const double *params, QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); -/* - * TODO + +/** + * @brief Query an environment property. + * @param[in] session The session used for the query. Must not be @c NULL. + * @param[in] environment The environment to query. Must not be @c NULL. + * @param[in] prop The property to query. Must be one of the values specified + * for @ref QDMI_Environment_Property. + * @param[in] size The size of the memory pointed to by @p value in bytes. Must + * be greater or equal to the size of the return type specified for @p prop, + * except when @p value is @c NULL, in which case it is ignored. + * @param[out] value A pointer to the memory location where the value of the + * property will be stored. If this is @c NULL, it is ignored. + * @param[out] size_ret The actual size of the data being queried in bytes. If + * this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the device supports the specified property and, + * when @p value is not @c NULL, the property was successfully retrieved. + * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the + * property. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p session or @p query is @c NULL, + * - @p prop is invalid, or + * - @p value is not @c NULL and @p size is less than the size of the data + * being queried. + * @return @ref QDMI_ERROR_BADSTATE if the property cannot be queried in the + * current state of the session, for example, because the session is not + * initialized. + * @return @ref QDMI_ERROR_FATAL if an unexpected error occurred. + * + * @remark Calling this function with @p value set to @c NULL is expected to + * allow checking if the device supports the specified property without + * retrieving the property and without the need to provide a buffer for it. + * Additionally, the size of the buffer needed to retrieve the property is + * returned in @p size_ret if @p size_ret is not @c NULL. + * See the @ref QDMI_device_query_environment_property documentation for an + * example. + * + * @attention May only be called after the session has been initialized with + * @ref QDMI_device_session_init. */ int QDMI_device_session_query_environment_property( @@ -556,37 +592,230 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @} */ // end of device_job_interface -/* - * TODO Documentation +/** @defgroup device_environment_query_interface QDMI Device Environment Query + * Interface + * @brief Provides functions to manage environment queries on a device. + * @details An environment query is a task submitted to a device for querying + * environmental variables, i.e. temperature or power. * + * The typical workflow for a device environment query is as follows: + * - Create an environment query with @ref + * QDMI_device_session_create_environment_query. + * - Set parameters for the environment query with @ref + * QDMI_device_environment_query_set_parameter + * - Submit the environment query to the device with @ref + * QDMI_device_environment_query_submit. + * - Check the status of the environment query with @ref + * QDMI_device_environment_query_check_status. + * - Wait for the environment query to finish with @ref + * QDMI_device_environment_query_wait. + * - Retrieve the results of the environment query with @ref + * QDMI_environment_query_get_results. + * - Free the environment query with @ref QDMI_device_environment_query_free + * when it is no longer used. + * + * @{ */ +/** + * @brief A handle for a device environment query. + * @details An opaque pointer to a type defined by the device that encapsulates + * all information about an environment query on a device. + * @remark Implementations of the underlying type will want to store the session + * handle used to create the environment query in the environment query handle + * to be able to access the session information when needed. + * @see QDMI_Environment_Query for the client-side job handle. + */ typedef struct QDMI_Device_Environment_Query_impl_d *QDMI_Device_Environment_Query; - +/** + * @brief Create an environment query. + * @details This is the main entry point for a driver to create an environment + * query for a device. The returned handle can be used throughout the @ref + * device_environment_query_interface "device environment query interface" to + * refer to the environment query. + * @param[in] session The session to create the environment query on. Must not + * be @c NULL. + * @param[out] query A pointer to a handle that will store the created + * environment query. Must not be @c NULL. The environment query must be freed + * by calling + * @ref QDMI_device_environment_query_free when it is no longer used. + * @return @ref QDMI_SUCCESS if the environment query was successfully created. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p session or @p query are @c + * NULL. + * @return @ref QDMI_ERROR_BADSTATE if the session is not in a state allowing + * the creation of an environment query, for example, because the session is not + * initialized. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if environment query creation failed due to a + * fatal error. + * + * @attention May only be called after the session has been initialized with + * @ref QDMI_device_session_init. + */ int QDMI_device_session_create_environment_query( QDMI_Device_Session session, QDMI_Device_Environment_Query *query); - +/** + * @brief Set a parameter for an environment query. + * @param[in] query A handle to an environment query for which to set @p param. + * Must not be @c NULL. + * @param[in] param The parameter whose value will be set. Must be one of the + * values specified for @ref QDMI_Device_Environment_Query_Parameter. + * @param[in] size The size of the data pointed to by @p value in bytes. Must + * not be zero, except when @p value is @c NULL, in which case it is ignored. + * @param[in] value A pointer to the memory location that contains the value of + * the parameter to be set. The data pointed to by @p value is copied and can be + * safely reused after this function returns. If this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the device supports the specified @ref + * QDMI_Device_Environment_Query_Parameter @p param and, when @p value is not @c + * NULL, the parameter was successfully set. + * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the + * parameter or the value of the parameter. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p query is @c NULL, + * - @p param is invalid, or + * - @p value is not @c NULL and @p size is zero or not the expected size for + * the parameter (if specified by the @ref + * QDMI_Device_Environment_Query_Parameter documentation). + * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the + * current state of the environment query, for example, because the environment + * query is already submitted. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal + * error. + * + * @remark Calling this function with @p value set to @c NULL is expected to + * allow checking if the device supports the specified parameter without setting + * the parameter and without the need to provide a value. + * See the @ref QDMI_environment_query_set_parameter documentation for an + * example. + */ int QDMI_device_environment_query_set_parameter( QDMI_Device_Environment_Query query, QDMI_Device_Environment_Query_Parameter param, size_t size, const void *value); - +/** + * @brief Submit an environment query to the device. + * @details This function can either be blocking until the job is finished or + * non-blocking and return while the job is running. In the latter case, the + * functions @ref QDMI_device_environment_query_check_status and @ref + * QDMI_device_environment_query_wait can be used to check the status and wait + * for the environment query to finish. + * @param[in] query The environment query to submit. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the job was successfully submitted. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p job is @c NULL. + * @return @ref QDMI_ERROR_BADSTATE if the job is in an invalid state. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the job submission failed. + */ int QDMI_device_environment_query_submit(QDMI_Device_Environment_Query query); -int QDMI_device_environment_query_get_results( - QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, - size_t size, void *data, size_t *size_ret); +/** + * @brief Cancel an already submitted environment query. + * @details Remove the environment query from the queue of waiting environment + * query. This changes the status of the environment query to @ref + * QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED. + * @param[in] query The environment query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query was successfully canceled. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the job + * already has the status @ref QDMI_ENVIRONMENT_QUERY_STATUS_DONE. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query could not be canceled. + */ +int QDMI_device_environment_query_cancel(QDMI_Device_Environment_Query query); +/** + * @brief Check the status of an environment query. + * @details This function is non-blocking and returns immediately with the + * environment query status. It is not required to call this function before + * calling @ref QDMI_environment_query_get_results. + * @param[in] query The environment query to check the status of. Must not be @c + * NULL. + * @param[out] status The status of the environment query. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query status was successfully + * checked. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "client environment query + * interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query status could not be + * checked. + */ int QDMI_device_environment_query_check_status( QDMI_Device_Environment_Query query, QDMI_Environment_Query_Status *status); - +/** + * @brief Wait for an environment query to finish. + * @details This function blocks until the environment query has either finished + * or has been canceled. + * @param[in] query The environment query to wait for. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment query is finished or canceled. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the environment query could not be waited + * for and this function returns before the environment query has finished or + * has been canceled. + */ int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); -int QDMI_device_environment_query_cancel(QDMI_Device_Environment_Query query); - +/** + * @brief Retrieve the results of an environment query. + * @param[in] query The environment query to retrieve the results from. Must not + * be @c NULL. + * @param[in] result The result to retrieve. Must be one of the values specified + * for @ref QDMI_Environment_Query_Result. + * @param[in] size The size of the buffer pointed to by @p data in bytes. Must + * be greater or equal to the size of the return type specified for the @ref + * QDMI_Environment_Query_Result @p result, except when @p data is @c NULL, in + * which case it is ignored. + * @param[out] data A pointer to the memory location where the results will be + * stored. If this is @c NULL, it is ignored. + * @param[out] size_ret The actual size of the data being queried in bytes. If + * this is @c NULL, it is ignored. + * @return @ref QDMI_SUCCESS if the device supports the specified result and, + * when @p data is not @c NULL, the results were successfully retrieved. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if + * - @p query is @c NULL, + * - @p query has not finished, + * - @p query was canceled, + * - @p result is invalid, or + * - @p data is not @c NULL and @p size is smaller than the size of the data + * being queried. + * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using + * the @ref device_environment_query_interface "device environment query + * interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. + * + * @remark Calling this function with @p data set to @c NULL is expected to + * allow checking if the device supports the specified result without + * retrieving the result and without the need to provide a buffer for the + * result. + * Additionally, the size of the buffer required to retrieve the result is + * returned in @p size_ret if @p size_ret is not @c NULL. + * See the @ref QDMI_environment_query_get_results documentation for an example. + */ +int QDMI_device_environment_query_get_results( + QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, + size_t size, void *data, size_t *size_ret); +/** + * @brief Free an environment query. + * @details Free the resources associated with a environment query. Using a + * environment query handle after it has been freed is undefined behavior. + * @param[in] query The environment query to free. + */ void QDMI_device_environment_query_free(QDMI_Device_Environment_Query query); +/** @} */ // end of device_environment_query_interface + /** @} */ // end of device_interface // NOLINTEND(performance-enum-size,modernize-use-using,modernize-redundant-void-arg) diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 7f168541..0e48fc17 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -71,8 +71,23 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; */ typedef struct QDMI_Operation_impl_d *QDMI_Operation; -/* - * TODO +/** + * @brief A handle for an environment. + * @details An opaque pointer to an implementation of the QDMI environment + * concept. The environmental factors of the laboratories can affect the + * operations and measurement results of quantum devices. Therefore, they are + * closely monitored. An environment generally represents any sensors that can + * be queried. They might be sensors for tempature, noise, etc. Each + * implementation of the @ref device_interface "QDMI Device Interface" defines the actual + * implementation of the concept. + * + * A simple example of an implementation is a struct that merely contains the + * environment ID, which can be used to identify the site. + * ``` + * struct QDMI_Environment_impl_d { + * char* id; + * }; + * ``` */ typedef struct QDMI_Environment_impl_d *QDMI_Environment; From ba5a67673e3e49c2f89c114ac48a0d102d949d6d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 05:37:49 +0000 Subject: [PATCH 20/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 2 +- include/qdmi/constants.h | 2 +- include/qdmi/types.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index b6f730c4..0da671d6 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -593,7 +593,7 @@ int QDMI_device_query_operation_property( * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, * &environment_unit_size); * if (ret != QDMI_SUCCESS) { - * // An error occured. + * // An error occurred. * ... * } * std::string environment_unit(environment_unit_size - 1, '\0'); diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index fb359228..6a62703f 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -647,7 +647,7 @@ enum QDMI_JOB_RESULT_T { /// Job result type. typedef enum QDMI_JOB_RESULT_T QDMI_Job_Result; -/// Enum of the enviroment properties that can be queried via @ref +/// Enum of the environment properties that can be queried via @ref /// QDMI_device_session_query_environment_property as part of the @ref /// device_interface "device interface" and via @ref /// QDMI_device_query_environment_property as part of the @ref client_interface diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 0e48fc17..3c29f1ca 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -77,9 +77,9 @@ typedef struct QDMI_Operation_impl_d *QDMI_Operation; * concept. The environmental factors of the laboratories can affect the * operations and measurement results of quantum devices. Therefore, they are * closely monitored. An environment generally represents any sensors that can - * be queried. They might be sensors for tempature, noise, etc. Each - * implementation of the @ref device_interface "QDMI Device Interface" defines the actual - * implementation of the concept. + * be queried. They might be sensors for temperature, noise, etc. Each + * implementation of the @ref device_interface "QDMI Device Interface" defines + * the actual implementation of the concept. * * A simple example of an implementation is a struct that merely contains the * environment ID, which can be used to identify the site. From e67355fc09233e6123e8f0bdf874ccbc07920360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 19 May 2025 14:47:41 +0200 Subject: [PATCH 21/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20updates=20on=20docum?= =?UTF-8?q?entation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/constants.h | 44 +++++++++++++++++++++++++--------------- include/qdmi/types.h | 2 +- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 6a62703f..9dfa00cb 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -653,26 +653,34 @@ typedef enum QDMI_JOB_RESULT_T QDMI_Job_Result; /// QDMI_device_query_environment_property as part of the @ref client_interface /// "client interface". enum QDMI_ENVIRONMENT_PROPERTY_T { - /// `char*` The ID of a environment. + /** + * @brief `char*` (string) The unique ID to identify the environment. + * @details TThe ID of an environment is used to identify the sensors. The + * sensors collect environmental data in the HPCQC Labs, i.e., temperature and + * pressure. + */ QDMI_ENVIRONMENT_PROPERTY_ID = 0, - /// `char*` The unit of an environment, i.e., Kelvin. + /// `char*` (string) The unit of an environment variable, e.g., Kelvin for + /// temperature. QDMI_ENVIRONMENT_PROPERTY_UNIT = 1, - /// `unsigned int` The sampiling rate of an environment in seconds. + /// `float` The samples per second of an environment. QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE = 2, /** * @brief The maximum value of the enum. - * @details It can be used by devices for bounds checking and validation of - * function parameters. + * @details It can be used by devices for bounds checking and + * validation of function parameters. * - * @attention This value must remain the last regular member of the enum - * besides the custom members and must be updated when new members are added. + * @attention This value must remain the last regular member of the + * enum besides the custom members and must be updated when new + * members are added. */ QDMI_ENVIRONMENT_PROPERTY_MAX = 3, /** * @brief This enum value is reserved for a custom property. - * @details The device defines the meaning and the type of this property. - * @attention The value of this enum member must not be changed to maintain - * binary compatibility. + * @details The device defines the meaning and the type of this + * property. + * @attention The value of this enum member must not be changed to + * maintain binary compatibility. */ QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 = 999999995, /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 @@ -729,8 +737,8 @@ typedef enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T */ enum QDMI_ENVIRONMENT_QUERY_RESULT_T { /** - * @brief `uint64_t*` (`unsigned 64 bit integer` list) The timestamps of the - * result + * @brief `uint64_t*` (`unsigned 64 bit integer` list) The timestamps at which + * the corresponding values in the results were recorded by a sensor. * @details The result of an environment query is represented as a key-value * mapping. This mapping is returned as a list of keys and an equal-length * list of values. The corresponding partners of the keys and values can be @@ -782,14 +790,18 @@ enum QDMI_ENVIRONMENT_QUERY_STATUS_T { * QDMI_environment_query_set_parameter. */ QDMI_ENVIRONMENT_QUERY_STATUS_CREATED = 0, - /// The environment query was submitted and is waiting to be executed. + /// The environment query was submitted. QDMI_ENVIRONMENT_QUERY_STATUS_SUBMITTED = 1, - /// The environment query is done, and the result can be retrieved. - QDMI_ENVIRONMENT_QUERY_STATUS_DONE = 2, + /// The environment query was received is waiting to be executed. + QDMI_ENVIRONMENT_QUERY_STATUS_QUEUED = 2, /// The environment query is running, and the result is not yet available. QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING = 3, + /// The environment query is done, and the result can be retrieved. + QDMI_ENVIRONMENT_QUERY_STATUS_DONE = 4, /// The environment query was canceled, and the result is not available. - QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED = 4 + QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED = 5, + /// An error occurred in the environment query's lifecycle. + QDMI_ENVIRONMENT_QUERY_STATUS_FAILED = 6 }; /// Environment query status type. typedef enum QDMI_ENVIRONMENT_QUERY_STATUS_T QDMI_Environment_Query_Status; diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 3c29f1ca..b2c5c0b8 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,7 +72,7 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** - * @brief A handle for an environment. + * @brief A handle for an environment variable. * @details An opaque pointer to an implementation of the QDMI environment * concept. The environmental factors of the laboratories can affect the * operations and measurement results of quantum devices. Therefore, they are From 94e4b255a48975b81bc68e37a072e78a05768aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Fri, 13 Jun 2025 16:20:20 +0200 Subject: [PATCH 22/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Better=20naming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/prefix_defs.txt | 26 +- examples/device/c/device.c | 138 ++++----- examples/device/cxx/device.cpp | 142 ++++----- examples/driver/qdmi_example_driver.cpp | 108 +++---- examples/fomac/example_fomac.cpp | 62 ++-- examples/fomac/example_fomac.hpp | 8 +- include/qdmi/client.h | 365 +++++++++++++----------- include/qdmi/constants.h | 154 +++++----- include/qdmi/device.h | 277 +++++++++--------- include/qdmi/types.h | 14 +- test/test_qdmi.cpp | 50 ++-- 11 files changed, 692 insertions(+), 652 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index 08119ef6..265696b1 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -24,16 +24,16 @@ QDMI_Site QDMI_Site_impl_d QDMI_Operation QDMI_Operation_impl_d -QDMI_Environment -QDMI_Environment_impl_d -QDMI_Device_Environment_Query -QDMI_Device_Environment_Query_impl_d -QDMI_device_session_query_environment_property -QDMI_device_session_create_environment_query -QDMI_device_environment_query_set_parameter -QDMI_device_environment_query_submit -QDMI_device_environment_query_get_results -QDMI_device_environment_query_check_status -QDMI_device_environment_query_wait -QDMI_device_environment_query_cancel -QDMI_device_environment_query_free +QDMI_EnvironmentSensor +QDMI_EnvironmentSensor_impl_d +QDMI_Device_EnvironmentSensor_Query +QDMI_Device_EnvironmentSensor_Query_impl_d +QDMI_device_session_query_environmentsensor_property +QDMI_device_session_create_environmentsensor_query +QDMI_device_environmentsensor_query_set_parameter +QDMI_device_environmentsensor_query_submit +QDMI_device_environmentsensor_query_get_results +QDMI_device_environmentsensor_query_check_status +QDMI_device_environmentsensor_query_wait +QDMI_device_environmentsensor_query_cancel +QDMI_device_environmentsensor_query_free diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 5b78bfba..9abf2edf 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -60,21 +60,21 @@ typedef struct C_QDMI_Operation_impl_d { char *name; } C_QDMI_Operation_impl_t; -typedef struct C_QDMI_Environment_impl_d { +typedef struct C_QDMI_EnvironmentSensor_impl_d { char *id; char *unit; int sampling_rate; // in seconds -} C_QDMI_Environment_impl_t; +} C_QDMI_EnvironmentSensor_impl_t; -typedef struct C_QDMI_Device_Environment_Query_impl_d { +typedef struct C_QDMI_Device_EnvironmentSensor_Query_impl_d { time_t start_time; time_t end_time; - C_QDMI_Environment environment; + C_QDMI_EnvironmentSensor environment_sensor; time_t *result_timestamps; float *result_values; size_t result_length; - QDMI_Environment_Query_Status status; -} C_QDMI_Device_Environment_Query_impl_t; + QDMI_EnvironmentSensor_Query_Status status; +} C_QDMI_Device_EnvironmentSensor_Query_impl_t; /** * @brief Static function to maintain the device status. @@ -106,8 +106,8 @@ void C_QDMI_set_device_status(QDMI_Device_Status status) { QDMI_Device_Status C_QDMI_read_device_status(void) { return *C_QDMI_get_device_status(); } -const C_QDMI_Environment C_DEVICE_ENVIRONMENTS[] = { - &(C_QDMI_Environment_impl_t){"t4k", "K", 60}, +const C_QDMI_EnvironmentSensor C_DEVICE_ENVIRONMENTSENSORS[] = { + &(C_QDMI_EnvironmentSensor_impl_t){"t4k", "K", 60}, }; const C_QDMI_Site C_DEVICE_SITES[] = { @@ -744,8 +744,8 @@ int C_QDMI_device_session_query_device_property(C_QDMI_Device_Session session, // The example device never requires calibration ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) - ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, - C_QDMI_Environment, C_DEVICE_ENVIRONMENTS, 1, prop, size, + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, + C_QDMI_EnvironmentSensor, C_DEVICE_ENVIRONMENTSENSORS, 1, prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; @@ -866,32 +866,32 @@ int C_QDMI_device_session_query_operation_property( return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] -int C_QDMI_device_session_query_environment_property( - C_QDMI_Device_Session session, C_QDMI_Environment environment, - QDMI_Environment_Property prop, size_t size, void *value, +int C_QDMI_device_session_query_environmentsensor_property( + C_QDMI_Device_Session session, C_QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, size_t size, void *value, size_t *size_ret) { - if (session == NULL || environment == NULL || (value != NULL && size == 0) || - (prop >= QDMI_ENVIRONMENT_PROPERTY_MAX && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM5)) { + if (session == NULL || environment_sensor == NULL || (value != NULL && size == 0) || + (prop >= QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM3 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM4 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } - ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_ID, environment->id, prop, size, + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, environment_sensor->id, prop, size, value, size_ret) - ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_UNIT, environment->unit, prop, + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, environment_sensor->unit, prop, size, value, size_ret) - ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, int, - environment->sampling_rate, prop, size, value, + ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, int, + environment_sensor->sampling_rate, prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } -int C_QDMI_device_session_create_environment_query( - C_QDMI_Device_Session session, C_QDMI_Device_Environment_Query *query) { +int C_QDMI_device_session_create_environmentsensor_query( + C_QDMI_Device_Session session, C_QDMI_Device_EnvironmentSensor_Query *query) { if (session == NULL || query == NULL) { return QDMI_ERROR_INVALIDARGUMENT; @@ -899,48 +899,48 @@ int C_QDMI_device_session_create_environment_query( if (session->status != INITIALIZED) { return QDMI_ERROR_BADSTATE; } - *query = malloc(sizeof(C_QDMI_Device_Environment_Query_impl_t)); - (*query)->environment = malloc(sizeof(C_QDMI_Environment)); + *query = malloc(sizeof(C_QDMI_Device_EnvironmentSensor_Query_impl_t)); + (*query)->environment_sensor = malloc(sizeof(C_QDMI_EnvironmentSensor)); (*query)->start_time = time(NULL); (*query)->end_time = time(NULL); return QDMI_SUCCESS; } -int C_QDMI_device_environment_query_set_parameter( - C_QDMI_Device_Environment_Query query, - QDMI_Device_Environment_Query_Parameter param, size_t size, +int C_QDMI_device_environmentsensor_query_set_parameter( + C_QDMI_Device_EnvironmentSensor_Query query, + QDMI_Device_EnvironmentSensor_Query_Parameter param, size_t size, const void *value) { if (query == NULL || (value != NULL && size == 0) || - (param >= QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5)) { + (param >= QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME: + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME: query->start_time = *(time_t *)(value); return QDMI_SUCCESS; - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME: + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME: query->end_time = *(time_t *)(value); return QDMI_SUCCESS; - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT: - query->environment = *(C_QDMI_Environment *)(value); + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR: + query->environment_sensor = *(C_QDMI_EnvironmentSensor *)(value); return QDMI_SUCCESS; default: return QDMI_ERROR_NOTSUPPORTED; } } -int C_QDMI_device_environment_query_submit( - C_QDMI_Device_Environment_Query query) { +int C_QDMI_device_environmentsensor_query_submit( + C_QDMI_Device_EnvironmentSensor_Query query) { - if (query == NULL || query->environment == NULL) { + if (query == NULL || query->environment_sensor == NULL) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -951,7 +951,7 @@ int C_QDMI_device_environment_query_submit( // here, the actual submission. // for demonstration purposes - int sampling_rate = query->environment->sampling_rate; + int sampling_rate = query->environment_sensor->sampling_rate; size_t result_length = (size_t)(time_difference / sampling_rate); @@ -967,22 +967,22 @@ int C_QDMI_device_environment_query_submit( return QDMI_SUCCESS; } -int C_QDMI_device_environment_query_get_results( - C_QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, +int C_QDMI_device_environmentsensor_query_get_results( + C_QDMI_Device_EnvironmentSensor_Query query, QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, size_t *size_ret) { if (query == NULL || (data != NULL && size == 0) || - (result >= QDMI_ENVIRONMENT_QUERY_RESULT_MAX && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5)) { + (result >= QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM1 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM2 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM3 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM4 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } size_t req_size = query->result_length; switch (result) { - case QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS: + case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS: req_size *= sizeof(time_t); if (data != NULL) { if (size < req_size) { @@ -995,7 +995,7 @@ int C_QDMI_device_environment_query_get_results( *(size_ret) = req_size; } return QDMI_SUCCESS; - case QDMI_ENVIRONMENT_QUERY_RESULT_VALUES: + case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES: req_size *= sizeof(float); if (data != NULL) { @@ -1016,48 +1016,48 @@ int C_QDMI_device_environment_query_get_results( return QDMI_SUCCESS; } -int C_QDMI_device_environment_query_check_status( - C_QDMI_Device_Environment_Query query, - QDMI_Environment_Query_Status *status) { +int C_QDMI_device_environmentsensor_query_check_status( + C_QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status) { if (query == NULL || status == NULL) { return QDMI_ERROR_INVALIDARGUMENT; } // randomly decide whether job is done or not - if (query->status == QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING && + if (query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_RUNNING && rand() % 2 == 0) { - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; } *status = query->status; return QDMI_SUCCESS; } -int C_QDMI_device_environment_query_wait( - C_QDMI_Device_Environment_Query query) { +int C_QDMI_device_environmentsensor_query_wait( + C_QDMI_Device_EnvironmentSensor_Query query) { if (query == NULL) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; return QDMI_SUCCESS; } -int C_QDMI_device_environment_query_cancel( - C_QDMI_Device_Environment_Query query) { +int C_QDMI_device_environmentsensor_query_cancel( + C_QDMI_Device_EnvironmentSensor_Query query) { - if (query == NULL || query->status == QDMI_ENVIRONMENT_QUERY_STATUS_DONE) { + if (query == NULL || query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED; return QDMI_SUCCESS; } -void C_QDMI_device_environment_query_free( - C_QDMI_Device_Environment_Query query) { +void C_QDMI_device_environmentsensor_query_free( + C_QDMI_Device_EnvironmentSensor_Query query) { free(query->result_timestamps); query->result_timestamps = NULL; diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index aac8ff47..f1b0ec90 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -80,21 +80,21 @@ struct CXX_QDMI_Operation_impl_d { std::string name; }; -struct CXX_QDMI_Environment_impl_d { +struct CXX_QDMI_EnvironmentSensor_impl_d { std::string id; std::string unit; std::chrono::duration sampling_rate{}; // in seconds }; -struct CXX_QDMI_Device_Environment_Query_impl_d { +struct CXX_QDMI_Device_EnvironmentSensor_Query_impl_d { std::chrono::time_point start_time{}; std::chrono::time_point end_time{}; - CXX_QDMI_Environment environment{}; + CXX_QDMI_EnvironmentSensor environment_sensor{}; std::vector> result_timestamps; std::vector result_values; size_t result_length{}; - QDMI_Environment_Query_Status status{}; + QDMI_EnvironmentSensor_Query_Status status{}; }; namespace { @@ -179,11 +179,11 @@ constexpr CXX_QDMI_Site_impl_d SITE4{4}; constexpr std::array CXX_DEVICE_SITES = { &SITE0, &SITE1, &SITE2, &SITE3, &SITE4}; -const CXX_QDMI_Environment_impl_d ENV0{"t4k", "K", +const CXX_QDMI_EnvironmentSensor_impl_d ENVSEN{"t4k", "K", std::chrono::duration{60}}; -constexpr std::array - CXX_DEVICE_ENVIRONMENTS{&ENV0}; +constexpr std::array + CXX_DEVICE_ENVIRONMENTSENSORS{&ENVSEN}; constexpr std::array // clang-format off @@ -799,8 +799,8 @@ int CXX_QDMI_device_session_query_device_property( ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) - ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, - CXX_QDMI_Environment, CXX_DEVICE_ENVIRONMENTS, prop, size, + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, + CXX_QDMI_EnvironmentSensor, CXX_DEVICE_ENVIRONMENTSENSORS, prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; @@ -899,32 +899,32 @@ int CXX_QDMI_device_session_query_operation_property( return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] -int CXX_QDMI_device_session_query_environment_property( - CXX_QDMI_Device_Session session, CXX_QDMI_Environment environment, - QDMI_Environment_Property prop, size_t size, void *value, +int CXX_QDMI_device_session_query_environmentsensor_property( + CXX_QDMI_Device_Session session, CXX_QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, size_t size, void *value, size_t *size_ret) { - if (session == nullptr || environment == nullptr || + if (session == nullptr || environment_sensor == nullptr || (value != nullptr && size == 0) || - (prop >= QDMI_ENVIRONMENT_PROPERTY_MAX && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 && - prop != QDMI_ENVIRONMENT_PROPERTY_CUSTOM5)) { + (prop >= QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM3 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM4 && + prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } - ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_ID, environment->id.c_str(), + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, environment_sensor->id.c_str(), prop, size, value, size_ret) - ADD_STRING_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_UNIT, environment->unit.c_str(), + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, environment_sensor->unit.c_str(), prop, size, value, size_ret) - ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, int, - environment->sampling_rate.count(), prop, size, + ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, int, + environment_sensor->sampling_rate.count(), prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } -int CXX_QDMI_device_session_create_environment_query( - CXX_QDMI_Device_Session session, CXX_QDMI_Device_Environment_Query *query) { +int CXX_QDMI_device_session_create_environmentsensor_query( + CXX_QDMI_Device_Session session, CXX_QDMI_Device_EnvironmentSensor_Query *query) { if (session == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -932,47 +932,47 @@ int CXX_QDMI_device_session_create_environment_query( if (session->status != CXX_QDMI_DEVICE_SESSION_STATUS::INITIALIZED) { return QDMI_ERROR_BADSTATE; } - *query = new CXX_QDMI_Device_Environment_Query_impl_d(); - (*query)->environment = new CXX_QDMI_Environment_impl_d(); + *query = new CXX_QDMI_Device_EnvironmentSensor_Query_impl_d(); + (*query)->environment_sensor = new CXX_QDMI_EnvironmentSensor_impl_d(); (*query)->start_time = std::chrono::system_clock::now(); (*query)->end_time = std::chrono::system_clock::now(); return QDMI_SUCCESS; } -int CXX_QDMI_device_environment_query_set_parameter( - CXX_QDMI_Device_Environment_Query query, - QDMI_Device_Environment_Query_Parameter param, size_t size, +int CXX_QDMI_device_environmentsensor_query_set_parameter( + CXX_QDMI_Device_EnvironmentSensor_Query query, + QDMI_Device_EnvironmentSensor_Query_Parameter param, size_t size, const void *value) { if (query == nullptr || (value != nullptr && size == 0) || - (param >= QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 && - param != QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5)) { + (param >= QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 && + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME: { + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME: { const auto *c_start_time_ptr = static_cast(value); query->start_time = std::chrono::system_clock::from_time_t(*c_start_time_ptr); return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME: { + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME: { const auto *c_end_time_ptr = static_cast(value); query->end_time = std::chrono::system_clock::from_time_t(*c_end_time_ptr); return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT: { + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR: { const auto *environment_ptr = - static_cast(value); - query->environment = *environment_ptr; + static_cast(value); + query->environment_sensor = *environment_ptr; return QDMI_SUCCESS; } default: @@ -980,10 +980,10 @@ int CXX_QDMI_device_environment_query_set_parameter( } } -int CXX_QDMI_device_environment_query_submit( - CXX_QDMI_Device_Environment_Query query) { +int CXX_QDMI_device_environmentsensor_query_submit( + CXX_QDMI_Device_EnvironmentSensor_Query query) { - if (query == nullptr || query->environment == nullptr) { + if (query == nullptr || query->environment_sensor == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -993,7 +993,7 @@ int CXX_QDMI_device_environment_query_submit( auto time_difference = std::chrono::round( query->end_time - query->start_time); - auto sampling_rate = query->environment->sampling_rate; + auto sampling_rate = query->environment_sensor->sampling_rate; auto result_length = static_cast(time_difference.count() / sampling_rate.count()); @@ -1009,7 +1009,7 @@ int CXX_QDMI_device_environment_query_submit( for (unsigned int i = 0; i < result_length; i++) { auto duration_to_add = std::chrono::duration_cast( - query->environment->sampling_rate * i); + query->environment_sensor->sampling_rate * i); auto next_time = query->start_time + duration_to_add; query->result_timestamps.emplace_back(next_time); query->result_values[i] = @@ -1019,23 +1019,23 @@ int CXX_QDMI_device_environment_query_submit( return QDMI_SUCCESS; } -int CXX_QDMI_device_environment_query_get_results( - CXX_QDMI_Device_Environment_Query query, - QDMI_Environment_Query_Result result, size_t size, void *data, +int CXX_QDMI_device_environmentsensor_query_get_results( + CXX_QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, size_t *size_ret) { if (query == nullptr || (data != nullptr && size == 0) || - (result >= QDMI_ENVIRONMENT_QUERY_RESULT_MAX && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 && - result != QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5)) { + (result >= QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM1 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM2 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM3 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM4 && + result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } size_t req_size = query->result_length; switch (result) { - case QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS: + case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS: req_size *= sizeof(time_t); if (data != nullptr) { if (size < req_size) { @@ -1052,7 +1052,7 @@ int CXX_QDMI_device_environment_query_get_results( *(size_ret) = req_size; } return QDMI_SUCCESS; - case QDMI_ENVIRONMENT_QUERY_RESULT_VALUES: + case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES: req_size *= sizeof(float); if (data != nullptr) { @@ -1073,47 +1073,47 @@ int CXX_QDMI_device_environment_query_get_results( return QDMI_SUCCESS; } -int CXX_QDMI_device_environment_query_check_status( - CXX_QDMI_Device_Environment_Query query, - QDMI_Environment_Query_Status *status) { +int CXX_QDMI_device_environmentsensor_query_check_status( + CXX_QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status) { if (query == nullptr || status == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } // randomly decide whether job is done or not - if (query->status == QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING && + if (query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_RUNNING && CXX_QDMI_generate_bit()) { - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; } *status = query->status; return QDMI_SUCCESS; } -int CXX_QDMI_device_environment_query_wait( - CXX_QDMI_Device_Environment_Query query) { +int CXX_QDMI_device_environmentsensor_query_wait( + CXX_QDMI_Device_EnvironmentSensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_DONE; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; return QDMI_SUCCESS; } -int CXX_QDMI_device_environment_query_cancel( - CXX_QDMI_Device_Environment_Query query) { +int CXX_QDMI_device_environmentsensor_query_cancel( + CXX_QDMI_Device_EnvironmentSensor_Query query) { - if (query == nullptr || query->status == QDMI_ENVIRONMENT_QUERY_STATUS_DONE) { + if (query == nullptr || query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED; + query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED; return QDMI_SUCCESS; } -void CXX_QDMI_device_environment_query_free( - CXX_QDMI_Device_Environment_Query query) { +void CXX_QDMI_device_environmentsensor_query_free( + CXX_QDMI_Device_EnvironmentSensor_Query query) { delete query; } diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 48065b20..b30b25f4 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -103,30 +103,30 @@ struct QDMI_Library { decltype(QDMI_device_session_query_operation_property) *device_session_query_operation_property{}; - decltype(QDMI_device_session_query_environment_property) - *device_session_query_environment_property{}; + decltype(QDMI_device_session_query_environmentsensor_property) + *device_session_query_environmentsensor_property{}; - decltype(QDMI_device_environment_query_set_parameter) - *device_environment_query_set_parameter{}; + decltype(QDMI_device_environmentsensor_query_set_parameter) + *device_environmentsensor_query_set_parameter{}; - decltype(QDMI_device_session_create_environment_query) - *device_session_create_environment_query{}; + decltype(QDMI_device_session_create_environmentsensor_query) + *device_session_create_environmentsensor_query{}; - decltype(QDMI_device_environment_query_submit) - *device_environment_query_submit{}; + decltype(QDMI_device_environmentsensor_query_submit) + *device_environmentsensor_query_submit{}; - decltype(QDMI_device_environment_query_get_results) - *device_environment_query_get_results{}; + decltype(QDMI_device_environmentsensor_query_get_results) + *device_environmentsensor_query_get_results{}; - decltype(QDMI_device_environment_query_check_status) - *device_environment_query_check_status{}; + decltype(QDMI_device_environmentsensor_query_check_status) + *device_environmentsensor_query_check_status{}; - decltype(QDMI_device_environment_query_wait) *device_environment_query_wait{}; + decltype(QDMI_device_environmentsensor_query_wait) *device_environmentsensor_query_wait{}; - decltype(QDMI_device_environment_query_cancel) - *device_environment_query_cancel{}; + decltype(QDMI_device_environmentsensor_query_cancel) + *device_environmentsensor_query_cancel{}; - decltype(QDMI_device_environment_query_free) *device_environment_query_free{}; + decltype(QDMI_device_environmentsensor_query_free) *device_environmentsensor_query_free{}; // default constructor QDMI_Library() = default; @@ -183,9 +183,9 @@ struct QDMI_Driver_State { std::unordered_set sessions; }; -struct QDMI_Environment_Query_impl_d { +struct QDMI_EnvironmentSensor_Query_impl_d { QDMI_Device device = nullptr; - QDMI_Device_Environment_Query env_query = nullptr; + QDMI_Device_EnvironmentSensor_Query env_query = nullptr; }; namespace { @@ -249,16 +249,16 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_device_property) LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) - LOAD_SYMBOL(library, prefix, device_session_query_environment_property) + LOAD_SYMBOL(library, prefix, device_session_query_environmentsensor_property) // device qnvironment interface - LOAD_SYMBOL(library, prefix, device_session_create_environment_query) - LOAD_SYMBOL(library, prefix, device_environment_query_set_parameter) - LOAD_SYMBOL(library, prefix, device_environment_query_submit) - LOAD_SYMBOL(library, prefix, device_environment_query_get_results) - LOAD_SYMBOL(library, prefix, device_environment_query_check_status) - LOAD_SYMBOL(library, prefix, device_environment_query_wait) - LOAD_SYMBOL(library, prefix, device_environment_query_cancel) - LOAD_SYMBOL(library, prefix, device_environment_query_free) + LOAD_SYMBOL(library, prefix, device_session_create_environmentsensor_query) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_set_parameter) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_submit) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_get_results) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_check_status) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_wait) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_cancel) + LOAD_SYMBOL(library, prefix, device_environmentsensor_query_free) // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) } catch (const std::exception &) { @@ -569,20 +569,20 @@ int QDMI_device_query_operation_property( prop, size, value, size_ret); } -int QDMI_device_query_environment_property(QDMI_Device device, - QDMI_Environment environment, - QDMI_Environment_Property prop, +int QDMI_device_query_environmentsensor_property(QDMI_Device device, + QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, const size_t size, void *value, size_t *size_ret) { if (device == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return device->library->device_session_query_environment_property( - device->device_session, environment, prop, size, value, size_ret); + return device->library->device_session_query_environmentsensor_property( + device->device_session, environment_sensor, prop, size, value, size_ret); } -int QDMI_device_create_environment_query(QDMI_Device dev, - QDMI_Environment_Query *query) { +int QDMI_device_create_environmentsensor_query(QDMI_Device dev, + QDMI_EnvironmentSensor_Query *query) { if (dev == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -591,72 +591,72 @@ int QDMI_device_create_environment_query(QDMI_Device dev, return QDMI_ERROR_PERMISSIONDENIED; } - *query = new QDMI_Environment_Query_impl_d(); + *query = new QDMI_EnvironmentSensor_Query_impl_d(); (*query)->device = dev; - return dev->library->device_session_create_environment_query( + return dev->library->device_session_create_environmentsensor_query( dev->device_session, &(*query)->env_query); } -int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, - QDMI_Environment_Query_Parameter param, +int QDMI_environmentsensor_query_set_parameter(QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Parameter param, size_t size, const void *value) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_set_parameter( + return query->device->library->device_environmentsensor_query_set_parameter( query->env_query, - static_cast(param), size, value); + static_cast(param), size, value); } -int QDMI_environment_query_submit(QDMI_Environment_Query query) { +int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_submit( + return query->device->library->device_environmentsensor_query_submit( query->env_query); } -int QDMI_environment_query_get_results(QDMI_Environment_Query query, - QDMI_Environment_Query_Result result, +int QDMI_environmentsensor_query_get_results(QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, size_t *size_ret) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_get_results( + return query->device->library->device_environmentsensor_query_get_results( query->env_query, result, size, data, size_ret); } -int QDMI_environment_query_check_status(QDMI_Environment_Query query, - QDMI_Environment_Query_Status *status) { +int QDMI_environmentsensor_query_check_status(QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_check_status( + return query->device->library->device_environmentsensor_query_check_status( query->env_query, status); } -int QDMI_environment_query_wait(QDMI_Environment_Query query) { +int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_wait( + return query->device->library->device_environmentsensor_query_wait( query->env_query); } -int QDMI_environment_query_cancel(QDMI_Environment_Query query) { +int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environment_query_cancel( + return query->device->library->device_environmentsensor_query_cancel( query->env_query); } -void QDMI_environment_query_free(QDMI_Environment_Query query) { +void QDMI_environmentsensor_query_free(QDMI_EnvironmentSensor_Query query) { if (query != nullptr) { - query->device->library->device_environment_query_free(query->env_query); + query->device->library->device_environmentsensor_query_free(query->env_query); delete query; } } diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 1ad8879b..90b4d7e0 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -201,61 +201,61 @@ auto FoMaC::get_parameters_num(const QDMI_Operation &op) const -> size_t { return parameters_num; } -auto FoMaC::get_environment_variables() const -> std::vector { - size_t environments_size = 0; +auto FoMaC::get_environment_variables() const -> std::vector { + size_t environment_sensor_size = 0; int ret = QDMI_device_query_device_property( - device, QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, 0, nullptr, - &environments_size); + device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, 0, nullptr, + &environment_sensor_size); throw_if_error(ret, "Failed to get the environment variable list size."); - std::vector environments(environments_size / + std::vector environment_sensors(environment_sensor_size / sizeof(QDMI_Site)); ret = QDMI_device_query_device_property( - device, QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES, environments_size, - static_cast(environments.data()), nullptr); + device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, environment_sensor_size, + static_cast(environment_sensors.data()), nullptr); throw_if_error(ret, "Failed to get the environment variables."); - return environments; + return environment_sensors; } -auto FoMaC::get_environment_id(QDMI_Environment environment) const +auto FoMaC::get_environment_id(QDMI_EnvironmentSensor environment_sensor) const -> std::string { - size_t environment_id_size = 0; + size_t environmentsensor_id_size = 0; - int ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_ID, 0, nullptr, - &environment_id_size); + int ret = QDMI_device_query_environmentsensor_property( + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, 0, nullptr, + &environmentsensor_id_size); throw_if_error(ret, "Failed to query the size for environment ID"); - std::string environment_id(environment_id_size - 1, '\0'); - ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_ID, - environment_id.size() + 1, environment_id.data(), nullptr); + std::string environmentsensor_id(environmentsensor_id_size - 1, '\0'); + ret = QDMI_device_query_environmentsensor_property( + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, + environmentsensor_id.size() + 1, environmentsensor_id.data(), nullptr); throw_if_error(ret, "Failed to query the environment ID"); - return environment_id; + return environmentsensor_id; } -auto FoMaC::get_environment_unit(QDMI_Environment environment) const +auto FoMaC::get_environment_unit(QDMI_EnvironmentSensor environment_sensor) const -> std::string { - size_t environment_unit_size = 0; + size_t environmentsensor_unit_size = 0; - int ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, - &environment_unit_size); + int ret = QDMI_device_query_environmentsensor_property( + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, nullptr, + &environmentsensor_unit_size); throw_if_error(ret, "Failed to query the size for environment unit"); - std::string environment_unit(environment_unit_size - 1, '\0'); - ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, - environment_unit.size() + 1, environment_unit.data(), nullptr); + std::string environmentsensor_unit(environmentsensor_unit_size - 1, '\0'); + ret = QDMI_device_query_environmentsensor_property( + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, + environmentsensor_unit.size() + 1, environmentsensor_unit.data(), nullptr); throw_if_error(ret, "Failed to query the environment unit"); - return environment_unit; + return environmentsensor_unit; } -auto FoMaC::get_environment_sampling_rate(QDMI_Environment environment) const +auto FoMaC::get_environment_sampling_rate(QDMI_EnvironmentSensor environment_sensor) const -> int { int sampling_rate = 0; - const int ret = QDMI_device_query_environment_property( - device, environment, QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE, sizeof(int), + const int ret = QDMI_device_query_environmentsensor_property( + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, sizeof(int), &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index 68b6291a..cd7bb889 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -65,14 +65,14 @@ class FoMaC { -> size_t; [[nodiscard]] auto get_environment_variables() const - -> std::vector; + -> std::vector; - [[nodiscard]] auto get_environment_id(QDMI_Environment environment) const + [[nodiscard]] auto get_environment_id(QDMI_EnvironmentSensor environment) const -> std::string; - [[nodiscard]] auto get_environment_unit(QDMI_Environment environment) const + [[nodiscard]] auto get_environment_unit(QDMI_EnvironmentSensor environment) const -> std::string; [[nodiscard]] auto - get_environment_sampling_rate(QDMI_Environment environment) const -> int; + get_environment_sampling_rate(QDMI_EnvironmentSensor environment) const -> int; }; diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 45d2ee41..1e86b1c3 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -50,8 +50,8 @@ extern "C" { * properties of devices. * - The @ref client_job_interface "client job interface" for submitting jobs * to devices. - * - The @ref client_environment_query_interface "client environment query - * interface" for querying environmental variables. + * - The @ref client_environmentsensor_query_interface "client environment + * sensor query interface" for querying environment sensors. * * @{ */ @@ -577,11 +577,12 @@ int QDMI_device_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an environment property. + * @brief Query an environment sensor property. * @param[in] device The device to query. Must not be @c NULL. - * @param[in] environment The environment to query. Must not be @c NULL. + * @param[in] environment_sensor The environment sensor to query. Must not be @c + NULL. * @param[in] prop The property to query. Must be one of the values specified - * for @ref QDMI_Environment_Property. + * for @ref QDMI_EnvironmentSensor_Property. * @param[in] size The size of the memory pointed to by @p value in bytes. Must * be greater or equal to the size of the return type specified for @p prop, * except when @p value is @c NULL, in which case it is ignored. @@ -594,54 +595,57 @@ int QDMI_device_query_operation_property( * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the * property. * @return @ref QDMI_ERROR_INVALIDARGUMENT if - * - @p device or @p environment is @c NULL, + * - @p device or @p environment_sensor is @c NULL, * - @p prop is invalid, or * - @p value is not @c NULL and @p size is less than the size of the data * being queried. * @return @ref QDMI_ERROR_FATAL if an unexpected error occurred. * * @note By calling this function with @p value set to @c NULL, the function can - * be used to check if the environment supports the specified property without + * be used to check if the environment sensor supports the specified property + without * retrieving the property and without the need to provide a buffer for it. * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. * - * @note For example, to query the unit of an environment, the following code - pattern + * @note For example, to query the unit of an environment sensor, the following + code pattern * can be used: * ``` * // Check if the device supports the property. - * auto ret = QDMI_device_query_environment_property( - * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, nullptr); + * auto ret = QDMI_device_query_environmentsensor_property( + * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, + nullptr, nullptr); * if (ret == QDMI_ERROR_NOTSUPPORTED) { * // The device does not support the property. * ... * } * * // Query the size of the property and the property. - * size_t environment_unit_size = 0; - * auto ret = QDMI_device_query_environment_property( - * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, 0, nullptr, - * &environment_unit_size); + * size_t environmentsensor_unit_size = 0; + * auto ret = QDMI_device_query_environmentsensor_property( + * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, + nullptr, + * &environmentsensor_unit_size); * if (ret != QDMI_SUCCESS) { * // An error occurred. * ... * } - * std::string environment_unit(environment_unit_size - 1, '\0'); - * ret = QDMI_device_query_environment_property( - * device, environment, QDMI_ENVIRONMENT_PROPERTY_UNIT, - * environment_unit.size() + 1, environment_unit.data(), nullptr); + * std::string environmentsensor_unit(environmentsensor_unit_size - 1, '\0'); + * ret = QDMI_device_query_environmentsensor_property( + * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, + * environmentsensor_unit.size() + 1, environmentsensor_unit.data(), + nullptr); * ``` * - * @remark @ref QDMI_Environment handles may be queried via @ref + * @remark @ref QDMI_EnvironmentSensor handles may be queried via @ref * QDMI_device_query_device_property with @ref - QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES. + QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS. */ -int QDMI_device_query_environment_property(QDMI_Device device, - QDMI_Environment environment, - QDMI_Environment_Property prop, - size_t size, void *value, - size_t *size_ret); +int QDMI_device_query_environmentsensor_property( + QDMI_Device device, QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, size_t size, void *value, + size_t *size_ret); /** @} */ // end of client_query_interface @@ -1050,84 +1054,87 @@ void QDMI_job_free(QDMI_Job job); /** @} */ // end of client_job_interface -/** @defgroup client_environment_query_interface QDMI Client Environment Query - * Interface - * @brief Provides functions to query environmental variables. - * @details An environment query is a task submitted by a client to a device - * for querying environmental variables, i.e. temperature or power. +/** @defgroup client_environmentsensor_query_interface QDMI Client Environment + * Sensor Query Interface + * @brief Provides functions to query environment sensors. + * @details An environment sensor query is a task submitted by a client to a + * device for querying environment sensors, i.e. temperature or power. * - * The typical workflow for a client environment query is as follows: - * - Create an environment query with @ref - * QDMI_device_create_environment_query. - * - Set parameters for the environment query with @ref - * QDMI_environment_query_set_parameter + * The typical workflow for a client environment sensor query is as follows: + * - Create an environment sensor query with @ref + * QDMI_device_create_environmentsensor_query. + * - Set parameters for the environment sensor query with @ref + * QDMI_environmentsensor_query_set_parameter * - Submit the environment query to the device with @ref - * QDMI_environment_query_submit. - * - Check the status of the environment query with @ref - * QDMI_environment_query_check_status. - * - Wait for the environment query to finish with @ref - * QDMI_environment_query_wait. - * - Retrieve the results of the environment query with @ref - * QDMI_environment_query_get_results. - * - Free the environment query with @ref QDMI_environment_query_free when it - * is no longer used. + * QDMI_environmentsensor_query_submit. + * - Check the status of the environment sensor query with @ref + * QDMI_environmentsensor_query_check_status. + * - Wait for the environment sensor query to finish with @ref + * QDMI_environmentsensor_query_wait. + * - Retrieve the results of the environment sensor query with @ref + * QDMI_environmentsensor_query_get_results. + * - Free the environment sensor query with @ref + * QDMI_environmentsensor_query_free when it is no longer used. * * @{ */ /** - * @brief A handle for a client-side environment query. + * @brief A handle for a client-side environment sensor query. * @details An opaque pointer to a type defined by the driver that encapsulates - * all information about an environment query submitted to a device by a client. + * all information about an environment sensor query submitted to a device by a + * client. * @remark Implementations of the underlying type will want to store the device - * handle used to create the environment query in the handle to be able to - * access the device when needed. - * @see QDMI_Device_Environment_Query for the device-side the environment query - * handle. + * handle used to create the environment sensor query in the handle to be able + * to access the device when needed. + * @see QDMI_Device_EnvironmentSensor_Query for the device-side the environment + * sensor query handle. */ -typedef struct QDMI_Environment_Query_impl_d *QDMI_Environment_Query; +typedef struct QDMI_EnvironmentSensor_Query_impl_d + *QDMI_EnvironmentSensor_Query; /** - * @brief Create an environment query. + * @brief Create an environment sensor query. * @details This is the main entry point for a client to submit an environment - * query to a device. The returned handle can be used throughout the @ref - * client_environment_query_interface "client environment query interface" to - * refer to the environment query. - * @param[in] device The device to create the environment query on. Must not be - * @c NULL. + * sensor query to a device. The returned handle can be used throughout the + * @ref client_environmentsensor_query_interface + * "client environment sensor query interface" to refer to the environment + * sensor query. + * @param[in] device The device to create the environment sensor query on. Must + * not be @c NULL. * @param[out] query A pointer to a handle that will store the created - * environment query. Must not be @c NULL. The job must be freed by calling @ref - * QDMI_environment_query_free when it is no longer used. + * environment sensor query. Must not be @c NULL. The job must be freed by + * calling @ref QDMI_environmentsensor_query_free when it is no longer used. * @return @ref QDMI_SUCCESS if the job was successfully created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query creation failed due to - * a fatal error. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed + * due to a fatal error. */ -int QDMI_device_create_environment_query(QDMI_Device device, - QDMI_Environment_Query *query); +int QDMI_device_create_environmentsensor_query( + QDMI_Device device, QDMI_EnvironmentSensor_Query *query); /** - * @brief Enum of the environment query parameters that can be set. + * @brief Enum of the environment sensor query parameters that can be set. * @details If not noted otherwise, parameters are mandatory and drivers must * require them to be set. */ -enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { +enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { /// The start time of the environment query interval. - QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME = 0, /// The end time of the environment query interval. - QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME = 1, /// The environment for the environment query. - QDMI_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT = 2, /// The maximum value of the enum. - QDMI_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX = 3, /** * @brief This enum value is reserved for a custom parameter. @@ -1135,52 +1142,52 @@ enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T { * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, - /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, + /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, - /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, + /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, - /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, + /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, - /// @see QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 + /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 }; -/// Environment query parameter type. -typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T - QDMI_Environment_Query_Parameter; +/// Environment sensor query parameter type. +typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T + QDMI_EnvironmentSensor_Query_Parameter; /** - * @brief Set a parameter for an environment. + * @brief Set a parameter for an environment sensor. * @param[in] query A handle to a job for which to set @p param. Must not be @c * NULL. * @param[in] param The parameter whose value will be set. Must be one of the - * values specified for @ref QDMI_Environment_Query_Parameter. + * values specified for @ref QDMI_EnvironmentSensor_Query_Parameter. * @param[in] size The size of the data pointed to by @p value in bytes. Must * not be zero, except when @p value is @c NULL, in which case it is ignored. * @param[in] value A pointer to the memory location that contains the value of * the parameter to be set. The data pointed to by @p value is copied and can be * safely reused after this function returns. If this is @c NULL, it is ignored. * @return @ref QDMI_SUCCESS if the driver supports the specified @ref - * QDMI_Environment_Query_Parameter @p param and, when @p value is not @c NULL, - * the parameter was successfully set. + * QDMI_EnvironmentSensor_Query_Parameter @p param and, when @p value is not @c + * NULL, the parameter was successfully set. * @return @ref QDMI_ERROR_NOTSUPPORTED if the driver does not support the * parameter or the value of the parameter. * @return @ref QDMI_ERROR_INVALIDARGUMENT if * - @p query is @c NULL, * - @p param is invalid, or * - @p value is not @c NULL and @p size is zero or not the expected size for - * the parameter (if specified by the @ref QDMI_Environment_Query_Parameter - * documentation). + * the parameter (if specified by the @ref + * QDMI_EnvironmentSensor_Query_Parameter documentation). * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the * current state of the job, for example, because the query is already * submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. * @@ -1193,8 +1200,8 @@ typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T * used: * ``` * // Check if the device supports setting the start time - * auto ret = QDMI_environment_query_set_parameter( - * query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, 0, nullptr); + * auto ret = QDMI_environmentsensor_query_set_parameter( + * query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, 0, nullptr); * if (ret == QDMI_ERROR_NOTSUPPORTED) { * // The device does not support setting the start time. * ... @@ -1202,97 +1209,107 @@ typedef enum QDMI_ENVIRONMENT_QUERY_PARAMETER_T * * // Set the start time. * uint64_t start_ts = 1744970400; - * QDMI_environment_query_set_parameter( - * query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), + * QDMI_environmentsensor_query_set_parameter( + * query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), * &start_ts); * ``` */ -int QDMI_environment_query_set_parameter(QDMI_Environment_Query query, - QDMI_Environment_Query_Parameter param, - size_t size, const void *value); +int QDMI_environmentsensor_query_set_parameter( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Parameter param, size_t size, + const void *value); /** - * @brief Submit an environment query to the device. - * @details This function can either be blocking until the environment query is - * finished or non-blocking and return while the environment query is running. - * In the latter case, the functions @ref QDMI_environment_query_check_status - * and @ref QDMI_environment_query_wait can be used to check the status and wait - * for the environment query to finish. - * @param[in] query The environment query to submit. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query was successfully + * @brief Submit an environment sensor query to the device. + * @details This function can either be blocking until the environment sensor + * query is finished or non-blocking and return while the environment sensor + * query is running. In the latter case, the functions @ref + * QDMI_environmentsensor_query_check_status and @ref + * QDMI_environmentsensor_query_wait can be used to check the status and wait + * for the environment sensor query to finish. + * @param[in] query The environment sensor query to submit. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment sensor query was successfully * submitted. - * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p environment query is @c NULL. - * @return @ref QDMI_ERROR_BADSTATE if the environment query is in an invalid - * state. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if environment sensor query is @c + * NULL. + * @return @ref QDMI_ERROR_BADSTATE if the environment sensor query is in an + * invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query submission failed. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query submission + * failed. */ -int QDMI_environment_query_submit(QDMI_Environment_Query query); +int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query); /** - * @brief Cancel an already submitted environment query. - * @details Remove the environment query from the queue of waiting environment - * query. This changes the status of the environment query to @ref - * QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED. - * @param[in] query The environment query to cancel. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query was successfully canceled. + * @brief Cancel an already submitted environment sensor query. + * @details Remove the environment sensor query from the queue of waiting + * environment sensor query. This changes the status of the environment sensor + * query to @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED. + * @param[in] query The environment sensor query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the - * environment query already has the status @ref - * QDMI_ENVIRONMENT_QUERY_STATUS_DONE. + * environment sensor query already has the status @ref + * QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query could not be canceled. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * canceled. */ -int QDMI_environment_query_cancel(QDMI_Environment_Query query); +int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query); /** - * @brief Check the status of an environment query. + * @brief Check the status of an environment sensor query. * @details This function is non-blocking and returns immediately with the - * environment query status. It is not required to call this function before - * calling @ref QDMI_environment_query_get_results. - * @param[in] query The environment query to check the status of. Must not be @c + * environment sensor query status. It is not required to call this function + * before calling @ref QDMI_environmentsensor_query_get_results. + * @param[in] query The environment sensor query to check the status of. Must + * not be @c NULL. + * @param[out] status The status of the environment sensor query. Must not be @c * NULL. - * @param[out] status The status of the environment query. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query status was successfully - * checked. + * @return @ref QDMI_SUCCESS if the environment sensor query status was + * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query status could not be - * checked. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could + * not be checked. */ -int QDMI_environment_query_check_status(QDMI_Environment_Query query, - QDMI_Environment_Query_Status *status); +int QDMI_environmentsensor_query_check_status( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status); /** - * @brief Wait for an environment query to finish. - * @details This function blocks until the environment query has either finished - * or has been canceled. - * @param[in] query The environment query to wait for. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query is finished or canceled. + * @brief Wait for an environment sensor query to finish. + * @details This function blocks until the environment sensor query has either + * finished or has been canceled. + * @param[in] query The environment sensor query to wait for. Must not be @c + * NULL. + * @return @ref QDMI_SUCCESS if the environment sensor query is finished or + * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query could not be waited - * for and this function returns before the environment query has finished or - * has been canceled. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * waited for and this function returns before the environment sensor query has + * finished or has been canceled. */ -int QDMI_environment_query_wait(QDMI_Environment_Query query); +int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query); /** - * @brief Retrieve the results of an environment query. - * @param[in] query The environment query to retrieve the results from. Must not - * be @c NULL. + * @brief Retrieve the results of an environment sensor query. + * @param[in] query The environment sensor query to retrieve the results from. + * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified - * for @ref QDMI_Environment_Query_Result. + * for @ref QDMI_EnvironmentSensor_Query_Result. * @param[in] size The size of the buffer pointed to by @p data in bytes. Must * be greater or equal to the size of the return type specified for the @ref - * QDMI_Environment_Query_Result @p result, except when @p data is @c NULL, in - * which case it is ignored. + * QDMI_EnvironmentSensor_Query_Result @p result, except when @p data is @c + * NULL, in which case it is ignored. * @param[out] data A pointer to the memory location where the results will be * stored. If this is @c NULL, it is ignored. * @param[out] size_ret The actual size of the data being queried in bytes. If @@ -1307,8 +1324,8 @@ int QDMI_environment_query_wait(QDMI_Environment_Query query); * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environment_query_interface "client environment query - * interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * * @note By calling this function with @p data set to @c NULL, the function can @@ -1318,36 +1335,38 @@ int QDMI_environment_query_wait(QDMI_Environment_Query query); * Additionally, the size of the buffer needed to retrieve the result is * returned in @p size_ret if @p size_ret is not @c NULL. * - * @note For example, to query the results of a environment query, + * @note For example, to query the results of a environment sensor query, * the following code pattern can be used: * ``` * // Query the size of the result. * size_t size; - * auto ret = QDMI_environment_query_get_results( - * query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, &size); + * auto ret = QDMI_environmentsensor_query_get_results( + * query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, 0, nullptr, &size); * * // Allocate memory for the result. * std::vector values; * values.reserve(size); * * // Query the result. - * QDMI_environment_query_get_results( - * query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, size, values.data(), nullptr); + * QDMI_environmentsensor_query_get_results( + * query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, size, values.data(), + * nullptr); * ``` */ -int QDMI_environment_query_get_results(QDMI_Environment_Query query, - QDMI_Environment_Query_Result result, - size_t size, void *data, - size_t *size_ret); +int QDMI_environmentsensor_query_get_results( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, + size_t *size_ret); /** - * @brief Free an environment query. - * @details Free the resources associated with a environment query. Using a - * environment query handle after it has been freed is undefined behavior. - * @param[in] query The environment query to free. + * @brief Free an environment sensor query. + * @details Free the resources associated with a environment sensor query. Using + * a environment sensor query handle after it has been freed is undefined + * behavior. + * @param[in] query The environment sensor query to free. */ -void QDMI_environment_query_free(QDMI_Environment_Query query); +void QDMI_environmentsensor_query_free(QDMI_EnvironmentSensor_Query query); -/** @} */ // end of client_environment_query_interface +/** @} */ // end of client_environmentsensor_query_interface /** @} */ // end of client_interface diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 23ae0305..c4fb55d6 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -326,7 +326,7 @@ enum QDMI_DEVICE_PROPERTY_T { /** * TODO */ - QDMI_DEVICE_PROPERTY_ENVIRONMENTVARIABLES = 9, + QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 9, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -764,24 +764,24 @@ enum QDMI_JOB_RESULT_T { /// Job result type. typedef enum QDMI_JOB_RESULT_T QDMI_Job_Result; -/// Enum of the environment properties that can be queried via @ref -/// QDMI_device_session_query_environment_property as part of the @ref +/// Enum of the environment sensor properties that can be queried via @ref +/// QDMI_device_session_query_environmentsensor_property as part of the @ref /// device_interface "device interface" and via @ref -/// QDMI_device_query_environment_property as part of the @ref client_interface -/// "client interface". -enum QDMI_ENVIRONMENT_PROPERTY_T { +/// QDMI_device_query_environmentsensor_property as part of the @ref +/// client_interface "client interface". +enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T { /** - * @brief `char*` (string) The unique ID to identify the environment. - * @details TThe ID of an environment is used to identify the sensors. The - * sensors collect environmental data in the HPCQC Labs, i.e., temperature and - * pressure. + * @brief `char*` (string) The unique ID to identify the environment sensor. + * @details The ID of an environment sensor is used to identify the sensors. + * The sensors collect environmental data in the HPCQC Labs, i.e., temperature + * and pressure. */ - QDMI_ENVIRONMENT_PROPERTY_ID = 0, - /// `char*` (string) The unit of an environment variable, e.g., Kelvin for + QDMI_ENVIRONMENTSENSOR_PROPERTY_ID = 0, + /// `char*` (string) The unit of an environment sensor, e.g., Kelvin for /// temperature. - QDMI_ENVIRONMENT_PROPERTY_UNIT = 1, - /// `float` The samples per second of an environment. - QDMI_ENVIRONMENT_PROPERTY_SAMPLING_RATE = 2, + QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT = 1, + /// `float` The samples per second of an environment sensor. + QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE = 2, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and @@ -791,7 +791,7 @@ enum QDMI_ENVIRONMENT_PROPERTY_T { * enum besides the custom members and must be updated when new * members are added. */ - QDMI_ENVIRONMENT_PROPERTY_MAX = 3, + QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX = 3, /** * @brief This enum value is reserved for a custom property. * @details The device defines the meaning and the type of this @@ -799,74 +799,76 @@ enum QDMI_ENVIRONMENT_PROPERTY_T { * @attention The value of this enum member must not be changed to * maintain binary compatibility. */ - QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 = 999999995, - /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENT_PROPERTY_CUSTOM2 = 999999996, - /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENT_PROPERTY_CUSTOM3 = 999999997, - /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENT_PROPERTY_CUSTOM4 = 999999998, - /// @see QDMI_ENVIRONMENT_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENT_PROPERTY_CUSTOM5 = 999999999 + QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 = 999999995, + /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 = 999999996, + /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM3 = 999999997, + /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM4 = 999999998, + /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 + QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5 = 999999999 }; /// Environment property type. -typedef enum QDMI_ENVIRONMENT_PROPERTY_T QDMI_Environment_Property; +typedef enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T QDMI_EnvironmentSensor_Property; /** - * @brief Enum of the device environment query parameters that can be set via - * @ref QDMI_device_environment_query_set_parameter. + * @brief Enum of the device environmentsensor query parameters that can be set + * via + * @ref QDMI_device_environmentsensor_query_set_parameter. * @details If not noted otherwise, parameters are mandatory and devices must * require them to be set. */ -enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T { - /// The start time of the environment query interval. - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_START_TIME = 0, - /// The end time of the environment query interval. - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_END_TIME = 1, - /// The environment for the environment query. - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT = 2, +enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { + /// The start time of the environment sensor query interval. + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME = 0, + /// The end time of the environment sensor query interval. + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME = 1, + /// The environment sensor for the environment sensor query. + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR = 2, /// The maximum value of the enum. - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_MAX = 3, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX = 3, /** * @brief This enum value is reserved for a custom parameter. * @details The devices defines the meaning and the type of this parameter. * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM1 = 999999995, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM2 = 999999996, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM3 = 999999997, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM4 = 999999998, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_CUSTOM5 = 999999999 + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 }; /// Device environment query parameter type. -typedef enum QDMI_DEVICE_ENVIRONMENT_QUERY_PARAMETER_T - QDMI_Device_Environment_Query_Parameter; +typedef enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T + QDMI_Device_EnvironmentSensor_Query_Parameter; /** - * @brief Enum of the formats the environment query results can be returned in. + * @brief Enum of the formats the environment sensor query results can be + * returned in. */ -enum QDMI_ENVIRONMENT_QUERY_RESULT_T { +enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T { /** * @brief `uint64_t*` (`unsigned 64 bit integer` list) The timestamps at which * the corresponding values in the results were recorded by a sensor. - * @details The result of an environment query is represented as a key-value - * mapping. This mapping is returned as a list of keys and an equal-length - * list of values. The corresponding partners of the keys and values can be - * found at the same index in the lists + * @details The result of an environment sensor query is represented as a + * key-value mapping. This mapping is returned as a list of keys and an + * equal-length list of values. The corresponding partners of the keys and + * values can be found at the same index in the lists */ - QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS = 0, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS = 0, /** * @brief `float*` (`float` list) The values of the result. - * @see QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS + * @see QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS */ - QDMI_ENVIRONMENT_QUERY_RESULT_VALUES = 1, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES = 1, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -875,53 +877,55 @@ enum QDMI_ENVIRONMENT_QUERY_RESULT_T { * @attention This value must remain the last regular member of the enum * besides the custom members and must be updated when new members are added. */ - QDMI_ENVIRONMENT_QUERY_RESULT_MAX = 2, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX = 2, /** * @brief This enum value is reserved for a custom result. * @details The device defines the meaning and the type of this result. * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM1 = 999999995, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM1 = 999999995, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM2 = 999999996, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM2 = 999999996, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM3 = 999999997, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM3 = 999999997, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM4 = 999999998, + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM4 = 999999998, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENT_QUERY_RESULT_CUSTOM5 = 999999999 + QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM5 = 999999999 }; /// Environment query result type. -typedef enum QDMI_ENVIRONMENT_QUERY_RESULT_T QDMI_Environment_Query_Result; +typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T + QDMI_EnvironmentSensor_Query_Result; /** - * @brief Enum of the status Environment query can have. - * @details See also @ref client_environment_query_interface for a description - * of the environment query's lifecycle. + * @brief Enum of the status Environment sensor query can have. + * @details See also @ref client_environmentsensor_query_interface for a + * description of the environment sensor query's lifecycle. */ -enum QDMI_ENVIRONMENT_QUERY_STATUS_T { +enum QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_T { /** - * @brief The environment query was created and can be configured via @ref - * QDMI_environment_query_set_parameter. + * @brief The environment sensor query was created and can be configured via + * @ref QDMI_environmentsensor_query_set_parameter. */ - QDMI_ENVIRONMENT_QUERY_STATUS_CREATED = 0, - /// The environment query was submitted. - QDMI_ENVIRONMENT_QUERY_STATUS_SUBMITTED = 1, + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CREATED = 0, + /// The environment sensor query was submitted. + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_SUBMITTED = 1, /// The environment query was received is waiting to be executed. - QDMI_ENVIRONMENT_QUERY_STATUS_QUEUED = 2, + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_QUEUED = 2, /// The environment query is running, and the result is not yet available. - QDMI_ENVIRONMENT_QUERY_STATUS_RUNNING = 3, + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_RUNNING = 3, /// The environment query is done, and the result can be retrieved. - QDMI_ENVIRONMENT_QUERY_STATUS_DONE = 4, + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE = 4, /// The environment query was canceled, and the result is not available. - QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED = 5, - /// An error occurred in the environment query's lifecycle. - QDMI_ENVIRONMENT_QUERY_STATUS_FAILED = 6 + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED = 5, + /// An error occurred in the environment sensor query's lifecycle. + QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_FAILED = 6 }; /// Environment query status type. -typedef enum QDMI_ENVIRONMENT_QUERY_STATUS_T QDMI_Environment_Query_Status; +typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_T + QDMI_EnvironmentSensor_Query_Status; // NOLINTEND(performance-enum-size, modernize-use-using) diff --git a/include/qdmi/device.h b/include/qdmi/device.h index a7f2eb31..17b12c3d 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -353,11 +353,12 @@ int QDMI_device_session_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an environment property. + * @brief Query an environment sensor property. * @param[in] session The session used for the query. Must not be @c NULL. - * @param[in] environment The environment to query. Must not be @c NULL. + * @param[in] environment_sensor The environment sensor to query. Must not be @c + * NULL. * @param[in] prop The property to query. Must be one of the values specified - * for @ref QDMI_Environment_Property. + * for @ref QDMI_EnvironmentSensor_Property. * @param[in] size The size of the memory pointed to by @p value in bytes. Must * be greater or equal to the size of the return type specified for @p prop, * except when @p value is @c NULL, in which case it is ignored. @@ -384,16 +385,17 @@ int QDMI_device_session_query_operation_property( * retrieving the property and without the need to provide a buffer for it. * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. - * See the @ref QDMI_device_query_environment_property documentation for an - * example. + * See the @ref QDMI_device_query_environmentsensor_property documentation for + * an example. * * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. */ -int QDMI_device_session_query_environment_property( - QDMI_Device_Session session, QDMI_Environment environment, - QDMI_Environment_Property prop, size_t size, void *value, size_t *size_ret); +int QDMI_device_session_query_environmentsensor_property( + QDMI_Device_Session session, QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, size_t size, void *value, + size_t *size_ret); /** @} */ // end of device_query_interface @@ -636,85 +638,87 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @} */ // end of device_job_interface -/** @defgroup device_environment_query_interface QDMI Device Environment Query - * Interface - * @brief Provides functions to manage environment queries on a device. - * @details An environment query is a task submitted to a device for querying - * environmental variables, i.e. temperature or power. +/** @defgroup device_environmentsensor_query_interface QDMI Device Environment + * Sensor Query Interface + * @brief Provides functions to manage environment sensor queries on a device. + * @details An environment sensor query is a task submitted to a device for + * querying environment sensors, i.e. temperature or power. * - * The typical workflow for a device environment query is as follows: - * - Create an environment query with @ref - * QDMI_device_session_create_environment_query. - * - Set parameters for the environment query with @ref - * QDMI_device_environment_query_set_parameter - * - Submit the environment query to the device with @ref - * QDMI_device_environment_query_submit. - * - Check the status of the environment query with @ref - * QDMI_device_environment_query_check_status. - * - Wait for the environment query to finish with @ref - * QDMI_device_environment_query_wait. - * - Retrieve the results of the environment query with @ref - * QDMI_environment_query_get_results. - * - Free the environment query with @ref QDMI_device_environment_query_free - * when it is no longer used. + * The typical workflow for a device environment sensor query is as follows: + * - Create an environment sensor query with @ref + * QDMI_device_session_create_environmentsensor_query. + * - Set parameters for the environment sensor query with @ref + * QDMI_device_environmentsensor_query_set_parameter + * - Submit the environment sensor query to the device with @ref + * QDMI_device_environmentsensor_query_submit. + * - Check the status of the environment sensor query with @ref + * QDMI_device_environmentsensor_query_check_status. + * - Wait for the environment sensor query to finish with @ref + * QDMI_device_environmentsensor_query_wait. + * - Retrieve the results of the environment sensor query with @ref + * QDMI_environmentsensor_query_get_results. + * - Free the environment sensor query with @ref + * QDMI_device_environmentsensor_query_free when it is no longer used. * * @{ */ /** - * @brief A handle for a device environment query. + * @brief A handle for a device environment sensor query. * @details An opaque pointer to a type defined by the device that encapsulates - * all information about an environment query on a device. + * all information about an environment sensor query on a device. * @remark Implementations of the underlying type will want to store the session - * handle used to create the environment query in the environment query handle - * to be able to access the session information when needed. - * @see QDMI_Environment_Query for the client-side job handle. + * handle used to create the environment sensor query in the environment sensor + * query handle to be able to access the session information when needed. + * @see QDMI_EnvironmentSensor_Query for the client-side job handle. */ -typedef struct QDMI_Device_Environment_Query_impl_d - *QDMI_Device_Environment_Query; +typedef struct QDMI_Device_EnvironmentSensor_Query_impl_d + *QDMI_Device_EnvironmentSensor_Query; /** - * @brief Create an environment query. + * @brief Create an environment sensor query. * @details This is the main entry point for a driver to create an environment - * query for a device. The returned handle can be used throughout the @ref - * device_environment_query_interface "device environment query interface" to - * refer to the environment query. - * @param[in] session The session to create the environment query on. Must not - * be @c NULL. + * sensor query for a device. The returned handle can be used throughout the + * @ref device_environmentsensor_query_interface + * "device environment sensor query interface" to refer to the environment + * query. + * @param[in] session The session to create the environment sensor query on. + * Must not be @c NULL. * @param[out] query A pointer to a handle that will store the created - * environment query. Must not be @c NULL. The environment query must be freed - * by calling - * @ref QDMI_device_environment_query_free when it is no longer used. - * @return @ref QDMI_SUCCESS if the environment query was successfully created. + * environment sensor query. Must not be @c NULL. The environment sensor query + * must be freed by calling + * @ref QDMI_device_environmentsensor_query_free when it is no longer used. + * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p session or @p query are @c * NULL. * @return @ref QDMI_ERROR_BADSTATE if the session is not in a state allowing - * the creation of an environment query, for example, because the session is not - * initialized. + * the creation of an environment sensor query, for example, because the session + * is not initialized. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if environment query creation failed due to a - * fatal error. + * the @ref device_environmentsensor_query_interface "device environment sensor + * query interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if environment sensor query creation failed due + * to a fatal error. * * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. */ -int QDMI_device_session_create_environment_query( - QDMI_Device_Session session, QDMI_Device_Environment_Query *query); +int QDMI_device_session_create_environmentsensor_query( + QDMI_Device_Session session, QDMI_Device_EnvironmentSensor_Query *query); /** - * @brief Set a parameter for an environment query. - * @param[in] query A handle to an environment query for which to set @p param. - * Must not be @c NULL. + * @brief Set a parameter for an environment sensor query. + * @param[in] query A handle to an environment sensor query for which to set @p + * param. Must not be @c NULL. * @param[in] param The parameter whose value will be set. Must be one of the - * values specified for @ref QDMI_Device_Environment_Query_Parameter. + * values specified for @ref QDMI_Device_EnvironmentSensor_Query_Parameter. * @param[in] size The size of the data pointed to by @p value in bytes. Must * not be zero, except when @p value is @c NULL, in which case it is ignored. * @param[in] value A pointer to the memory location that contains the value of * the parameter to be set. The data pointed to by @p value is copied and can be * safely reused after this function returns. If this is @c NULL, it is ignored. * @return @ref QDMI_SUCCESS if the device supports the specified @ref - * QDMI_Device_Environment_Query_Parameter @p param and, when @p value is not @c - * NULL, the parameter was successfully set. + * QDMI_Device_EnvironmentSensor_Query_Parameter @p param and, when @p value is + * not @c NULL, the parameter was successfully set. * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the * parameter or the value of the parameter. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @@ -722,105 +726,114 @@ int QDMI_device_session_create_environment_query( * - @p param is invalid, or * - @p value is not @c NULL and @p size is zero or not the expected size for * the parameter (if specified by the @ref - * QDMI_Device_Environment_Query_Parameter documentation). + * QDMI_Device_EnvironmentSensor_Query_Parameter documentation). * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the - * current state of the environment query, for example, because the environment - * query is already submitted. + * current state of the environment sensor query, for example, because the + * environment sensor query is already submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. + * the @ref device_environmentsensor_query_interface "device environment sensor + * query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. * * @remark Calling this function with @p value set to @c NULL is expected to * allow checking if the device supports the specified parameter without setting * the parameter and without the need to provide a value. - * See the @ref QDMI_environment_query_set_parameter documentation for an + * See the @ref QDMI_environmentsensor_query_set_parameter documentation for an * example. */ -int QDMI_device_environment_query_set_parameter( - QDMI_Device_Environment_Query query, - QDMI_Device_Environment_Query_Parameter param, size_t size, +int QDMI_device_environmentsensor_query_set_parameter( + QDMI_Device_EnvironmentSensor_Query query, + QDMI_Device_EnvironmentSensor_Query_Parameter param, size_t size, const void *value); /** - * @brief Submit an environment query to the device. + * @brief Submit an environment sensor query to the device. * @details This function can either be blocking until the job is finished or * non-blocking and return while the job is running. In the latter case, the - * functions @ref QDMI_device_environment_query_check_status and @ref - * QDMI_device_environment_query_wait can be used to check the status and wait - * for the environment query to finish. - * @param[in] query The environment query to submit. Must not be @c NULL. + * functions @ref QDMI_device_environmentsensor_query_check_status and @ref + * QDMI_device_environmentsensor_query_wait can be used to check the status and + * wait for the environment sensor query to finish. + * @param[in] query The environment sensor query to submit. Must not be @c NULL. * @return @ref QDMI_SUCCESS if the job was successfully submitted. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p job is @c NULL. * @return @ref QDMI_ERROR_BADSTATE if the job is in an invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. + * the @ref device_environmentsensor_query_interface "device environment sensro + * query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the job submission failed. */ -int QDMI_device_environment_query_submit(QDMI_Device_Environment_Query query); +int QDMI_device_environmentsensor_query_submit( + QDMI_Device_EnvironmentSensor_Query query); /** - * @brief Cancel an already submitted environment query. - * @details Remove the environment query from the queue of waiting environment - * query. This changes the status of the environment query to @ref - * QDMI_ENVIRONMENT_QUERY_STATUS_CANCELED. - * @param[in] query The environment query to cancel. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query was successfully canceled. + * @brief Cancel an already submitted environment sensor query. + * @details Remove the environment sensor query from the queue of waiting + * environment sensor query. This changes the status of the environment query to + * @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED. + * @param[in] query The environment sensor query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the job - * already has the status @ref QDMI_ENVIRONMENT_QUERY_STATUS_DONE. + * already has the status @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query could not be canceled. + * the @ref device_environmentsensor_query_interface "device environment sensor + * query interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * canceled. */ -int QDMI_device_environment_query_cancel(QDMI_Device_Environment_Query query); +int QDMI_device_environmentsensor_query_cancel( + QDMI_Device_EnvironmentSensor_Query query); /** - * @brief Check the status of an environment query. + * @brief Check the status of an environment sensor query. * @details This function is non-blocking and returns immediately with the - * environment query status. It is not required to call this function before - * calling @ref QDMI_environment_query_get_results. - * @param[in] query The environment query to check the status of. Must not be @c + * environment sensor query status. It is not required to call this function + * before calling @ref QDMI_environmentsensor_query_get_results. + * @param[in] query The environment sensor query to check the status of. Must + * not be @c NULL. + * @param[out] status The status of the environment sensor query. Must not be @c * NULL. - * @param[out] status The status of the environment query. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query status was successfully - * checked. + * @return @ref QDMI_SUCCESS if the environment sensor query status was + * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "client environment query - * interface" for the device in the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query status could not be - * checked. - */ -int QDMI_device_environment_query_check_status( - QDMI_Device_Environment_Query query, QDMI_Environment_Query_Status *status); + * the @ref device_environmentsensor_query_interface "client environment sensor + * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could + * not be checked. + */ +int QDMI_device_environmentsensor_query_check_status( + QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status); /** - * @brief Wait for an environment query to finish. - * @details This function blocks until the environment query has either finished - * or has been canceled. - * @param[in] query The environment query to wait for. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment query is finished or canceled. + * @brief Wait for an environment sensor query to finish. + * @details This function blocks until the environment sensor query has either + * finished or has been canceled. + * @param[in] query The environment sensor query to wait for. Must not be @c + * NULL. + * @return @ref QDMI_SUCCESS if the environment sensor query is finished or + * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if the environment query could not be waited - * for and this function returns before the environment query has finished or - * has been canceled. + * the @ref device_environmentsensor_query_interface "device environment sensor + * query interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * waited for and this function returns before the environment sensor query has + * finished or has been canceled. */ -int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); +int QDMI_device_environmentsensor_query_wait( + QDMI_Device_EnvironmentSensor_Query query); /** - * @brief Retrieve the results of an environment query. - * @param[in] query The environment query to retrieve the results from. Must not - * be @c NULL. + * @brief Retrieve the results of an environment sensor query. + * @param[in] query The environment sensor query to retrieve the results from. + * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified - * for @ref QDMI_Environment_Query_Result. + * for @ref QDMI_EnvironmentSensor_Query_Result. * @param[in] size The size of the buffer pointed to by @p data in bytes. Must * be greater or equal to the size of the return type specified for the @ref - * QDMI_Environment_Query_Result @p result, except when @p data is @c NULL, in - * which case it is ignored. + * QDMI_EnvironmentSensor_Query_Result @p result, except when @p data is @c + * NULL, in which case it is ignored. * @param[out] data A pointer to the memory location where the results will be * stored. If this is @c NULL, it is ignored. * @param[out] size_ret The actual size of the data being queried in bytes. If @@ -835,8 +848,8 @@ int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environment_query_interface "device environment query - * interface" for the current session. + * the @ref device_environmentsensor_query_interface "device environment sensor + * query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * * @remark Calling this function with @p data set to @c NULL is expected to @@ -845,20 +858,24 @@ int QDMI_device_environment_query_wait(QDMI_Device_Environment_Query query); * result. * Additionally, the size of the buffer required to retrieve the result is * returned in @p size_ret if @p size_ret is not @c NULL. - * See the @ref QDMI_environment_query_get_results documentation for an example. + * See the @ref QDMI_environmentsensor_query_get_results documentation for an + * example. */ -int QDMI_device_environment_query_get_results( - QDMI_Device_Environment_Query query, QDMI_Environment_Query_Result result, - size_t size, void *data, size_t *size_ret); +int QDMI_device_environmentsensor_query_get_results( + QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, + size_t *size_ret); /** - * @brief Free an environment query. - * @details Free the resources associated with a environment query. Using a - * environment query handle after it has been freed is undefined behavior. - * @param[in] query The environment query to free. + * @brief Free an environment sensor query. + * @details Free the resources associated with a environment sensor query. Using + * a environment sensor query handle after it has been freed is undefined + * behavior. + * @param[in] query The environment sensor query to free. */ -void QDMI_device_environment_query_free(QDMI_Device_Environment_Query query); +void QDMI_device_environmentsensor_query_free( + QDMI_Device_EnvironmentSensor_Query query); -/** @} */ // end of device_environment_query_interface +/** @} */ // end of device_environmentsensor_query_interface /** @} */ // end of device_interface diff --git a/include/qdmi/types.h b/include/qdmi/types.h index b2c5c0b8..0d3a54e0 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,24 +72,24 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** - * @brief A handle for an environment variable. + * @brief A handle for an environment sensor variable. * @details An opaque pointer to an implementation of the QDMI environment - * concept. The environmental factors of the laboratories can affect the + * sensor concept. The environmental factors of the laboratories can affect the * operations and measurement results of quantum devices. Therefore, they are - * closely monitored. An environment generally represents any sensors that can - * be queried. They might be sensors for temperature, noise, etc. Each + * closely monitored. An environment sensor generally represents any sensors + * that can be queried. They might be sensors for temperature, noise, etc. Each * implementation of the @ref device_interface "QDMI Device Interface" defines * the actual implementation of the concept. * * A simple example of an implementation is a struct that merely contains the - * environment ID, which can be used to identify the site. + * environment sensor ID, which can be used to identify the site. * ``` - * struct QDMI_Environment_impl_d { + * struct QDMI_EnvironmentSensor_impl_d { * char* id; * }; * ``` */ -typedef struct QDMI_Environment_impl_d *QDMI_Environment; +typedef struct QDMI_EnvironmentSensor_impl_d *QDMI_EnvironmentSensor; // NOLINTEND(modernize-use-using) diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index a288d641..d7c56cb8 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -994,69 +994,69 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { const auto fomac = FoMaC(device); - auto environments = fomac.get_environment_variables(); + std::vector environment_sensors = fomac.get_environment_variables(); - ASSERT_GT(environments.size(), 0); + ASSERT_GT(environment_sensors.size(), 0); - for (const auto &environment : environments) { - QDMI_Environment_Query query = nullptr; - QDMI_Environment_Query_Status status; + for (QDMI_EnvironmentSensor environment_sensor : environment_sensors) { + QDMI_EnvironmentSensor_Query query = nullptr; + QDMI_EnvironmentSensor_Query_Status status = {}; time_t start_time = time(&start_time); time_t end_time = time(&end_time) + 600; - EXPECT_EQ(QDMI_device_create_environment_query(device, &query), + EXPECT_EQ(QDMI_device_create_environmentsensor_query(device, &query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_set_parameter( - query, QDMI_ENVIRONMENT_QUERY_PARAMETER_ENVIRONMENT, - sizeof(QDMI_Environment), &environment), + EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( + query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT, + sizeof(QDMI_EnvironmentSensor), &environment_sensor), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_set_parameter( - query, QDMI_ENVIRONMENT_QUERY_PARAMETER_START_TIME, + EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( + query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, sizeof(time_t), &start_time), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_set_parameter( - query, QDMI_ENVIRONMENT_QUERY_PARAMETER_END_TIME, + EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( + query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME, sizeof(time_t), &end_time), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_submit(query), QDMI_SUCCESS); + EXPECT_EQ(QDMI_environmentsensor_query_submit(query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_wait(query), QDMI_SUCCESS); + EXPECT_EQ(QDMI_environmentsensor_query_wait(query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environment_query_check_status(query, &status), + EXPECT_EQ(QDMI_environmentsensor_query_check_status(query, &status), QDMI_SUCCESS); size_t timestamps_size = 0; - EXPECT_EQ(QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, 0, nullptr, + EXPECT_EQ(QDMI_environmentsensor_query_get_results( + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, 0, nullptr, ×tamps_size), QDMI_SUCCESS); std::vector timestamps; timestamps.reserve(timestamps_size); - EXPECT_EQ(QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_TIMESTAMPS, + EXPECT_EQ(QDMI_environmentsensor_query_get_results( + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, timestamps_size, timestamps.data(), nullptr), QDMI_SUCCESS); size_t size_values = 0; - EXPECT_EQ(QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, 0, nullptr, + EXPECT_EQ(QDMI_environmentsensor_query_get_results( + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, 0, nullptr, &size_values), QDMI_SUCCESS); std::vector values; values.reserve(size_values); - EXPECT_EQ(QDMI_environment_query_get_results( - query, QDMI_ENVIRONMENT_QUERY_RESULT_VALUES, size_values, + EXPECT_EQ(QDMI_environmentsensor_query_get_results( + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, size_values, values.data(), nullptr), QDMI_SUCCESS); - QDMI_environment_query_free(query); + QDMI_environmentsensor_query_free(query); } } From 20a284121954cc4413ae7a12a0476e59a088d0c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:23:11 +0000 Subject: [PATCH 23/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 30 +++++++++------- examples/device/cxx/device.cpp | 29 ++++++++------- examples/driver/qdmi_example_driver.cpp | 48 ++++++++++++++----------- examples/fomac/example_fomac.cpp | 30 ++++++++-------- examples/fomac/example_fomac.hpp | 11 +++--- test/test_qdmi.cpp | 11 +++--- 6 files changed, 89 insertions(+), 70 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 9abf2edf..86413dd7 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -745,8 +745,8 @@ int C_QDMI_device_session_query_device_property(C_QDMI_Device_Session session, ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, - C_QDMI_EnvironmentSensor, C_DEVICE_ENVIRONMENTSENSORS, 1, prop, size, - value, size_ret) + C_QDMI_EnvironmentSensor, C_DEVICE_ENVIRONMENTSENSORS, 1, + prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] @@ -870,7 +870,8 @@ int C_QDMI_device_session_query_environmentsensor_property( C_QDMI_Device_Session session, C_QDMI_EnvironmentSensor environment_sensor, QDMI_EnvironmentSensor_Property prop, size_t size, void *value, size_t *size_ret) { - if (session == NULL || environment_sensor == NULL || (value != NULL && size == 0) || + if (session == NULL || environment_sensor == NULL || + (value != NULL && size == 0) || (prop >= QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX && prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 && prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 && @@ -880,18 +881,19 @@ int C_QDMI_device_session_query_environmentsensor_property( return QDMI_ERROR_INVALIDARGUMENT; } - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, environment_sensor->id, prop, size, - value, size_ret) - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, environment_sensor->unit, prop, - size, value, size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, + environment_sensor->id, prop, size, value, size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, + environment_sensor->unit, prop, size, value, size_ret) ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, int, - environment_sensor->sampling_rate, prop, size, value, - size_ret) + environment_sensor->sampling_rate, prop, size, + value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } int C_QDMI_device_session_create_environmentsensor_query( - C_QDMI_Device_Session session, C_QDMI_Device_EnvironmentSensor_Query *query) { + C_QDMI_Device_Session session, + C_QDMI_Device_EnvironmentSensor_Query *query) { if (session == NULL || query == NULL) { return QDMI_ERROR_INVALIDARGUMENT; @@ -968,8 +970,9 @@ int C_QDMI_device_environmentsensor_query_submit( } int C_QDMI_device_environmentsensor_query_get_results( - C_QDMI_Device_EnvironmentSensor_Query query, QDMI_EnvironmentSensor_Query_Result result, - size_t size, void *data, size_t *size_ret) { + C_QDMI_Device_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, + size_t *size_ret) { if (query == NULL || (data != NULL && size == 0) || (result >= QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX && @@ -1047,7 +1050,8 @@ int C_QDMI_device_environmentsensor_query_wait( int C_QDMI_device_environmentsensor_query_cancel( C_QDMI_Device_EnvironmentSensor_Query query) { - if (query == NULL || query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { + if (query == NULL || + query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { return QDMI_ERROR_INVALIDARGUMENT; } diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index f1b0ec90..e41c8b92 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -180,7 +180,7 @@ constexpr std::array CXX_DEVICE_SITES = { &SITE0, &SITE1, &SITE2, &SITE3, &SITE4}; const CXX_QDMI_EnvironmentSensor_impl_d ENVSEN{"t4k", "K", - std::chrono::duration{60}}; + std::chrono::duration{60}}; constexpr std::array CXX_DEVICE_ENVIRONMENTSENSORS{&ENVSEN}; @@ -800,8 +800,8 @@ int CXX_QDMI_device_session_query_device_property( prop, size, value, size_ret) ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, - CXX_QDMI_EnvironmentSensor, CXX_DEVICE_ENVIRONMENTSENSORS, prop, size, - value, size_ret) + CXX_QDMI_EnvironmentSensor, CXX_DEVICE_ENVIRONMENTSENSORS, + prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] @@ -900,7 +900,8 @@ int CXX_QDMI_device_session_query_operation_property( } /// [DOXYGEN FUNCTION END] int CXX_QDMI_device_session_query_environmentsensor_property( - CXX_QDMI_Device_Session session, CXX_QDMI_EnvironmentSensor environment_sensor, + CXX_QDMI_Device_Session session, + CXX_QDMI_EnvironmentSensor environment_sensor, QDMI_EnvironmentSensor_Property prop, size_t size, void *value, size_t *size_ret) { if (session == nullptr || environment_sensor == nullptr || @@ -913,18 +914,21 @@ int CXX_QDMI_device_session_query_environmentsensor_property( prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, environment_sensor->id.c_str(), - prop, size, value, size_ret) - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, environment_sensor->unit.c_str(), - prop, size, value, size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, + environment_sensor->id.c_str(), prop, size, value, + size_ret) + ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, + environment_sensor->unit.c_str(), prop, size, value, + size_ret) ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, int, - environment_sensor->sampling_rate.count(), prop, size, - value, size_ret) + environment_sensor->sampling_rate.count(), prop, + size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } int CXX_QDMI_device_session_create_environmentsensor_query( - CXX_QDMI_Device_Session session, CXX_QDMI_Device_EnvironmentSensor_Query *query) { + CXX_QDMI_Device_Session session, + CXX_QDMI_Device_EnvironmentSensor_Query *query) { if (session == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -1104,7 +1108,8 @@ int CXX_QDMI_device_environmentsensor_query_wait( int CXX_QDMI_device_environmentsensor_query_cancel( CXX_QDMI_Device_EnvironmentSensor_Query query) { - if (query == nullptr || query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { + if (query == nullptr || + query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { return QDMI_ERROR_INVALIDARGUMENT; } diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index b30b25f4..bd98958c 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -121,12 +121,14 @@ struct QDMI_Library { decltype(QDMI_device_environmentsensor_query_check_status) *device_environmentsensor_query_check_status{}; - decltype(QDMI_device_environmentsensor_query_wait) *device_environmentsensor_query_wait{}; + decltype(QDMI_device_environmentsensor_query_wait) + *device_environmentsensor_query_wait{}; decltype(QDMI_device_environmentsensor_query_cancel) *device_environmentsensor_query_cancel{}; - decltype(QDMI_device_environmentsensor_query_free) *device_environmentsensor_query_free{}; + decltype(QDMI_device_environmentsensor_query_free) + *device_environmentsensor_query_free{}; // default constructor QDMI_Library() = default; @@ -249,7 +251,8 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_device_property) LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) - LOAD_SYMBOL(library, prefix, device_session_query_environmentsensor_property) + LOAD_SYMBOL(library, prefix, + device_session_query_environmentsensor_property) // device qnvironment interface LOAD_SYMBOL(library, prefix, device_session_create_environmentsensor_query) LOAD_SYMBOL(library, prefix, device_environmentsensor_query_set_parameter) @@ -569,11 +572,10 @@ int QDMI_device_query_operation_property( prop, size, value, size_ret); } -int QDMI_device_query_environmentsensor_property(QDMI_Device device, - QDMI_EnvironmentSensor environment_sensor, - QDMI_EnvironmentSensor_Property prop, - const size_t size, void *value, - size_t *size_ret) { +int QDMI_device_query_environmentsensor_property( + QDMI_Device device, QDMI_EnvironmentSensor environment_sensor, + QDMI_EnvironmentSensor_Property prop, const size_t size, void *value, + size_t *size_ret) { if (device == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -581,8 +583,8 @@ int QDMI_device_query_environmentsensor_property(QDMI_Device device, device->device_session, environment_sensor, prop, size, value, size_ret); } -int QDMI_device_create_environmentsensor_query(QDMI_Device dev, - QDMI_EnvironmentSensor_Query *query) { +int QDMI_device_create_environmentsensor_query( + QDMI_Device dev, QDMI_EnvironmentSensor_Query *query) { if (dev == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -597,15 +599,17 @@ int QDMI_device_create_environmentsensor_query(QDMI_Device dev, dev->device_session, &(*query)->env_query); } -int QDMI_environmentsensor_query_set_parameter(QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Parameter param, - size_t size, const void *value) { +int QDMI_environmentsensor_query_set_parameter( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Parameter param, size_t size, + const void *value) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } return query->device->library->device_environmentsensor_query_set_parameter( query->env_query, - static_cast(param), size, value); + static_cast(param), size, + value); } int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query) { @@ -616,10 +620,10 @@ int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query) { query->env_query); } -int QDMI_environmentsensor_query_get_results(QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Result result, - size_t size, void *data, - size_t *size_ret) { +int QDMI_environmentsensor_query_get_results( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, + size_t *size_ret) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -627,8 +631,9 @@ int QDMI_environmentsensor_query_get_results(QDMI_EnvironmentSensor_Query query, query->env_query, result, size, data, size_ret); } -int QDMI_environmentsensor_query_check_status(QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Status *status) { +int QDMI_environmentsensor_query_check_status( + QDMI_EnvironmentSensor_Query query, + QDMI_EnvironmentSensor_Query_Status *status) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -656,7 +661,8 @@ int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query) { void QDMI_environmentsensor_query_free(QDMI_EnvironmentSensor_Query query) { if (query != nullptr) { - query->device->library->device_environmentsensor_query_free(query->env_query); + query->device->library->device_environmentsensor_query_free( + query->env_query); delete query; } } diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 90b4d7e0..27bc8ef2 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -201,14 +201,15 @@ auto FoMaC::get_parameters_num(const QDMI_Operation &op) const -> size_t { return parameters_num; } -auto FoMaC::get_environment_variables() const -> std::vector { +auto FoMaC::get_environment_variables() const + -> std::vector { size_t environment_sensor_size = 0; int ret = QDMI_device_query_device_property( device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, 0, nullptr, &environment_sensor_size); throw_if_error(ret, "Failed to get the environment variable list size."); - std::vector environment_sensors(environment_sensor_size / - sizeof(QDMI_Site)); + std::vector environment_sensors( + environment_sensor_size / sizeof(QDMI_Site)); ret = QDMI_device_query_device_property( device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, environment_sensor_size, static_cast(environment_sensors.data()), nullptr); @@ -221,8 +222,8 @@ auto FoMaC::get_environment_id(QDMI_EnvironmentSensor environment_sensor) const size_t environmentsensor_id_size = 0; int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, 0, nullptr, - &environmentsensor_id_size); + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, 0, + nullptr, &environmentsensor_id_size); throw_if_error(ret, "Failed to query the size for environment ID"); std::string environmentsensor_id(environmentsensor_id_size - 1, '\0'); ret = QDMI_device_query_environmentsensor_property( @@ -233,30 +234,31 @@ auto FoMaC::get_environment_id(QDMI_EnvironmentSensor environment_sensor) const return environmentsensor_id; } -auto FoMaC::get_environment_unit(QDMI_EnvironmentSensor environment_sensor) const - -> std::string { +auto FoMaC::get_environment_unit( + QDMI_EnvironmentSensor environment_sensor) const -> std::string { size_t environmentsensor_unit_size = 0; int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, nullptr, - &environmentsensor_unit_size); + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, + nullptr, &environmentsensor_unit_size); throw_if_error(ret, "Failed to query the size for environment unit"); std::string environmentsensor_unit(environmentsensor_unit_size - 1, '\0'); ret = QDMI_device_query_environmentsensor_property( device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, - environmentsensor_unit.size() + 1, environmentsensor_unit.data(), nullptr); + environmentsensor_unit.size() + 1, environmentsensor_unit.data(), + nullptr); throw_if_error(ret, "Failed to query the environment unit"); return environmentsensor_unit; } -auto FoMaC::get_environment_sampling_rate(QDMI_EnvironmentSensor environment_sensor) const - -> int { +auto FoMaC::get_environment_sampling_rate( + QDMI_EnvironmentSensor environment_sensor) const -> int { int sampling_rate = 0; const int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, sizeof(int), - &sampling_rate, nullptr); + device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, + sizeof(int), &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); return sampling_rate; diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index cd7bb889..4000e2c1 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -67,12 +67,13 @@ class FoMaC { [[nodiscard]] auto get_environment_variables() const -> std::vector; - [[nodiscard]] auto get_environment_id(QDMI_EnvironmentSensor environment) const - -> std::string; + [[nodiscard]] auto + get_environment_id(QDMI_EnvironmentSensor environment) const -> std::string; - [[nodiscard]] auto get_environment_unit(QDMI_EnvironmentSensor environment) const - -> std::string; + [[nodiscard]] auto + get_environment_unit(QDMI_EnvironmentSensor environment) const -> std::string; [[nodiscard]] auto - get_environment_sampling_rate(QDMI_EnvironmentSensor environment) const -> int; + get_environment_sampling_rate(QDMI_EnvironmentSensor environment) const + -> int; }; diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index d7c56cb8..9a1613d4 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -994,7 +994,8 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { const auto fomac = FoMaC(device); - std::vector environment_sensors = fomac.get_environment_variables(); + std::vector environment_sensors = + fomac.get_environment_variables(); ASSERT_GT(environment_sensors.size(), 0); @@ -1031,8 +1032,8 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { size_t timestamps_size = 0; EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, 0, nullptr, - ×tamps_size), + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, 0, + nullptr, ×tamps_size), QDMI_SUCCESS); std::vector timestamps; @@ -1053,8 +1054,8 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { values.reserve(size_values); EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, size_values, - values.data(), nullptr), + query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, + size_values, values.data(), nullptr), QDMI_SUCCESS); QDMI_environmentsensor_query_free(query); From e239964d3f8902d8a841ed2ecbc4f09d51c7d9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 10:42:26 +0200 Subject: [PATCH 24/61] =?UTF-8?q?=F0=9F=8E=A8=20timeout=20parameter=20for?= =?UTF-8?q?=20environmentsensor=5Fquery=5Fwait=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 2 +- examples/driver/qdmi_example_driver.cpp | 5 +++-- include/qdmi/client.h | 8 ++++++-- include/qdmi/device.h | 7 +++++-- test/test_qdmi.cpp | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 86413dd7..2325f1e1 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -1037,7 +1037,7 @@ int C_QDMI_device_environmentsensor_query_check_status( } int C_QDMI_device_environmentsensor_query_wait( - C_QDMI_Device_EnvironmentSensor_Query query) { + C_QDMI_Device_EnvironmentSensor_Query query, size_t timeout) { if (query == NULL) { return QDMI_ERROR_INVALIDARGUMENT; diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index bd98958c..3acdc7fc 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -642,12 +642,13 @@ int QDMI_environmentsensor_query_check_status( query->env_query, status); } -int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query) { +int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, + size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } return query->device->library->device_environmentsensor_query_wait( - query->env_query); + query->env_query, timeout); } int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query) { diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 1e86b1c3..ab557b69 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -1285,20 +1285,24 @@ int QDMI_environmentsensor_query_check_status( /** * @brief Wait for an environment sensor query to finish. * @details This function blocks until the environment sensor query has either - * finished or has been canceled. + * finished or has been canceled, or the timeout has been reached. * @param[in] query The environment sensor query to wait for. Must not be @c * NULL. + * @param[in] timeout The timeout in seconds. * @return @ref QDMI_SUCCESS if the environment sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using * the @ref client_environmentsensor_query_interface "client environment sensor * query interface" for the device in the current session. + * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the query did + * not finish within the specified time. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be * waited for and this function returns before the environment sensor query has * finished or has been canceled. */ -int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query); +int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, + size_t timeout); /** * @brief Retrieve the results of an environment sensor query. diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 17b12c3d..02fadeb8 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -808,21 +808,24 @@ int QDMI_device_environmentsensor_query_check_status( /** * @brief Wait for an environment sensor query to finish. * @details This function blocks until the environment sensor query has either - * finished or has been canceled. + * finished or has been canceled, or the timeout has been reached. * @param[in] query The environment sensor query to wait for. Must not be @c * NULL. + * @param[in] timeout The timeout in seconds. * @return @ref QDMI_SUCCESS if the environment sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using * the @ref device_environmentsensor_query_interface "device environment sensor * query interface" for the current session. + * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the job did not + * finish within the specified time. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be * waited for and this function returns before the environment sensor query has * finished or has been canceled. */ int QDMI_device_environmentsensor_query_wait( - QDMI_Device_EnvironmentSensor_Query query); + QDMI_Device_EnvironmentSensor_Query query, size_t timeout); /** * @brief Retrieve the results of an environment sensor query. diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 9a1613d4..4288b2e6 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -1025,7 +1025,7 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { EXPECT_EQ(QDMI_environmentsensor_query_submit(query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_wait(query), QDMI_SUCCESS); + EXPECT_EQ(QDMI_environmentsensor_query_wait(query, 0), QDMI_SUCCESS); EXPECT_EQ(QDMI_environmentsensor_query_check_status(query, &status), QDMI_SUCCESS); From 7474cbee01218b8a70a3ec2efb24297fdadb83a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 11:16:36 +0200 Subject: [PATCH 25/61] =?UTF-8?q?=F0=9F=8E=A8=20consisting=20parameter=20n?= =?UTF-8?q?aming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 4 ++-- examples/device/cxx/device.cpp | 6 +++--- include/qdmi/client.h | 5 +++-- include/qdmi/constants.h | 8 ++++---- include/qdmi/device.h | 1 + test/test_qdmi.cpp | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index 2325f1e1..c2378d34 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -925,10 +925,10 @@ int C_QDMI_device_environmentsensor_query_set_parameter( } switch (param) { - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME: + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME: query->start_time = *(time_t *)(value); return QDMI_SUCCESS; - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME: + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME: query->end_time = *(time_t *)(value); return QDMI_SUCCESS; case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR: diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index e41c8b92..d83f2549 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -960,13 +960,13 @@ int CXX_QDMI_device_environmentsensor_query_set_parameter( } switch (param) { - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME: { + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME: { const auto *c_start_time_ptr = static_cast(value); query->start_time = std::chrono::system_clock::from_time_t(*c_start_time_ptr); return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME: { + case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME: { const auto *c_end_time_ptr = static_cast(value); query->end_time = std::chrono::system_clock::from_time_t(*c_end_time_ptr); @@ -1095,7 +1095,7 @@ int CXX_QDMI_device_environmentsensor_query_check_status( } int CXX_QDMI_device_environmentsensor_query_wait( - CXX_QDMI_Device_EnvironmentSensor_Query query) { + CXX_QDMI_Device_EnvironmentSensor_Query query, size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; diff --git a/include/qdmi/client.h b/include/qdmi/client.h index ab557b69..22dd483a 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -1125,10 +1125,10 @@ int QDMI_device_create_environmentsensor_query( enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { /// The start time of the environment query interval. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME = 0, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME = 0, /// The end time of the environment query interval. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME = 1, + QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME = 1, /// The environment for the environment query. QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT = 2, @@ -1289,6 +1289,7 @@ int QDMI_environmentsensor_query_check_status( * @param[in] query The environment sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. + * If this is zero, the function waits indefinitely until the job has finished. * @return @ref QDMI_SUCCESS if the environment sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index c4fb55d6..cc22e57b 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -822,9 +822,9 @@ typedef enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T QDMI_EnvironmentSensor_Property; */ enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { /// The start time of the environment sensor query interval. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME = 0, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME = 0, /// The end time of the environment sensor query interval. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME = 1, + QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME = 1, /// The environment sensor for the environment sensor query. QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR = 2, /// The maximum value of the enum. @@ -856,8 +856,8 @@ typedef enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T */ enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T { /** - * @brief `uint64_t*` (`unsigned 64 bit integer` list) The timestamps at which - * the corresponding values in the results were recorded by a sensor. + * @brief `uint64_t*` (`unsigned 64 bit integer` list) The UNIX timestamps at + * which the corresponding values in the results were recorded by a sensor. * @details The result of an environment sensor query is represented as a * key-value mapping. This mapping is returned as a list of keys and an * equal-length list of values. The corresponding partners of the keys and diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 02fadeb8..0286d71a 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -812,6 +812,7 @@ int QDMI_device_environmentsensor_query_check_status( * @param[in] query The environment sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. + * If this is zero, the function waits indefinitely until the job has finished. * @return @ref QDMI_SUCCESS if the environment sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 4288b2e6..bcb3c63f 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -1014,12 +1014,12 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { QDMI_SUCCESS); EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( - query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, + query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME, sizeof(time_t), &start_time), QDMI_SUCCESS); EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( - query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_END_TIME, + query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME, sizeof(time_t), &end_time), QDMI_SUCCESS); From c71b2c3edf9730e84874493417ff089289cdd808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 13:17:42 +0200 Subject: [PATCH 26/61] =?UTF-8?q?=F0=9F=9A=A8=20fix=20linter=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/c/device.c | 12 +++++++++--- examples/device/cxx/device.cpp | 25 +++++++++++++------------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/examples/device/c/device.c b/examples/device/c/device.c index c2378d34..6337cb0f 100644 --- a/examples/device/c/device.c +++ b/examples/device/c/device.c @@ -69,6 +69,7 @@ typedef struct C_QDMI_EnvironmentSensor_impl_d { typedef struct C_QDMI_Device_EnvironmentSensor_Query_impl_d { time_t start_time; time_t end_time; + size_t timeout; C_QDMI_EnvironmentSensor environment_sensor; time_t *result_timestamps; float *result_values; @@ -901,8 +902,11 @@ int C_QDMI_device_session_create_environmentsensor_query( if (session->status != INITIALIZED) { return QDMI_ERROR_BADSTATE; } - *query = malloc(sizeof(C_QDMI_Device_EnvironmentSensor_Query_impl_t)); - (*query)->environment_sensor = malloc(sizeof(C_QDMI_EnvironmentSensor)); + + *query = (C_QDMI_Device_EnvironmentSensor_Query)malloc( + sizeof(C_QDMI_Device_EnvironmentSensor_Query_impl_t)); + (*query)->environment_sensor = + (C_QDMI_EnvironmentSensor)malloc(sizeof(C_QDMI_EnvironmentSensor_impl_t)); (*query)->start_time = time(NULL); (*query)->end_time = time(NULL); @@ -920,7 +924,8 @@ int C_QDMI_device_environmentsensor_query_set_parameter( param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 && param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 && param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5)) { + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5) || + value == NULL) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { @@ -1044,6 +1049,7 @@ int C_QDMI_device_environmentsensor_query_wait( } query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; + query->timeout = timeout; return QDMI_SUCCESS; } diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index d83f2549..b9b99d32 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -29,6 +29,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include #include @@ -87,8 +88,9 @@ struct CXX_QDMI_EnvironmentSensor_impl_d { }; struct CXX_QDMI_Device_EnvironmentSensor_Query_impl_d { - std::chrono::time_point start_time{}; - std::chrono::time_point end_time{}; + std::chrono::time_point start_time; + std::chrono::time_point end_time; + size_t timeout{}; CXX_QDMI_EnvironmentSensor environment_sensor{}; std::vector> result_timestamps; @@ -955,28 +957,26 @@ int CXX_QDMI_device_environmentsensor_query_set_parameter( param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 && param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 && param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5)) { + param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5) || + value == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME: { - const auto *c_start_time_ptr = static_cast(value); - query->start_time = - std::chrono::system_clock::from_time_t(*c_start_time_ptr); + query->start_time = std::chrono::system_clock::from_time_t( + *static_cast(value)); return QDMI_SUCCESS; } case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME: { - - const auto *c_end_time_ptr = static_cast(value); - query->end_time = std::chrono::system_clock::from_time_t(*c_end_time_ptr); + query->end_time = std::chrono::system_clock::from_time_t( + *static_cast(value)); return QDMI_SUCCESS; } case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR: { - const auto *environment_ptr = - static_cast(value); - query->environment_sensor = *environment_ptr; + query->environment_sensor = + *(static_cast(value)); return QDMI_SUCCESS; } default: @@ -1102,6 +1102,7 @@ int CXX_QDMI_device_environmentsensor_query_wait( } query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; + query->timeout = timeout; return QDMI_SUCCESS; } From d0db550bf021cde6bf66dfcaa86a9dafaa1b83a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 14:34:45 +0200 Subject: [PATCH 27/61] =?UTF-8?q?=F0=9F=9A=A8=20Fixing=20linter=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 1 + test/test_qdmi.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index b9b99d32..f20fc4a1 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -33,6 +33,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include #include diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index bcb3c63f..b60c0104 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -28,7 +28,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include -#include +#include #include #include #include @@ -994,7 +994,7 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { const auto fomac = FoMaC(device); - std::vector environment_sensors = + const std::vector environment_sensors = fomac.get_environment_variables(); ASSERT_GT(environment_sensors.size(), 0); @@ -1010,7 +1010,7 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT, - sizeof(QDMI_EnvironmentSensor), &environment_sensor), + sizeof(QDMI_EnvironmentSensor), &*environment_sensor), QDMI_SUCCESS); EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( From 0e9bcb21da9e00249aeebd9b543cb3c4a7d9e554 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 12:35:00 +0000 Subject: [PATCH 28/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 2 +- test/test_qdmi.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index f20fc4a1..93a187ec 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -31,9 +31,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include -#include #include #include #include diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index b60c0104..954fb0f7 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -24,11 +24,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include #include #include -#include #include #include #include From d2218d584a2da8f3ad59bf8f685a8c9131c581b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 16:16:58 +0200 Subject: [PATCH 29/61] =?UTF-8?q?=F0=9F=9A=A8=20linter=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_qdmi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 954fb0f7..41ed027b 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -1010,7 +1010,8 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT, - sizeof(QDMI_EnvironmentSensor), &*environment_sensor), + sizeof(QDMI_EnvironmentSensor), + static_cast(&environment_sensor)), QDMI_SUCCESS); EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( From 889b27c6c49f5d5297f0820fb8bf7357cf43b6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ercu=CC=88ment=20Kaya?= Date: Mon, 16 Jun 2025 18:04:38 +0200 Subject: [PATCH 30/61] =?UTF-8?q?=F0=9F=9A=A8=20lint=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index 93a187ec..b88ea2d5 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -995,8 +995,8 @@ int CXX_QDMI_device_environmentsensor_query_submit( // here, the actual submission. // for demonstration purposes - auto time_difference = std::chrono::round( - query->end_time - query->start_time); + auto time_difference = std::chrono::round( // NOLINT(misc-include-cleaner) + query->end_time - query->start_time); auto sampling_rate = query->environment_sensor->sampling_rate; From a83cbf4b896d853c30b22886c5addae0c6c04dd7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:04:57 +0000 Subject: [PATCH 31/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/cxx/device.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/device/cxx/device.cpp b/examples/device/cxx/device.cpp index b88ea2d5..c81483b2 100644 --- a/examples/device/cxx/device.cpp +++ b/examples/device/cxx/device.cpp @@ -995,8 +995,9 @@ int CXX_QDMI_device_environmentsensor_query_submit( // here, the actual submission. // for demonstration purposes - auto time_difference = std::chrono::round( // NOLINT(misc-include-cleaner) - query->end_time - query->start_time); + auto time_difference = + std::chrono::round( // NOLINT(misc-include-cleaner) + query->end_time - query->start_time); auto sampling_rate = query->environment_sensor->sampling_rate; From 123d2e649425423bba028254b2a7f3685d6896ab Mon Sep 17 00:00:00 2001 From: Kaya Date: Thu, 31 Jul 2025 17:10:44 +0200 Subject: [PATCH 32/61] =?UTF-8?q?=F0=9F=A9=B9=20minor=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index f78da879..d116dfdf 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -334,7 +334,7 @@ enum QDMI_DEVICE_PROPERTY_T { /** * TODO */ - QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 9, + QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 10, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of From f562d03373ef917c6bcd25bfe8cd6f6c0ad8f014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= <49598189+kayaercument@users.noreply.github.com> Date: Fri, 1 Aug 2025 09:12:36 +0200 Subject: [PATCH 33/61] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yannick Stade <100073938+ystade@users.noreply.github.com> Signed-off-by: Ercรผment Kaya <49598189+kayaercument@users.noreply.github.com> --- examples/fomac/example_fomac.cpp | 2 +- include/qdmi/device.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 27bc8ef2..9c80911d 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -201,7 +201,7 @@ auto FoMaC::get_parameters_num(const QDMI_Operation &op) const -> size_t { return parameters_num; } -auto FoMaC::get_environment_variables() const +auto FoMaC::get_environment_sensors() const -> std::vector { size_t environment_sensor_size = 0; int ret = QDMI_device_query_device_property( diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 0286d71a..40add57f 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -697,7 +697,7 @@ typedef struct QDMI_Device_EnvironmentSensor_Query_impl_d * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using * the @ref device_environmentsensor_query_interface "device environment sensor * query interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if environment sensor query creation failed due + * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed due * to a fatal error. * * @attention May only be called after the session has been initialized with @@ -758,7 +758,7 @@ int QDMI_device_environmentsensor_query_set_parameter( * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p job is @c NULL. * @return @ref QDMI_ERROR_BADSTATE if the job is in an invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensro + * the @ref device_environmentsensor_query_interface "device environment sensor * query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the job submission failed. */ @@ -808,7 +808,7 @@ int QDMI_device_environmentsensor_query_check_status( /** * @brief Wait for an environment sensor query to finish. * @details This function blocks until the environment sensor query has either - * finished or has been canceled, or the timeout has been reached. + * finished, has been canceled, or the timeout has been reached. * @param[in] query The environment sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. @@ -871,8 +871,8 @@ int QDMI_device_environmentsensor_query_get_results( size_t *size_ret); /** * @brief Free an environment sensor query. - * @details Free the resources associated with a environment sensor query. Using - * a environment sensor query handle after it has been freed is undefined + * @details Free the resources associated with an environment sensor query. Using + * an environment sensor query handle after it has been freed is undefined * behavior. * @param[in] query The environment sensor query to free. */ From 64ea415d8defafff0390c95bffd34205cf5b8772 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 07:12:46 +0000 Subject: [PATCH 34/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/device.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 40add57f..7ee6f516 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -697,8 +697,8 @@ typedef struct QDMI_Device_EnvironmentSensor_Query_impl_d * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using * the @ref device_environmentsensor_query_interface "device environment sensor * query interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed due - * to a fatal error. + * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed + * due to a fatal error. * * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. @@ -871,8 +871,8 @@ int QDMI_device_environmentsensor_query_get_results( size_t *size_ret); /** * @brief Free an environment sensor query. - * @details Free the resources associated with an environment sensor query. Using - * an environment sensor query handle after it has been freed is undefined + * @details Free the resources associated with an environment sensor query. + * Using an environment sensor query handle after it has been freed is undefined * behavior. * @param[in] query The environment sensor query to free. */ From 6df7deeda37092590fd3391c2b24b521f1b97456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Mon, 4 Aug 2025 09:10:46 +0200 Subject: [PATCH 35/61] =?UTF-8?q?=F0=9F=93=9D=20improvements=20on=20the=20?= =?UTF-8?q?documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/fomac/example_fomac.cpp | 1 - examples/fomac/example_fomac.hpp | 2 +- include/qdmi/client.h | 43 +++++++++++++++++++------------- include/qdmi/constants.h | 5 +++- include/qdmi/device.h | 37 ++++++++++++++------------- test/test_qdmi.cpp | 4 +-- 6 files changed, 51 insertions(+), 41 deletions(-) diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 9c80911d..68880d63 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -25,7 +25,6 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "example_fomac.hpp" #include "qdmi/client.h" -#include "qdmi/constants.h" #include #include diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index 4000e2c1..11d23e3e 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -64,7 +64,7 @@ class FoMaC { [[nodiscard]] auto get_parameters_num(const QDMI_Operation &op) const -> size_t; - [[nodiscard]] auto get_environment_variables() const + [[nodiscard]] auto get_environment_sensors() const -> std::vector; [[nodiscard]] auto diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 22dd483a..ef11ce4f 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -50,8 +50,8 @@ extern "C" { * properties of devices. * - The @ref client_job_interface "client job interface" for submitting jobs * to devices. - * - The @ref client_environmentsensor_query_interface "client environment - * sensor query interface" for querying environment sensors. + * - The @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for querying environment sensors. * * @{ */ @@ -1054,8 +1054,8 @@ void QDMI_job_free(QDMI_Job job); /** @} */ // end of client_job_interface -/** @defgroup client_environmentsensor_query_interface QDMI Client Environment - * Sensor Query Interface +/** @defgroup client_environmentsensor_query_interface + * QDMI Client Environment Sensor Query Interface * @brief Provides functions to query environment sensors. * @details An environment sensor query is a task submitted by a client to a * device for querying environment sensors, i.e. temperature or power. @@ -1108,8 +1108,9 @@ typedef struct QDMI_EnvironmentSensor_Query_impl_d * @return @ref QDMI_SUCCESS if the job was successfully created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed * due to a fatal error. */ @@ -1186,8 +1187,9 @@ typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T * current state of the job, for example, because the query is already * submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. * @@ -1234,8 +1236,9 @@ int QDMI_environmentsensor_query_set_parameter( * @return @ref QDMI_ERROR_BADSTATE if the environment sensor query is in an * invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query submission * failed. */ @@ -1253,8 +1256,9 @@ int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query); * environment sensor query already has the status @ref * QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be * canceled. */ @@ -1273,8 +1277,9 @@ int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query); * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could * not be checked. */ @@ -1294,8 +1299,9 @@ int QDMI_environmentsensor_query_check_status( * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the query did * not finish within the specified time. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be @@ -1329,8 +1335,9 @@ int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref client_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * * @note By calling this function with @p data set to @c NULL, the function can diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index d116dfdf..e8ec0c8c 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -332,7 +332,10 @@ enum QDMI_DEVICE_PROPERTY_T { */ QDMI_DEVICE_PROPERTY_PULSESUPPORT = 9, /** - * TODO + * @brief `QDMI_EnvironmentSensor*` (@ref QDMI_EnvironmentSensor list) The + * envoronment sensors of the device. + * @details The returned @ref QDMI_EnvironmentSensor handles may be used to + * query envoronment sensors. */ QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 10, /** diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 7ee6f516..7c8c4c30 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -638,8 +638,8 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @} */ // end of device_job_interface -/** @defgroup device_environmentsensor_query_interface QDMI Device Environment - * Sensor Query Interface +/** @defgroup device_environmentsensor_query_interface + * QDMI Device Environment Sensor Query Interface * @brief Provides functions to manage environment sensor queries on a device. * @details An environment sensor query is a task submitted to a device for * querying environment sensors, i.e. temperature or power. @@ -695,8 +695,8 @@ typedef struct QDMI_Device_EnvironmentSensor_Query_impl_d * the creation of an environment sensor query, for example, because the session * is not initialized. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed * due to a fatal error. * @@ -731,8 +731,8 @@ int QDMI_device_session_create_environmentsensor_query( * current state of the environment sensor query, for example, because the * environment sensor query is already submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. * @@ -758,8 +758,8 @@ int QDMI_device_environmentsensor_query_set_parameter( * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p job is @c NULL. * @return @ref QDMI_ERROR_BADSTATE if the job is in an invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the job submission failed. */ int QDMI_device_environmentsensor_query_submit( @@ -776,8 +776,8 @@ int QDMI_device_environmentsensor_query_submit( * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the job * already has the status @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be * canceled. */ @@ -797,8 +797,9 @@ int QDMI_device_environmentsensor_query_cancel( * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "client environment sensor - * query interface" for the device in the current session. + * the @ref device_environmentsensor_query_interface + * "client environment sensor query interface" for the device in the current + * session. * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could * not be checked. */ @@ -817,8 +818,8 @@ int QDMI_device_environmentsensor_query_check_status( * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the job did not * finish within the specified time. * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be @@ -844,16 +845,16 @@ int QDMI_device_environmentsensor_query_wait( * this is @c NULL, it is ignored. * @return @ref QDMI_SUCCESS if the device supports the specified result and, * when @p data is not @c NULL, the results were successfully retrieved. + * @return @ref QDMI_ERROR_BADSTATE if the @p query has not finished or was + * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if * - @p query is @c NULL, - * - @p query has not finished, - * - @p query was canceled, * - @p result is invalid, or * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface "device environment sensor - * query interface" for the current session. + * the @ref device_environmentsensor_query_interface + * "device environment sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * * @remark Calling this function with @p data set to @c NULL is expected to diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index e886f0df..0e53e2f2 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -976,7 +976,7 @@ TEST_P(QDMIImplementationTest, QueryEveryEnvironmentProperties) { const auto fomac = FoMaC(device); - auto environments = fomac.get_environment_variables(); + auto environments = fomac.get_environment_sensors(); ASSERT_GT(environments.size(), 0); @@ -1001,7 +1001,7 @@ TEST_P(QDMIImplementationTest, EnvironmentQuery) { const auto fomac = FoMaC(device); const std::vector environment_sensors = - fomac.get_environment_variables(); + fomac.get_environment_sensors(); ASSERT_GT(environment_sensors.size(), 0); From e3e6694d7cc42a9f654edb1aca80c35b76d198d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 5 Aug 2025 09:36:12 +0200 Subject: [PATCH 36/61] =?UTF-8?q?=F0=9F=8E=A8=20renaming=20QDMI=5FEnvironm?= =?UTF-8?q?ent=20to=20QDMI=5FTelemetry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/prefix_defs.txt | 26 +- examples/device/device.cpp | 154 ++++++----- examples/driver/qdmi_example_driver.cpp | 123 +++++---- examples/fomac/example_fomac.cpp | 86 +++---- examples/fomac/example_fomac.hpp | 15 +- include/qdmi/client.h | 328 ++++++++++++------------ include/qdmi/constants.h | 170 ++++++------ include/qdmi/device.h | 246 +++++++++--------- include/qdmi/types.h | 14 +- test/test_qdmi.cpp | 76 +++--- 10 files changed, 616 insertions(+), 622 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index 265696b1..bc64909a 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -24,16 +24,16 @@ QDMI_Site QDMI_Site_impl_d QDMI_Operation QDMI_Operation_impl_d -QDMI_EnvironmentSensor -QDMI_EnvironmentSensor_impl_d -QDMI_Device_EnvironmentSensor_Query -QDMI_Device_EnvironmentSensor_Query_impl_d -QDMI_device_session_query_environmentsensor_property -QDMI_device_session_create_environmentsensor_query -QDMI_device_environmentsensor_query_set_parameter -QDMI_device_environmentsensor_query_submit -QDMI_device_environmentsensor_query_get_results -QDMI_device_environmentsensor_query_check_status -QDMI_device_environmentsensor_query_wait -QDMI_device_environmentsensor_query_cancel -QDMI_device_environmentsensor_query_free +QDMI_TelemetrySensor +QDMI_TelemetrySensor_impl_d +QDMI_Device_TelemetrySensor_Query +QDMI_Device_TelemetrySensor_Query_impl_d +QDMI_device_session_query_telemetrysensor_property +QDMI_device_session_create_telemetrysensor_query +QDMI_device_telemetrysensor_query_set_parameter +QDMI_device_telemetrysensor_query_submit +QDMI_device_telemetrysensor_query_get_results +QDMI_device_telemetrysensor_query_check_status +QDMI_device_telemetrysensor_query_wait +QDMI_device_telemetrysensor_query_cancel +QDMI_device_telemetrysensor_query_free diff --git a/examples/device/device.cpp b/examples/device/device.cpp index 3c5be5b1..f8b84c24 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -81,22 +81,22 @@ struct CXX_QDMI_Operation_impl_d { std::string name; }; -struct CXX_QDMI_EnvironmentSensor_impl_d { +struct CXX_QDMI_TelemetrySensor_impl_d { std::string id; std::string unit; std::chrono::duration sampling_rate{}; // in seconds }; -struct CXX_QDMI_Device_EnvironmentSensor_Query_impl_d { +struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { std::chrono::time_point start_time; std::chrono::time_point end_time; size_t timeout{}; - CXX_QDMI_EnvironmentSensor environment_sensor{}; + CXX_QDMI_TelemetrySensor telemetry_sensor{}; std::vector> result_timestamps; std::vector result_values; size_t result_length{}; - QDMI_EnvironmentSensor_Query_Status status{}; + QDMI_TelemetrySensor_Query_Status status{}; }; namespace { @@ -181,11 +181,11 @@ constexpr CXX_QDMI_Site_impl_d SITE4{4}; constexpr std::array CXX_DEVICE_SITES = { &SITE0, &SITE1, &SITE2, &SITE3, &SITE4}; -const CXX_QDMI_EnvironmentSensor_impl_d ENVSEN{"t4k", "K", - std::chrono::duration{60}}; +const CXX_QDMI_TelemetrySensor_impl_d ENVSEN{"t4k", "K", + std::chrono::duration{60}}; -constexpr std::array - CXX_DEVICE_ENVIRONMENTSENSORS{&ENVSEN}; +constexpr std::array + CXX_DEVICE_TELEMETRYSENSORS{&ENVSEN}; constexpr std::array // clang-format off @@ -801,9 +801,9 @@ int CXX_QDMI_device_session_query_device_property( ADD_SINGLE_VALUE_PROPERTY(QDMI_DEVICE_PROPERTY_NEEDSCALIBRATION, size_t, 0, prop, size, value, size_ret) - ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, - CXX_QDMI_EnvironmentSensor, CXX_DEVICE_ENVIRONMENTSENSORS, - prop, size, value, size_ret) + ADD_LIST_PROPERTY(QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS, + CXX_QDMI_TelemetrySensor, CXX_DEVICE_TELEMETRYSENSORS, prop, + size, value, size_ret) ADD_SINGLE_VALUE_PROPERTY( QDMI_DEVICE_PROPERTY_PULSESUPPORT, QDMI_Device_Pulse_Support_Level, QDMI_DEVICE_PULSE_SUPPORT_LEVEL_NONE, prop, size, value, size_ret) @@ -904,36 +904,34 @@ int CXX_QDMI_device_session_query_operation_property( return QDMI_ERROR_NOTSUPPORTED; } /// [DOXYGEN FUNCTION END] -int CXX_QDMI_device_session_query_environmentsensor_property( - CXX_QDMI_Device_Session session, - CXX_QDMI_EnvironmentSensor environment_sensor, - QDMI_EnvironmentSensor_Property prop, size_t size, void *value, +int CXX_QDMI_device_session_query_telemetrysensor_property( + CXX_QDMI_Device_Session session, CXX_QDMI_TelemetrySensor telemetry_sensor, + QDMI_TelemetrySensor_Property prop, size_t size, void *value, size_t *size_ret) { - if (session == nullptr || environment_sensor == nullptr || + if (session == nullptr || telemetry_sensor == nullptr || (value != nullptr && size == 0) || - (prop >= QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX && - prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 && - prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 && - prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM3 && - prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM4 && - prop != QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5)) { + (prop >= QDMI_TELEMETRYSENSOR_PROPERTY_MAX && + prop != QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 && + prop != QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM2 && + prop != QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM3 && + prop != QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM4 && + prop != QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, - environment_sensor->id.c_str(), prop, size, value, - size_ret) - ADD_STRING_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, - environment_sensor->unit.c_str(), prop, size, value, + ADD_STRING_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_ID, + telemetry_sensor->id.c_str(), prop, size, value, size_ret) + ADD_STRING_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, + telemetry_sensor->unit.c_str(), prop, size, value, size_ret) - ADD_SINGLE_VALUE_PROPERTY(QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, int, - environment_sensor->sampling_rate.count(), prop, - size, value, size_ret) + ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, int, + telemetry_sensor->sampling_rate.count(), prop, size, + value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } -int CXX_QDMI_device_session_create_environmentsensor_query( +int CXX_QDMI_device_session_create_telemetrysensor_query( CXX_QDMI_Device_Session session, - CXX_QDMI_Device_EnvironmentSensor_Query *query) { + CXX_QDMI_Device_TelemetrySensor_Query *query) { if (session == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -941,45 +939,45 @@ int CXX_QDMI_device_session_create_environmentsensor_query( if (session->status != CXX_QDMI_DEVICE_SESSION_STATUS::INITIALIZED) { return QDMI_ERROR_BADSTATE; } - *query = new CXX_QDMI_Device_EnvironmentSensor_Query_impl_d(); - (*query)->environment_sensor = new CXX_QDMI_EnvironmentSensor_impl_d(); + *query = new CXX_QDMI_Device_TelemetrySensor_Query_impl_d(); + (*query)->telemetry_sensor = new CXX_QDMI_TelemetrySensor_impl_d(); (*query)->start_time = std::chrono::system_clock::now(); (*query)->end_time = std::chrono::system_clock::now(); return QDMI_SUCCESS; } -int CXX_QDMI_device_environmentsensor_query_set_parameter( - CXX_QDMI_Device_EnvironmentSensor_Query query, - QDMI_Device_EnvironmentSensor_Query_Parameter param, size_t size, +int CXX_QDMI_device_telemetrysensor_query_set_parameter( + CXX_QDMI_Device_TelemetrySensor_Query query, + QDMI_Device_TelemetrySensor_Query_Parameter param, size_t size, const void *value) { if (query == nullptr || (value != nullptr && size == 0) || - (param >= QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 && - param != QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5) || + (param >= QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_MAX && + param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 && + param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM2 && + param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 && + param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 && + param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5) || value == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME: { + case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME: { query->start_time = std::chrono::system_clock::from_time_t( *static_cast(value)); return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME: { + case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME: { query->end_time = std::chrono::system_clock::from_time_t( *static_cast(value)); return QDMI_SUCCESS; } - case QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR: { - query->environment_sensor = - *(static_cast(value)); + case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRYSENSOR: { + query->telemetry_sensor = + *(static_cast(value)); return QDMI_SUCCESS; } default: @@ -987,10 +985,10 @@ int CXX_QDMI_device_environmentsensor_query_set_parameter( } } -int CXX_QDMI_device_environmentsensor_query_submit( - CXX_QDMI_Device_EnvironmentSensor_Query query) { +int CXX_QDMI_device_telemetrysensor_query_submit( + CXX_QDMI_Device_TelemetrySensor_Query query) { - if (query == nullptr || query->environment_sensor == nullptr) { + if (query == nullptr || query->telemetry_sensor == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -1001,7 +999,7 @@ int CXX_QDMI_device_environmentsensor_query_submit( std::chrono::round( // NOLINT(misc-include-cleaner) query->end_time - query->start_time); - auto sampling_rate = query->environment_sensor->sampling_rate; + auto sampling_rate = query->telemetry_sensor->sampling_rate; auto result_length = static_cast(time_difference.count() / sampling_rate.count()); @@ -1017,7 +1015,7 @@ int CXX_QDMI_device_environmentsensor_query_submit( for (unsigned int i = 0; i < result_length; i++) { auto duration_to_add = std::chrono::duration_cast( - query->environment_sensor->sampling_rate * i); + query->telemetry_sensor->sampling_rate * i); auto next_time = query->start_time + duration_to_add; query->result_timestamps.emplace_back(next_time); query->result_values[i] = @@ -1027,23 +1025,23 @@ int CXX_QDMI_device_environmentsensor_query_submit( return QDMI_SUCCESS; } -int CXX_QDMI_device_environmentsensor_query_get_results( - CXX_QDMI_Device_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, +int CXX_QDMI_device_telemetrysensor_query_get_results( + CXX_QDMI_Device_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Result result, size_t size, void *data, size_t *size_ret) { if (query == nullptr || (data != nullptr && size == 0) || - (result >= QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX && - result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM1 && - result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM2 && - result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM3 && - result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM4 && - result != QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM5)) { + (result >= QDMI_TELEMETRYSENSOR_QUERY_RESULT_MAX && + result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 && + result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM2 && + result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM3 && + result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM4 && + result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } size_t req_size = query->result_length; switch (result) { - case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS: + case QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS: req_size *= sizeof(time_t); if (data != nullptr) { if (size < req_size) { @@ -1060,7 +1058,7 @@ int CXX_QDMI_device_environmentsensor_query_get_results( *(size_ret) = req_size; } return QDMI_SUCCESS; - case QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES: + case QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES: req_size *= sizeof(float); if (data != nullptr) { @@ -1081,49 +1079,49 @@ int CXX_QDMI_device_environmentsensor_query_get_results( return QDMI_SUCCESS; } -int CXX_QDMI_device_environmentsensor_query_check_status( - CXX_QDMI_Device_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Status *status) { +int CXX_QDMI_device_telemetrysensor_query_check_status( + CXX_QDMI_Device_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Status *status) { if (query == nullptr || status == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } // randomly decide whether job is done or not - if (query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_RUNNING && + if (query->status == QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING && CXX_QDMI_generate_bit()) { - query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; + query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE; } *status = query->status; return QDMI_SUCCESS; } -int CXX_QDMI_device_environmentsensor_query_wait( - CXX_QDMI_Device_EnvironmentSensor_Query query, size_t timeout) { +int CXX_QDMI_device_telemetrysensor_query_wait( + CXX_QDMI_Device_TelemetrySensor_Query query, size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE; + query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE; query->timeout = timeout; return QDMI_SUCCESS; } -int CXX_QDMI_device_environmentsensor_query_cancel( - CXX_QDMI_Device_EnvironmentSensor_Query query) { +int CXX_QDMI_device_telemetrysensor_query_cancel( + CXX_QDMI_Device_TelemetrySensor_Query query) { if (query == nullptr || - query->status == QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE) { + query->status == QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE) { return QDMI_ERROR_INVALIDARGUMENT; } - query->status = QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED; + query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CANCELED; return QDMI_SUCCESS; } -void CXX_QDMI_device_environmentsensor_query_free( - CXX_QDMI_Device_EnvironmentSensor_Query query) { +void CXX_QDMI_device_telemetrysensor_query_free( + CXX_QDMI_Device_TelemetrySensor_Query query) { delete query; } diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 7d6d543b..e2af1a91 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -103,32 +103,32 @@ struct QDMI_Library { decltype(QDMI_device_session_query_operation_property) *device_session_query_operation_property{}; - decltype(QDMI_device_session_query_environmentsensor_property) - *device_session_query_environmentsensor_property{}; + decltype(QDMI_device_session_query_telemetrysensor_property) + *device_session_query_telemetrysensor_property{}; - decltype(QDMI_device_environmentsensor_query_set_parameter) - *device_environmentsensor_query_set_parameter{}; + decltype(QDMI_device_telemetrysensor_query_set_parameter) + *device_telemetrysensor_query_set_parameter{}; - decltype(QDMI_device_session_create_environmentsensor_query) - *device_session_create_environmentsensor_query{}; + decltype(QDMI_device_session_create_telemetrysensor_query) + *device_session_create_telemetrysensor_query{}; - decltype(QDMI_device_environmentsensor_query_submit) - *device_environmentsensor_query_submit{}; + decltype(QDMI_device_telemetrysensor_query_submit) + *device_telemetrysensor_query_submit{}; - decltype(QDMI_device_environmentsensor_query_get_results) - *device_environmentsensor_query_get_results{}; + decltype(QDMI_device_telemetrysensor_query_get_results) + *device_telemetrysensor_query_get_results{}; - decltype(QDMI_device_environmentsensor_query_check_status) - *device_environmentsensor_query_check_status{}; + decltype(QDMI_device_telemetrysensor_query_check_status) + *device_telemetrysensor_query_check_status{}; - decltype(QDMI_device_environmentsensor_query_wait) - *device_environmentsensor_query_wait{}; + decltype(QDMI_device_telemetrysensor_query_wait) + *device_telemetrysensor_query_wait{}; - decltype(QDMI_device_environmentsensor_query_cancel) - *device_environmentsensor_query_cancel{}; + decltype(QDMI_device_telemetrysensor_query_cancel) + *device_telemetrysensor_query_cancel{}; - decltype(QDMI_device_environmentsensor_query_free) - *device_environmentsensor_query_free{}; + decltype(QDMI_device_telemetrysensor_query_free) + *device_telemetrysensor_query_free{}; // default constructor QDMI_Library() = default; @@ -185,9 +185,9 @@ struct QDMI_Driver_State { std::unordered_set sessions; }; -struct QDMI_EnvironmentSensor_Query_impl_d { +struct QDMI_TelemetrySensor_Query_impl_d { QDMI_Device device = nullptr; - QDMI_Device_EnvironmentSensor_Query env_query = nullptr; + QDMI_Device_TelemetrySensor_Query env_query = nullptr; }; namespace { @@ -251,17 +251,16 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_device_property) LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) - LOAD_SYMBOL(library, prefix, - device_session_query_environmentsensor_property) + LOAD_SYMBOL(library, prefix, device_session_query_telemetrysensor_property) // device qnvironment interface - LOAD_SYMBOL(library, prefix, device_session_create_environmentsensor_query) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_set_parameter) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_submit) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_get_results) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_check_status) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_wait) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_cancel) - LOAD_SYMBOL(library, prefix, device_environmentsensor_query_free) + LOAD_SYMBOL(library, prefix, device_session_create_telemetrysensor_query) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_set_parameter) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_submit) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_get_results) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_check_status) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_wait) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_cancel) + LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_free) // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast) } catch (const std::exception &) { @@ -575,19 +574,19 @@ int QDMI_device_query_operation_property( prop, size, value, size_ret); } -int QDMI_device_query_environmentsensor_property( - QDMI_Device device, QDMI_EnvironmentSensor environment_sensor, - QDMI_EnvironmentSensor_Property prop, const size_t size, void *value, +int QDMI_device_query_telemetrysensor_property( + QDMI_Device device, QDMI_TelemetrySensor telemetry_sensor, + QDMI_TelemetrySensor_Property prop, const size_t size, void *value, size_t *size_ret) { if (device == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return device->library->device_session_query_environmentsensor_property( - device->device_session, environment_sensor, prop, size, value, size_ret); + return device->library->device_session_query_telemetrysensor_property( + device->device_session, telemetry_sensor, prop, size, value, size_ret); } -int QDMI_device_create_environmentsensor_query( - QDMI_Device dev, QDMI_EnvironmentSensor_Query *query) { +int QDMI_device_create_telemetrysensor_query( + QDMI_Device dev, QDMI_TelemetrySensor_Query *query) { if (dev == nullptr || query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -596,77 +595,75 @@ int QDMI_device_create_environmentsensor_query( return QDMI_ERROR_PERMISSIONDENIED; } - *query = new QDMI_EnvironmentSensor_Query_impl_d(); + *query = new QDMI_TelemetrySensor_Query_impl_d(); (*query)->device = dev; - return dev->library->device_session_create_environmentsensor_query( + return dev->library->device_session_create_telemetrysensor_query( dev->device_session, &(*query)->env_query); } -int QDMI_environmentsensor_query_set_parameter( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Parameter param, size_t size, +int QDMI_telemetrysensor_query_set_parameter( + QDMI_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Parameter param, size_t size, const void *value) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_set_parameter( + return query->device->library->device_telemetrysensor_query_set_parameter( query->env_query, - static_cast(param), size, + static_cast(param), size, value); } -int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query) { +int QDMI_telemetrysensor_query_submit(QDMI_TelemetrySensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_submit( + return query->device->library->device_telemetrysensor_query_submit( query->env_query); } -int QDMI_environmentsensor_query_get_results( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, - size_t *size_ret) { +int QDMI_telemetrysensor_query_get_results( + QDMI_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Result result, + size_t size, void *data, size_t *size_ret) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_get_results( + return query->device->library->device_telemetrysensor_query_get_results( query->env_query, result, size, data, size_ret); } -int QDMI_environmentsensor_query_check_status( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Status *status) { +int QDMI_telemetrysensor_query_check_status( + QDMI_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Status *status) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_check_status( + return query->device->library->device_telemetrysensor_query_check_status( query->env_query, status); } -int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, - size_t timeout) { +int QDMI_telemetrysensor_query_wait(QDMI_TelemetrySensor_Query query, + size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_wait( + return query->device->library->device_telemetrysensor_query_wait( query->env_query, timeout); } -int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query) { +int QDMI_telemetrysensor_query_cancel(QDMI_TelemetrySensor_Query query) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } - return query->device->library->device_environmentsensor_query_cancel( + return query->device->library->device_telemetrysensor_query_cancel( query->env_query); } -void QDMI_environmentsensor_query_free(QDMI_EnvironmentSensor_Query query) { +void QDMI_telemetrysensor_query_free(QDMI_TelemetrySensor_Query query) { if (query != nullptr) { - query->device->library->device_environmentsensor_query_free( - query->env_query); + query->device->library->device_telemetrysensor_query_free(query->env_query); delete query; } } diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 68880d63..42c81f85 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -200,63 +200,61 @@ auto FoMaC::get_parameters_num(const QDMI_Operation &op) const -> size_t { return parameters_num; } -auto FoMaC::get_environment_sensors() const - -> std::vector { - size_t environment_sensor_size = 0; +auto FoMaC::get_telemetry_sensors() const -> std::vector { + size_t telemetry_sensor_size = 0; int ret = QDMI_device_query_device_property( - device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, 0, nullptr, - &environment_sensor_size); - throw_if_error(ret, "Failed to get the environment variable list size."); - std::vector environment_sensors( - environment_sensor_size / sizeof(QDMI_Site)); + device, QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS, 0, nullptr, + &telemetry_sensor_size); + throw_if_error(ret, "Failed to get the telemetry variable list size."); + std::vector telemetry_sensors(telemetry_sensor_size / + sizeof(QDMI_Site)); ret = QDMI_device_query_device_property( - device, QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS, environment_sensor_size, - static_cast(environment_sensors.data()), nullptr); - throw_if_error(ret, "Failed to get the environment variables."); - return environment_sensors; + device, QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS, telemetry_sensor_size, + static_cast(telemetry_sensors.data()), nullptr); + throw_if_error(ret, "Failed to get the telemetry variables."); + return telemetry_sensors; } -auto FoMaC::get_environment_id(QDMI_EnvironmentSensor environment_sensor) const +auto FoMaC::get_telemetry_id(QDMI_TelemetrySensor telemetry_sensor) const -> std::string { - size_t environmentsensor_id_size = 0; - - int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, 0, - nullptr, &environmentsensor_id_size); - throw_if_error(ret, "Failed to query the size for environment ID"); - std::string environmentsensor_id(environmentsensor_id_size - 1, '\0'); - ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_ID, - environmentsensor_id.size() + 1, environmentsensor_id.data(), nullptr); - throw_if_error(ret, "Failed to query the environment ID"); - - return environmentsensor_id; + size_t telemetrysensor_id_size = 0; + + int ret = QDMI_device_query_telemetrysensor_property( + device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_ID, 0, nullptr, + &telemetrysensor_id_size); + throw_if_error(ret, "Failed to query the size for telemetry ID"); + std::string telemetrysensor_id(telemetrysensor_id_size - 1, '\0'); + ret = QDMI_device_query_telemetrysensor_property( + device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_ID, + telemetrysensor_id.size() + 1, telemetrysensor_id.data(), nullptr); + throw_if_error(ret, "Failed to query the telemetry ID"); + + return telemetrysensor_id; } -auto FoMaC::get_environment_unit( - QDMI_EnvironmentSensor environment_sensor) const -> std::string { - size_t environmentsensor_unit_size = 0; +auto FoMaC::get_telemetry_unit(QDMI_TelemetrySensor telemetry_sensor) const + -> std::string { + size_t telemetrysensor_unit_size = 0; - int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, - nullptr, &environmentsensor_unit_size); - throw_if_error(ret, "Failed to query the size for environment unit"); + int ret = QDMI_device_query_telemetrysensor_property( + device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, 0, nullptr, + &telemetrysensor_unit_size); + throw_if_error(ret, "Failed to query the size for telemetry unit"); - std::string environmentsensor_unit(environmentsensor_unit_size - 1, '\0'); - ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, - environmentsensor_unit.size() + 1, environmentsensor_unit.data(), - nullptr); - throw_if_error(ret, "Failed to query the environment unit"); + std::string telemetrysensor_unit(telemetrysensor_unit_size - 1, '\0'); + ret = QDMI_device_query_telemetrysensor_property( + device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, + telemetrysensor_unit.size() + 1, telemetrysensor_unit.data(), nullptr); + throw_if_error(ret, "Failed to query the telemetry unit"); - return environmentsensor_unit; + return telemetrysensor_unit; } -auto FoMaC::get_environment_sampling_rate( - QDMI_EnvironmentSensor environment_sensor) const -> int { +auto FoMaC::get_telemetry_sampling_rate( + QDMI_TelemetrySensor telemetry_sensor) const -> int { int sampling_rate = 0; - const int ret = QDMI_device_query_environmentsensor_property( - device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE, + const int ret = QDMI_device_query_telemetrysensor_property( + device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, sizeof(int), &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index 11d23e3e..233512e5 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -64,16 +64,15 @@ class FoMaC { [[nodiscard]] auto get_parameters_num(const QDMI_Operation &op) const -> size_t; - [[nodiscard]] auto get_environment_sensors() const - -> std::vector; + [[nodiscard]] auto get_telemetry_sensors() const + -> std::vector; - [[nodiscard]] auto - get_environment_id(QDMI_EnvironmentSensor environment) const -> std::string; + [[nodiscard]] auto get_telemetry_id(QDMI_TelemetrySensor telemetry) const + -> std::string; - [[nodiscard]] auto - get_environment_unit(QDMI_EnvironmentSensor environment) const -> std::string; + [[nodiscard]] auto get_telemetry_unit(QDMI_TelemetrySensor telemetry) const + -> std::string; [[nodiscard]] auto - get_environment_sampling_rate(QDMI_EnvironmentSensor environment) const - -> int; + get_telemetry_sampling_rate(QDMI_TelemetrySensor telemetry) const -> int; }; diff --git a/include/qdmi/client.h b/include/qdmi/client.h index ef11ce4f..de5e3988 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -50,8 +50,9 @@ extern "C" { * properties of devices. * - The @ref client_job_interface "client job interface" for submitting jobs * to devices. - * - The @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for querying environment sensors. + * - The @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for querying telemetry sensors from + * devices. * * @{ */ @@ -577,12 +578,12 @@ int QDMI_device_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an environment sensor property. + * @brief Query an telemetry sensor property. * @param[in] device The device to query. Must not be @c NULL. - * @param[in] environment_sensor The environment sensor to query. Must not be @c + * @param[in] telemetry_sensor The telemetry sensor to query. Must not be @c NULL. * @param[in] prop The property to query. Must be one of the values specified - * for @ref QDMI_EnvironmentSensor_Property. + * for @ref QDMI_TelemetrySensor_Property. * @param[in] size The size of the memory pointed to by @p value in bytes. Must * be greater or equal to the size of the return type specified for @p prop, * except when @p value is @c NULL, in which case it is ignored. @@ -595,26 +596,26 @@ int QDMI_device_query_operation_property( * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the * property. * @return @ref QDMI_ERROR_INVALIDARGUMENT if - * - @p device or @p environment_sensor is @c NULL, + * - @p device or @p telemetry_sensor is @c NULL, * - @p prop is invalid, or * - @p value is not @c NULL and @p size is less than the size of the data * being queried. * @return @ref QDMI_ERROR_FATAL if an unexpected error occurred. * * @note By calling this function with @p value set to @c NULL, the function can - * be used to check if the environment sensor supports the specified property + * be used to check if the telemetry sensor supports the specified property without * retrieving the property and without the need to provide a buffer for it. * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. * - * @note For example, to query the unit of an environment sensor, the following + * @note For example, to query the unit of an telemetry sensor, the following code pattern * can be used: * ``` * // Check if the device supports the property. - * auto ret = QDMI_device_query_environmentsensor_property( - * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, + * auto ret = QDMI_device_query_telemetrysensor_property( + * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, 0, nullptr, nullptr); * if (ret == QDMI_ERROR_NOTSUPPORTED) { * // The device does not support the property. @@ -622,29 +623,29 @@ int QDMI_device_query_operation_property( * } * * // Query the size of the property and the property. - * size_t environmentsensor_unit_size = 0; - * auto ret = QDMI_device_query_environmentsensor_property( - * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, 0, + * size_t telemetrysensor_unit_size = 0; + * auto ret = QDMI_device_query_telemetrysensor_property( + * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, 0, nullptr, - * &environmentsensor_unit_size); + * &telemetrysensor_unit_size); * if (ret != QDMI_SUCCESS) { * // An error occurred. * ... * } - * std::string environmentsensor_unit(environmentsensor_unit_size - 1, '\0'); - * ret = QDMI_device_query_environmentsensor_property( - * device, environment_sensor, QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT, - * environmentsensor_unit.size() + 1, environmentsensor_unit.data(), + * std::string telemetrysensor_unit(telemetrysensor_unit_size - 1, '\0'); + * ret = QDMI_device_query_telemetrysensor_property( + * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, + * telemetrysensor_unit.size() + 1, telemetrysensor_unit.data(), nullptr); * ``` * - * @remark @ref QDMI_EnvironmentSensor handles may be queried via @ref + * @remark @ref QDMI_TelemetrySensor handles may be queried via @ref * QDMI_device_query_device_property with @ref - QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS. + QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS. */ -int QDMI_device_query_environmentsensor_property( - QDMI_Device device, QDMI_EnvironmentSensor environment_sensor, - QDMI_EnvironmentSensor_Property prop, size_t size, void *value, +int QDMI_device_query_telemetrysensor_property( + QDMI_Device device, QDMI_TelemetrySensor telemetry_sensor, + QDMI_TelemetrySensor_Property prop, size_t size, void *value, size_t *size_ret); /** @} */ // end of client_query_interface @@ -1054,88 +1055,87 @@ void QDMI_job_free(QDMI_Job job); /** @} */ // end of client_job_interface -/** @defgroup client_environmentsensor_query_interface - * QDMI Client Environment Sensor Query Interface - * @brief Provides functions to query environment sensors. - * @details An environment sensor query is a task submitted by a client to a - * device for querying environment sensors, i.e. temperature or power. +/** @defgroup client_telemetrysensor_query_interface \ + * QDMI Client Telemetry Sensor Query Interface + * @brief Provides functions to query telemetry sensors. + * @details An telemetry sensor query is a task submitted by a client to a + * device for querying telemetry sensors, i.e. temperature or power. * - * The typical workflow for a client environment sensor query is as follows: - * - Create an environment sensor query with @ref - * QDMI_device_create_environmentsensor_query. - * - Set parameters for the environment sensor query with @ref - * QDMI_environmentsensor_query_set_parameter - * - Submit the environment query to the device with @ref - * QDMI_environmentsensor_query_submit. - * - Check the status of the environment sensor query with @ref - * QDMI_environmentsensor_query_check_status. - * - Wait for the environment sensor query to finish with @ref - * QDMI_environmentsensor_query_wait. - * - Retrieve the results of the environment sensor query with @ref - * QDMI_environmentsensor_query_get_results. - * - Free the environment sensor query with @ref - * QDMI_environmentsensor_query_free when it is no longer used. + * The typical workflow for a client telemetry sensor query is as follows: + * - Create an telemetry sensor query with @ref + * QDMI_device_create_telemetrysensor_query. + * - Set parameters for the telemetry sensor query with @ref + * QDMI_telemetrysensor_query_set_parameter + * - Submit the telemetry query to the device with @ref + * QDMI_telemetrysensor_query_submit. + * - Check the status of the telemetry sensor query with @ref + * QDMI_telemetrysensor_query_check_status. + * - Wait for the telemetry sensor query to finish with @ref + * QDMI_telemetrysensor_query_wait. + * - Retrieve the results of the telemetry sensor query with @ref + * QDMI_telemetrysensor_query_get_results. + * - Free the telemetry sensor query with @ref + * QDMI_telemetrysensor_query_free when it is no longer used. * * @{ */ /** - * @brief A handle for a client-side environment sensor query. + * @brief A handle for a client-side telemetry sensor query. * @details An opaque pointer to a type defined by the driver that encapsulates - * all information about an environment sensor query submitted to a device by a + * all information about an telemetry sensor query submitted to a device by a * client. * @remark Implementations of the underlying type will want to store the device - * handle used to create the environment sensor query in the handle to be able + * handle used to create the telemetry sensor query in the handle to be able * to access the device when needed. - * @see QDMI_Device_EnvironmentSensor_Query for the device-side the environment + * @see QDMI_Device_TelemetrySensor_Query for the device-side the telemetry * sensor query handle. */ -typedef struct QDMI_EnvironmentSensor_Query_impl_d - *QDMI_EnvironmentSensor_Query; +typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; /** - * @brief Create an environment sensor query. - * @details This is the main entry point for a client to submit an environment + * @brief Create an telemetry sensor query. + * @details This is the main entry point for a client to submit an telemetry * sensor query to a device. The returned handle can be used throughout the - * @ref client_environmentsensor_query_interface - * "client environment sensor query interface" to refer to the environment + * @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" to refer to the telemetry * sensor query. - * @param[in] device The device to create the environment sensor query on. Must + * @param[in] device The device to create the telemetry sensor query on. Must * not be @c NULL. * @param[out] query A pointer to a handle that will store the created - * environment sensor query. Must not be @c NULL. The job must be freed by - * calling @ref QDMI_environmentsensor_query_free when it is no longer used. + * telemetry sensor query. Must not be @c NULL. The job must be freed by + * calling @ref QDMI_telemetrysensor_query_free when it is no longer used. * @return @ref QDMI_SUCCESS if the job was successfully created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query creation failed * due to a fatal error. */ -int QDMI_device_create_environmentsensor_query( - QDMI_Device device, QDMI_EnvironmentSensor_Query *query); +int QDMI_device_create_telemetrysensor_query(QDMI_Device device, + QDMI_TelemetrySensor_Query *query); /** - * @brief Enum of the environment sensor query parameters that can be set. + * @brief Enum of the telemetry sensor query parameters that can be set. * @details If not noted otherwise, parameters are mandatory and drivers must * require them to be set. */ -enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { +enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T { - /// The start time of the environment query interval. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME = 0, + /// The start time of the telemetry query interval. + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME = 0, - /// The end time of the environment query interval. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME = 1, + /// The end time of the telemetry query interval. + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME = 1, - /// The environment for the environment query. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT = 2, + /// The telemetry for the telemetry query. + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRY = 2, /// The maximum value of the enum. - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX = 3, + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_MAX = 3, /** * @brief This enum value is reserved for a custom parameter. @@ -1143,37 +1143,37 @@ enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, - /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, + /// @see QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, - /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, + /// @see QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, - /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, + /// @see QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, - /// @see QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 + /// @see QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 + QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 }; -/// Environment sensor query parameter type. -typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T - QDMI_EnvironmentSensor_Query_Parameter; +/// Telemetry sensor query parameter type. +typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T + QDMI_TelemetrySensor_Query_Parameter; /** - * @brief Set a parameter for an environment sensor. + * @brief Set a parameter for an telemetry sensor. * @param[in] query A handle to a job for which to set @p param. Must not be @c * NULL. * @param[in] param The parameter whose value will be set. Must be one of the - * values specified for @ref QDMI_EnvironmentSensor_Query_Parameter. + * values specified for @ref QDMI_TelemetrySensor_Query_Parameter. * @param[in] size The size of the data pointed to by @p value in bytes. Must * not be zero, except when @p value is @c NULL, in which case it is ignored. * @param[in] value A pointer to the memory location that contains the value of * the parameter to be set. The data pointed to by @p value is copied and can be * safely reused after this function returns. If this is @c NULL, it is ignored. * @return @ref QDMI_SUCCESS if the driver supports the specified @ref - * QDMI_EnvironmentSensor_Query_Parameter @p param and, when @p value is not @c + * QDMI_TelemetrySensor_Query_Parameter @p param and, when @p value is not @c * NULL, the parameter was successfully set. * @return @ref QDMI_ERROR_NOTSUPPORTED if the driver does not support the * parameter or the value of the parameter. @@ -1182,13 +1182,13 @@ typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T * - @p param is invalid, or * - @p value is not @c NULL and @p size is zero or not the expected size for * the parameter (if specified by the @ref - * QDMI_EnvironmentSensor_Query_Parameter documentation). + * QDMI_TelemetrySensor_Query_Parameter documentation). * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the * current state of the job, for example, because the query is already * submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. @@ -1202,8 +1202,8 @@ typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T * used: * ``` * // Check if the device supports setting the start time - * auto ret = QDMI_environmentsensor_query_set_parameter( - * query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, 0, nullptr); + * auto ret = QDMI_telemetrysensor_query_set_parameter( + * query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_START_TIME, 0, nullptr); * if (ret == QDMI_ERROR_NOTSUPPORTED) { * // The device does not support setting the start time. * ... @@ -1211,115 +1211,114 @@ typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_T * * // Set the start time. * uint64_t start_ts = 1744970400; - * QDMI_environmentsensor_query_set_parameter( - * query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), + * QDMI_telemetrysensor_query_set_parameter( + * query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), * &start_ts); * ``` */ -int QDMI_environmentsensor_query_set_parameter( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Parameter param, size_t size, - const void *value); +int QDMI_telemetrysensor_query_set_parameter( + QDMI_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Parameter param, size_t size, const void *value); /** - * @brief Submit an environment sensor query to the device. - * @details This function can either be blocking until the environment sensor - * query is finished or non-blocking and return while the environment sensor + * @brief Submit an telemetry sensor query to the device. + * @details This function can either be blocking until the telemetry sensor + * query is finished or non-blocking and return while the telemetry sensor * query is running. In the latter case, the functions @ref - * QDMI_environmentsensor_query_check_status and @ref - * QDMI_environmentsensor_query_wait can be used to check the status and wait - * for the environment sensor query to finish. - * @param[in] query The environment sensor query to submit. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * QDMI_telemetrysensor_query_check_status and @ref + * QDMI_telemetrysensor_query_wait can be used to check the status and wait + * for the telemetry sensor query to finish. + * @param[in] query The telemetry sensor query to submit. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the telemetry sensor query was successfully * submitted. - * @return @ref QDMI_ERROR_INVALIDARGUMENT if environment sensor query is @c + * @return @ref QDMI_ERROR_INVALIDARGUMENT if telemetry sensor query is @c * NULL. - * @return @ref QDMI_ERROR_BADSTATE if the environment sensor query is in an + * @return @ref QDMI_ERROR_BADSTATE if the telemetry sensor query is in an * invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query submission + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query submission * failed. */ -int QDMI_environmentsensor_query_submit(QDMI_EnvironmentSensor_Query query); +int QDMI_telemetrysensor_query_submit(QDMI_TelemetrySensor_Query query); /** - * @brief Cancel an already submitted environment sensor query. - * @details Remove the environment sensor query from the queue of waiting - * environment sensor query. This changes the status of the environment sensor - * query to @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED. - * @param[in] query The environment sensor query to cancel. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * @brief Cancel an already submitted telemetry sensor query. + * @details Remove the telemetry sensor query from the queue of waiting + * telemetry sensor query. This changes the status of the telemetry sensor + * query to @ref QDMI_TELEMETRYSENSOR_QUERY_STATUS_CANCELED. + * @param[in] query The telemetry sensor query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the telemetry sensor query was successfully * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the - * environment sensor query already has the status @ref - * QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. + * telemetry sensor query already has the status @ref + * QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query could not be * canceled. */ -int QDMI_environmentsensor_query_cancel(QDMI_EnvironmentSensor_Query query); +int QDMI_telemetrysensor_query_cancel(QDMI_TelemetrySensor_Query query); /** - * @brief Check the status of an environment sensor query. + * @brief Check the status of an telemetry sensor query. * @details This function is non-blocking and returns immediately with the - * environment sensor query status. It is not required to call this function - * before calling @ref QDMI_environmentsensor_query_get_results. - * @param[in] query The environment sensor query to check the status of. Must + * telemetry sensor query status. It is not required to call this function + * before calling @ref QDMI_telemetrysensor_query_get_results. + * @param[in] query The telemetry sensor query to check the status of. Must * not be @c NULL. - * @param[out] status The status of the environment sensor query. Must not be @c + * @param[out] status The status of the telemetry sensor query. Must not be @c * NULL. - * @return @ref QDMI_SUCCESS if the environment sensor query status was + * @return @ref QDMI_SUCCESS if the telemetry sensor query status was * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query status could * not be checked. */ -int QDMI_environmentsensor_query_check_status( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Status *status); +int QDMI_telemetrysensor_query_check_status( + QDMI_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Status *status); /** - * @brief Wait for an environment sensor query to finish. - * @details This function blocks until the environment sensor query has either + * @brief Wait for an telemetry sensor query to finish. + * @details This function blocks until the telemetry sensor query has either * finished or has been canceled, or the timeout has been reached. - * @param[in] query The environment sensor query to wait for. Must not be @c + * @param[in] query The telemetry sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. * If this is zero, the function waits indefinitely until the job has finished. - * @return @ref QDMI_SUCCESS if the environment sensor query is finished or + * @return @ref QDMI_SUCCESS if the telemetry sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the query did * not finish within the specified time. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be - * waited for and this function returns before the environment sensor query has + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query could not be + * waited for and this function returns before the telemetry sensor query has * finished or has been canceled. */ -int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, - size_t timeout); +int QDMI_telemetrysensor_query_wait(QDMI_TelemetrySensor_Query query, + size_t timeout); /** - * @brief Retrieve the results of an environment sensor query. - * @param[in] query The environment sensor query to retrieve the results from. + * @brief Retrieve the results of an telemetry sensor query. + * @param[in] query The telemetry sensor query to retrieve the results from. * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified - * for @ref QDMI_EnvironmentSensor_Query_Result. + * for @ref QDMI_TelemetrySensor_Query_Result. * @param[in] size The size of the buffer pointed to by @p data in bytes. Must * be greater or equal to the size of the return type specified for the @ref - * QDMI_EnvironmentSensor_Query_Result @p result, except when @p data is @c + * QDMI_TelemetrySensor_Query_Result @p result, except when @p data is @c * NULL, in which case it is ignored. * @param[out] data A pointer to the memory location where the results will be * stored. If this is @c NULL, it is ignored. @@ -1335,8 +1334,8 @@ int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using - * the @ref client_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref client_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * @@ -1347,38 +1346,37 @@ int QDMI_environmentsensor_query_wait(QDMI_EnvironmentSensor_Query query, * Additionally, the size of the buffer needed to retrieve the result is * returned in @p size_ret if @p size_ret is not @c NULL. * - * @note For example, to query the results of a environment sensor query, + * @note For example, to query the results of a telemetry sensor query, * the following code pattern can be used: * ``` * // Query the size of the result. * size_t size; - * auto ret = QDMI_environmentsensor_query_get_results( - * query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, 0, nullptr, &size); + * auto ret = QDMI_telemetrysensor_query_get_results( + * query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, 0, nullptr, &size); * * // Allocate memory for the result. * std::vector values; * values.reserve(size); * * // Query the result. - * QDMI_environmentsensor_query_get_results( - * query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, size, values.data(), + * QDMI_telemetrysensor_query_get_results( + * query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, size, values.data(), * nullptr); * ``` */ -int QDMI_environmentsensor_query_get_results( - QDMI_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, - size_t *size_ret); +int QDMI_telemetrysensor_query_get_results( + QDMI_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Result result, + size_t size, void *data, size_t *size_ret); /** - * @brief Free an environment sensor query. - * @details Free the resources associated with a environment sensor query. Using - * a environment sensor query handle after it has been freed is undefined + * @brief Free an telemetry sensor query. + * @details Free the resources associated with a telemetry sensor query. Using + * a telemetry sensor query handle after it has been freed is undefined * behavior. - * @param[in] query The environment sensor query to free. + * @param[in] query The telemetry sensor query to free. */ -void QDMI_environmentsensor_query_free(QDMI_EnvironmentSensor_Query query); +void QDMI_telemetrysensor_query_free(QDMI_TelemetrySensor_Query query); -/** @} */ // end of client_environmentsensor_query_interface +/** @} */ // end of client_telemetrysensor_query_interface /** @} */ // end of client_interface diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index e8ec0c8c..93194d00 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -64,7 +64,7 @@ enum QDMI_DEVICE_SESSION_PARAMETER_T { * @details If this parameter is set and the device supports it, the device * must use the specified baseURL or API endpoint for the session. Devices may * use this parameter to switch between different versions of the API or - * different endpoints for testing or production environments. + * different endpoints for testing or production telemetrys. */ QDMI_DEVICE_SESSION_PARAMETER_BASEURL = 0, /** @@ -332,12 +332,12 @@ enum QDMI_DEVICE_PROPERTY_T { */ QDMI_DEVICE_PROPERTY_PULSESUPPORT = 9, /** - * @brief `QDMI_EnvironmentSensor*` (@ref QDMI_EnvironmentSensor list) The + * @brief `QDMI_TelemetrySensor*` (@ref QDMI_TelemetrySensor list) The * envoronment sensors of the device. - * @details The returned @ref QDMI_EnvironmentSensor handles may be used to + * @details The returned @ref QDMI_TelemetrySensor handles may be used to * query envoronment sensors. */ - QDMI_DEVICE_PROPERTY_ENVIRONMENTSENSORS = 10, + QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS = 10, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -814,24 +814,24 @@ enum QDMI_DEVICE_PULSE_SUPPORT_LEVEL_T { /// Pulse support level type. typedef enum QDMI_DEVICE_PULSE_SUPPORT_LEVEL_T QDMI_Device_Pulse_Support_Level; -/// Enum of the environment sensor properties that can be queried via @ref -/// QDMI_device_session_query_environmentsensor_property as part of the @ref +/// Enum of the telemetry sensor properties that can be queried via @ref +/// QDMI_device_session_query_telemetrysensor_property as part of the @ref /// device_interface "device interface" and via @ref -/// QDMI_device_query_environmentsensor_property as part of the @ref +/// QDMI_device_query_telemetrysensor_property as part of the @ref /// client_interface "client interface". -enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T { +enum QDMI_TELEMETRYSENSOR_PROPERTY_T { /** - * @brief `char*` (string) The unique ID to identify the environment sensor. - * @details The ID of an environment sensor is used to identify the sensors. - * The sensors collect environmental data in the HPCQC Labs, i.e., temperature + * @brief `char*` (string) The unique ID to identify the telemetry sensor. + * @details The ID of an telemetry sensor is used to identify the sensors. + * The sensors collect telemetryal data in the HPCQC Labs, i.e., temperature * and pressure. */ - QDMI_ENVIRONMENTSENSOR_PROPERTY_ID = 0, - /// `char*` (string) The unit of an environment sensor, e.g., Kelvin for + QDMI_TELEMETRYSENSOR_PROPERTY_ID = 0, + /// `char*` (string) The unit of an telemetry sensor, e.g., Kelvin for /// temperature. - QDMI_ENVIRONMENTSENSOR_PROPERTY_UNIT = 1, - /// `float` The samples per second of an environment sensor. - QDMI_ENVIRONMENTSENSOR_PROPERTY_SAMPLINGRATE = 2, + QDMI_TELEMETRYSENSOR_PROPERTY_UNIT = 1, + /// `float` The samples per second of an telemetry sensor. + QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE = 2, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and @@ -841,7 +841,7 @@ enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T { * enum besides the custom members and must be updated when new * members are added. */ - QDMI_ENVIRONMENTSENSOR_PROPERTY_MAX = 3, + QDMI_TELEMETRYSENSOR_PROPERTY_MAX = 3, /** * @brief This enum value is reserved for a custom property. * @details The device defines the meaning and the type of this @@ -849,76 +849,76 @@ enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T { * @attention The value of this enum member must not be changed to * maintain binary compatibility. */ - QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 = 999999995, - /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM2 = 999999996, - /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM3 = 999999997, - /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM4 = 999999998, - /// @see QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_PROPERTY_CUSTOM5 = 999999999 + QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 = 999999995, + /// @see QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 + QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM2 = 999999996, + /// @see QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 + QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM3 = 999999997, + /// @see QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 + QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM4 = 999999998, + /// @see QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM1 + QDMI_TELEMETRYSENSOR_PROPERTY_CUSTOM5 = 999999999 }; -/// Environment property type. -typedef enum QDMI_ENVIRONMENTSENSOR_PROPERTY_T QDMI_EnvironmentSensor_Property; +/// Telemetry property type. +typedef enum QDMI_TELEMETRYSENSOR_PROPERTY_T QDMI_TelemetrySensor_Property; /** - * @brief Enum of the device environmentsensor query parameters that can be set + * @brief Enum of the device telemetrysensor query parameters that can be set * via - * @ref QDMI_device_environmentsensor_query_set_parameter. + * @ref QDMI_device_telemetrysensor_query_set_parameter. * @details If not noted otherwise, parameters are mandatory and devices must * require them to be set. */ -enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T { - /// The start time of the environment sensor query interval. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME = 0, - /// The end time of the environment sensor query interval. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME = 1, - /// The environment sensor for the environment sensor query. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENTSENSOR = 2, +enum QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_T { + /// The start time of the telemetry sensor query interval. + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME = 0, + /// The end time of the telemetry sensor query interval. + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME = 1, + /// The telemetry sensor for the telemetry sensor query. + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRYSENSOR = 2, /// The maximum value of the enum. - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_MAX = 3, + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_MAX = 3, /** * @brief This enum value is reserved for a custom parameter. * @details The devices defines the meaning and the type of this parameter. * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 - QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 + QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 }; -/// Device environment query parameter type. -typedef enum QDMI_DEVICE_ENVIRONMENTSENSOR_QUERY_PARAMETER_T - QDMI_Device_EnvironmentSensor_Query_Parameter; +/// Device telemetry query parameter type. +typedef enum QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_T + QDMI_Device_TelemetrySensor_Query_Parameter; /** - * @brief Enum of the formats the environment sensor query results can be + * @brief Enum of the formats the telemetry sensor query results can be * returned in. */ -enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T { +enum QDMI_TELEMETRYSENSOR_QUERY_RESULT_T { /** * @brief `uint64_t*` (`unsigned 64 bit integer` list) The UNIX timestamps at * which the corresponding values in the results were recorded by a sensor. - * @details The result of an environment sensor query is represented as a + * @details The result of an telemetry sensor query is represented as a * key-value mapping. This mapping is returned as a list of keys and an * equal-length list of values. The corresponding partners of the keys and * values can be found at the same index in the lists */ - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS = 0, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS = 0, /** * @brief `float*` (`float` list) The values of the result. - * @see QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS + * @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS */ - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES = 1, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES = 1, /** * @brief The maximum value of the enum. * @details It can be used by devices for bounds checking and validation of @@ -927,55 +927,55 @@ enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T { * @attention This value must remain the last regular member of the enum * besides the custom members and must be updated when new members are added. */ - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_MAX = 2, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_MAX = 2, /** * @brief This enum value is reserved for a custom result. * @details The device defines the meaning and the type of this result. * @attention The value of this enum member must not be changed to maintain * binary compatibility. */ - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM1 = 999999995, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 = 999999995, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM2 = 999999996, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM2 = 999999996, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM3 = 999999997, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM3 = 999999997, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM4 = 999999998, + QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM4 = 999999998, /// @see QDMI_JOB_RESULT_CUSTOM1 - QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_CUSTOM5 = 999999999 + QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM5 = 999999999 }; -/// Environment query result type. -typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_T - QDMI_EnvironmentSensor_Query_Result; +/// Telemetry query result type. +typedef enum QDMI_TELEMETRYSENSOR_QUERY_RESULT_T + QDMI_TelemetrySensor_Query_Result; /** - * @brief Enum of the status Environment sensor query can have. - * @details See also @ref client_environmentsensor_query_interface for a - * description of the environment sensor query's lifecycle. + * @brief Enum of the status Telemetry sensor query can have. + * @details See also @ref client_telemetrysensor_query_interface for a + * description of the telemetry sensor query's lifecycle. */ -enum QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_T { - /** - * @brief The environment sensor query was created and can be configured via - * @ref QDMI_environmentsensor_query_set_parameter. - */ - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CREATED = 0, - /// The environment sensor query was submitted. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_SUBMITTED = 1, - /// The environment query was received is waiting to be executed. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_QUEUED = 2, - /// The environment query is running, and the result is not yet available. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_RUNNING = 3, - /// The environment query is done, and the result can be retrieved. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE = 4, - /// The environment query was canceled, and the result is not available. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED = 5, - /// An error occurred in the environment sensor query's lifecycle. - QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_FAILED = 6 +enum QDMI_TELEMETRYSENSOR_QUERY_STATUS_T { + /** + * @brief The telemetry sensor query was created and can be configured via + * @ref QDMI_telemetrysensor_query_set_parameter. + */ + QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED = 0, + /// The telemetry sensor query was submitted. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_SUBMITTED = 1, + /// The telemetry query was received is waiting to be executed. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_QUEUED = 2, + /// The telemetry query is running, and the result is not yet available. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING = 3, + /// The telemetry query is done, and the result can be retrieved. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE = 4, + /// The telemetry query was canceled, and the result is not available. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_CANCELED = 5, + /// An error occurred in the telemetry sensor query's lifecycle. + QDMI_TELEMETRYSENSOR_QUERY_STATUS_FAILED = 6 }; -/// Environment query status type. -typedef enum QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_T - QDMI_EnvironmentSensor_Query_Status; +/// Telemetry query status type. +typedef enum QDMI_TELEMETRYSENSOR_QUERY_STATUS_T + QDMI_TelemetrySensor_Query_Status; // NOLINTEND(performance-enum-size, modernize-use-using) diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 7c8c4c30..4c783dfc 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -43,7 +43,8 @@ extern "C" { * @details This is an interface between the QDMI driver and the device. * It includes functions to initialize and finalize a device, as well as to * manage sessions between a QDMI driver and a device, query properties of the - * device, and submit jobs to the device. + * device, submit jobs to the device, and query telemetry sensor + * data from the device. * * The device interface is split into three parts: * - The @ref device_session_interface "device session interface" for managing @@ -52,6 +53,9 @@ extern "C" { * properties of the device. * - The @ref device_job_interface "device job interface" for submitting jobs * to the device. + * - The @ref device_telemetrysensor_query_interface + * " device telemetry sensor query interface" for querying telemetry sensor + * data from the device. * * @{ */ @@ -353,12 +357,12 @@ int QDMI_device_session_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an environment sensor property. + * @brief Query an telemetry sensor property. * @param[in] session The session used for the query. Must not be @c NULL. - * @param[in] environment_sensor The environment sensor to query. Must not be @c + * @param[in] telemetry_sensor The telemetry sensor to query. Must not be @c * NULL. * @param[in] prop The property to query. Must be one of the values specified - * for @ref QDMI_EnvironmentSensor_Property. + * for @ref QDMI_TelemetrySensor_Property. * @param[in] size The size of the memory pointed to by @p value in bytes. Must * be greater or equal to the size of the return type specified for @p prop, * except when @p value is @c NULL, in which case it is ignored. @@ -385,16 +389,16 @@ int QDMI_device_session_query_operation_property( * retrieving the property and without the need to provide a buffer for it. * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. - * See the @ref QDMI_device_query_environmentsensor_property documentation for + * See the @ref QDMI_device_query_telemetrysensor_property documentation for * an example. * * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. */ -int QDMI_device_session_query_environmentsensor_property( - QDMI_Device_Session session, QDMI_EnvironmentSensor environment_sensor, - QDMI_EnvironmentSensor_Property prop, size_t size, void *value, +int QDMI_device_session_query_telemetrysensor_property( + QDMI_Device_Session session, QDMI_TelemetrySensor telemetry_sensor, + QDMI_TelemetrySensor_Property prop, size_t size, void *value, size_t *size_ret); /** @} */ // end of device_query_interface @@ -638,86 +642,86 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @} */ // end of device_job_interface -/** @defgroup device_environmentsensor_query_interface - * QDMI Device Environment Sensor Query Interface - * @brief Provides functions to manage environment sensor queries on a device. - * @details An environment sensor query is a task submitted to a device for - * querying environment sensors, i.e. temperature or power. +/** @defgroup device_telemetrysensor_query_interface \ + * QDMI Device Telemetry Sensor Query Interface + * @brief Provides functions to manage telemetry sensor queries on a device. + * @details An telemetry sensor query is a task submitted to a device for + * querying telemetry sensors, i.e. temperature or power. * - * The typical workflow for a device environment sensor query is as follows: - * - Create an environment sensor query with @ref - * QDMI_device_session_create_environmentsensor_query. - * - Set parameters for the environment sensor query with @ref - * QDMI_device_environmentsensor_query_set_parameter - * - Submit the environment sensor query to the device with @ref - * QDMI_device_environmentsensor_query_submit. - * - Check the status of the environment sensor query with @ref - * QDMI_device_environmentsensor_query_check_status. - * - Wait for the environment sensor query to finish with @ref - * QDMI_device_environmentsensor_query_wait. - * - Retrieve the results of the environment sensor query with @ref - * QDMI_environmentsensor_query_get_results. - * - Free the environment sensor query with @ref - * QDMI_device_environmentsensor_query_free when it is no longer used. + * The typical workflow for a device telemetry sensor query is as follows: + * - Create an telemetry sensor query with @ref + * QDMI_device_session_create_telemetrysensor_query. + * - Set parameters for the telemetry sensor query with @ref + * QDMI_device_telemetrysensor_query_set_parameter + * - Submit the telemetry sensor query to the device with @ref + * QDMI_device_telemetrysensor_query_submit. + * - Check the status of the telemetry sensor query with @ref + * QDMI_device_telemetrysensor_query_check_status. + * - Wait for the telemetry sensor query to finish with @ref + * QDMI_device_telemetrysensor_query_wait. + * - Retrieve the results of the telemetry sensor query with @ref + * QDMI_telemetrysensor_query_get_results. + * - Free the telemetry sensor query with @ref + * QDMI_device_telemetrysensor_query_free when it is no longer used. * * @{ */ /** - * @brief A handle for a device environment sensor query. + * @brief A handle for a device telemetry sensor query. * @details An opaque pointer to a type defined by the device that encapsulates - * all information about an environment sensor query on a device. + * all information about an telemetry sensor query on a device. * @remark Implementations of the underlying type will want to store the session - * handle used to create the environment sensor query in the environment sensor + * handle used to create the telemetry sensor query in the telemetry sensor * query handle to be able to access the session information when needed. - * @see QDMI_EnvironmentSensor_Query for the client-side job handle. + * @see QDMI_TelemetrySensor_Query for the client-side job handle. */ -typedef struct QDMI_Device_EnvironmentSensor_Query_impl_d - *QDMI_Device_EnvironmentSensor_Query; +typedef struct QDMI_Device_TelemetrySensor_Query_impl_d + *QDMI_Device_TelemetrySensor_Query; /** - * @brief Create an environment sensor query. - * @details This is the main entry point for a driver to create an environment + * @brief Create an telemetry sensor query. + * @details This is the main entry point for a driver to create an telemetry * sensor query for a device. The returned handle can be used throughout the - * @ref device_environmentsensor_query_interface - * "device environment sensor query interface" to refer to the environment + * @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" to refer to the telemetry * query. - * @param[in] session The session to create the environment sensor query on. + * @param[in] session The session to create the telemetry sensor query on. * Must not be @c NULL. * @param[out] query A pointer to a handle that will store the created - * environment sensor query. Must not be @c NULL. The environment sensor query + * telemetry sensor query. Must not be @c NULL. The telemetry sensor query * must be freed by calling - * @ref QDMI_device_environmentsensor_query_free when it is no longer used. - * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * @ref QDMI_device_telemetrysensor_query_free when it is no longer used. + * @return @ref QDMI_SUCCESS if the telemetry sensor query was successfully * created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p session or @p query are @c * NULL. * @return @ref QDMI_ERROR_BADSTATE if the session is not in a state allowing - * the creation of an environment sensor query, for example, because the session + * the creation of an telemetry sensor query, for example, because the session * is not initialized. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query creation failed + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query creation failed * due to a fatal error. * * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. */ -int QDMI_device_session_create_environmentsensor_query( - QDMI_Device_Session session, QDMI_Device_EnvironmentSensor_Query *query); +int QDMI_device_session_create_telemetrysensor_query( + QDMI_Device_Session session, QDMI_Device_TelemetrySensor_Query *query); /** - * @brief Set a parameter for an environment sensor query. - * @param[in] query A handle to an environment sensor query for which to set @p + * @brief Set a parameter for an telemetry sensor query. + * @param[in] query A handle to an telemetry sensor query for which to set @p * param. Must not be @c NULL. * @param[in] param The parameter whose value will be set. Must be one of the - * values specified for @ref QDMI_Device_EnvironmentSensor_Query_Parameter. + * values specified for @ref QDMI_Device_TelemetrySensor_Query_Parameter. * @param[in] size The size of the data pointed to by @p value in bytes. Must * not be zero, except when @p value is @c NULL, in which case it is ignored. * @param[in] value A pointer to the memory location that contains the value of * the parameter to be set. The data pointed to by @p value is copied and can be * safely reused after this function returns. If this is @c NULL, it is ignored. * @return @ref QDMI_SUCCESS if the device supports the specified @ref - * QDMI_Device_EnvironmentSensor_Query_Parameter @p param and, when @p value is + * QDMI_Device_TelemetrySensor_Query_Parameter @p param and, when @p value is * not @c NULL, the parameter was successfully set. * @return @ref QDMI_ERROR_NOTSUPPORTED if the device does not support the * parameter or the value of the parameter. @@ -726,118 +730,118 @@ int QDMI_device_session_create_environmentsensor_query( * - @p param is invalid, or * - @p value is not @c NULL and @p size is zero or not the expected size for * the parameter (if specified by the @ref - * QDMI_Device_EnvironmentSensor_Query_Parameter documentation). + * QDMI_Device_TelemetrySensor_Query_Parameter documentation). * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the - * current state of the environment sensor query, for example, because the - * environment sensor query is already submitted. + * current state of the telemetry sensor query, for example, because the + * telemetry sensor query is already submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if setting the parameter failed due to a fatal * error. * * @remark Calling this function with @p value set to @c NULL is expected to * allow checking if the device supports the specified parameter without setting * the parameter and without the need to provide a value. - * See the @ref QDMI_environmentsensor_query_set_parameter documentation for an + * See the @ref QDMI_telemetrysensor_query_set_parameter documentation for an * example. */ -int QDMI_device_environmentsensor_query_set_parameter( - QDMI_Device_EnvironmentSensor_Query query, - QDMI_Device_EnvironmentSensor_Query_Parameter param, size_t size, +int QDMI_device_telemetrysensor_query_set_parameter( + QDMI_Device_TelemetrySensor_Query query, + QDMI_Device_TelemetrySensor_Query_Parameter param, size_t size, const void *value); /** - * @brief Submit an environment sensor query to the device. + * @brief Submit an telemetry sensor query to the device. * @details This function can either be blocking until the job is finished or * non-blocking and return while the job is running. In the latter case, the - * functions @ref QDMI_device_environmentsensor_query_check_status and @ref - * QDMI_device_environmentsensor_query_wait can be used to check the status and - * wait for the environment sensor query to finish. - * @param[in] query The environment sensor query to submit. Must not be @c NULL. + * functions @ref QDMI_device_telemetrysensor_query_check_status and @ref + * QDMI_device_telemetrysensor_query_wait can be used to check the status and + * wait for the telemetry sensor query to finish. + * @param[in] query The telemetry sensor query to submit. Must not be @c NULL. * @return @ref QDMI_SUCCESS if the job was successfully submitted. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p job is @c NULL. * @return @ref QDMI_ERROR_BADSTATE if the job is in an invalid state. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if the job submission failed. */ -int QDMI_device_environmentsensor_query_submit( - QDMI_Device_EnvironmentSensor_Query query); +int QDMI_device_telemetrysensor_query_submit( + QDMI_Device_TelemetrySensor_Query query); /** - * @brief Cancel an already submitted environment sensor query. - * @details Remove the environment sensor query from the queue of waiting - * environment sensor query. This changes the status of the environment query to - * @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_CANCELED. - * @param[in] query The environment sensor query to cancel. Must not be @c NULL. - * @return @ref QDMI_SUCCESS if the environment sensor query was successfully + * @brief Cancel an already submitted telemetry sensor query. + * @details Remove the telemetry sensor query from the queue of waiting + * telemetry sensor query. This changes the status of the telemetry query to + * @ref QDMI_TELEMETRYSENSOR_QUERY_STATUS_CANCELED. + * @param[in] query The telemetry sensor query to cancel. Must not be @c NULL. + * @return @ref QDMI_SUCCESS if the telemetry sensor query was successfully * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL or the job - * already has the status @ref QDMI_ENVIRONMENTSENSOR_QUERY_STATUS_DONE. + * already has the status @ref QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query could not be * canceled. */ -int QDMI_device_environmentsensor_query_cancel( - QDMI_Device_EnvironmentSensor_Query query); +int QDMI_device_telemetrysensor_query_cancel( + QDMI_Device_TelemetrySensor_Query query); /** - * @brief Check the status of an environment sensor query. + * @brief Check the status of an telemetry sensor query. * @details This function is non-blocking and returns immediately with the - * environment sensor query status. It is not required to call this function - * before calling @ref QDMI_environmentsensor_query_get_results. - * @param[in] query The environment sensor query to check the status of. Must + * telemetry sensor query status. It is not required to call this function + * before calling @ref QDMI_telemetrysensor_query_get_results. + * @param[in] query The telemetry sensor query to check the status of. Must * not be @c NULL. - * @param[out] status The status of the environment sensor query. Must not be @c + * @param[out] status The status of the telemetry sensor query. Must not be @c * NULL. - * @return @ref QDMI_SUCCESS if the environment sensor query status was + * @return @ref QDMI_SUCCESS if the telemetry sensor query status was * successfully checked. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query or @p status is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "client environment sensor query interface" for the device in the current + * the @ref device_telemetrysensor_query_interface + * "client telemetry sensor query interface" for the device in the current * session. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query status could + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query status could * not be checked. */ -int QDMI_device_environmentsensor_query_check_status( - QDMI_Device_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Status *status); +int QDMI_device_telemetrysensor_query_check_status( + QDMI_Device_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Status *status); /** - * @brief Wait for an environment sensor query to finish. - * @details This function blocks until the environment sensor query has either + * @brief Wait for an telemetry sensor query to finish. + * @details This function blocks until the telemetry sensor query has either * finished, has been canceled, or the timeout has been reached. - * @param[in] query The environment sensor query to wait for. Must not be @c + * @param[in] query The telemetry sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. * If this is zero, the function waits indefinitely until the job has finished. - * @return @ref QDMI_SUCCESS if the environment sensor query is finished or + * @return @ref QDMI_SUCCESS if the telemetry sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. * @return @ref QDMI_ERROR_TIMEOUT if @p timeout is not zero and the job did not * finish within the specified time. - * @return @ref QDMI_ERROR_FATAL if the environment sensor query could not be - * waited for and this function returns before the environment sensor query has + * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query could not be + * waited for and this function returns before the telemetry sensor query has * finished or has been canceled. */ -int QDMI_device_environmentsensor_query_wait( - QDMI_Device_EnvironmentSensor_Query query, size_t timeout); +int QDMI_device_telemetrysensor_query_wait( + QDMI_Device_TelemetrySensor_Query query, size_t timeout); /** - * @brief Retrieve the results of an environment sensor query. - * @param[in] query The environment sensor query to retrieve the results from. + * @brief Retrieve the results of an telemetry sensor query. + * @param[in] query The telemetry sensor query to retrieve the results from. * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified - * for @ref QDMI_EnvironmentSensor_Query_Result. + * for @ref QDMI_TelemetrySensor_Query_Result. * @param[in] size The size of the buffer pointed to by @p data in bytes. Must * be greater or equal to the size of the return type specified for the @ref - * QDMI_EnvironmentSensor_Query_Result @p result, except when @p data is @c + * QDMI_TelemetrySensor_Query_Result @p result, except when @p data is @c * NULL, in which case it is ignored. * @param[out] data A pointer to the memory location where the results will be * stored. If this is @c NULL, it is ignored. @@ -853,8 +857,8 @@ int QDMI_device_environmentsensor_query_wait( * - @p data is not @c NULL and @p size is smaller than the size of the data * being queried. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using - * the @ref device_environmentsensor_query_interface - * "device environment sensor query interface" for the current session. + * the @ref device_telemetrysensor_query_interface + * "device telemetry sensor query interface" for the current session. * @return @ref QDMI_ERROR_FATAL if an error occurred during the retrieval. * * @remark Calling this function with @p data set to @c NULL is expected to @@ -863,24 +867,24 @@ int QDMI_device_environmentsensor_query_wait( * result. * Additionally, the size of the buffer required to retrieve the result is * returned in @p size_ret if @p size_ret is not @c NULL. - * See the @ref QDMI_environmentsensor_query_get_results documentation for an + * See the @ref QDMI_telemetrysensor_query_get_results documentation for an * example. */ -int QDMI_device_environmentsensor_query_get_results( - QDMI_Device_EnvironmentSensor_Query query, - QDMI_EnvironmentSensor_Query_Result result, size_t size, void *data, +int QDMI_device_telemetrysensor_query_get_results( + QDMI_Device_TelemetrySensor_Query query, + QDMI_TelemetrySensor_Query_Result result, size_t size, void *data, size_t *size_ret); /** - * @brief Free an environment sensor query. - * @details Free the resources associated with an environment sensor query. - * Using an environment sensor query handle after it has been freed is undefined + * @brief Free an telemetry sensor query. + * @details Free the resources associated with an telemetry sensor query. + * Using an telemetry sensor query handle after it has been freed is undefined * behavior. - * @param[in] query The environment sensor query to free. + * @param[in] query The telemetry sensor query to free. */ -void QDMI_device_environmentsensor_query_free( - QDMI_Device_EnvironmentSensor_Query query); +void QDMI_device_telemetrysensor_query_free( + QDMI_Device_TelemetrySensor_Query query); -/** @} */ // end of device_environmentsensor_query_interface +/** @} */ // end of device_telemetrysensor_query_interface /** @} */ // end of device_interface diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 0d3a54e0..890502cc 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,24 +72,24 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** - * @brief A handle for an environment sensor variable. - * @details An opaque pointer to an implementation of the QDMI environment - * sensor concept. The environmental factors of the laboratories can affect the + * @brief A handle for an telemetry sensor variable. + * @details An opaque pointer to an implementation of the QDMI telemetry + * sensor concept. The telemetryal factors of the laboratories can affect the * operations and measurement results of quantum devices. Therefore, they are - * closely monitored. An environment sensor generally represents any sensors + * closely monitored. An telemetry sensor generally represents any sensors * that can be queried. They might be sensors for temperature, noise, etc. Each * implementation of the @ref device_interface "QDMI Device Interface" defines * the actual implementation of the concept. * * A simple example of an implementation is a struct that merely contains the - * environment sensor ID, which can be used to identify the site. + * telemetry sensor ID, which can be used to identify the site. * ``` - * struct QDMI_EnvironmentSensor_impl_d { + * struct QDMI_TelemetrySensor_impl_d { * char* id; * }; * ``` */ -typedef struct QDMI_EnvironmentSensor_impl_d *QDMI_EnvironmentSensor; +typedef struct QDMI_TelemetrySensor_impl_d *QDMI_TelemetrySensor; // NOLINTEND(modernize-use-using) diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 0e53e2f2..03aa0af8 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -972,99 +972,99 @@ TEST_P(QDMIImplementationTest, QueryPulseSupportLevel) { EXPECT_EQ(pulse_support_level, QDMI_DEVICE_PULSE_SUPPORT_LEVEL_NONE); } -TEST_P(QDMIImplementationTest, QueryEveryEnvironmentProperties) { +TEST_P(QDMIImplementationTest, QueryEveryTelemetryProperties) { const auto fomac = FoMaC(device); - auto environments = fomac.get_environment_sensors(); + auto telemetrys = fomac.get_telemetry_sensors(); - ASSERT_GT(environments.size(), 0); + ASSERT_GT(telemetrys.size(), 0); - for (const auto &environment : environments) { + for (const auto &telemetry : telemetrys) { - auto environment_id = fomac.get_environment_id(environment); - EXPECT_STRNE(environment_id.c_str(), ""); + auto telemetry_id = fomac.get_telemetry_id(telemetry); + EXPECT_STRNE(telemetry_id.c_str(), ""); - auto environment_unit = fomac.get_environment_unit(environment); - EXPECT_STRNE(environment_unit.c_str(), ""); + auto telemetry_unit = fomac.get_telemetry_unit(telemetry); + EXPECT_STRNE(telemetry_unit.c_str(), ""); - auto sampling_rate = fomac.get_environment_sampling_rate(environment); + auto sampling_rate = fomac.get_telemetry_sampling_rate(telemetry); EXPECT_GT(sampling_rate, 0); } } -TEST_P(QDMIImplementationTest, EnvironmentQuery) { +TEST_P(QDMIImplementationTest, TelemetryQuery) { if (mode == TEST_SESSION_MODE::READONLY) { GTEST_SKIP() << "Skipping test for read-only session"; } const auto fomac = FoMaC(device); - const std::vector environment_sensors = - fomac.get_environment_sensors(); + const std::vector telemetry_sensors = + fomac.get_telemetry_sensors(); - ASSERT_GT(environment_sensors.size(), 0); + ASSERT_GT(telemetry_sensors.size(), 0); - for (QDMI_EnvironmentSensor environment_sensor : environment_sensors) { - QDMI_EnvironmentSensor_Query query = nullptr; - QDMI_EnvironmentSensor_Query_Status status = {}; + for (QDMI_TelemetrySensor telemetry_sensor : telemetry_sensors) { + QDMI_TelemetrySensor_Query query = nullptr; + QDMI_TelemetrySensor_Query_Status status = {}; time_t start_time = time(&start_time); time_t end_time = time(&end_time) + 600; - EXPECT_EQ(QDMI_device_create_environmentsensor_query(device, &query), + EXPECT_EQ(QDMI_device_create_telemetrysensor_query(device, &query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( - query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENVIRONMENT, - sizeof(QDMI_EnvironmentSensor), - static_cast(&environment_sensor)), + EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( + query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRY, + sizeof(QDMI_TelemetrySensor), + static_cast(&telemetry_sensor)), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( - query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_STARTTIME, + EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( + query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME, sizeof(time_t), &start_time), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_set_parameter( - query, QDMI_ENVIRONMENTSENSOR_QUERY_PARAMETER_ENDTIME, + EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( + query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME, sizeof(time_t), &end_time), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_submit(query), QDMI_SUCCESS); + EXPECT_EQ(QDMI_telemetrysensor_query_submit(query), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_wait(query, 0), QDMI_SUCCESS); + EXPECT_EQ(QDMI_telemetrysensor_query_wait(query, 0), QDMI_SUCCESS); - EXPECT_EQ(QDMI_environmentsensor_query_check_status(query, &status), + EXPECT_EQ(QDMI_telemetrysensor_query_check_status(query, &status), QDMI_SUCCESS); size_t timestamps_size = 0; - EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, 0, + EXPECT_EQ(QDMI_telemetrysensor_query_get_results( + query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, 0, nullptr, ×tamps_size), QDMI_SUCCESS); std::vector timestamps; timestamps.reserve(timestamps_size); - EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_TIMESTAMPS, + EXPECT_EQ(QDMI_telemetrysensor_query_get_results( + query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, timestamps_size, timestamps.data(), nullptr), QDMI_SUCCESS); size_t size_values = 0; - EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, 0, nullptr, + EXPECT_EQ(QDMI_telemetrysensor_query_get_results( + query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, 0, nullptr, &size_values), QDMI_SUCCESS); std::vector values; values.reserve(size_values); - EXPECT_EQ(QDMI_environmentsensor_query_get_results( - query, QDMI_ENVIRONMENTSENSOR_QUERY_RESULT_VALUES, - size_values, values.data(), nullptr), + EXPECT_EQ(QDMI_telemetrysensor_query_get_results( + query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, size_values, + values.data(), nullptr), QDMI_SUCCESS); - QDMI_environmentsensor_query_free(query); + QDMI_telemetrysensor_query_free(query); } } From 0bda557f579584bddaefc8fce908f58e4858a501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 5 Aug 2025 11:38:39 +0200 Subject: [PATCH 37/61] =?UTF-8?q?=F0=9F=8E=A8=20minor=20change=20in=20exam?= =?UTF-8?q?ple?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 9 ++++----- examples/fomac/example_fomac.cpp | 6 +++--- examples/fomac/example_fomac.hpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index f8b84c24..8192d187 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -84,7 +84,7 @@ struct CXX_QDMI_Operation_impl_d { struct CXX_QDMI_TelemetrySensor_impl_d { std::string id; std::string unit; - std::chrono::duration sampling_rate{}; // in seconds + std::chrono::seconds sampling_rate; }; struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { @@ -923,9 +923,9 @@ int CXX_QDMI_device_session_query_telemetrysensor_property( ADD_STRING_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, telemetry_sensor->unit.c_str(), prop, size, value, size_ret) - ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, int, - telemetry_sensor->sampling_rate.count(), prop, size, - value, size_ret) + ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, + long int, telemetry_sensor->sampling_rate.count(), + prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } @@ -940,7 +940,6 @@ int CXX_QDMI_device_session_create_telemetrysensor_query( return QDMI_ERROR_BADSTATE; } *query = new CXX_QDMI_Device_TelemetrySensor_Query_impl_d(); - (*query)->telemetry_sensor = new CXX_QDMI_TelemetrySensor_impl_d(); (*query)->start_time = std::chrono::system_clock::now(); (*query)->end_time = std::chrono::system_clock::now(); diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 42c81f85..787c3b2f 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -251,11 +251,11 @@ auto FoMaC::get_telemetry_unit(QDMI_TelemetrySensor telemetry_sensor) const } auto FoMaC::get_telemetry_sampling_rate( - QDMI_TelemetrySensor telemetry_sensor) const -> int { - int sampling_rate = 0; + QDMI_TelemetrySensor telemetry_sensor) const -> int64_t { + int64_t sampling_rate = 0; const int ret = QDMI_device_query_telemetrysensor_property( device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, - sizeof(int), &sampling_rate, nullptr); + sizeof(int64_t), &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); return sampling_rate; diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index 233512e5..32ddd97a 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -74,5 +74,5 @@ class FoMaC { -> std::string; [[nodiscard]] auto - get_telemetry_sampling_rate(QDMI_TelemetrySensor telemetry) const -> int; + get_telemetry_sampling_rate(QDMI_TelemetrySensor telemetry) const -> int64_t; }; From 56ba00de7bd6bda553745081d2ef58b1aa28bb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 5 Aug 2025 14:26:02 +0200 Subject: [PATCH 38/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20fix=20minor=20typ?= =?UTF-8?q?os?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/constants.h | 4 ++-- include/qdmi/types.h | 4 ++-- test/test_qdmi.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 93194d00..87100044 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -64,7 +64,7 @@ enum QDMI_DEVICE_SESSION_PARAMETER_T { * @details If this parameter is set and the device supports it, the device * must use the specified baseURL or API endpoint for the session. Devices may * use this parameter to switch between different versions of the API or - * different endpoints for testing or production telemetrys. + * different endpoints for testing or production environments. */ QDMI_DEVICE_SESSION_PARAMETER_BASEURL = 0, /** @@ -823,7 +823,7 @@ enum QDMI_TELEMETRYSENSOR_PROPERTY_T { /** * @brief `char*` (string) The unique ID to identify the telemetry sensor. * @details The ID of an telemetry sensor is used to identify the sensors. - * The sensors collect telemetryal data in the HPCQC Labs, i.e., temperature + * The sensors collect telemetry data in the HPCQC Labs, i.e., temperature * and pressure. */ QDMI_TELEMETRYSENSOR_PROPERTY_ID = 0, diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 890502cc..6e040977 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,9 +72,9 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** - * @brief A handle for an telemetry sensor variable. + * @brief A handle for an telemetry sensor. * @details An opaque pointer to an implementation of the QDMI telemetry - * sensor concept. The telemetryal factors of the laboratories can affect the + * sensor concept. The telemetry factors of the laboratories can affect the * operations and measurement results of quantum devices. Therefore, they are * closely monitored. An telemetry sensor generally represents any sensors * that can be queried. They might be sensors for temperature, noise, etc. Each diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 03aa0af8..9f5cccb5 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -976,11 +976,11 @@ TEST_P(QDMIImplementationTest, QueryEveryTelemetryProperties) { const auto fomac = FoMaC(device); - auto telemetrys = fomac.get_telemetry_sensors(); + auto telemetries = fomac.get_telemetry_sensors(); - ASSERT_GT(telemetrys.size(), 0); + ASSERT_GT(telemetries.size(), 0); - for (const auto &telemetry : telemetrys) { + for (const auto &telemetry : telemetries) { auto telemetry_id = fomac.get_telemetry_id(telemetry); EXPECT_STRNE(telemetry_id.c_str(), ""); From aff6f1e95fee1af70edb9dcdc978dadd6354bb40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 5 Aug 2025 16:53:55 +0200 Subject: [PATCH 39/61] =?UTF-8?q?=F0=9F=93=9D=20minor=20documentation=20ex?= =?UTF-8?q?tension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index 8192d187..ee14c647 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -994,6 +994,9 @@ int CXX_QDMI_device_telemetrysensor_query_submit( // here, the actual submission. // for demonstration purposes + + // Clang-tidy generates a warning due to a known bug + // https://github.com/llvm/llvm-project/issues/98122 auto time_difference = std::chrono::round( // NOLINT(misc-include-cleaner) query->end_time - query->start_time); From 10710d032236a8021551fb3ab1e3028bd3dc03a0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 14:55:35 +0000 Subject: [PATCH 40/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index ee14c647..a63d4cd4 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -994,7 +994,7 @@ int CXX_QDMI_device_telemetrysensor_query_submit( // here, the actual submission. // for demonstration purposes - + // Clang-tidy generates a warning due to a known bug // https://github.com/llvm/llvm-project/issues/98122 auto time_difference = From e305c4672a4bc69de26a23cd1c241ce279307df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= <49598189+kayaercument@users.noreply.github.com> Date: Wed, 13 Aug 2025 07:12:25 +0200 Subject: [PATCH 41/61] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yannick Stade <100073938+ystade@users.noreply.github.com> Signed-off-by: Ercรผment Kaya <49598189+kayaercument@users.noreply.github.com> --- cmake/prefix_defs.txt | 2 +- examples/device/device.cpp | 2 +- include/qdmi/constants.h | 20 +++++++++++--------- include/qdmi/types.h | 10 +++++----- test/test_qdmi.cpp | 4 ++-- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmake/prefix_defs.txt b/cmake/prefix_defs.txt index bc64909a..e541d08a 100644 --- a/cmake/prefix_defs.txt +++ b/cmake/prefix_defs.txt @@ -29,7 +29,7 @@ QDMI_TelemetrySensor_impl_d QDMI_Device_TelemetrySensor_Query QDMI_Device_TelemetrySensor_Query_impl_d QDMI_device_session_query_telemetrysensor_property -QDMI_device_session_create_telemetrysensor_query +QDMI_device_session_create_device_telemetrysensor_query QDMI_device_telemetrysensor_query_set_parameter QDMI_device_telemetrysensor_query_submit QDMI_device_telemetrysensor_query_get_results diff --git a/examples/device/device.cpp b/examples/device/device.cpp index a63d4cd4..d168251b 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -924,7 +924,7 @@ int CXX_QDMI_device_session_query_telemetrysensor_property( telemetry_sensor->unit.c_str(), prop, size, value, size_ret) ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, - long int, telemetry_sensor->sampling_rate.count(), + int32_t, telemetry_sensor->sampling_rate.count(), prop, size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 87100044..3771fada 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -333,9 +333,9 @@ enum QDMI_DEVICE_PROPERTY_T { QDMI_DEVICE_PROPERTY_PULSESUPPORT = 9, /** * @brief `QDMI_TelemetrySensor*` (@ref QDMI_TelemetrySensor list) The - * envoronment sensors of the device. + * telemetry sensors of the device. * @details The returned @ref QDMI_TelemetrySensor handles may be used to - * query envoronment sensors. + * query telemetry sensors. */ QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS = 10, /** @@ -814,11 +814,13 @@ enum QDMI_DEVICE_PULSE_SUPPORT_LEVEL_T { /// Pulse support level type. typedef enum QDMI_DEVICE_PULSE_SUPPORT_LEVEL_T QDMI_Device_Pulse_Support_Level; -/// Enum of the telemetry sensor properties that can be queried via @ref -/// QDMI_device_session_query_telemetrysensor_property as part of the @ref -/// device_interface "device interface" and via @ref -/// QDMI_device_query_telemetrysensor_property as part of the @ref -/// client_interface "client interface". +/** + * Enum of the telemetry sensor properties that can be queried via @ref + * QDMI_device_session_query_telemetrysensor_property as part of the @ref + * device_interface "device interface" and via @ref + * QDMI_device_query_telemetrysensor_property as part of the @ref + * client_interface "client interface". + */ enum QDMI_TELEMETRYSENSOR_PROPERTY_T { /** * @brief `char*` (string) The unique ID to identify the telemetry sensor. @@ -949,7 +951,7 @@ typedef enum QDMI_TELEMETRYSENSOR_QUERY_RESULT_T QDMI_TelemetrySensor_Query_Result; /** - * @brief Enum of the status Telemetry sensor query can have. + * @brief Enum of the status a telemetry sensor query can have. * @details See also @ref client_telemetrysensor_query_interface for a * description of the telemetry sensor query's lifecycle. */ @@ -962,7 +964,7 @@ enum QDMI_TELEMETRYSENSOR_QUERY_STATUS_T { QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED = 0, /// The telemetry sensor query was submitted. QDMI_TELEMETRYSENSOR_QUERY_STATUS_SUBMITTED = 1, - /// The telemetry query was received is waiting to be executed. + /// The telemetry query was received and is waiting to be executed. QDMI_TELEMETRYSENSOR_QUERY_STATUS_QUEUED = 2, /// The telemetry query is running, and the result is not yet available. QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING = 3, diff --git a/include/qdmi/types.h b/include/qdmi/types.h index 6e040977..a9d920b4 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -72,12 +72,12 @@ typedef struct QDMI_Site_impl_d *QDMI_Site; typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** - * @brief A handle for an telemetry sensor. + * @brief A handle for a telemetry sensor. * @details An opaque pointer to an implementation of the QDMI telemetry - * sensor concept. The telemetry factors of the laboratories can affect the - * operations and measurement results of quantum devices. Therefore, they are - * closely monitored. An telemetry sensor generally represents any sensors - * that can be queried. They might be sensors for temperature, noise, etc. Each + * sensor concept. The environment can affect the and measurement results + * of quantum devices. Therefore, the environment is closely monitored by telemetry + * sensors. A telemetry sensor generally represents any sensor whose recorded data + * can be queried. There might be sensors for temperature, noise, etc. Each * implementation of the @ref device_interface "QDMI Device Interface" defines * the actual implementation of the concept. * diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 9f5cccb5..c415d5d3 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -1008,8 +1008,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { for (QDMI_TelemetrySensor telemetry_sensor : telemetry_sensors) { QDMI_TelemetrySensor_Query query = nullptr; QDMI_TelemetrySensor_Query_Status status = {}; - time_t start_time = time(&start_time); - time_t end_time = time(&end_time) + 600; + time_t start_time = time(nullptr); + time_t end_time = time(nullptr) + 600; EXPECT_EQ(QDMI_device_create_telemetrysensor_query(device, &query), QDMI_SUCCESS); From 9f38ad94349ece90f2fccb220555d86b0325fe36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Thu, 14 Aug 2025 20:17:51 +0200 Subject: [PATCH 42/61] =?UTF-8?q?=F0=9F=8E=A8=20improvements=20based=20on?= =?UTF-8?q?=20the=20suggestions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 68 ++++++++++++------------- examples/driver/qdmi_example_driver.cpp | 9 ++-- examples/fomac/example_fomac.cpp | 6 +-- examples/fomac/example_fomac.hpp | 2 +- include/qdmi/constants.h | 60 ++++++++++++++-------- include/qdmi/device.h | 4 +- include/qdmi/types.h | 12 ++--- test/test_qdmi.cpp | 12 +++-- 8 files changed, 96 insertions(+), 77 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index d168251b..c833a3f8 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -84,19 +84,18 @@ struct CXX_QDMI_Operation_impl_d { struct CXX_QDMI_TelemetrySensor_impl_d { std::string id; std::string unit; - std::chrono::seconds sampling_rate; + uint64_t sampling_rate; }; struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { std::chrono::time_point start_time; std::chrono::time_point end_time; - size_t timeout{}; - CXX_QDMI_TelemetrySensor telemetry_sensor{}; + std::chrono::seconds timeout; + CXX_QDMI_TelemetrySensor telemetry_sensor; std::vector> result_timestamps; - std::vector result_values; - size_t result_length{}; - QDMI_TelemetrySensor_Query_Status status{}; + std::vector result_values; + QDMI_TelemetrySensor_Query_Status status; }; namespace { @@ -181,8 +180,7 @@ constexpr CXX_QDMI_Site_impl_d SITE4{4}; constexpr std::array CXX_DEVICE_SITES = { &SITE0, &SITE1, &SITE2, &SITE3, &SITE4}; -const CXX_QDMI_TelemetrySensor_impl_d ENVSEN{"t4k", "K", - std::chrono::duration{60}}; +const CXX_QDMI_TelemetrySensor_impl_d ENVSEN{"t4k", "K", 60}; constexpr std::array CXX_DEVICE_TELEMETRYSENSORS{&ENVSEN}; @@ -924,12 +922,12 @@ int CXX_QDMI_device_session_query_telemetrysensor_property( telemetry_sensor->unit.c_str(), prop, size, value, size_ret) ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, - int32_t, telemetry_sensor->sampling_rate.count(), - prop, size, value, size_ret) + uint64_t, telemetry_sensor->sampling_rate, prop, + size, value, size_ret) return QDMI_ERROR_NOTSUPPORTED; } -int CXX_QDMI_device_session_create_telemetrysensor_query( +int CXX_QDMI_device_session_create_device_telemetrysensor_query( CXX_QDMI_Device_Session session, CXX_QDMI_Device_TelemetrySensor_Query *query) { @@ -942,6 +940,7 @@ int CXX_QDMI_device_session_create_telemetrysensor_query( *query = new CXX_QDMI_Device_TelemetrySensor_Query_impl_d(); (*query)->start_time = std::chrono::system_clock::now(); (*query)->end_time = std::chrono::system_clock::now(); + (*query)->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; return QDMI_SUCCESS; } @@ -958,7 +957,7 @@ int CXX_QDMI_device_telemetrysensor_query_set_parameter( param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 && param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 && param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5) || - value == nullptr) { + value == nullptr || (size != sizeof(decltype(query->start_time)))) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { @@ -994,7 +993,7 @@ int CXX_QDMI_device_telemetrysensor_query_submit( // here, the actual submission. // for demonstration purposes - + query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING; // Clang-tidy generates a warning due to a known bug // https://github.com/llvm/llvm-project/issues/98122 auto time_difference = @@ -1004,24 +1003,24 @@ int CXX_QDMI_device_telemetrysensor_query_submit( auto sampling_rate = query->telemetry_sensor->sampling_rate; auto result_length = - static_cast(time_difference.count() / sampling_rate.count()); - + static_cast(time_difference.count()) / sampling_rate; query->result_timestamps.clear(); query->result_timestamps.reserve(result_length); query->result_values.clear(); query->result_values.reserve(result_length); - query->result_length = result_length; - + auto interval = std::chrono::seconds(sampling_rate); for (unsigned int i = 0; i < result_length; i++) { - auto duration_to_add = - std::chrono::duration_cast( - query->telemetry_sensor->sampling_rate * i); - auto next_time = query->start_time + duration_to_add; + + auto next_time = query->start_time + interval * i; query->result_timestamps.emplace_back(next_time); - query->result_values[i] = - static_cast(rand()) / (static_cast(RAND_MAX / 100)); + + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution<> dis(0.0, RAND_MAX); + double random_value = dis(gen); + query->result_values[i] = random_value; } return QDMI_SUCCESS; @@ -1041,36 +1040,35 @@ int CXX_QDMI_device_telemetrysensor_query_get_results( result != QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM5)) { return QDMI_ERROR_INVALIDARGUMENT; } - size_t req_size = query->result_length; + size_t required_size = query->result_values.size(); switch (result) { case QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS: - req_size *= sizeof(time_t); + required_size *= sizeof(time_t); if (data != nullptr) { - if (size < req_size) { + if (size < required_size) { return QDMI_ERROR_INVALIDARGUMENT; } auto *data_ptr = static_cast(data); - for (size_t i = 0; i < query->result_length; i++) { - data_ptr[i] = - std::chrono::system_clock::to_time_t(query->result_timestamps[i]); + for (auto timestamps : query->result_timestamps) { + *data_ptr++ = std::chrono::system_clock::to_time_t(timestamps); } } if ((size_ret) != nullptr) { - *(size_ret) = req_size; + *(size_ret) = required_size; } return QDMI_SUCCESS; case QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES: - req_size *= sizeof(float); + required_size *= sizeof(double); if (data != nullptr) { - if (size < req_size) { + if (size < required_size) { return QDMI_ERROR_INVALIDARGUMENT; } - memcpy(data, query->result_values.data(), req_size); + memcpy(data, query->result_values.data(), required_size); } if ((size_ret) != nullptr) { - *(size_ret) = req_size; + *(size_ret) = required_size; } return QDMI_SUCCESS; @@ -1106,7 +1104,7 @@ int CXX_QDMI_device_telemetrysensor_query_wait( } query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE; - query->timeout = timeout; + query->timeout = std::chrono::seconds(timeout); return QDMI_SUCCESS; } diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index e2af1a91..f473f334 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -109,8 +109,8 @@ struct QDMI_Library { decltype(QDMI_device_telemetrysensor_query_set_parameter) *device_telemetrysensor_query_set_parameter{}; - decltype(QDMI_device_session_create_telemetrysensor_query) - *device_session_create_telemetrysensor_query{}; + decltype(QDMI_device_session_create_device_telemetrysensor_query) + *device_session_create_device_telemetrysensor_query{}; decltype(QDMI_device_telemetrysensor_query_submit) *device_telemetrysensor_query_submit{}; @@ -253,7 +253,8 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_operation_property) LOAD_SYMBOL(library, prefix, device_session_query_telemetrysensor_property) // device qnvironment interface - LOAD_SYMBOL(library, prefix, device_session_create_telemetrysensor_query) + LOAD_SYMBOL(library, prefix, + device_session_create_device_telemetrysensor_query) LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_set_parameter) LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_submit) LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_get_results) @@ -597,7 +598,7 @@ int QDMI_device_create_telemetrysensor_query( *query = new QDMI_TelemetrySensor_Query_impl_d(); (*query)->device = dev; - return dev->library->device_session_create_telemetrysensor_query( + return dev->library->device_session_create_device_telemetrysensor_query( dev->device_session, &(*query)->env_query); } diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index 787c3b2f..0b5fe191 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -251,11 +251,11 @@ auto FoMaC::get_telemetry_unit(QDMI_TelemetrySensor telemetry_sensor) const } auto FoMaC::get_telemetry_sampling_rate( - QDMI_TelemetrySensor telemetry_sensor) const -> int64_t { - int64_t sampling_rate = 0; + QDMI_TelemetrySensor telemetry_sensor) const -> uint64_t { + uint64_t sampling_rate = 0; const int ret = QDMI_device_query_telemetrysensor_property( device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, - sizeof(int64_t), &sampling_rate, nullptr); + sizeof(uint64_t), &sampling_rate, nullptr); throw_if_error(ret, "Failed to query the sampling rate"); return sampling_rate; diff --git a/examples/fomac/example_fomac.hpp b/examples/fomac/example_fomac.hpp index 32ddd97a..c0bcf85d 100644 --- a/examples/fomac/example_fomac.hpp +++ b/examples/fomac/example_fomac.hpp @@ -74,5 +74,5 @@ class FoMaC { -> std::string; [[nodiscard]] auto - get_telemetry_sampling_rate(QDMI_TelemetrySensor telemetry) const -> int64_t; + get_telemetry_sampling_rate(QDMI_TelemetrySensor telemetry) const -> uint64_t; }; diff --git a/include/qdmi/constants.h b/include/qdmi/constants.h index 3771fada..54a0ed5e 100644 --- a/include/qdmi/constants.h +++ b/include/qdmi/constants.h @@ -824,15 +824,19 @@ typedef enum QDMI_DEVICE_PULSE_SUPPORT_LEVEL_T QDMI_Device_Pulse_Support_Level; enum QDMI_TELEMETRYSENSOR_PROPERTY_T { /** * @brief `char*` (string) The unique ID to identify the telemetry sensor. - * @details The ID of an telemetry sensor is used to identify the sensors. - * The sensors collect telemetry data in the HPCQC Labs, i.e., temperature - * and pressure. + * @details The ID of a telemetry sensor is used to identify the sensors. The + * sensors collect telemetry data in the environments that the quantum devices + * are hosted, such as HPCQC Labs, i.e., temperature and pressure. */ QDMI_TELEMETRYSENSOR_PROPERTY_ID = 0, - /// `char*` (string) The unit of an telemetry sensor, e.g., Kelvin for - /// temperature. + /** + * `char*` (string) The unit of a telemetry sensor, e.g., Kelvin for + * temperature. + */ QDMI_TELEMETRYSENSOR_PROPERTY_UNIT = 1, - /// `float` The samples per second of an telemetry sensor. + /** + * `uint64_t` The samples per second of a telemetry sensor. + */ QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE = 2, /** * @brief The maximum value of the enum. @@ -873,13 +877,22 @@ typedef enum QDMI_TELEMETRYSENSOR_PROPERTY_T QDMI_TelemetrySensor_Property; * require them to be set. */ enum QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_T { - /// The start time of the telemetry sensor query interval. + /** + * `time_t` The start time of the telemetry sensor query interval. + */ QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME = 0, - /// The end time of the telemetry sensor query interval. + /** + * `time_t` The end time of the telemetry sensor query interval. + */ QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME = 1, - /// The telemetry sensor for the telemetry sensor query. + /** + * `QDMI_TelemetrySensor *` The telemetry sensor for the telemetry sensor + * query. + */ QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRYSENSOR = 2, - /// The maximum value of the enum. + /** + * The maximum value of the enum. + */ QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_MAX = 3, /** * @brief This enum value is reserved for a custom parameter. @@ -888,13 +901,13 @@ enum QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_T { * binary compatibility. */ QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 = 999999995, - /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 + /// @see QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM2 = 999999996, - /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 + /// @see QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 = 999999997, - /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 + /// @see QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 = 999999998, - /// @see QDMI_DEVICE_JOB_PARAMETER_CUSTOM1 + /// @see QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM1 QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5 = 999999999 }; @@ -908,16 +921,19 @@ typedef enum QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_T */ enum QDMI_TELEMETRYSENSOR_QUERY_RESULT_T { /** - * @brief `uint64_t*` (`unsigned 64 bit integer` list) The UNIX timestamps at + * @brief `time_t*` (`unsigned 64 bit integer` list) The UNIX timestamps at * which the corresponding values in the results were recorded by a sensor. - * @details The result of an telemetry sensor query is represented as a + * @details The result of a telemetry sensor query is represented as a * key-value mapping. This mapping is returned as a list of keys and an * equal-length list of values. The corresponding partners of the keys and - * values can be found at the same index in the lists + * values can be found at the same index in the lists. + * + * This constant denotes the list of keys, @ref + * QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES denotes the list of values. */ QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS = 0, /** - * @brief `float*` (`float` list) The values of the result. + * @brief `double*` (`double` list) The values of the result. * @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS */ QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES = 1, @@ -937,13 +953,13 @@ enum QDMI_TELEMETRYSENSOR_QUERY_RESULT_T { * binary compatibility. */ QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 = 999999995, - /// @see QDMI_JOB_RESULT_CUSTOM1 + /// @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM2 = 999999996, - /// @see QDMI_JOB_RESULT_CUSTOM1 + /// @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM3 = 999999997, - /// @see QDMI_JOB_RESULT_CUSTOM1 + /// @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM4 = 999999998, - /// @see QDMI_JOB_RESULT_CUSTOM1 + /// @see QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM1 QDMI_TELEMETRYSENSOR_QUERY_RESULT_CUSTOM5 = 999999999 }; /// Telemetry query result type. diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 4c783dfc..04437a1d 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -650,7 +650,7 @@ void QDMI_device_job_free(QDMI_Device_Job job); * * The typical workflow for a device telemetry sensor query is as follows: * - Create an telemetry sensor query with @ref - * QDMI_device_session_create_telemetrysensor_query. + * QDMI_device_session_create_device_telemetrysensor_query. * - Set parameters for the telemetry sensor query with @ref * QDMI_device_telemetrysensor_query_set_parameter * - Submit the telemetry sensor query to the device with @ref @@ -707,7 +707,7 @@ typedef struct QDMI_Device_TelemetrySensor_Query_impl_d * @attention May only be called after the session has been initialized with * @ref QDMI_device_session_init. */ -int QDMI_device_session_create_telemetrysensor_query( +int QDMI_device_session_create_device_telemetrysensor_query( QDMI_Device_Session session, QDMI_Device_TelemetrySensor_Query *query); /** * @brief Set a parameter for an telemetry sensor query. diff --git a/include/qdmi/types.h b/include/qdmi/types.h index a9d920b4..f9bec388 100644 --- a/include/qdmi/types.h +++ b/include/qdmi/types.h @@ -74,12 +74,12 @@ typedef struct QDMI_Operation_impl_d *QDMI_Operation; /** * @brief A handle for a telemetry sensor. * @details An opaque pointer to an implementation of the QDMI telemetry - * sensor concept. The environment can affect the and measurement results - * of quantum devices. Therefore, the environment is closely monitored by telemetry - * sensors. A telemetry sensor generally represents any sensor whose recorded data - * can be queried. There might be sensors for temperature, noise, etc. Each - * implementation of the @ref device_interface "QDMI Device Interface" defines - * the actual implementation of the concept. + * sensor concept. The environment can affect the and measurement results + * of quantum devices. Therefore, the environment is closely monitored by + * telemetry sensors. A telemetry sensor generally represents any sensor whose + * recorded data can be queried. There might be sensors for temperature, noise, + * etc. Each implementation of the @ref device_interface "QDMI Device Interface" + * defines the actual implementation of the concept. * * A simple example of an implementation is a struct that merely contains the * telemetry sensor ID, which can be used to identify the site. diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index c415d5d3..f6b7eeb2 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -19,6 +19,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "example_fomac.hpp" #include "example_tool.hpp" #include "qdmi/client.h" +#include "qdmi/constants.h" #include "utils/test_impl.hpp" #include @@ -1007,7 +1008,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { for (QDMI_TelemetrySensor telemetry_sensor : telemetry_sensors) { QDMI_TelemetrySensor_Query query = nullptr; - QDMI_TelemetrySensor_Query_Status status = {}; + QDMI_TelemetrySensor_Query_Status status = + QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; time_t start_time = time(nullptr); time_t end_time = time(nullptr) + 600; @@ -1037,6 +1039,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { EXPECT_EQ(QDMI_telemetrysensor_query_check_status(query, &status), QDMI_SUCCESS); + EXPECT_EQ(status, QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE); + size_t timestamps_size = 0; EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, 0, @@ -1044,7 +1048,7 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { QDMI_SUCCESS); std::vector timestamps; - timestamps.reserve(timestamps_size); + timestamps.reserve(timestamps_size / sizeof(time_t)); EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, @@ -1057,8 +1061,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { &size_values), QDMI_SUCCESS); - std::vector values; - values.reserve(size_values); + std::vector values; + values.reserve(size_values / sizeof(double)); EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, size_values, From aba1df17f961a59961f243cacfaf1b77b0d5fd51 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:24:27 +0000 Subject: [PATCH 43/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_qdmi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 2121ec6a..59ebc470 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -26,9 +26,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include +#include #include #include -#include #include #include #include From 80cd57795d02109960b7904ed07557f6869ca6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Fri, 15 Aug 2025 00:15:37 +0200 Subject: [PATCH 44/61] =?UTF-8?q?=F0=9F=9A=A8=20lint=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index 60081523..647cb38c 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -90,12 +90,13 @@ struct CXX_QDMI_TelemetrySensor_impl_d { struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { std::chrono::time_point start_time; std::chrono::time_point end_time; - std::chrono::seconds timeout; - CXX_QDMI_TelemetrySensor telemetry_sensor; + std::chrono::seconds timeout = std::chrono::seconds(); + CXX_QDMI_TelemetrySensor telemetry_sensor = nullptr; std::vector> result_timestamps; std::vector result_values; - QDMI_TelemetrySensor_Query_Status status; + QDMI_TelemetrySensor_Query_Status status = + QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; }; namespace { @@ -1036,8 +1037,7 @@ int CXX_QDMI_device_telemetrysensor_query_submit( std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<> dis(0.0, RAND_MAX); - double random_value = dis(gen); - query->result_values[i] = random_value; + query->result_values[i] = dis(gen); } return QDMI_SUCCESS; From 4ef85b5076865236fd75ada0a173da6f91f9a642 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Fri, 29 Aug 2025 14:06:52 +0200 Subject: [PATCH 45/61] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20try=20with=20codecov?= =?UTF-8?q?=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- .github/workflows/reusable-cpp-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-cpp-ci.yml b/.github/workflows/reusable-cpp-ci.yml index aa2d8223..5f0d6854 100644 --- a/.github/workflows/reusable-cpp-ci.yml +++ b/.github/workflows/reusable-cpp-ci.yml @@ -65,4 +65,4 @@ jobs: with: fail_ci_if_error: true flags: cpp - use_oidc: true + token: ${{ secrets.CODECOV_TOKEN }} From 34718bc9488ef18ea72f0389cc86b5964d6dc628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Wed, 3 Sep 2025 18:09:09 +0200 Subject: [PATCH 46/61] =?UTF-8?q?=F0=9F=8E=A8=20minor=20refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_qdmi.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 59ebc470..1ff87e0a 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -19,7 +19,6 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "example_fomac.hpp" #include "example_tool.hpp" #include "qdmi/client.h" -#include "qdmi/constants.h" #include "utils/test_impl.hpp" #include From 5a121c5d4262ccdab820617274e48802012ba17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Wed, 17 Sep 2025 12:02:32 +0200 Subject: [PATCH 47/61] =?UTF-8?q?=F0=9F=92=9A=20codecov=20fix=20attempt=20?= =?UTF-8?q?using=20oidc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/reusable-cpp-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-cpp-ci.yml b/.github/workflows/reusable-cpp-ci.yml index ac978be7..7faea1eb 100644 --- a/.github/workflows/reusable-cpp-ci.yml +++ b/.github/workflows/reusable-cpp-ci.yml @@ -14,9 +14,6 @@ on: description: "Additional arguments to pass to CMake on macOS" default: "" type: string - secrets: - CODECOV_TOKEN: - required: true jobs: cpp-tests-ubuntu: @@ -45,6 +42,9 @@ jobs: coverage: name: ๐Ÿ“ˆ runs-on: ubuntu-latest + permissions: + contents: read # Required for the `actions/checkout` action + id-token: write # Required for the `codecov/codecov-action` action env: CMAKE_BUILD_PARALLEL_LEVEL: 4 CTEST_PARALLEL_LEVEL: 4 @@ -65,4 +65,4 @@ jobs: with: fail_ci_if_error: true flags: cpp - token: ${{ secrets.CODECOV_TOKEN }} + use_oidc: true From f8eb819a71ffb004dfbeea6a9ff35daa04814ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Wed, 17 Sep 2025 12:03:51 +0200 Subject: [PATCH 48/61] =?UTF-8?q?=F0=9F=92=9A=20codecov=20fix=20attempt=20?= =?UTF-8?q?usind=20oidc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cedf97be..7e97b62a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,8 +29,6 @@ jobs: with: # do not try to build docs in test builds cmake-args: "-DBUILD_QDMI_DOCS=OFF -G Ninja" - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} linter: name: ๐Ÿ‡จโ€Œ Lint From 3a3576d7071b72f936a4bf6981671d970d9d3b74 Mon Sep 17 00:00:00 2001 From: Yannick Stade <100073938+ystade@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:10:16 +0200 Subject: [PATCH 49/61] =?UTF-8?q?=F0=9F=8E=A8=20Clean-up=20example=20imple?= =?UTF-8?q?mentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index 647cb38c..cb038e7e 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -90,7 +90,7 @@ struct CXX_QDMI_TelemetrySensor_impl_d { struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { std::chrono::time_point start_time; std::chrono::time_point end_time; - std::chrono::seconds timeout = std::chrono::seconds(); + std::chrono::seconds timeout{}; CXX_QDMI_TelemetrySensor telemetry_sensor = nullptr; std::vector> result_timestamps; @@ -922,7 +922,7 @@ int CXX_QDMI_device_session_query_operation_property( int CXX_QDMI_device_session_query_telemetrysensor_property( CXX_QDMI_Device_Session session, CXX_QDMI_TelemetrySensor telemetry_sensor, - QDMI_TelemetrySensor_Property prop, size_t size, void *value, + const QDMI_TelemetrySensor_Property prop, const size_t size, void *value, size_t *size_ret) { if (session == nullptr || telemetry_sensor == nullptr || (value != nullptr && size == 0) || @@ -965,7 +965,7 @@ int CXX_QDMI_device_session_create_device_telemetrysensor_query( int CXX_QDMI_device_telemetrysensor_query_set_parameter( CXX_QDMI_Device_TelemetrySensor_Query query, - QDMI_Device_TelemetrySensor_Query_Parameter param, size_t size, + const QDMI_Device_TelemetrySensor_Query_Parameter param, const size_t size, const void *value) { if (query == nullptr || (value != nullptr && size == 0) || @@ -1014,13 +1014,13 @@ int CXX_QDMI_device_telemetrysensor_query_submit( query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING; // Clang-tidy generates a warning due to a known bug // https://github.com/llvm/llvm-project/issues/98122 - auto time_difference = + const auto time_difference = std::chrono::round( // NOLINT(misc-include-cleaner) query->end_time - query->start_time); - auto sampling_rate = query->telemetry_sensor->sampling_rate; + const auto sampling_rate = query->telemetry_sensor->sampling_rate; - auto result_length = + const auto result_length = static_cast(time_difference.count()) / sampling_rate; query->result_timestamps.clear(); query->result_timestamps.reserve(result_length); @@ -1028,15 +1028,15 @@ int CXX_QDMI_device_telemetrysensor_query_submit( query->result_values.clear(); query->result_values.reserve(result_length); - auto interval = std::chrono::seconds(sampling_rate); + const auto interval = std::chrono::seconds(sampling_rate); + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution<> dis(0.0, RAND_MAX); for (unsigned int i = 0; i < result_length; i++) { - auto next_time = query->start_time + interval * i; + const auto next_time = query->start_time + interval * i; query->result_timestamps.emplace_back(next_time); - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_real_distribution<> dis(0.0, RAND_MAX); query->result_values[i] = dis(gen); } @@ -1045,8 +1045,8 @@ int CXX_QDMI_device_telemetrysensor_query_submit( int CXX_QDMI_device_telemetrysensor_query_get_results( CXX_QDMI_Device_TelemetrySensor_Query query, - QDMI_TelemetrySensor_Query_Result result, size_t size, void *data, - size_t *size_ret) { + const QDMI_TelemetrySensor_Query_Result result, const size_t size, + void *data, size_t *size_ret) { if (query == nullptr || (data != nullptr && size == 0) || (result >= QDMI_TELEMETRYSENSOR_QUERY_RESULT_MAX && @@ -1092,8 +1092,6 @@ int CXX_QDMI_device_telemetrysensor_query_get_results( default: return QDMI_ERROR_NOTSUPPORTED; } - - return QDMI_SUCCESS; } int CXX_QDMI_device_telemetrysensor_query_check_status( @@ -1114,7 +1112,7 @@ int CXX_QDMI_device_telemetrysensor_query_check_status( } int CXX_QDMI_device_telemetrysensor_query_wait( - CXX_QDMI_Device_TelemetrySensor_Query query, size_t timeout) { + CXX_QDMI_Device_TelemetrySensor_Query query, const size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; From 35dc853e19f4358e948981b80821b4c1835b387d Mon Sep 17 00:00:00 2001 From: Yannick Stade <100073938+ystade@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:15:59 +0200 Subject: [PATCH 50/61] =?UTF-8?q?=F0=9F=8E=A8=20Minor=20improvements=20in?= =?UTF-8?q?=20example=20driver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/driver/qdmi_example_driver.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index f473f334..51181543 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -252,7 +252,7 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) LOAD_SYMBOL(library, prefix, device_session_query_telemetrysensor_property) - // device qnvironment interface + // device environment interface LOAD_SYMBOL(library, prefix, device_session_create_device_telemetrysensor_query) LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_set_parameter) @@ -577,7 +577,7 @@ int QDMI_device_query_operation_property( int QDMI_device_query_telemetrysensor_property( QDMI_Device device, QDMI_TelemetrySensor telemetry_sensor, - QDMI_TelemetrySensor_Property prop, const size_t size, void *value, + const QDMI_TelemetrySensor_Property prop, const size_t size, void *value, size_t *size_ret) { if (device == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -604,7 +604,7 @@ int QDMI_device_create_telemetrysensor_query( int QDMI_telemetrysensor_query_set_parameter( QDMI_TelemetrySensor_Query query, - QDMI_TelemetrySensor_Query_Parameter param, size_t size, + const QDMI_TelemetrySensor_Query_Parameter param, const size_t size, const void *value) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; @@ -624,8 +624,9 @@ int QDMI_telemetrysensor_query_submit(QDMI_TelemetrySensor_Query query) { } int QDMI_telemetrysensor_query_get_results( - QDMI_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Result result, - size_t size, void *data, size_t *size_ret) { + QDMI_TelemetrySensor_Query query, + const QDMI_TelemetrySensor_Query_Result result, const size_t size, + void *data, size_t *size_ret) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -645,7 +646,7 @@ int QDMI_telemetrysensor_query_check_status( } int QDMI_telemetrysensor_query_wait(QDMI_TelemetrySensor_Query query, - size_t timeout) { + const size_t timeout) { if (query == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } From c7ffdc3c9d1b2608b3b629a0437eb7b9c9ba21eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 10:57:49 +0200 Subject: [PATCH 51/61] =?UTF-8?q?=E2=8F=AA=20revert=20codecov=20fix=20atte?= =?UTF-8?q?mpt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 ++ .github/workflows/reusable-cpp-ci.yml | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4db11a3..9ac88be7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,8 @@ jobs: with: # do not try to build docs in test builds cmake-args: "-DBUILD_QDMI_DOCS=OFF -G Ninja" + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} linter: name: ๐Ÿ‡จโ€Œ Lint diff --git a/.github/workflows/reusable-cpp-ci.yml b/.github/workflows/reusable-cpp-ci.yml index c8cc6cc8..08b36238 100644 --- a/.github/workflows/reusable-cpp-ci.yml +++ b/.github/workflows/reusable-cpp-ci.yml @@ -14,6 +14,9 @@ on: description: "Additional arguments to pass to CMake on macOS" default: "" type: string + secrets: + CODECOV_TOKEN: + required: true jobs: cpp-tests-ubuntu: @@ -42,9 +45,6 @@ jobs: coverage: name: ๐Ÿ“ˆ runs-on: ubuntu-latest - permissions: - contents: read # Required for the `actions/checkout` action - id-token: write # Required for the `codecov/codecov-action` action env: CMAKE_BUILD_PARALLEL_LEVEL: 4 CTEST_PARALLEL_LEVEL: 4 @@ -65,4 +65,4 @@ jobs: with: fail_ci_if_error: true flags: cpp - use_oidc: true + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file From e3467e62ca86c1226683c19e797b295eee395a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 10:59:08 +0200 Subject: [PATCH 52/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20fix=20typos=20in?= =?UTF-8?q?=20the=20documents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 26 +++++++++++++------------- include/qdmi/device.h | 32 ++++++++++++++++---------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 67ceef0c..922b2498 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -578,7 +578,7 @@ int QDMI_device_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an telemetry sensor property. + * @brief Query a telemetry sensor property. * @param[in] device The device to query. Must not be @c NULL. * @param[in] telemetry_sensor The telemetry sensor to query. Must not be @c NULL. @@ -609,7 +609,7 @@ int QDMI_device_query_operation_property( * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. * - * @note For example, to query the unit of an telemetry sensor, the following + * @note For example, to query the unit of a telemetry sensor, the following code pattern * can be used: * ``` @@ -1058,11 +1058,11 @@ void QDMI_job_free(QDMI_Job job); /** @defgroup client_telemetrysensor_query_interface \ * QDMI Client Telemetry Sensor Query Interface * @brief Provides functions to query telemetry sensors. - * @details An telemetry sensor query is a task submitted by a client to a + * @details A telemetry sensor query is a task submitted by a client to a * device for querying telemetry sensors, i.e. temperature or power. * * The typical workflow for a client telemetry sensor query is as follows: - * - Create an telemetry sensor query with @ref + * - Create a telemetry sensor query with @ref * QDMI_device_create_telemetrysensor_query. * - Set parameters for the telemetry sensor query with @ref * QDMI_telemetrysensor_query_set_parameter @@ -1083,7 +1083,7 @@ void QDMI_job_free(QDMI_Job job); /** * @brief A handle for a client-side telemetry sensor query. * @details An opaque pointer to a type defined by the driver that encapsulates - * all information about an telemetry sensor query submitted to a device by a + * all information about a telemetry sensor query submitted to a device by a * client. * @remark Implementations of the underlying type will want to store the device * handle used to create the telemetry sensor query in the handle to be able @@ -1094,8 +1094,8 @@ void QDMI_job_free(QDMI_Job job); typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; /** - * @brief Create an telemetry sensor query. - * @details This is the main entry point for a client to submit an telemetry + * @brief Create a telemetry sensor query. + * @details This is the main entry point for a client to submit a telemetry * sensor query to a device. The returned handle can be used throughout the * @ref client_telemetrysensor_query_interface * "client telemetry sensor query interface" to refer to the telemetry @@ -1162,7 +1162,7 @@ enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T { typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T QDMI_TelemetrySensor_Query_Parameter; /** - * @brief Set a parameter for an telemetry sensor. + * @brief Set a parameter for a telemetry sensor. * @param[in] query A handle to a job for which to set @p param. Must not be @c * NULL. * @param[in] param The parameter whose value will be set. Must be one of the @@ -1220,7 +1220,7 @@ int QDMI_telemetrysensor_query_set_parameter( QDMI_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Parameter param, size_t size, const void *value); /** - * @brief Submit an telemetry sensor query to the device. + * @brief Submit a telemetry sensor query to the device. * @details This function can either be blocking until the telemetry sensor * query is finished or non-blocking and return while the telemetry sensor * query is running. In the latter case, the functions @ref @@ -1264,7 +1264,7 @@ int QDMI_telemetrysensor_query_submit(QDMI_TelemetrySensor_Query query); int QDMI_telemetrysensor_query_cancel(QDMI_TelemetrySensor_Query query); /** - * @brief Check the status of an telemetry sensor query. + * @brief Check the status of a telemetry sensor query. * @details This function is non-blocking and returns immediately with the * telemetry sensor query status. It is not required to call this function * before calling @ref QDMI_telemetrysensor_query_get_results. @@ -1287,7 +1287,7 @@ int QDMI_telemetrysensor_query_check_status( QDMI_TelemetrySensor_Query_Status *status); /** - * @brief Wait for an telemetry sensor query to finish. + * @brief Wait for a telemetry sensor query to finish. * @details This function blocks until the telemetry sensor query has either * finished or has been canceled, or the timeout has been reached. * @param[in] query The telemetry sensor query to wait for. Must not be @c @@ -1311,7 +1311,7 @@ int QDMI_telemetrysensor_query_wait(QDMI_TelemetrySensor_Query query, size_t timeout); /** - * @brief Retrieve the results of an telemetry sensor query. + * @brief Retrieve the results of a telemetry sensor query. * @param[in] query The telemetry sensor query to retrieve the results from. * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified @@ -1368,7 +1368,7 @@ int QDMI_telemetrysensor_query_get_results( QDMI_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Result result, size_t size, void *data, size_t *size_ret); /** - * @brief Free an telemetry sensor query. + * @brief Free a telemetry sensor query. * @details Free the resources associated with a telemetry sensor query. Using * a telemetry sensor query handle after it has been freed is undefined * behavior. diff --git a/include/qdmi/device.h b/include/qdmi/device.h index 04437a1d..76f013ad 100644 --- a/include/qdmi/device.h +++ b/include/qdmi/device.h @@ -357,7 +357,7 @@ int QDMI_device_session_query_operation_property( QDMI_Operation_Property prop, size_t size, void *value, size_t *size_ret); /** - * @brief Query an telemetry sensor property. + * @brief Query a telemetry sensor property. * @param[in] session The session used for the query. Must not be @c NULL. * @param[in] telemetry_sensor The telemetry sensor to query. Must not be @c * NULL. @@ -645,11 +645,11 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** @defgroup device_telemetrysensor_query_interface \ * QDMI Device Telemetry Sensor Query Interface * @brief Provides functions to manage telemetry sensor queries on a device. - * @details An telemetry sensor query is a task submitted to a device for + * @details A telemetry sensor query is a task submitted to a device for * querying telemetry sensors, i.e. temperature or power. * * The typical workflow for a device telemetry sensor query is as follows: - * - Create an telemetry sensor query with @ref + * - Create a telemetry sensor query with @ref * QDMI_device_session_create_device_telemetrysensor_query. * - Set parameters for the telemetry sensor query with @ref * QDMI_device_telemetrysensor_query_set_parameter @@ -670,7 +670,7 @@ void QDMI_device_job_free(QDMI_Device_Job job); /** * @brief A handle for a device telemetry sensor query. * @details An opaque pointer to a type defined by the device that encapsulates - * all information about an telemetry sensor query on a device. + * all information about a telemetry sensor query on a device. * @remark Implementations of the underlying type will want to store the session * handle used to create the telemetry sensor query in the telemetry sensor * query handle to be able to access the session information when needed. @@ -679,8 +679,8 @@ void QDMI_device_job_free(QDMI_Device_Job job); typedef struct QDMI_Device_TelemetrySensor_Query_impl_d *QDMI_Device_TelemetrySensor_Query; /** - * @brief Create an telemetry sensor query. - * @details This is the main entry point for a driver to create an telemetry + * @brief Create a telemetry sensor query. + * @details This is the main entry point for a driver to create a telemetry * sensor query for a device. The returned handle can be used throughout the * @ref device_telemetrysensor_query_interface * "device telemetry sensor query interface" to refer to the telemetry @@ -696,7 +696,7 @@ typedef struct QDMI_Device_TelemetrySensor_Query_impl_d * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p session or @p query are @c * NULL. * @return @ref QDMI_ERROR_BADSTATE if the session is not in a state allowing - * the creation of an telemetry sensor query, for example, because the session + * the creation of a telemetry sensor query, for example, because the session * is not initialized. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the device does not allow using * the @ref device_telemetrysensor_query_interface @@ -710,8 +710,8 @@ typedef struct QDMI_Device_TelemetrySensor_Query_impl_d int QDMI_device_session_create_device_telemetrysensor_query( QDMI_Device_Session session, QDMI_Device_TelemetrySensor_Query *query); /** - * @brief Set a parameter for an telemetry sensor query. - * @param[in] query A handle to an telemetry sensor query for which to set @p + * @brief Set a parameter for a telemetry sensor query. + * @param[in] query A handle to a telemetry sensor query for which to set @p * param. Must not be @c NULL. * @param[in] param The parameter whose value will be set. Must be one of the * values specified for @ref QDMI_Device_TelemetrySensor_Query_Parameter. @@ -751,7 +751,7 @@ int QDMI_device_telemetrysensor_query_set_parameter( QDMI_Device_TelemetrySensor_Query_Parameter param, size_t size, const void *value); /** - * @brief Submit an telemetry sensor query to the device. + * @brief Submit a telemetry sensor query to the device. * @details This function can either be blocking until the job is finished or * non-blocking and return while the job is running. In the latter case, the * functions @ref QDMI_device_telemetrysensor_query_check_status and @ref @@ -789,7 +789,7 @@ int QDMI_device_telemetrysensor_query_cancel( QDMI_Device_TelemetrySensor_Query query); /** - * @brief Check the status of an telemetry sensor query. + * @brief Check the status of a telemetry sensor query. * @details This function is non-blocking and returns immediately with the * telemetry sensor query status. It is not required to call this function * before calling @ref QDMI_telemetrysensor_query_get_results. @@ -811,7 +811,7 @@ int QDMI_device_telemetrysensor_query_check_status( QDMI_Device_TelemetrySensor_Query query, QDMI_TelemetrySensor_Query_Status *status); /** - * @brief Wait for an telemetry sensor query to finish. + * @brief Wait for a telemetry sensor query to finish. * @details This function blocks until the telemetry sensor query has either * finished, has been canceled, or the timeout has been reached. * @param[in] query The telemetry sensor query to wait for. Must not be @c @@ -834,7 +834,7 @@ int QDMI_device_telemetrysensor_query_wait( QDMI_Device_TelemetrySensor_Query query, size_t timeout); /** - * @brief Retrieve the results of an telemetry sensor query. + * @brief Retrieve the results of a telemetry sensor query. * @param[in] query The telemetry sensor query to retrieve the results from. * Must not be @c NULL. * @param[in] result The result to retrieve. Must be one of the values specified @@ -875,9 +875,9 @@ int QDMI_device_telemetrysensor_query_get_results( QDMI_TelemetrySensor_Query_Result result, size_t size, void *data, size_t *size_ret); /** - * @brief Free an telemetry sensor query. - * @details Free the resources associated with an telemetry sensor query. - * Using an telemetry sensor query handle after it has been freed is undefined + * @brief Free a telemetry sensor query. + * @details Free the resources associated with a telemetry sensor query. + * Using a telemetry sensor query handle after it has been freed is undefined * behavior. * @param[in] query The telemetry sensor query to free. */ From b4c416dabc3c154d856eb05996eb47331dea1751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 11:06:36 +0200 Subject: [PATCH 53/61] =?UTF-8?q?=F0=9F=93=9D=20additional=20documentation?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/driver/qdmi_example_driver.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 51181543..cfba76ce 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -102,31 +102,31 @@ struct QDMI_Library { /// Function pointer to @ref QDMI_device_session_query_operation_property. decltype(QDMI_device_session_query_operation_property) *device_session_query_operation_property{}; - + /// Function pointer to @ref QDMI_device_session_query_telemetrysensor_property. decltype(QDMI_device_session_query_telemetrysensor_property) *device_session_query_telemetrysensor_property{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_set_parameter. decltype(QDMI_device_telemetrysensor_query_set_parameter) *device_telemetrysensor_query_set_parameter{}; - + /// Function pointer to @ref QDMI_device_session_create_device_telemetrysensor_query. decltype(QDMI_device_session_create_device_telemetrysensor_query) *device_session_create_device_telemetrysensor_query{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_submit. decltype(QDMI_device_telemetrysensor_query_submit) *device_telemetrysensor_query_submit{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_get_results. decltype(QDMI_device_telemetrysensor_query_get_results) *device_telemetrysensor_query_get_results{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_check_status. decltype(QDMI_device_telemetrysensor_query_check_status) *device_telemetrysensor_query_check_status{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_wait. decltype(QDMI_device_telemetrysensor_query_wait) *device_telemetrysensor_query_wait{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_cancel. decltype(QDMI_device_telemetrysensor_query_cancel) *device_telemetrysensor_query_cancel{}; - + /// Function pointer to @ref QDMI_device_telemetrysensor_query_free. decltype(QDMI_device_telemetrysensor_query_free) *device_telemetrysensor_query_free{}; From d61e4e72e66061e2d9c6ff4c22fd7278f2fd4cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 13:41:15 +0200 Subject: [PATCH 54/61] =?UTF-8?q?=F0=9F=9A=A8=20fix=20lint=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/reusable-cpp-ci.yml | 2 +- examples/driver/qdmi_example_driver.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-cpp-ci.yml b/.github/workflows/reusable-cpp-ci.yml index 08b36238..d3c744c2 100644 --- a/.github/workflows/reusable-cpp-ci.yml +++ b/.github/workflows/reusable-cpp-ci.yml @@ -65,4 +65,4 @@ jobs: with: fail_ci_if_error: true flags: cpp - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index cfba76ce..6bb5faa7 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -102,13 +102,15 @@ struct QDMI_Library { /// Function pointer to @ref QDMI_device_session_query_operation_property. decltype(QDMI_device_session_query_operation_property) *device_session_query_operation_property{}; - /// Function pointer to @ref QDMI_device_session_query_telemetrysensor_property. + /// Function pointer to @ref + /// QDMI_device_session_query_telemetrysensor_property. decltype(QDMI_device_session_query_telemetrysensor_property) *device_session_query_telemetrysensor_property{}; /// Function pointer to @ref QDMI_device_telemetrysensor_query_set_parameter. decltype(QDMI_device_telemetrysensor_query_set_parameter) *device_telemetrysensor_query_set_parameter{}; - /// Function pointer to @ref QDMI_device_session_create_device_telemetrysensor_query. + /// Function pointer to @ref + /// QDMI_device_session_create_device_telemetrysensor_query. decltype(QDMI_device_session_create_device_telemetrysensor_query) *device_session_create_device_telemetrysensor_query{}; /// Function pointer to @ref QDMI_device_telemetrysensor_query_submit. From abe1b30c19d8630fb2c4d85cdef55f09093ae40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 14:02:50 +0200 Subject: [PATCH 55/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20fix=20typos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/fomac/example_fomac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fomac/example_fomac.cpp b/examples/fomac/example_fomac.cpp index f7fb84aa..fb694774 100644 --- a/examples/fomac/example_fomac.cpp +++ b/examples/fomac/example_fomac.cpp @@ -230,13 +230,13 @@ auto FoMaC::get_telemetry_sensors() const -> std::vector { int ret = QDMI_device_query_device_property( device, QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS, 0, nullptr, &telemetry_sensor_size); - throw_if_error(ret, "Failed to get the telemetry variable list size."); + throw_if_error(ret, "Failed to get the telemetry sensor list size."); std::vector telemetry_sensors(telemetry_sensor_size / sizeof(QDMI_Site)); ret = QDMI_device_query_device_property( device, QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS, telemetry_sensor_size, static_cast(telemetry_sensors.data()), nullptr); - throw_if_error(ret, "Failed to get the telemetry variables."); + throw_if_error(ret, "Failed to get the telemetry sensors."); return telemetry_sensors; } From 891abf38bad60720d0d38d4c4faf74f5a6cb1d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 14:04:36 +0200 Subject: [PATCH 56/61] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20corrects=20weird?= =?UTF-8?q?=20line=20breaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 922b2498..2364764d 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -581,7 +581,7 @@ int QDMI_device_query_operation_property( * @brief Query a telemetry sensor property. * @param[in] device The device to query. Must not be @c NULL. * @param[in] telemetry_sensor The telemetry sensor to query. Must not be @c - NULL. + * NULL. * @param[in] prop The property to query. Must be one of the values specified * for @ref QDMI_TelemetrySensor_Property. * @param[in] size The size of the memory pointed to by @p value in bytes. Must @@ -604,8 +604,8 @@ int QDMI_device_query_operation_property( * * @note By calling this function with @p value set to @c NULL, the function can * be used to check if the telemetry sensor supports the specified property - without - * retrieving the property and without the need to provide a buffer for it. + * without retrieving the property and without the need to provide a buffer for + * it. * Additionally, the size of the buffer needed to retrieve the property is * returned in @p size_ret if @p size_ret is not @c NULL. * @@ -616,7 +616,7 @@ int QDMI_device_query_operation_property( * // Check if the device supports the property. * auto ret = QDMI_device_query_telemetrysensor_property( * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, 0, - nullptr, nullptr); + * nullptr, nullptr); * if (ret == QDMI_ERROR_NOTSUPPORTED) { * // The device does not support the property. * ... @@ -636,7 +636,7 @@ int QDMI_device_query_operation_property( * ret = QDMI_device_query_telemetrysensor_property( * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, * telemetrysensor_unit.size() + 1, telemetrysensor_unit.data(), - nullptr); + * nullptr); * ``` * * @remark @ref QDMI_TelemetrySensor handles may be queried via @ref @@ -1088,7 +1088,7 @@ void QDMI_job_free(QDMI_Job job); * @remark Implementations of the underlying type will want to store the device * handle used to create the telemetry sensor query in the handle to be able * to access the device when needed. - * @see QDMI_Device_TelemetrySensor_Query for the device-side the telemetry + * @see QDMI_Device_TelemetrySensor_Query for the device-side telemetry * sensor query handle. */ typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; From abbbbd56c860dfdefcbcc5c7fe91be7a67562e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Tue, 30 Sep 2025 16:48:02 +0200 Subject: [PATCH 57/61] =?UTF-8?q?=F0=9F=8E=A8=20improve=20consistent=20usa?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 28 +++++++++++++++++----------- test/test_qdmi.cpp | 20 ++++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index cb038e7e..fba2a558 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -33,7 +33,6 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include #include -#include #include #include #include @@ -975,19 +974,23 @@ int CXX_QDMI_device_telemetrysensor_query_set_parameter( param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM3 && param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM4 && param != QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_CUSTOM5) || - value == nullptr || (size != sizeof(decltype(query->start_time)))) { + value == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME: { - query->start_time = std::chrono::system_clock::from_time_t( - *static_cast(value)); + if (size < sizeof(std::chrono::time_point)) { + return QDMI_ERROR_INVALIDARGUMENT; + } + std::memcpy(&query->start_time, value, size); return QDMI_SUCCESS; } case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME: { - query->end_time = std::chrono::system_clock::from_time_t( - *static_cast(value)); + std::memcpy(&query->end_time, value, size); + if (size < sizeof(std::chrono::time_point)) { + return QDMI_ERROR_INVALIDARGUMENT; + } return QDMI_SUCCESS; } @@ -1037,7 +1040,7 @@ int CXX_QDMI_device_telemetrysensor_query_submit( const auto next_time = query->start_time + interval * i; query->result_timestamps.emplace_back(next_time); - query->result_values[i] = dis(gen); + query->result_values.emplace_back(dis(gen)); } return QDMI_SUCCESS; @@ -1060,14 +1063,17 @@ int CXX_QDMI_device_telemetrysensor_query_get_results( size_t required_size = query->result_values.size(); switch (result) { case QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS: - required_size *= sizeof(time_t); + required_size *= sizeof(std::chrono::time_point); if (data != nullptr) { if (size < required_size) { return QDMI_ERROR_INVALIDARGUMENT; } - auto *data_ptr = static_cast(data); - for (auto timestamps : query->result_timestamps) { - *data_ptr++ = std::chrono::system_clock::to_time_t(timestamps); + auto *data_ptr = + static_cast *>( + data); + for (auto timestamp : query->result_timestamps) { + std::memcpy(data_ptr++, ×tamp, + sizeof(std::chrono::time_point)); } } diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 1ff87e0a..766fef39 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -22,10 +22,10 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "utils/test_impl.hpp" #include +#include #include #include #include -#include #include #include #include @@ -1162,8 +1162,10 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { QDMI_TelemetrySensor_Query query = nullptr; QDMI_TelemetrySensor_Query_Status status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; - time_t start_time = time(nullptr); - time_t end_time = time(nullptr) + 600; + + auto start_time = std::chrono::system_clock::now(); + + auto end_time = start_time + std::chrono::minutes(10); EXPECT_EQ(QDMI_device_create_telemetrysensor_query(device, &query), QDMI_SUCCESS); @@ -1176,12 +1178,12 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME, - sizeof(time_t), &start_time), + sizeof(decltype(start_time)), &start_time), QDMI_SUCCESS); EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME, - sizeof(time_t), &end_time), + sizeof(decltype(end_time)), &end_time), QDMI_SUCCESS); EXPECT_EQ(QDMI_telemetrysensor_query_submit(query), QDMI_SUCCESS); @@ -1199,12 +1201,14 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { nullptr, ×tamps_size), QDMI_SUCCESS); - std::vector timestamps; - timestamps.reserve(timestamps_size / sizeof(time_t)); + std::vector> timestamps{ + timestamps_size / + sizeof(std::chrono::time_point)}; EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, - timestamps_size, timestamps.data(), nullptr), + timestamps_size, static_cast(timestamps.data()), + nullptr), QDMI_SUCCESS); size_t size_values = 0; From c7432aa5079c6ac420bebee350ddb569e228d983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= <49598189+kayaercument@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:53:20 +0200 Subject: [PATCH 58/61] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yannick Stade <100073938+ystade@users.noreply.github.com> Signed-off-by: Ercรผment Kaya <49598189+kayaercument@users.noreply.github.com> --- include/qdmi/client.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 2364764d..4d9f7bd9 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -1057,9 +1057,9 @@ void QDMI_job_free(QDMI_Job job); /** @defgroup client_telemetrysensor_query_interface \ * QDMI Client Telemetry Sensor Query Interface - * @brief Provides functions to query telemetry sensors. - * @details A telemetry sensor query is a task submitted by a client to a - * device for querying telemetry sensors, i.e. temperature or power. + * @brief Provides functions to query data from telemetry sensors. + * @details An telemetry sensor query is a task submitted by a client to a + * device for querying data from telemetry sensors, i.e. temperature or power. * * The typical workflow for a client telemetry sensor query is as follows: * - Create a telemetry sensor query with @ref @@ -1103,9 +1103,9 @@ typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; * @param[in] device The device to create the telemetry sensor query on. Must * not be @c NULL. * @param[out] query A pointer to a handle that will store the created - * telemetry sensor query. Must not be @c NULL. The job must be freed by + * telemetry sensor query. Must not be @c NULL. The query must be freed by * calling @ref QDMI_telemetrysensor_query_free when it is no longer used. - * @return @ref QDMI_SUCCESS if the job was successfully created. + * @return @ref QDMI_SUCCESS if the query was successfully created. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using * the @ref client_telemetrysensor_query_interface @@ -1163,7 +1163,7 @@ typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T QDMI_TelemetrySensor_Query_Parameter; /** * @brief Set a parameter for a telemetry sensor. - * @param[in] query A handle to a job for which to set @p param. Must not be @c + * @param[in] query A handle to a query for which to set @p param. Must not be @c * NULL. * @param[in] param The parameter whose value will be set. Must be one of the * values specified for @ref QDMI_TelemetrySensor_Query_Parameter. @@ -1184,7 +1184,7 @@ typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T * the parameter (if specified by the @ref * QDMI_TelemetrySensor_Query_Parameter documentation). * @return @ref QDMI_ERROR_BADSTATE if the parameter cannot be set in the - * current state of the job, for example, because the query is already + * current state of the query, for example, because the query is already * submitted. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using * the @ref client_telemetrysensor_query_interface From ecc8fcd61a240139c6c5003de8eff83725e2bc07 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:53:31 +0000 Subject: [PATCH 59/61] =?UTF-8?q?=F0=9F=8E=A8=20pre-commit=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/qdmi/client.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 4d9f7bd9..74ec15b5 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -1163,8 +1163,8 @@ typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T QDMI_TelemetrySensor_Query_Parameter; /** * @brief Set a parameter for a telemetry sensor. - * @param[in] query A handle to a query for which to set @p param. Must not be @c - * NULL. + * @param[in] query A handle to a query for which to set @p param. Must not be + * @c NULL. * @param[in] param The parameter whose value will be set. Must be one of the * values specified for @ref QDMI_TelemetrySensor_Query_Parameter. * @param[in] size The size of the data pointed to by @p value in bytes. Must From b88ff2f9d3bf9ba467790a59df232883ef0e59b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Wed, 1 Oct 2025 18:18:14 +0200 Subject: [PATCH 60/61] =?UTF-8?q?=F0=9F=8E=A8=20use=20ctime=20instead=20of?= =?UTF-8?q?=20chrono?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 69 ++++++++++++------------- examples/driver/qdmi_example_driver.cpp | 16 ++++-- include/qdmi/client.h | 58 +++++++++++++++------ test/test_qdmi.cpp | 29 ++++------- 4 files changed, 97 insertions(+), 75 deletions(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index fba2a558..584d3c1c 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -26,17 +26,18 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include #include -#include #include #include #include #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -83,16 +84,15 @@ struct CXX_QDMI_Operation_impl_d { struct CXX_QDMI_TelemetrySensor_impl_d { std::string id; std::string unit; - uint64_t sampling_rate; + time_t sampling_rate; }; struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { - std::chrono::time_point start_time; - std::chrono::time_point end_time; - std::chrono::seconds timeout{}; + std::unique_ptr start_time = nullptr; + std::unique_ptr end_time = nullptr; + size_t timeout{}; CXX_QDMI_TelemetrySensor telemetry_sensor = nullptr; - std::vector> - result_timestamps; + std::vector result_timestamps; std::vector result_values; QDMI_TelemetrySensor_Query_Status status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; @@ -938,9 +938,9 @@ int CXX_QDMI_device_session_query_telemetrysensor_property( ADD_STRING_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, telemetry_sensor->unit.c_str(), prop, size, value, size_ret) - ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, - uint64_t, telemetry_sensor->sampling_rate, prop, - size, value, size_ret) + ADD_SINGLE_VALUE_PROPERTY(QDMI_TELEMETRYSENSOR_PROPERTY_SAMPLINGRATE, time_t, + telemetry_sensor->sampling_rate, prop, size, value, + size_ret) return QDMI_ERROR_NOTSUPPORTED; } @@ -955,8 +955,9 @@ int CXX_QDMI_device_session_create_device_telemetrysensor_query( return QDMI_ERROR_BADSTATE; } *query = new CXX_QDMI_Device_TelemetrySensor_Query_impl_d(); - (*query)->start_time = std::chrono::system_clock::now(); - (*query)->end_time = std::chrono::system_clock::now(); + (*query)->start_time = nullptr; + (*query)->end_time = nullptr; + (*query)->telemetry_sensor = nullptr; (*query)->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; return QDMI_SUCCESS; @@ -978,25 +979,28 @@ int CXX_QDMI_device_telemetrysensor_query_set_parameter( return QDMI_ERROR_INVALIDARGUMENT; } switch (param) { - case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME: { - if (size < sizeof(std::chrono::time_point)) { + if (size < sizeof(time_t)) { return QDMI_ERROR_INVALIDARGUMENT; } - std::memcpy(&query->start_time, value, size); + query->start_time = + std::make_unique(*static_cast(value)); return QDMI_SUCCESS; } case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME: { - std::memcpy(&query->end_time, value, size); - if (size < sizeof(std::chrono::time_point)) { + if (size < sizeof(time_t)) { return QDMI_ERROR_INVALIDARGUMENT; } + query->end_time = + std::make_unique(*static_cast(value)); return QDMI_SUCCESS; } - case QDMI_DEVICE_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRYSENSOR: { + if (size < sizeof(CXX_QDMI_TelemetrySensor)) { + return QDMI_ERROR_INVALIDARGUMENT; + } query->telemetry_sensor = - *(static_cast(value)); + *static_cast(value); return QDMI_SUCCESS; } default: @@ -1007,7 +1011,8 @@ int CXX_QDMI_device_telemetrysensor_query_set_parameter( int CXX_QDMI_device_telemetrysensor_query_submit( CXX_QDMI_Device_TelemetrySensor_Query query) { - if (query == nullptr || query->telemetry_sensor == nullptr) { + if (query == nullptr || query->telemetry_sensor == nullptr || + query->start_time == nullptr || query->end_time == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -1015,29 +1020,25 @@ int CXX_QDMI_device_telemetrysensor_query_submit( // for demonstration purposes query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_RUNNING; - // Clang-tidy generates a warning due to a known bug - // https://github.com/llvm/llvm-project/issues/98122 - const auto time_difference = - std::chrono::round( // NOLINT(misc-include-cleaner) - query->end_time - query->start_time); + + time_t time_difference = *query->end_time - *query->start_time; const auto sampling_rate = query->telemetry_sensor->sampling_rate; const auto result_length = - static_cast(time_difference.count()) / sampling_rate; + static_cast(time_difference / sampling_rate); query->result_timestamps.clear(); query->result_timestamps.reserve(result_length); query->result_values.clear(); query->result_values.reserve(result_length); - const auto interval = std::chrono::seconds(sampling_rate); std::random_device rd; std::mt19937 gen(rd()); std::uniform_real_distribution<> dis(0.0, RAND_MAX); for (unsigned int i = 0; i < result_length; i++) { - const auto next_time = query->start_time + interval * i; + time_t next_time = *query->start_time + sampling_rate * i; query->result_timestamps.emplace_back(next_time); query->result_values.emplace_back(dis(gen)); @@ -1063,18 +1064,12 @@ int CXX_QDMI_device_telemetrysensor_query_get_results( size_t required_size = query->result_values.size(); switch (result) { case QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS: - required_size *= sizeof(std::chrono::time_point); + required_size *= sizeof(time_t); if (data != nullptr) { if (size < required_size) { return QDMI_ERROR_INVALIDARGUMENT; } - auto *data_ptr = - static_cast *>( - data); - for (auto timestamp : query->result_timestamps) { - std::memcpy(data_ptr++, ×tamp, - sizeof(std::chrono::time_point)); - } + memcpy(data, query->result_timestamps.data(), required_size); } if ((size_ret) != nullptr) { @@ -1125,7 +1120,7 @@ int CXX_QDMI_device_telemetrysensor_query_wait( } query->status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_DONE; - query->timeout = std::chrono::seconds(timeout); + query->timeout = timeout; return QDMI_SUCCESS; } diff --git a/examples/driver/qdmi_example_driver.cpp b/examples/driver/qdmi_example_driver.cpp index 6bb5faa7..45a4dd26 100644 --- a/examples/driver/qdmi_example_driver.cpp +++ b/examples/driver/qdmi_example_driver.cpp @@ -254,7 +254,7 @@ void QDMI_library_load(const std::string &lib_name, const std::string &prefix) { LOAD_SYMBOL(library, prefix, device_session_query_site_property) LOAD_SYMBOL(library, prefix, device_session_query_operation_property) LOAD_SYMBOL(library, prefix, device_session_query_telemetrysensor_property) - // device environment interface + // device telemetry sensor interface LOAD_SYMBOL(library, prefix, device_session_create_device_telemetrysensor_query) LOAD_SYMBOL(library, prefix, device_telemetrysensor_query_set_parameter) @@ -589,8 +589,9 @@ int QDMI_device_query_telemetrysensor_property( } int QDMI_device_create_telemetrysensor_query( - QDMI_Device dev, QDMI_TelemetrySensor_Query *query) { - if (dev == nullptr || query == nullptr) { + QDMI_Device dev, QDMI_TelemetrySensor *telemetry_sensor, + QDMI_TelemetrySensor_Query *query) { + if (dev == nullptr || query == nullptr || telemetry_sensor == nullptr) { return QDMI_ERROR_INVALIDARGUMENT; } @@ -600,8 +601,15 @@ int QDMI_device_create_telemetrysensor_query( *query = new QDMI_TelemetrySensor_Query_impl_d(); (*query)->device = dev; - return dev->library->device_session_create_device_telemetrysensor_query( + int err = dev->library->device_session_create_device_telemetrysensor_query( dev->device_session, &(*query)->env_query); + if (err != QDMI_SUCCESS) { + return err; + } + + return QDMI_telemetrysensor_query_set_parameter( + *query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRY, + sizeof(QDMI_TelemetrySensor), static_cast(telemetry_sensor)); } int QDMI_telemetrysensor_query_set_parameter( diff --git a/include/qdmi/client.h b/include/qdmi/client.h index 74ec15b5..32abadce 100644 --- a/include/qdmi/client.h +++ b/include/qdmi/client.h @@ -610,7 +610,7 @@ int QDMI_device_query_operation_property( * returned in @p size_ret if @p size_ret is not @c NULL. * * @note For example, to query the unit of a telemetry sensor, the following - code pattern + * code pattern * can be used: * ``` * // Check if the device supports the property. @@ -626,7 +626,7 @@ int QDMI_device_query_operation_property( * size_t telemetrysensor_unit_size = 0; * auto ret = QDMI_device_query_telemetrysensor_property( * device, telemetry_sensor, QDMI_TELEMETRYSENSOR_PROPERTY_UNIT, 0, - nullptr, + * nullptr, * &telemetrysensor_unit_size); * if (ret != QDMI_SUCCESS) { * // An error occurred. @@ -641,7 +641,7 @@ int QDMI_device_query_operation_property( * * @remark @ref QDMI_TelemetrySensor handles may be queried via @ref * QDMI_device_query_device_property with @ref - QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS. + * QDMI_DEVICE_PROPERTY_TELEMETRYSENSORS. */ int QDMI_device_query_telemetrysensor_property( QDMI_Device device, QDMI_TelemetrySensor telemetry_sensor, @@ -1102,11 +1102,14 @@ typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; * sensor query. * @param[in] device The device to create the telemetry sensor query on. Must * not be @c NULL. + * @param[in] telemetry_sensor The telemetry sensor to query data from. Must + * not be @c NULL. * @param[out] query A pointer to a handle that will store the created * telemetry sensor query. Must not be @c NULL. The query must be freed by * calling @ref QDMI_telemetrysensor_query_free when it is no longer used. * @return @ref QDMI_SUCCESS if the query was successfully created. - * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device or @p query are @c NULL. + * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p device, @p telemetry_sensor or + * @p query are @c NULL. * @return @ref QDMI_ERROR_PERMISSIONDENIED if the driver does not allow using * the @ref client_telemetrysensor_query_interface * "client telemetry sensor query interface" for the device in the current @@ -1114,8 +1117,9 @@ typedef struct QDMI_TelemetrySensor_Query_impl_d *QDMI_TelemetrySensor_Query; * @return @ref QDMI_ERROR_FATAL if the telemetry sensor query creation failed * due to a fatal error. */ -int QDMI_device_create_telemetrysensor_query(QDMI_Device device, - QDMI_TelemetrySensor_Query *query); +int QDMI_device_create_telemetrysensor_query( + QDMI_Device device, QDMI_TelemetrySensor *telemetry_sensor, + QDMI_TelemetrySensor_Query *query); /** * @brief Enum of the telemetry sensor query parameters that can be set. @@ -1124,17 +1128,38 @@ int QDMI_device_create_telemetrysensor_query(QDMI_Device device, */ enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T { - - /// The start time of the telemetry query interval. + /** + * @brief `time_t` The start time of the telemetry query interval. + * @details This parameter is required. It specifies the start time of the + * telemetry query interval as a UNIX timestamp. If the value is invalid, the + * @ref QDMI_telemetrysensor_query_set_parameter function must return @ref + * QDMI_ERROR_INVALIDARGUMENT. + */ QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME = 0, - - /// The end time of the telemetry query interval. + /** + * @brief `time_t` The end time of the telemetry query interval. + * @details This parameter is required. It specifies the end time of the + * telemetry query interval as a UNIX timestamp. If the value is invalid, the + * @ref QDMI_telemetrysensor_query_set_parameter function must return @ref + * QDMI_ERROR_INVALIDARGUMENT. + */ QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME = 1, - - /// The telemetry for the telemetry query. + /** + * @brief `QDMI_TelemetrySensor` The telemetry sensor to query data from. + * @details This parameter is required. It specifies the telemetry sensor to + * query data from. If the value is invalid, the @ref + * QDMI_telemetrysensor_query_set_parameter function must return @ref + * QDMI_ERROR_INVALIDARGUMENT. end time of the telemetry query interval. + */ QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRY = 2, - /// The maximum value of the enum. + /** + * @brief The maximum value of the enum. + * @details It can be used by drivers for bounds checking and validation of + * function parameters. + * @attention This value must remain the last regular member of the enum + * besides the custom members and must be updated when new members are added. + */ QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_MAX = 3, /** @@ -1210,9 +1235,9 @@ typedef enum QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_T * } * * // Set the start time. - * uint64_t start_ts = 1744970400; + * time_t start_ts = 1744970400; * QDMI_telemetrysensor_query_set_parameter( - * query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_START_TIME, sizeof(uint64_t), + * query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_START_TIME, sizeof(time_t), * &start_ts); * ``` */ @@ -1293,7 +1318,8 @@ int QDMI_telemetrysensor_query_check_status( * @param[in] query The telemetry sensor query to wait for. Must not be @c * NULL. * @param[in] timeout The timeout in seconds. - * If this is zero, the function waits indefinitely until the job has finished. + * If this is zero, the function waits indefinitely until the telemetry sensor + * query has finished. * @return @ref QDMI_SUCCESS if the telemetry sensor query is finished or * canceled. * @return @ref QDMI_ERROR_INVALIDARGUMENT if @p query is @c NULL. diff --git a/test/test_qdmi.cpp b/test/test_qdmi.cpp index 766fef39..b0105e76 100644 --- a/test/test_qdmi.cpp +++ b/test/test_qdmi.cpp @@ -22,10 +22,10 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "utils/test_impl.hpp" #include -#include #include #include #include +#include #include #include #include @@ -1163,27 +1163,21 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { QDMI_TelemetrySensor_Query_Status status = QDMI_TELEMETRYSENSOR_QUERY_STATUS_CREATED; - auto start_time = std::chrono::system_clock::now(); + time_t start_timestamp = time(nullptr); + time_t end_timestamp = time(nullptr) + 600; // 10 minutes later - auto end_time = start_time + std::chrono::minutes(10); - - EXPECT_EQ(QDMI_device_create_telemetrysensor_query(device, &query), - QDMI_SUCCESS); - - EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( - query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_TELEMETRY, - sizeof(QDMI_TelemetrySensor), - static_cast(&telemetry_sensor)), + EXPECT_EQ(QDMI_device_create_telemetrysensor_query( + device, &telemetry_sensor, &query), QDMI_SUCCESS); EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_STARTTIME, - sizeof(decltype(start_time)), &start_time), + sizeof(time_t), &start_timestamp), QDMI_SUCCESS); EXPECT_EQ(QDMI_telemetrysensor_query_set_parameter( query, QDMI_TELEMETRYSENSOR_QUERY_PARAMETER_ENDTIME, - sizeof(decltype(end_time)), &end_time), + sizeof(time_t), &end_timestamp), QDMI_SUCCESS); EXPECT_EQ(QDMI_telemetrysensor_query_submit(query), QDMI_SUCCESS); @@ -1201,9 +1195,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { nullptr, ×tamps_size), QDMI_SUCCESS); - std::vector> timestamps{ - timestamps_size / - sizeof(std::chrono::time_point)}; + size_t timestamp_length = timestamps_size / sizeof(time_t); + std::vector timestamps(timestamp_length); EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_TIMESTAMPS, @@ -1217,8 +1210,8 @@ TEST_P(QDMIImplementationTest, TelemetryQuery) { &size_values), QDMI_SUCCESS); - std::vector values; - values.reserve(size_values / sizeof(double)); + size_t values_length = timestamps_size / sizeof(time_t); + std::vector values(values_length); EXPECT_EQ(QDMI_telemetrysensor_query_get_results( query, QDMI_TELEMETRYSENSOR_QUERY_RESULT_VALUES, size_values, From 72cf9eb1371b8cda5d58a3625c67887008b88b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erc=C3=BCment=20Kaya?= Date: Wed, 1 Oct 2025 18:23:04 +0200 Subject: [PATCH 61/61] =?UTF-8?q?=F0=9F=8E=A8=20=20minor=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/device/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/device/device.cpp b/examples/device/device.cpp index 584d3c1c..6ede7781 100644 --- a/examples/device/device.cpp +++ b/examples/device/device.cpp @@ -90,7 +90,7 @@ struct CXX_QDMI_TelemetrySensor_impl_d { struct CXX_QDMI_Device_TelemetrySensor_Query_impl_d { std::unique_ptr start_time = nullptr; std::unique_ptr end_time = nullptr; - size_t timeout{}; + size_t timeout = 0; CXX_QDMI_TelemetrySensor telemetry_sensor = nullptr; std::vector result_timestamps; std::vector result_values;