Runtime and scheduling
Core interfaces
The SDK root owns the lifecycle of all configured capabilities. Use glove() to access the Glove domain. Constructor parameters are in Configuration reference.
Sdk::glove()
Enter the glove capability.
Type
Glove Sdk::glove() const;Returns
Details
- Call conditions: SDK not closed.
Errors
ClosedHandleError, capability unavailable.
Sdk::start()
Start devices and capabilities in this object’s scope.
Type
void Sdk::start() const;Returns
void.
Details
- Call conditions: After preparing to read data.
Errors
- Connection, identity, data stream, or lifecycle errors.
See also
Sdk::update()
Perform one SDK scheduling pass and return its update result.
Type
UpdateResult Sdk::update() const;Returns
Details
- Call conditions: Started and no other run mode in use.
- Call
sleep()on each result only once; see Runtime for run modes and wait semantics.
Errors
LifecycleError.
Example
sdk is an SDK with its devices and targets already configured. Call sleep() once per update result, and do not start a background runner at the same time.
sdk.start();
for (int i = 0; i < 100; ++i) {
const auto update = sdk.update();
if (update.sleep() == qnbot::SleepResult::no_tasks) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
sdk.close();Complete example: manual_runtime.cpp.
See also
Sdk::run_forever()
Advance SDK scheduling on the current thread until stopped.
Type
void Sdk::run_forever() const;Returns
void.
Details
- Call conditions: Started and no other run mode in use.
- Blocks the current thread; do not mix with background execution or manual
update().
Errors
LifecycleError.
Example
sdk is an SDK with its devices and targets already configured. This call occupies the current thread. See the complete example for shutdown handling.
sdk.start();
sdk.run_forever();
sdk.close();Complete example: foreground_runtime.cpp.
See also
Sdk::run_background()
Start background scheduling so the current thread can continue.
Type
void Sdk::run_background() const;Returns
void.
Details
- Call conditions: Started and no other run mode in use.
- Mutually exclusive with
run_forever()and manualupdate(). Request stop and calljoin()to finish.
Errors
LifecycleError, background runtime errors.
Example
sdk is an SDK with its devices and targets already configured. The application thread remains available. Request shutdown, join the thread, and then close the scope.
sdk.start();
sdk.run_background();
std::this_thread::sleep_for(std::chrono::seconds(1));
sdk.request_stop();
sdk.join();
sdk.close();Complete example: background_runtime.cpp.
See also
Sdk::request_stop()
Request that the current run loop stop.
Type
void Sdk::request_stop() const;Returns
void.
Errors
LifecycleError, background errors.
See also
Sdk::join()
Wait for the background thread and report background runtime errors.
Type
void Sdk::join() const;Returns
void.
Details
- Call
request_stop()first. This method reports background errors; do not omit the wait.
Errors
LifecycleError, background errors.
See also
Sdk::stop()
Stop the current scope and disconnect its devices.
Type
void Sdk::stop() const;Returns
void.
Details
- The scope can be started again; stopping a device cancels active calibration.
Errors
- Errors during stopping.
See also
Sdk::close()
Close the current scope and release its resources.
Type
void Sdk::close();Returns
void.
Errors
- Errors during closing; the object is invalid after closing.
See also
Sdk::health()
Read the health summary for the current scope.
Type
Health Sdk::health() const;Returns
Details
- Call conditions: SDK not closed.
Errors
ClosedHandleError.