Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
0887df6
✨ Initial QDMI Environment impl
kayaercument Mar 24, 2025
302c416
🎨 pre-commit fixes
pre-commit-ci[bot] Mar 24, 2025
3aab49e
🎨 renaming definitions for qdmi environment
kayaercument Apr 4, 2025
52bd8d7
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 4, 2025
49cc0bf
🚚 rename environment to environmentvariable
kayaercument Apr 8, 2025
3ba8a92
✨ Implemention of QDMI Enviroment functions in example C device
kayaercument Apr 8, 2025
6f658f6
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 8, 2025
25abdd4
✏️ fix typo
kayaercument Apr 8, 2025
98971ba
✨ additional functions and their implementations in example c device
kayaercument Apr 9, 2025
98a8659
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 9, 2025
c2b2935
✨ additional definations in the client interface
kayaercument Apr 9, 2025
f88b60c
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 9, 2025
c1591fe
✨ Implemention of QDMI Enviroment functions in example CXX device
kayaercument Apr 9, 2025
4e7b8f8
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 9, 2025
bd849ae
✨ implementation of qdmi environment function in example driver, foma…
kayaercument Apr 9, 2025
3858563
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 9, 2025
3929d0a
🎨 minor changes
kayaercument Apr 9, 2025
16afe77
🎨 pre-commit fixes
pre-commit-ci[bot] Apr 9, 2025
9bbc775
Merge branch 'develop' into 152-env-prop
burgholzer May 2, 2025
7b3e8df
✏️ initial documentation for qdmi_environment
kayaercument May 9, 2025
ba5a676
🎨 pre-commit fixes
pre-commit-ci[bot] May 9, 2025
e67355f
✏️ updates on documentation
kayaercument May 19, 2025
67312db
Merge branch 'Munich-Quantum-Software-Stack:develop' into 152-env-prop
kayaercument Jun 5, 2025
94e4b25
✏️ Better naming
kayaercument Jun 13, 2025
20a2841
🎨 pre-commit fixes
pre-commit-ci[bot] Jun 13, 2025
e239964
🎨 timeout parameter for environmentsensor_query_wait functions
kayaercument Jun 16, 2025
7474cbe
🎨 consisting parameter naming
kayaercument Jun 16, 2025
83a6b18
Merge branch 'develop' into 152-env-prop
kayaercument Jun 16, 2025
c71b2c3
🚨 fix linter warnings
kayaercument Jun 16, 2025
d0db550
🚨 Fixing linter warnings
kayaercument Jun 16, 2025
0e9bcb2
🎨 pre-commit fixes
pre-commit-ci[bot] Jun 16, 2025
d2218d5
🚨 linter fix
kayaercument Jun 16, 2025
889b27c
🚨 lint fix
kayaercument Jun 16, 2025
a83cbf4
🎨 pre-commit fixes
pre-commit-ci[bot] Jun 16, 2025
709ac33
Merge branch 'develop' into 152-env-prop
kayaercument Jun 17, 2025
4572c14
Merge remote-tracking branch 'upstream/develop' into 152-env-prop
Jul 31, 2025
123d2e6
🩹 minor fix
Jul 31, 2025
f562d03
Apply suggestions from code review
kayaercument Aug 1, 2025
64ea415
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 1, 2025
6df7dee
📝 improvements on the documentation
kayaercument Aug 4, 2025
e3e6694
🎨 renaming QDMI_Environment to QDMI_Telemetry
kayaercument Aug 5, 2025
04a8218
Merge branch 'develop' into 152-env-prop
kayaercument Aug 5, 2025
0bda557
🎨 minor change in example
kayaercument Aug 5, 2025
56ba00d
✏️ fix minor typos
kayaercument Aug 5, 2025
aff6f1e
📝 minor documentation extension
kayaercument Aug 5, 2025
10710d0
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 5, 2025
e305c46
Apply suggestions from code review
kayaercument Aug 13, 2025
9f38ad9
🎨 improvements based on the suggestions
kayaercument Aug 14, 2025
248a112
Merge remote-tracking branch 'upstream/develop' into 152-env-prop
kayaercument Aug 14, 2025
aba1df1
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 14, 2025
80cd577
🚨 lint fix
kayaercument Aug 14, 2025
ab49391
Merge branch 'develop' into 152-env-prop
kayaercument Aug 18, 2025
3234155
Merge branch 'develop' into 152-env-prop
burgholzer Aug 29, 2025
2f2e03e
Merge branch 'develop' into 152-env-prop
burgholzer Aug 29, 2025
4ef85b5
⚗️ try with codecov token
burgholzer Aug 29, 2025
0202474
Merge branch 'develop' into 152-env-prop
burgholzer Aug 29, 2025
34718bc
🎨 minor refactor
kayaercument Sep 3, 2025
5a121c5
💚 codecov fix attempt using oidc
kayaercument Sep 17, 2025
f8eb819
💚 codecov fix attempt usind oidc
kayaercument Sep 17, 2025
d2f3321
Merge branch 'develop' into 152-env-prop
kayaercument Sep 17, 2025
8c747b3
Merge branch 'develop' into 152-env-prop
burgholzer Sep 17, 2025
3a3576d
🎨 Clean-up example implementation
ystade Sep 26, 2025
35dc853
🎨 Minor improvements in example driver
ystade Sep 26, 2025
c7ffdc3
⏪ revert codecov fix attempt
kayaercument Sep 30, 2025
e3467e6
✏️ fix typos in the documents
kayaercument Sep 30, 2025
b4c416d
📝 additional documentations
kayaercument Sep 30, 2025
d61e4e7
🚨 fix lint warning
kayaercument Sep 30, 2025
abe1b30
✏️ fix typos
kayaercument Sep 30, 2025
891abf3
✏️ corrects weird line breaks
kayaercument Sep 30, 2025
abbbbd5
🎨 improve consistent usage
kayaercument Sep 30, 2025
c7432aa
Apply suggestions from code review
kayaercument Sep 30, 2025
ecc8fcd
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 30, 2025
b88ff2f
🎨 use ctime instead of chrono
kayaercument Oct 1, 2025
72cf9eb
🎨 minor change
kayaercument Oct 1, 2025
ddd73a1
Merge branch 'develop' into 152-env-prop
burgholzer Oct 8, 2025
80628dd
Merge branch 'develop' into 152-env-prop
burgholzer Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmake/prefix_defs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,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
224 changes: 224 additions & 0 deletions examples/device/c/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

enum C_QDMI_DEVICE_SESSION_STATUS { ALLOCATED, INITIALIZED };

Expand Down Expand Up @@ -57,6 +58,22 @@ typedef struct C_QDMI_Operation_impl_d {
char *name;
} C_QDMI_Operation_impl_t;

typedef struct C_QDMI_Environment_impl_d {
char *id;
char *unit;
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 environment;
time_t *result_timestamps;
float *result_values;
size_t result_length;
QDMI_Environment_Query_Status status;
} C_QDMI_Device_Environment_Query_impl_t;

/**
* @brief Static function to maintain the device status.
* @return a pointer to the device status.
Expand Down Expand Up @@ -87,6 +104,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 C_DEVICE_ENVIRONMENTS[] = {
&(C_QDMI_Environment_impl_t){"t4k", "K", 60},
};

const C_QDMI_Site C_DEVICE_SITES[] = {
&(C_QDMI_Site_impl_t){0}, &(C_QDMI_Site_impl_t){1},
Expand Down Expand Up @@ -696,6 +716,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)

return QDMI_ERROR_NOTSUPPORTED;
} /// [DOXYGEN FUNCTION END]
Expand Down Expand Up @@ -814,3 +837,204 @@ 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)->environment = 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->environment = *(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->environment == NULL) {
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
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(float) * 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;
}

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);
}
Loading
Loading