// Generated by tools/generate_bindings.py -- do not edit by hand.
// Mechanical output: lint findings here are the generator's business.
#![allow(clippy::all, unused_imports, rustdoc::bare_urls)]
use crate::error::{check, Error, Result};
use crate::object::{BaseObject, Interface, Ref};
use crate::sys;
use crate::value::{Complex, Ratio, Value};
use crate::generated::*;
use std::ffi::c_char;
/// Config provider is an interface that was made for populating an options dictionary of an instance builder from external sources like a config file, environment variables, or command line arguments. The process of population of the dictionary have to be alligned with rules: - all keys are set in lowercase. Values are set without case changes. - if a provider is trying to override an existing value, it has to have the same type. For example provider can not replace integer value with string or object with list - if a provider is overriding a list, it replaces old list items with a new one.
/// Wrapper over the openDAQ `daqConfigProvider` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ConfigProvider(pub(crate) BaseObject);
impl std::ops::Deref for ConfigProvider {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ConfigProvider {}
unsafe impl Interface for ConfigProvider {
const NAME: &'static str = "daqConfigProvider";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqConfigProvider_getInterfaceId)(&mut id) };
Some(id)
}
unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
Ref::from_owned(ptr).map(Self::__from_ref)
}
fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl ConfigProvider {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ConfigProvider(BaseObject(r)) }
}
impl std::fmt::Display for ConfigProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ConfigProvider> for Value {
fn from(value: &ConfigProvider) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ConfigProvider> for Value {
fn from(value: ConfigProvider) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ConfigProvider {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// The top-level openDAQ object. It acts as container for the openDAQ context and the base module manager.
/// It forwards all Device and PropertyObject calls to the current root device, making the calls on the Instance
/// and root device equivalent.
/// On creation, it creates a Client device - a default device implementation that can load any function blocks
/// present in the module manager search path. If the native openDAQ client-module is loaded, the Client device
/// can connect to any TMS enabled device by using the `addDevice` function. The Client is set as the root device
/// when the instance is created.
/// Wrapper over the openDAQ `daqInstance` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Instance(pub(crate) Device);
impl std::ops::Deref for Instance {
type Target = Device;
fn deref(&self) -> &Device { &self.0 }
}
impl crate::sealed::Sealed for Instance {}
unsafe impl Interface for Instance {
const NAME: &'static str = "daqInstance";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqInstance_getInterfaceId)(&mut id) };
Some(id)
}
unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
Ref::from_owned(ptr).map(Self::__from_ref)
}
fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl Instance {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Instance(Device::__from_ref(r)) }
}
impl std::fmt::Display for Instance {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Instance> for Value {
fn from(value: &Instance) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Instance> for Value {
fn from(value: Instance) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Instance {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Builder component of Instance objects. Contains setter methods to configure the Instance parameters, such as Context (Logger, Scheduler, ModuleManager) and RootDevice. Contains a `build` method that builds the Instance object.
/// The InstanceBuilder provides a fluent interface for setting various configuration options for an Instance
/// object before its creation. It allows customization of the logger, module manager, scheduler and root device.
/// Once configured, calling the `build` method returns a fully initialized Instance object with the specified settings.
/// @subsection Configuration Methods:
/// The InstanceBuilder provides the following configuration methods:
/// - **Logger:** The custom Logger for the Instance. This logger will be used for logging messages related to the Instance and its components.
/// If a custom logger is set, the `Logger sink` will be ignored since it is only used with the default Instance logger.
/// If custom logger was not set, builder will generate Instance with default logger.
/// - **Global log level:** The Logger global log level for the Instance. All log messages with a severity
/// level equal to or higher than the specified level will be processed. Default log level is LogLevel::Default
/// - **Component log level:** The Logger level for a specific component of the Instance. Log messages related to
/// that component will be processed according to the specified log level. By default, each component uses the global log level.
/// - **Logger sink:** The logger sink to the default Instance logger. This sink will be responsible for processing log messages,
/// such as writing them to a file or sending them to a remote server. If `Logger` has been set, configuring of the 'Logger sink' has no effect in building Instance.
/// If logger sinks has not been configure, the Instance uses 'default sinks'.
/// - **Module manager:** The custom ModuleManager for the Instance. When configured, the default module manager path will be ignored.
/// If module manager has not configured, the Instance uses built in manager
/// - **Module path:** The path for the default ModuleManager of the Instance. If a custom module manager has not been set,
/// this path will be used to load modules. Default module path is empty string
/// - **Scheduler:** The custom scheduler for the Instance. If set, the number of worker threads will be ignored.
/// If scheduler has not been configured, the Instance uses default schduler.
/// - **Scheduler worker num:** The number of worker threads in the scheduler of the Instance. if a scheduler has not been set and worker num is 0,
/// which considers as maximum number of concurrent threads.
/// - **Default root device local ID:** The local id of the default client root device. Has no effect if `Root device` has been congigured.
/// - **Default root device info:** The information of default root device of the Instance such as serial number. Has no effect if `Root device` has been congigured.
/// - **Root device:** The connection string of a device that replaces the default openDAQ root device (virtual client).
/// When the instance is created a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure.
/// When configured, the `Default root device local ID` and `Default root device info` will be ignored.
/// - **Sink log level:** The sink logger level of the default Instance logger. This level is ignored if a custom logger has been configured.
/// - **Config provider:** The config provider is expanding the local options of instance builder from json file or command lines.
/// If value was set before, provider will override this with new one.
/// - **Module options:** Local options dictionary of instance builder has `modules` key which contains custom values for modules.
/// By default this dictionary is empty, but can be populated from json file, env variables or command line arguments.
/// Wrapper over the openDAQ `daqInstanceBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct InstanceBuilder(pub(crate) BaseObject);
impl std::ops::Deref for InstanceBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for InstanceBuilder {}
unsafe impl Interface for InstanceBuilder {
const NAME: &'static str = "daqInstanceBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqInstanceBuilder_getInterfaceId)(&mut id) };
Some(id)
}
unsafe fn from_raw(ptr: *mut std::ffi::c_void) -> Option<Self> {
Ref::from_owned(ptr).map(Self::__from_ref)
}
fn as_base_object(&self) -> &BaseObject { &self.0 }
}
impl InstanceBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { InstanceBuilder(BaseObject(r)) }
}
impl std::fmt::Display for InstanceBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&InstanceBuilder> for Value {
fn from(value: &InstanceBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<InstanceBuilder> for Value {
fn from(value: InstanceBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for InstanceBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
impl ConfigProvider {
/// Calls the openDAQ C function `daqConfigProvider_createCmdLineArgsConfigProvider()`.
pub fn cmd_line_args(cmd_line_args: impl Into<Value>) -> Result<ConfigProvider> {
let __cmd_line_args = crate::value::to_daq(&cmd_line_args.into())?;
let mut __obj: *mut sys::daqConfigProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConfigProvider_createCmdLineArgsConfigProvider)(&mut __obj, crate::value::opt_ref_ptr(&__cmd_line_args) as *mut _) };
check(__code, "daqConfigProvider_createCmdLineArgsConfigProvider")?;
Ok(unsafe { crate::marshal::require_object::<ConfigProvider>(__obj as *mut _, "daqConfigProvider_createCmdLineArgsConfigProvider") }?)
}
/// Calls the openDAQ C function `daqConfigProvider_createEnvConfigProvider()`.
pub fn env() -> Result<ConfigProvider> {
let mut __obj: *mut sys::daqConfigProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConfigProvider_createEnvConfigProvider)(&mut __obj) };
check(__code, "daqConfigProvider_createEnvConfigProvider")?;
Ok(unsafe { crate::marshal::require_object::<ConfigProvider>(__obj as *mut _, "daqConfigProvider_createEnvConfigProvider") }?)
}
/// Calls the openDAQ C function `daqConfigProvider_createJsonConfigProvider()`.
pub fn json(filename: &str) -> Result<ConfigProvider> {
let __filename = crate::marshal::make_string(filename)?;
let mut __obj: *mut sys::daqConfigProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConfigProvider_createJsonConfigProvider)(&mut __obj, __filename.as_ptr() as *mut _) };
check(__code, "daqConfigProvider_createJsonConfigProvider")?;
Ok(unsafe { crate::marshal::require_object::<ConfigProvider>(__obj as *mut _, "daqConfigProvider_createJsonConfigProvider") }?)
}
/// Populate the existing options dictionary with variables from config provider
/// @param options The options dictionary
/// Calls the openDAQ C function `daqConfigProvider_populateOptions()`.
pub fn populate_options(&self, options: impl Into<Value>) -> Result<()> {
let __options = crate::value::to_daq(&options.into())?;
let __code = unsafe { (crate::sys::api().daqConfigProvider_populateOptions)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__options) as *mut _) };
check(__code, "daqConfigProvider_populateOptions")?;
Ok(())
}
}
impl InstanceBuilder {
/// Populates internal options dictionary with values from set config provider
/// @param configProvider The configuration provider
/// Calls the openDAQ C function `daqInstanceBuilder_addConfigProvider()`.
pub fn add_config_provider(&self, config_provider: &ConfigProvider) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_addConfigProvider)(self.as_raw() as *mut _, config_provider.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_addConfigProvider")?;
Ok(())
}
/// Adds a discovery server to the context
/// @param serverName The discovery server to add
/// openDAQ supports the "mdns" server by default, but must be added to the instance builder to be enabled.
/// Calls the openDAQ C function `daqInstanceBuilder_addDiscoveryServer()`.
pub fn add_discovery_server(&self, server_name: &str) -> Result<()> {
let __server_name = crate::marshal::make_string(server_name)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_addDiscoveryServer)(self.as_raw() as *mut _, __server_name.as_ptr() as *mut _) };
check(__code, "daqInstanceBuilder_addDiscoveryServer")?;
Ok(())
}
/// Adds the logger sink of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance.
/// @param sink The logger sink of the default Instance logger
/// Calls the openDAQ C function `daqInstanceBuilder_addLoggerSink()`.
pub fn add_logger_sink(&self, sink: &LoggerSink) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_addLoggerSink)(self.as_raw() as *mut _, sink.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_addLoggerSink")?;
Ok(())
}
/// Add the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.
/// @param path The path for the default ModuleManager of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_addModulePath()`.
pub fn add_module_path(&self, path: &str) -> Result<()> {
let __path = crate::marshal::make_string(path)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_addModulePath)(self.as_raw() as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqInstanceBuilder_addModulePath")?;
Ok(())
}
/// Builds and returns an Instance object using the currently set values of the Builder.
/// @param\[out\] instance The built Instance.
/// Calls the openDAQ C function `daqInstanceBuilder_build()`.
pub fn build(&self) -> Result<Option<Instance>> {
let mut __instance: *mut sys::daqInstance = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_build)(self.as_raw() as *mut _, &mut __instance) };
check(__code, "daqInstanceBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Instance>(__instance as *mut _) })
}
/// Creates a InstanceBuilder with no parameters configured.
/// Calls the openDAQ C function `daqInstanceBuilder_createInstanceBuilder()`.
pub fn new() -> Result<InstanceBuilder> {
let mut __obj: *mut sys::daqInstanceBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_createInstanceBuilder)(&mut __obj) };
check(__code, "daqInstanceBuilder_createInstanceBuilder")?;
Ok(unsafe { crate::marshal::require_object::<InstanceBuilder>(__obj as *mut _, "daqInstanceBuilder_createInstanceBuilder") }?)
}
/// Allows enabling or disabling standard configuration providers, including JsonConfigProvider, based on the specified flag.
/// @param flag Boolean flag indicating whether to enable (true) or disable (false) standard config providers.
/// Calls the openDAQ C function `daqInstanceBuilder_enableStandardProviders()`.
pub fn enable_standard_providers(&self, flag: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_enableStandardProviders)(self.as_raw() as *mut _, u8::from(flag)) };
check(__code, "daqInstanceBuilder_enableStandardProviders")?;
Ok(())
}
/// Gets the AuthenticationProvider of Instance
/// @param\[out\] authenticationProvider The AuthenticationProvider of Instance.
/// Calls the openDAQ C function `daqInstanceBuilder_getAuthenticationProvider()`.
pub fn authentication_provider(&self) -> Result<Option<AuthenticationProvider>> {
let mut __authentication_provider: *mut sys::daqAuthenticationProvider = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getAuthenticationProvider)(self.as_raw() as *mut _, &mut __authentication_provider) };
check(__code, "daqInstanceBuilder_getAuthenticationProvider")?;
Ok(unsafe { crate::marshal::take_object::<AuthenticationProvider>(__authentication_provider as *mut _) })
}
/// Gets the dictionary of component names and log level which will be added to logger components
/// @param\[out\] components The dictionary of component names and log level
/// Calls the openDAQ C function `daqInstanceBuilder_getComponentsLogLevel()`.
pub fn components_log_level(&self) -> Result<std::collections::HashMap<String, NumberObject>> {
let mut __components: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getComponentsLogLevel)(self.as_raw() as *mut _, &mut __components) };
check(__code, "daqInstanceBuilder_getComponentsLogLevel")?;
Ok(unsafe { crate::marshal::take_dict::<String, NumberObject>(__components as *mut _, "daqInstanceBuilder_getComponentsLogLevel") }?)
}
/// Returns a context object of the instance.
/// @param\[out\] context The Context object of the instance.
/// Calls the openDAQ C function `daqInstanceBuilder_getContext()`.
pub fn context(&self) -> Result<Option<Context>> {
let mut __context: *mut sys::daqContext = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getContext)(self.as_raw() as *mut _, &mut __context) };
check(__code, "daqInstanceBuilder_getContext")?;
Ok(unsafe { crate::marshal::take_object::<Context>(__context as *mut _) })
}
/// Gets the default device info of Instance
/// @param deviceInfo The default device info of Instance. Returns nullptr, if default device info has not been set.
/// Calls the openDAQ C function `daqInstanceBuilder_getDefaultRootDeviceInfo()`.
pub fn default_root_device_info(&self) -> Result<Option<DeviceInfo>> {
let mut __device_info: *mut sys::daqDeviceInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getDefaultRootDeviceInfo)(self.as_raw() as *mut _, &mut __device_info) };
check(__code, "daqInstanceBuilder_getDefaultRootDeviceInfo")?;
Ok(unsafe { crate::marshal::take_object::<DeviceInfo>(__device_info as *mut _) })
}
/// Gets the default root device local id
/// @param\[out\] localId The default root device local id. Returns empty string id default root device local is has not been set.
/// Calls the openDAQ C function `daqInstanceBuilder_getDefaultRootDeviceLocalId()`.
pub fn default_root_device_local_id(&self) -> Result<String> {
let mut __local_id: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getDefaultRootDeviceLocalId)(self.as_raw() as *mut _, &mut __local_id) };
check(__code, "daqInstanceBuilder_getDefaultRootDeviceLocalId")?;
Ok(unsafe { crate::marshal::take_string(__local_id) })
}
/// Gets the dictionary of discovery servers
/// @param\[out\] serverNames The dictionary of discovery server names
/// Calls the openDAQ C function `daqInstanceBuilder_getDiscoveryServers()`.
pub fn discovery_servers(&self) -> Result<Vec<String>> {
let mut __server_names: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getDiscoveryServers)(self.as_raw() as *mut _, &mut __server_names) };
check(__code, "daqInstanceBuilder_getDiscoveryServers")?;
Ok(unsafe { crate::marshal::take_list::<String>(__server_names as *mut _, "daqInstanceBuilder_getDiscoveryServers") }?)
}
/// Gets the default Logger global level of Instance
/// @param\[out\] logLevel The Logger global level of Instance. Returns LogLevel::Default, If global log level has not been set
/// Calls the openDAQ C function `daqInstanceBuilder_getGlobalLogLevel()`.
pub fn global_log_level(&self) -> Result<LogLevel> {
let mut __log_level: u32 = 0;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getGlobalLogLevel)(self.as_raw() as *mut _, &mut __log_level) };
check(__code, "daqInstanceBuilder_getGlobalLogLevel")?;
Ok(crate::marshal::enum_out(LogLevel::from_raw(__log_level), "daqInstanceBuilder_getGlobalLogLevel")?)
}
/// Calls the openDAQ C function `daqInstanceBuilder_getLoadAuthenticatedModulesOnly()`.
pub fn load_authenticated_modules_only(&self) -> Result<bool> {
let mut __auth_only: u8 = 0;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getLoadAuthenticatedModulesOnly)(self.as_raw() as *mut _, &mut __auth_only) };
check(__code, "daqInstanceBuilder_getLoadAuthenticatedModulesOnly")?;
Ok(__auth_only != 0)
}
/// Gets the Logger of the Instance. Returns nullptr if custom logger has not been set
/// @param\[out\] logger The Logger of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_getLogger()`.
pub fn logger(&self) -> Result<Option<Logger>> {
let mut __logger: *mut sys::daqLogger = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getLogger)(self.as_raw() as *mut _, &mut __logger) };
check(__code, "daqInstanceBuilder_getLogger")?;
Ok(unsafe { crate::marshal::take_object::<Logger>(__logger as *mut _) })
}
/// Gets the list of logger sinks for the default Instance logger.
/// @param\[out\] sinks The list of logger sinks of the default Instance logger
/// Calls the openDAQ C function `daqInstanceBuilder_getLoggerSinks()`.
pub fn logger_sinks(&self) -> Result<Vec<LoggerSink>> {
let mut __sinks: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getLoggerSinks)(self.as_raw() as *mut _, &mut __sinks) };
check(__code, "daqInstanceBuilder_getLoggerSinks")?;
Ok(unsafe { crate::marshal::take_list::<LoggerSink>(__sinks as *mut _, "daqInstanceBuilder_getLoggerSinks") }?)
}
/// Gets the authenticator object.
/// @param\[out\] authenticator Verifier object. Will return nullptr if not set.
/// Calls the openDAQ C function `daqInstanceBuilder_getModuleAuthenticator()`.
pub fn module_authenticator(&self) -> Result<Option<ModuleAuthenticator>> {
let mut __authenticator: *mut sys::daqModuleAuthenticator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getModuleAuthenticator)(self.as_raw() as *mut _, &mut __authenticator) };
check(__code, "daqInstanceBuilder_getModuleAuthenticator")?;
Ok(unsafe { crate::marshal::take_object::<ModuleAuthenticator>(__authenticator as *mut _) })
}
/// Gets the custom ModuleManager of Instance
/// @param\[out\] moduleManager The ModuleManager of Instance. Returns nullptr, if custom ModuleManager has not been set
/// Calls the openDAQ C function `daqInstanceBuilder_getModuleManager()`.
pub fn module_manager(&self) -> Result<Option<ModuleManager>> {
let mut __module_manager: *mut sys::daqModuleManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getModuleManager)(self.as_raw() as *mut _, &mut __module_manager) };
check(__code, "daqInstanceBuilder_getModuleManager")?;
Ok(unsafe { crate::marshal::take_object::<ModuleManager>(__module_manager as *mut _) })
}
/// Gets the path for the default ModuleManager of Instance.
/// @param\[out\] path The path for the default ModuleManager of Instance. Returns empty string, If module path has not been set
/// Calls the openDAQ C function `daqInstanceBuilder_getModulePath()`.
pub fn module_path(&self) -> Result<String> {
let mut __path: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getModulePath)(self.as_raw() as *mut _, &mut __path) };
check(__code, "daqInstanceBuilder_getModulePath")?;
Ok(unsafe { crate::marshal::take_string(__path) })
}
/// Get the list of paths for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.
/// @param paths The paths for the default ModuleManager of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_getModulePathsList()`.
pub fn module_paths_list(&self) -> Result<Vec<String>> {
let mut __paths: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getModulePathsList)(self.as_raw() as *mut _, &mut __paths) };
check(__code, "daqInstanceBuilder_getModulePathsList")?;
Ok(unsafe { crate::marshal::take_list::<String>(__paths as *mut _, "daqInstanceBuilder_getModulePathsList") }?)
}
/// Gets the dictionary of instance options
/// @param\[out\] options The dictionary of instance options
/// Calls the openDAQ C function `daqInstanceBuilder_getOptions()`.
pub fn options(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __options: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getOptions)(self.as_raw() as *mut _, &mut __options) };
check(__code, "daqInstanceBuilder_getOptions")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__options as *mut _, "daqInstanceBuilder_getOptions") }?)
}
/// Gets the connection string for the default root device of Instance.
/// @param\[out\] connectionString The connection string for the root device of Instance. Returns nullptr, if root device connection string has not been set.
/// Calls the openDAQ C function `daqInstanceBuilder_getRootDevice()`.
pub fn root_device(&self) -> Result<String> {
let mut __connection_string: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getRootDevice)(self.as_raw() as *mut _, &mut __connection_string) };
check(__code, "daqInstanceBuilder_getRootDevice")?;
Ok(unsafe { crate::marshal::take_string(__connection_string) })
}
/// Gets the configuration property object for the default root device of Instance.
/// @param\[out\] config The configuraton property object for the root device of Instance. Returns nullptr, for the default configuration property object.
/// Calls the openDAQ C function `daqInstanceBuilder_getRootDeviceConfig()`.
pub fn root_device_config(&self) -> Result<Option<PropertyObject>> {
let mut __config: *mut sys::daqPropertyObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getRootDeviceConfig)(self.as_raw() as *mut _, &mut __config) };
check(__code, "daqInstanceBuilder_getRootDeviceConfig")?;
Ok(unsafe { crate::marshal::take_object::<PropertyObject>(__config as *mut _) })
}
/// Gets the custom scheduler of Instance
/// @param\[out\] scheduler The custom scheduler of Instance. Returns nullptr, if custom Scheduler has not been set.
/// Calls the openDAQ C function `daqInstanceBuilder_getScheduler()`.
pub fn scheduler(&self) -> Result<Option<Scheduler>> {
let mut __scheduler: *mut sys::daqScheduler = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getScheduler)(self.as_raw() as *mut _, &mut __scheduler) };
check(__code, "daqInstanceBuilder_getScheduler")?;
Ok(unsafe { crate::marshal::take_object::<Scheduler>(__scheduler as *mut _) })
}
/// Gets the amount of worker threads in the scheduler of Instance.
/// @param\[out\] numWorkers The amount of worker threads in the scheduler of Instance. Returns 0, if worker num has not been set
/// Calls the openDAQ C function `daqInstanceBuilder_getSchedulerWorkerNum()`.
pub fn scheduler_worker_num(&self) -> Result<usize> {
let mut __num_workers: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getSchedulerWorkerNum)(self.as_raw() as *mut _, &mut __num_workers) };
check(__code, "daqInstanceBuilder_getSchedulerWorkerNum")?;
Ok(__num_workers)
}
/// Checks whether the scheduler will be created with main loop support.
/// @param\[out\] useMainLoop True if the scheduler will be configured with main loop support; otherwise, false.
/// Calls the openDAQ C function `daqInstanceBuilder_getUsingSchedulerMainLoop()`.
pub fn using_scheduler_main_loop(&self) -> Result<bool> {
let mut __use_main_loop: u8 = 0;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_getUsingSchedulerMainLoop)(self.as_raw() as *mut _, &mut __use_main_loop) };
check(__code, "daqInstanceBuilder_getUsingSchedulerMainLoop")?;
Ok(__use_main_loop != 0)
}
/// Sets the AuthenticationProvider for the Instance.
/// @param authenticationProvider The AuthenticationProvider for the Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setAuthenticationProvider()`.
pub fn set_authentication_provider(&self, authentication_provider: &AuthenticationProvider) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setAuthenticationProvider)(self.as_raw() as *mut _, authentication_provider.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setAuthenticationProvider")?;
Ok(())
}
/// Sets The Logger level for a specific component of the Instance. Log messages related to that component will be processed according to the specified log level.
/// @param component The name of Instance component
/// @param logLevel The log level of Instance component
/// Calls the openDAQ C function `daqInstanceBuilder_setComponentLogLevel()`.
pub fn set_component_log_level(&self, component: &str, log_level: LogLevel) -> Result<()> {
let __component = crate::marshal::make_string(component)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setComponentLogLevel)(self.as_raw() as *mut _, __component.as_ptr() as *mut _, log_level as u32) };
check(__code, "daqInstanceBuilder_setComponentLogLevel")?;
Ok(())
}
/// Sets the Context object of the instance. This overwrites other context related settings such as logger, scheduler and module manager settings.
/// @param context The Context object for instance.
/// Calls the openDAQ C function `daqInstanceBuilder_setContext()`.
pub fn set_context(&self, context: &Context) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setContext)(self.as_raw() as *mut _, context.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setContext")?;
Ok(())
}
/// Sets the default device info of Instance. If device info has been set, method getInfo of Instance will return set device info if Root Device has not been set
/// @param deviceInfo The device info of the default device of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setDefaultRootDeviceInfo()`.
pub fn set_default_root_device_info(&self, device_info: &DeviceInfo) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setDefaultRootDeviceInfo)(self.as_raw() as *mut _, device_info.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setDefaultRootDeviceInfo")?;
Ok(())
}
/// Sets the local id for default device. Has no effect if `Root device` has been congigured.
/// @param localId The default root device local id
/// Calls the openDAQ C function `daqInstanceBuilder_setDefaultRootDeviceLocalId()`.
pub fn set_default_root_device_local_id(&self, local_id: &str) -> Result<()> {
let __local_id = crate::marshal::make_string(local_id)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setDefaultRootDeviceLocalId)(self.as_raw() as *mut _, __local_id.as_ptr() as *mut _) };
check(__code, "daqInstanceBuilder_setDefaultRootDeviceLocalId")?;
Ok(())
}
/// Sets the Logger global log level for the Instance. All log messages with a severity level equal to or higher than the specified level will be processed.
/// @param logLevel The Logger global level of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setGlobalLogLevel()`.
pub fn set_global_log_level(&self, log_level: LogLevel) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setGlobalLogLevel)(self.as_raw() as *mut _, log_level as u32) };
check(__code, "daqInstanceBuilder_setGlobalLogLevel")?;
Ok(())
}
/// Calls the openDAQ C function `daqInstanceBuilder_setLoadAuthenticatedModulesOnly()`.
pub fn set_load_authenticated_modules_only(&self, auth_only: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setLoadAuthenticatedModulesOnly)(self.as_raw() as *mut _, u8::from(auth_only)) };
check(__code, "daqInstanceBuilder_setLoadAuthenticatedModulesOnly")?;
Ok(())
}
/// Sets the custom Logger for the Instance. This logger will be used for logging messages related to the Instance and its components. When configured, the `Logger sink` will be ignored, as it is in use only with the default Instance logger.
/// @param logger The custom Logger of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setLogger()`.
pub fn set_logger(&self, logger: &Logger) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setLogger)(self.as_raw() as *mut _, logger.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setLogger")?;
Ok(())
}
/// Set verification class for modules. The class will check each module DLL and verify it's authenticity before it is loaded.
/// @param authenticator Verifier object.
/// Calls the openDAQ C function `daqInstanceBuilder_setModuleAuthenticator()`.
pub fn set_module_authenticator(&self, authenticator: &ModuleAuthenticator) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setModuleAuthenticator)(self.as_raw() as *mut _, authenticator.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setModuleAuthenticator")?;
Ok(())
}
/// Sets The custom ModuleManager for the Instance.
/// @param moduleManager The custom ModuleManager of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setModuleManager()`.
pub fn set_module_manager(&self, module_manager: &ModuleManager) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setModuleManager)(self.as_raw() as *mut _, module_manager.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setModuleManager")?;
Ok(())
}
/// Sets the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.
/// @param path The path for the default ModuleManager of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setModulePath()`.
pub fn set_module_path(&self, path: &str) -> Result<()> {
let __path = crate::marshal::make_string(path)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setModulePath)(self.as_raw() as *mut _, __path.as_ptr() as *mut _) };
check(__code, "daqInstanceBuilder_setModulePath")?;
Ok(())
}
/// Sets the connection string for a device that replaces the default openDAQ root device. When the instance is created, a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure.
/// @param connectionString The connection string for the root device of the Instance.
/// @param config A config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. In case of nullptr, a default configuration is used.
/// Calls the openDAQ C function `daqInstanceBuilder_setRootDevice()`.
pub fn set_root_device(&self, connection_string: &str) -> Result<()> {
let __connection_string = crate::marshal::make_string(connection_string)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setRootDevice)(self.as_raw() as *mut _, __connection_string.as_ptr() as *mut _, std::ptr::null_mut()) };
check(__code, "daqInstanceBuilder_setRootDevice")?;
Ok(())
}
/// Sets the connection string for a device that replaces the default openDAQ root device. When the instance is created, a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure.
/// @param connectionString The connection string for the root device of the Instance.
/// @param config A config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. In case of nullptr, a default configuration is used.
/// Calls the openDAQ C function `daqInstanceBuilder_setRootDevice()`.
pub fn set_root_device_with(&self, connection_string: &str, config: Option<&PropertyObject>) -> Result<()> {
let __connection_string = crate::marshal::make_string(connection_string)?;
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setRootDevice)(self.as_raw() as *mut _, __connection_string.as_ptr() as *mut _, config.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqInstanceBuilder_setRootDevice")?;
Ok(())
}
/// Sets the custom scheduler of Instance
/// @param scheduler The custom scheduler of Instance
/// Calls the openDAQ C function `daqInstanceBuilder_setScheduler()`.
pub fn set_scheduler(&self, scheduler: &Scheduler) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setScheduler)(self.as_raw() as *mut _, scheduler.as_raw() as *mut _) };
check(__code, "daqInstanceBuilder_setScheduler")?;
Ok(())
}
/// Sets the number of worker threads in the scheduler of the Instance. If Scheduler has been set, configuring of Scheduler worker num has no effect in building Instance.
/// @param numWorkers The amount of worker threads in the scheduler of Instance. If @c is 0, then the amount of workers is the maximum number of concurrent threads supported by the implementation.
/// Calls the openDAQ C function `daqInstanceBuilder_setSchedulerWorkerNum()`.
pub fn set_scheduler_worker_num(&self, num_workers: usize) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setSchedulerWorkerNum)(self.as_raw() as *mut _, num_workers) };
check(__code, "daqInstanceBuilder_setSchedulerWorkerNum")?;
Ok(())
}
/// Sets the sink logger level of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance.
/// @param sink The sink logger of the default Instance logger
/// @param logLevel The sink logger level of the default Instance logger
/// Calls the openDAQ C function `daqInstanceBuilder_setSinkLogLevel()`.
pub fn set_sink_log_level(&self, sink: &LoggerSink, log_level: LogLevel) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setSinkLogLevel)(self.as_raw() as *mut _, sink.as_raw() as *mut _, log_level as u32) };
check(__code, "daqInstanceBuilder_setSinkLogLevel")?;
Ok(())
}
/// Enables or disables usage of the scheduler's main loop.
/// @param useMainLoop Whether to construct the scheduler with main loop support.
/// If enabled, the scheduler will be constructed with the main worker, allowing use of the main loop.
/// Note that enabling this does not automatically start the main loop. To start it, you must call
/// `IScheduler::runMainLoop()` or `IScheduler::runMainLoopIteration()`.
/// Calls the openDAQ C function `daqInstanceBuilder_setUsingSchedulerMainLoop()`.
pub fn set_using_scheduler_main_loop(&self, use_main_loop: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInstanceBuilder_setUsingSchedulerMainLoop)(self.as_raw() as *mut _, u8::from(use_main_loop)) };
check(__code, "daqInstanceBuilder_setUsingSchedulerMainLoop")?;
Ok(())
}
}
impl Instance {
/// Creates and adds streaming and "OpenDAQOPCUA" servers with default configurations.
/// @param\[out\] servers List of added created servers.
/// Calls the openDAQ C function `daqInstance_addStandardServers()`.
pub fn add_standard_servers(&self) -> Result<Vec<Server>> {
let mut __servers: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstance_addStandardServers)(self.as_raw() as *mut _, &mut __servers) };
check(__code, "daqInstance_addStandardServers")?;
Ok(unsafe { crate::marshal::take_list::<Server>(__servers as *mut _, "daqInstance_addStandardServers") }?)
}
/// Get a dictionary of available server types as \<IString, IServerType\> pairs
/// @param\[out\] serverTypes The dictionary of available server types.
/// Calls the openDAQ C function `daqInstance_getAvailableServerTypes()`.
pub fn available_server_types(&self) -> Result<std::collections::HashMap<String, ServerType>> {
let mut __server_types: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstance_getAvailableServerTypes)(self.as_raw() as *mut _, &mut __server_types) };
check(__code, "daqInstance_getAvailableServerTypes")?;
Ok(unsafe { crate::marshal::take_dict::<String, ServerType>(__server_types as *mut _, "daqInstance_getAvailableServerTypes") }?)
}
/// Gets the Module manager.
/// @param\[out\] manager The module manager.
/// Calls the openDAQ C function `daqInstance_getModuleManager()`.
pub fn module_manager(&self) -> Result<Option<ModuleManager>> {
let mut __manager: *mut sys::daqModuleManager = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstance_getModuleManager)(self.as_raw() as *mut _, &mut __manager) };
check(__code, "daqInstance_getModuleManager")?;
Ok(unsafe { crate::marshal::take_object::<ModuleManager>(__manager as *mut _) })
}
/// Gets the current root device.
/// @param\[out\] rootDevice The current root device.
/// All Device calls invoked on the Instance are forwarded to the current root device.
/// Calls the openDAQ C function `daqInstance_getRootDevice()`.
pub fn root_device(&self) -> Result<Option<Device>> {
let mut __root_device: *mut sys::daqDevice = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqInstance_getRootDevice)(self.as_raw() as *mut _, &mut __root_device) };
check(__code, "daqInstance_getRootDevice")?;
Ok(unsafe { crate::marshal::take_object::<Device>(__root_device as *mut _) })
}
/// Adds a device with the connection string as root device.
/// @param connectionString The connection string containing the address of the device.
/// @param config A config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. In case of nullptr, a default configuration is used.
/// All Device calls invoked on the Instance are forwarded to the root device. The root device can only be set once.
/// Calls the openDAQ C function `daqInstance_setRootDevice()`.
pub fn set_root_device(&self, connection_string: &str) -> Result<()> {
let __connection_string = crate::marshal::make_string(connection_string)?;
let __code = unsafe { (crate::sys::api().daqInstance_setRootDevice)(self.as_raw() as *mut _, __connection_string.as_ptr() as *mut _, std::ptr::null_mut()) };
check(__code, "daqInstance_setRootDevice")?;
Ok(())
}
/// Adds a device with the connection string as root device.
/// @param connectionString The connection string containing the address of the device.
/// @param config A config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. In case of nullptr, a default configuration is used.
/// All Device calls invoked on the Instance are forwarded to the root device. The root device can only be set once.
/// Calls the openDAQ C function `daqInstance_setRootDevice()`.
pub fn set_root_device_with(&self, connection_string: &str, config: Option<&PropertyObject>) -> Result<()> {
let __connection_string = crate::marshal::make_string(connection_string)?;
let __code = unsafe { (crate::sys::api().daqInstance_setRootDevice)(self.as_raw() as *mut _, __connection_string.as_ptr() as *mut _, config.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqInstance_setRootDevice")?;
Ok(())
}
}