// 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;
/// An allocator used to allocate memory.
/// The default BB allocator simply uses `malloc`, but the user can implement a custom allocator to
/// override this behavior (perhaps using a memory pool or different allocation strategy). An
/// example/reference implementation is provided which uses Microsoft `mimalloc`.
/// Wrapper over the openDAQ `daqAllocator` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Allocator(pub(crate) BaseObject);
impl std::ops::Deref for Allocator {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Allocator {}
unsafe impl Interface for Allocator {
const NAME: &'static str = "daqAllocator";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqAllocator_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 Allocator {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Allocator(BaseObject(r)) }
}
impl std::fmt::Display for Allocator {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Allocator> for Value {
fn from(value: &Allocator) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Allocator> for Value {
fn from(value: Allocator) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Allocator {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Represents a connection between an Input port and Signal. Acts as a queue for packets sent by the signal, which can be read by the input port and the input port's owner.
/// The Connection provides standard queue methods, allowing for packets to be put at the back
/// of the queue, and popped from the front. Additionally, the front packet can be inspected via
/// `peek`, and the number of queued packets can be obtained through `getPacketCount`.
/// The Connection has a reference to the connected Signal and Input port.
/// Wrapper over the openDAQ `daqConnection` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Connection(pub(crate) BaseObject);
impl std::ops::Deref for Connection {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Connection {}
unsafe impl Interface for Connection {
const NAME: &'static str = "daqConnection";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqConnection_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 Connection {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Connection(BaseObject(r)) }
}
impl std::fmt::Display for Connection {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Connection> for Value {
fn from(value: &Connection) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Connection> for Value {
fn from(value: Connection) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Connection {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup opendaq_signal_path
/// @addtogroup opendaq_connection ConnectionInternal
/// Wrapper over the openDAQ `daqConnectionInternal` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ConnectionInternal(pub(crate) BaseObject);
impl std::ops::Deref for ConnectionInternal {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ConnectionInternal {}
unsafe impl Interface for ConnectionInternal {
const NAME: &'static str = "daqConnectionInternal";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqConnectionInternal_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 ConnectionInternal {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ConnectionInternal(BaseObject(r)) }
}
impl std::fmt::Display for ConnectionInternal {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ConnectionInternal> for Value {
fn from(value: &ConnectionInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ConnectionInternal> for Value {
fn from(value: ConnectionInternal) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ConnectionInternal {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Describes the data sent by a signal, defining how they are to be interpreted by anyone receiving the signal's packets.
/// The data descriptor provides all information required on how to process data buffers, and how to interpret the data.
/// It contains the following fields:
/// - `Name`: A descriptive name of the data being described. In example, when the values describe the amplitude of spectrum data, the name
/// would be `Amplitude`.
/// - `Dimensions`: A list of dimensions of the signal. A sample descriptor can have 0 or more dimensions. A signal with 1 dimension
/// has vector data. A signal with 2 dimensions has matrix data, a signal with 0 has a single value for each sample.
/// - `SampleType`: An enum value that specifies the underlying data type (eg. Float64, Int32, String,...)
/// - `Unit`: The unit of the data in the signal's packets.
/// - `ValueRange`: The value range of the data in a signal's packets defining the lowest and highest expected values. The range is not
/// enforced.
/// - `Rule`: The data rule that defines how a signal value is calculated from an implicit initialization value when the rule type is not
/// `Explicit`.
/// - `Origin`: Defines the starting point of the signal. If set, all values are added to the absolute origin when read.
/// - `TickResolution`: Used to scale signal ticks into their physical unit. In example, a resolution of 1/1000 with the unit being `seconds`
/// states that a value of 1 correlates to 1 millisecond.
/// - `PostScaling`: Defines a scaling transformation, which should be applied to data carried by the signal's packets when read. If
/// `PostScaling` is used, the `Rule`, `Resolution`, and `Origin` must not be configured. The `SampleType` must match the
/// `outputDataType` of the `PostScaling`.
/// - `StructFields`: A list of DataDescriptor. The descriptor list is used to define complex data samples. When defined, the sample
/// buffer is laid out so that the data described by the first DataDescriptor is at the start, followed by the data
/// described by the second and so on. If the list is not empty, all descriptor parameters except for `Name` and
/// `Dimensions` should not be configured. See below for a explanation of Structure data descriptors.
/// - `ReferenceDomainInfo`: If set, gives the common identifier of one domain group. Signals with the same Reference Domain ID share a
/// common synchronization source (all the signals in a group either come from the same device or are synchronized
/// using a protocol, such as PTP, NTP, IRIG, etc.). Those signals can always be read together, implying that a
/// Multi Reader can be used to read the signals if their sampling rates are compatible.
/// @subsection data_descriptor_dimensions Dimensions
/// The list of dimensions determines the rank of values described by the descriptor. In example, if the list contains 1 dimension, the data
/// values are vectors. If it contains 2, the data values are matrices, if 0, the descriptor describes a single value.
/// When the data is placed into packet buffers, the values are laid out in packet buffers linearly, where each value fills up
/// `sizeof(sampleType) * (dimensionSize1 * dimensionSize2 *...)` bytes.
/// Data descriptor objects implement the Struct methods internally and are Core type `ctStruct`.
/// @subsection data_descriptor_struct_fields Struct fields
/// A DataDescriptor with the `StructFields` field filled with other descriptors is used to represent signal data in the form of structures.
/// It allows for custom and complex structures to be described and sent by a signal.
/// When evaluating a struct descriptor, their struct field values are laid out in the packet buffers in the order they are placed in
/// the `structFields` list. Eg. a struct with 3 fields, of types \[int64_t, float, double\] will have a buffer composed of an int64_t value,
/// followed by a float, and lastly a double value.
/// Note that if the Dimensions field of the DataDescriptor is not empty, struct data can also be of a higher rank
/// (eg. a vector/matrix of structs).
/// @subsection data_descriptor_calculation_order Value calculation
/// Besides the struct fields and dimensions, the Value descriptor also provides 4 fields which need to be taken into account and calculated
/// when reading packet buffers: `Rule`, `Resolution`, `Origin`, and `PostScaling`.
/// @subsubsection data_descriptor_calculation_without_scaling Without `PostScaling`
/// 1. Check and apply `Rule`:
/// - If the rule is `explicit`, the values of a packet are present in the packet's data buffer
/// - If not `explicit`, the packet's values need to be calculated. To calculate them, take the PacketOffset and SampleCount of the
/// packet. Use the PacketOffset, as well as the index of the sample in a packet to calculate the rule's output value: `Value = PacketOffset + Rule(Index)`.
/// Eg. `Value = PacketOffset + Delta * Index + Start`
/// 2. Apply `TickResolution`:
/// - If the `TickResolution` is set, multiply the value from 1. with the `Resolution`. This scales the value into the `Unit` of the value
/// descriptor.
/// - If not set, keep the value from 1.
/// 3. Add `Origin`:
/// - If the `Origin` is set, take the value from 2. and add it to the `Origin`.
/// In example, if using the Unix Epoch, a value `1669279690` in seconds would mean Thursday, 24 November 2022 08:48:10 GMT.
/// - If not set, keep the value from 2.
/// @subsubsection data_descriptor_calculation_with_scaling With `PostScaling`
/// If `PostScaling` is set, the `Rule` must be explicit, while `Resolution` and `Origin` must not be configured.
/// To calculate the value with `PostScaling` configured, take the values of the packet's data buffer and apply the post scaling to each
/// value in the buffer: `Value = PostScaling(Value)`, eg. `Value = Value * Scale + Offset`
/// Wrapper over the openDAQ `daqDataDescriptor` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DataDescriptor(pub(crate) BaseObject);
impl std::ops::Deref for DataDescriptor {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DataDescriptor {}
unsafe impl Interface for DataDescriptor {
const NAME: &'static str = "daqDataDescriptor";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDataDescriptor_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 DataDescriptor {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DataDescriptor(BaseObject(r)) }
}
impl std::fmt::Display for DataDescriptor {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DataDescriptor> for Value {
fn from(value: &DataDescriptor) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DataDescriptor> for Value {
fn from(value: DataDescriptor) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DataDescriptor {
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 Data descriptor objects. Contains setter methods that allow for Data descriptor parameter configuration, and a `build` method that builds the Data descriptor.
/// Wrapper over the openDAQ `daqDataDescriptorBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DataDescriptorBuilder(pub(crate) BaseObject);
impl std::ops::Deref for DataDescriptorBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DataDescriptorBuilder {}
unsafe impl Interface for DataDescriptorBuilder {
const NAME: &'static str = "daqDataDescriptorBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDataDescriptorBuilder_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 DataDescriptorBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DataDescriptorBuilder(BaseObject(r)) }
}
impl std::fmt::Display for DataDescriptorBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DataDescriptorBuilder> for Value {
fn from(value: &DataDescriptorBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DataDescriptorBuilder> for Value {
fn from(value: DataDescriptorBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DataDescriptorBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Packet that contains data sent by a signal. The data can be either explicit, or implicit.
/// Explicit data is contained within a signal's buffer, accessible through `getRawData`, while implicit
/// packets do not carry any data. Their values are calculated given a rule, packet offset, and the index of
/// a sample within the data buffer.
/// To obtain implicitly calculated, or scaled values, `getData` should be used. The data descriptor and sample
/// count provide information about the type and amount of data available at the obtained address.
/// Wrapper over the openDAQ `daqDataPacket` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DataPacket(pub(crate) Packet);
impl std::ops::Deref for DataPacket {
type Target = Packet;
fn deref(&self) -> &Packet { &self.0 }
}
impl crate::sealed::Sealed for DataPacket {}
unsafe impl Interface for DataPacket {
const NAME: &'static str = "daqDataPacket";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDataPacket_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 DataPacket {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DataPacket(Packet::__from_ref(r)) }
}
impl std::fmt::Display for DataPacket {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DataPacket> for Value {
fn from(value: &DataPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DataPacket> for Value {
fn from(value: DataPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DataPacket {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Rule that defines how a signal value is calculated from an implicit initialization value when the rule type is not `Explicit`.
/// Data rule objects implement the Struct methods internally and are Core type `ctStruct`.
/// @subsection data_rule_explicit Explicit rule
/// When the rule type of the Data rule is set to `Explicit`, the values passed through the signal path, described by
/// the Value descriptor are stored in packet buffers.
/// The Explicit rule can have 2 optional parameters:
/// - `minExpectedDelta`: Specifies the minimum difference in value between two subsequent samples
/// - `maxExpectedDelta`: Specifies the maximum difference in value between two subsequent samples
/// These are mostly used for domain signals to specify the expected rate of a signal, or the expected timeout of a signal.
/// The delta parameters should be configured to match the deltas in terms of the raw signal values (before scaling/resolution
/// are applied).
/// An explicit rule must have either both or none of these parameters. To use only one, the other must be set to 0.
/// @subsection data_rule_implicit Implicit rule
/// When the rule type of the Data rule is not `Explicit`, the buffers of packets are empty. The values must instead be
/// calculated via the Implicit value found in the packet buffers in conjunction with the parameters of the rule. Each
/// implicit rule type specifies its own required set of parameters.
/// @subsubsection data_rule_linear Linear rule
/// The parameters include a `delta` and `start` integer members. The values are calculated according to the following
/// equation: \<em\>packetOffset + sampleIndex * delta + start\</em\>.
/// @subsubsection data_rule_linear Constant rule
/// The parameters contain a `constant` number member. The value described by the constant rule is always equal to the
/// constant.
/// Wrapper over the openDAQ `daqDataRule` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DataRule(pub(crate) BaseObject);
impl std::ops::Deref for DataRule {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DataRule {}
unsafe impl Interface for DataRule {
const NAME: &'static str = "daqDataRule";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDataRule_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 DataRule {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DataRule(BaseObject(r)) }
}
impl std::fmt::Display for DataRule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DataRule> for Value {
fn from(value: &DataRule) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DataRule> for Value {
fn from(value: DataRule) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DataRule {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Configuration component of Data rule objects. Contains setter methods that allow for Data rule parameter configuration, and a `build` method that builds the Data rule.
/// Wrapper over the openDAQ `daqDataRuleBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DataRuleBuilder(pub(crate) BaseObject);
impl std::ops::Deref for DataRuleBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DataRuleBuilder {}
unsafe impl Interface for DataRuleBuilder {
const NAME: &'static str = "daqDataRuleBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDataRuleBuilder_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 DataRuleBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DataRuleBuilder(BaseObject(r)) }
}
impl std::fmt::Display for DataRuleBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DataRuleBuilder> for Value {
fn from(value: &DataRuleBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DataRuleBuilder> for Value {
fn from(value: DataRuleBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DataRuleBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Callback which is called when external memory is no longer needed and can be freed.
/// This interface is used with blueberry packets that are created with external memory. Provider
/// of external memory is responsible to provide a custom deleter, which is called when the packet is
/// destroyed.
/// Wrapper over the openDAQ `daqDeleter` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Deleter(pub(crate) BaseObject);
impl std::ops::Deref for Deleter {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Deleter {}
unsafe impl Interface for Deleter {
const NAME: &'static str = "daqDeleter";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDeleter_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 Deleter {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Deleter(BaseObject(r)) }
}
impl std::fmt::Display for Deleter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Deleter> for Value {
fn from(value: &Deleter) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Deleter> for Value {
fn from(value: Deleter) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Deleter {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Describes a dimension of the signal's data. Eg. a column/row in a matrix.
/// Dimension objects define the size and labels of a single data dimension. Labels, in concert
/// with the unit, provide information about the position of data in a structure. For example, for vector
/// rank data in a frequency domain, the unit would be Hz, and the labels would range from the minimum to the maximum
/// frequency of the spectrum.
/// The number of dimensions a sample descriptor defines the rank of the signals data. When no dimensions are
/// present, one sample is a single value. When there's one dimension, a sample contains a vector of values,
/// when there are three a sample contains a matrix. Higher ranks of data can be represented by adding more
/// dimension objects to a sample descriptor.
/// The labels can be defined with a Rule (in example a linear rule with a coefficient and offset), where the
/// the data index is the input to the rule. In example
/// A Linear rule with coefficient = 5, offset = 10, size = 5 provides the following list of labels:
/// \[10, 15, 20, 25, 30\]
/// To specify the labels can explicitly, the List dimension rule can be used. The list rule allows for a list of
/// numbers, strings, or ranges to be used as the dimension labels.
/// Dimension objects implement the Struct methods internally and are Core type `ctStruct`.
/// Wrapper over the openDAQ `daqDimension` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Dimension(pub(crate) BaseObject);
impl std::ops::Deref for Dimension {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Dimension {}
unsafe impl Interface for Dimension {
const NAME: &'static str = "daqDimension";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDimension_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 Dimension {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Dimension(BaseObject(r)) }
}
impl std::fmt::Display for Dimension {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Dimension> for Value {
fn from(value: &Dimension) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Dimension> for Value {
fn from(value: Dimension) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Dimension {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Configuration component of Dimension objects. Contains setter methods that allow for Dimension parameter configuration, and a `build` method that builds the Dimension.
/// Wrapper over the openDAQ `daqDimensionBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DimensionBuilder(pub(crate) BaseObject);
impl std::ops::Deref for DimensionBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DimensionBuilder {}
unsafe impl Interface for DimensionBuilder {
const NAME: &'static str = "daqDimensionBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDimensionBuilder_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 DimensionBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DimensionBuilder(BaseObject(r)) }
}
impl std::fmt::Display for DimensionBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DimensionBuilder> for Value {
fn from(value: &DimensionBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DimensionBuilder> for Value {
fn from(value: DimensionBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DimensionBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Rule that defines the labels (alternatively called bins, ticks) of a dimension.
/// Each dimension has a rule, which is queried and parsed by the dimension `getLabels` and `getSize` calls.
/// Three different rule types are supported by openDAQ, with all others having to be set to `custom` type, requiring
/// anyone using them to parse them manually.
/// Dimension rule objects implement the Struct methods internally and are Core type `ctStruct`.
/// @subsection dimension_rule_types Rule types
/// @subsubsection linear_dimension_rule Linear dimension rule
/// The parameters include a `delta`, `start`, and `size` number members. The list of labels of size `size` is generated by
/// the equation: \<em\>index * delta + start\</em\>, where the index starts with 0 and goes up to `size - 1`.
/// In example: `delta = 10, start = 5, size = 5` produces the following list of samples -\> \[5, 15, 25, 35, 45\]
/// @subsubsection logarithmic_dimension_rule Logarithmic dimension rule
/// The parameters include a `delta`, `start`, `base` and `size` number members. The list of labels of size `size` is generated by
/// the equation: \<em\>base ^ (index * delta + start)\</em\>, where the index starts with 0 and goes up to `size - 1`.
/// In example: `delta = 1, start = -2, base = 10 size = 5` produces the following list of samples -\> \[0.01, 0.1, 1, 10, 20\]
/// @subsubsection list_dimension_rule List dimension rule
/// The parameters include a `list` list-typed member. The `list` contains labels, implicitly also defining the dimension size.
/// The labels in the list can be either strings, numbers, or ranges.
/// String example list: `list` = \["banana", "apple", "coconut"\]
/// Number example list: = \[1.2, 10.5, 20.2, 50.7\]
/// Range example list: \[1-10, 10-20, 20-30, 30-40, 40-50\]
/// Wrapper over the openDAQ `daqDimensionRule` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DimensionRule(pub(crate) BaseObject);
impl std::ops::Deref for DimensionRule {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DimensionRule {}
unsafe impl Interface for DimensionRule {
const NAME: &'static str = "daqDimensionRule";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDimensionRule_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 DimensionRule {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DimensionRule(BaseObject(r)) }
}
impl std::fmt::Display for DimensionRule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DimensionRule> for Value {
fn from(value: &DimensionRule) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DimensionRule> for Value {
fn from(value: DimensionRule) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DimensionRule {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Configuration component of Dimension rule objects. Contains setter methods that allow for Dimension rule parameter configuration, and a `build` method that builds the Dimension rule.
/// Wrapper over the openDAQ `daqDimensionRuleBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct DimensionRuleBuilder(pub(crate) BaseObject);
impl std::ops::Deref for DimensionRuleBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for DimensionRuleBuilder {}
unsafe impl Interface for DimensionRuleBuilder {
const NAME: &'static str = "daqDimensionRuleBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqDimensionRuleBuilder_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 DimensionRuleBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { DimensionRuleBuilder(BaseObject(r)) }
}
impl std::fmt::Display for DimensionRuleBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&DimensionRuleBuilder> for Value {
fn from(value: &DimensionRuleBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<DimensionRuleBuilder> for Value {
fn from(value: DimensionRuleBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for DimensionRuleBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal functions used by openDAQ core. This interface should never be used in client SDK or module code.
/// Wrapper over the openDAQ `daqInputPortPrivate` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct InputPortPrivate(pub(crate) BaseObject);
impl std::ops::Deref for InputPortPrivate {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for InputPortPrivate {}
unsafe impl Interface for InputPortPrivate {
const NAME: &'static str = "daqInputPortPrivate";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqInputPortPrivate_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 InputPortPrivate {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { InputPortPrivate(BaseObject(r)) }
}
impl std::fmt::Display for InputPortPrivate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&InputPortPrivate> for Value {
fn from(value: &InputPortPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl From<InputPortPrivate> for Value {
fn from(value: InputPortPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for InputPortPrivate {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Used to subscribe to packet destruction
/// Wrapper over the openDAQ `daqPacketDestructCallback` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct PacketDestructCallback(pub(crate) BaseObject);
impl std::ops::Deref for PacketDestructCallback {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for PacketDestructCallback {}
unsafe impl Interface for PacketDestructCallback {
const NAME: &'static str = "daqPacketDestructCallback";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqPacketDestructCallback_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 PacketDestructCallback {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { PacketDestructCallback(BaseObject(r)) }
}
impl std::fmt::Display for PacketDestructCallback {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&PacketDestructCallback> for Value {
fn from(value: &PacketDestructCallback) -> Value { Value::Object(value.to_base_object()) }
}
impl From<PacketDestructCallback> for Value {
fn from(value: PacketDestructCallback) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for PacketDestructCallback {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Describes a range of values between the `lowValue` and `highValue` boundaries.
/// Range objects implement the Struct methods internally and are Core type `ctStruct`.
/// Wrapper over the openDAQ `daqRange` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Range(pub(crate) BaseObject);
impl std::ops::Deref for Range {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Range {}
unsafe impl Interface for Range {
const NAME: &'static str = "daqRange";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqRange_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 Range {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Range(BaseObject(r)) }
}
impl std::fmt::Display for Range {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Range> for Value {
fn from(value: &Range) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Range> for Value {
fn from(value: Range) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Range {
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 Reference Domain Info objects. Contains setter methods that allow for Reference Domain Info parameter configuration, and a `build` method that builds the Reference Domain Info.
/// Wrapper over the openDAQ `daqReferenceDomainInfoBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ReferenceDomainInfoBuilder(pub(crate) BaseObject);
impl std::ops::Deref for ReferenceDomainInfoBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ReferenceDomainInfoBuilder {}
unsafe impl Interface for ReferenceDomainInfoBuilder {
const NAME: &'static str = "daqReferenceDomainInfoBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_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 ReferenceDomainInfoBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ReferenceDomainInfoBuilder(BaseObject(r)) }
}
impl std::fmt::Display for ReferenceDomainInfoBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ReferenceDomainInfoBuilder> for Value {
fn from(value: &ReferenceDomainInfoBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ReferenceDomainInfoBuilder> for Value {
fn from(value: ReferenceDomainInfoBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ReferenceDomainInfoBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// @ingroup opendaq_packets
/// @addtogroup opendaq_reusable_data_packet Reusable Data packet
/// Wrapper over the openDAQ `daqReusableDataPacket` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ReusableDataPacket(pub(crate) BaseObject);
impl std::ops::Deref for ReusableDataPacket {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ReusableDataPacket {}
unsafe impl Interface for ReusableDataPacket {
const NAME: &'static str = "daqReusableDataPacket";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqReusableDataPacket_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 ReusableDataPacket {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ReusableDataPacket(BaseObject(r)) }
}
impl std::fmt::Display for ReusableDataPacket {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ReusableDataPacket> for Value {
fn from(value: &ReusableDataPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ReusableDataPacket> for Value {
fn from(value: ReusableDataPacket) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ReusableDataPacket {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Private rule interface implemented by Dimension rules, Data rules and Scaling. Allows for parameter verification.
/// Wrapper over the openDAQ `daqRulePrivate` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct RulePrivate(pub(crate) BaseObject);
impl std::ops::Deref for RulePrivate {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for RulePrivate {}
unsafe impl Interface for RulePrivate {
const NAME: &'static str = "daqRulePrivate";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqRulePrivate_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 RulePrivate {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { RulePrivate(BaseObject(r)) }
}
impl std::fmt::Display for RulePrivate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&RulePrivate> for Value {
fn from(value: &RulePrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl From<RulePrivate> for Value {
fn from(value: RulePrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for RulePrivate {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Signal descriptor field that defines a scaling transformation, which should be applied to data carried by the signal's packets when read.
/// Each scaling specifies its `scalingType` and parses the parameters accordingly. The parameters
/// are to be interpreted and used as specified by each specific scaling type as detailed below.
/// Additionally, each Scaling object states is input and output data types. The inputDataType
/// describes the raw data type of the signal value (that data is input into the scaling scaling),
/// while the outputDataType should match the sample type of the signal's value descriptor.
/// Scaling objects implement the Struct methods internally and are Core type `ctStruct`.
/// @subsection scaling_types Scaling types
/// @subsubsection scaling_types_linear Linear scaling
/// Linear scaling parameters must have two entries:
/// - Scale: coefficient by which the input data is to be multiplied
/// - Offset: a constant that is added to the \<em\>scale * value\</em\> multiplication result
/// The linear scaling output is calculated as follows: \<em\>inputValue * scale + offset\</em\>
/// Wrapper over the openDAQ `daqScaling` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Scaling(pub(crate) BaseObject);
impl std::ops::Deref for Scaling {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Scaling {}
unsafe impl Interface for Scaling {
const NAME: &'static str = "daqScaling";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqScaling_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 Scaling {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Scaling(BaseObject(r)) }
}
impl std::fmt::Display for Scaling {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Scaling> for Value {
fn from(value: &Scaling) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Scaling> for Value {
fn from(value: Scaling) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Scaling {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Configuration component of Scaling objects. Contains setter methods that allow for Scaling parameter configuration, and a `build` method that builds the Scaling object.
/// Wrapper over the openDAQ `daqScalingBuilder` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ScalingBuilder(pub(crate) BaseObject);
impl std::ops::Deref for ScalingBuilder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ScalingBuilder {}
unsafe impl Interface for ScalingBuilder {
const NAME: &'static str = "daqScalingBuilder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqScalingBuilder_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 ScalingBuilder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ScalingBuilder(BaseObject(r)) }
}
impl std::fmt::Display for ScalingBuilder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ScalingBuilder> for Value {
fn from(value: &ScalingBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ScalingBuilder> for Value {
fn from(value: ScalingBuilder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ScalingBuilder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal functions used by openDAQ core. This interface should never be used in client SDK or module code.
/// Wrapper over the openDAQ `daqScalingCalcPrivate` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct ScalingCalcPrivate(pub(crate) BaseObject);
impl std::ops::Deref for ScalingCalcPrivate {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for ScalingCalcPrivate {}
unsafe impl Interface for ScalingCalcPrivate {
const NAME: &'static str = "daqScalingCalcPrivate";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqScalingCalcPrivate_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 ScalingCalcPrivate {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { ScalingCalcPrivate(BaseObject(r)) }
}
impl std::fmt::Display for ScalingCalcPrivate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&ScalingCalcPrivate> for Value {
fn from(value: &ScalingCalcPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl From<ScalingCalcPrivate> for Value {
fn from(value: ScalingCalcPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for ScalingCalcPrivate {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// The configuration component of a Signal. Allows for configuration of its properties, managing its streaming sources, and sending packets through its connections.
/// The Signal config is most often accessible only to the devices or function blocks that own
/// the signal. They react on property, or input signal changes to modify a signal's data descriptor,
/// and send processed/acquired data down its signal path.
/// Wrapper over the openDAQ `daqSignalConfig` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct SignalConfig(pub(crate) Signal);
impl std::ops::Deref for SignalConfig {
type Target = Signal;
fn deref(&self) -> &Signal { &self.0 }
}
impl crate::sealed::Sealed for SignalConfig {}
unsafe impl Interface for SignalConfig {
const NAME: &'static str = "daqSignalConfig";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqSignalConfig_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 SignalConfig {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { SignalConfig(Signal::__from_ref(r)) }
}
impl std::fmt::Display for SignalConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&SignalConfig> for Value {
fn from(value: &SignalConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl From<SignalConfig> for Value {
fn from(value: SignalConfig) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for SignalConfig {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal functions of a signal containing event methods that are called on certain events. Eg. when a signal is connected to an input port, or when a signal is used as a domain signal of another.
/// Wrapper over the openDAQ `daqSignalEvents` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct SignalEvents(pub(crate) BaseObject);
impl std::ops::Deref for SignalEvents {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for SignalEvents {}
unsafe impl Interface for SignalEvents {
const NAME: &'static str = "daqSignalEvents";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqSignalEvents_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 SignalEvents {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { SignalEvents(BaseObject(r)) }
}
impl std::fmt::Display for SignalEvents {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&SignalEvents> for Value {
fn from(value: &SignalEvents) -> Value { Value::Object(value.to_base_object()) }
}
impl From<SignalEvents> for Value {
fn from(value: SignalEvents) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for SignalEvents {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
/// Internal functions used by openDAQ core. This interface should never be used in client SDK or module code.
/// Wrapper over the openDAQ `daqSignalPrivate` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct SignalPrivate(pub(crate) BaseObject);
impl std::ops::Deref for SignalPrivate {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for SignalPrivate {}
unsafe impl Interface for SignalPrivate {
const NAME: &'static str = "daqSignalPrivate";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqSignalPrivate_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 SignalPrivate {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { SignalPrivate(BaseObject(r)) }
}
impl std::fmt::Display for SignalPrivate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&SignalPrivate> for Value {
fn from(value: &SignalPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl From<SignalPrivate> for Value {
fn from(value: SignalPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for SignalPrivate {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
impl Allocator {
/// Calls the openDAQ C function `daqAllocator_createMallocAllocator()`.
pub fn malloc() -> Result<Allocator> {
let mut __obj: *mut sys::daqAllocator = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqAllocator_createMallocAllocator)(&mut __obj) };
check(__code, "daqAllocator_createMallocAllocator")?;
Ok(unsafe { crate::marshal::require_object::<Allocator>(__obj as *mut _, "daqAllocator_createMallocAllocator") }?)
}
}
impl ConnectionInternal {
/// Enqueues an event packet with the last descriptor at the front of the queue.
///
/// Calls the openDAQ C function `daqConnectionInternal_enqueueLastDescriptor()`.
pub fn enqueue_last_descriptor(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqConnectionInternal_enqueueLastDescriptor)(self.as_raw() as *mut _) };
check(__code, "daqConnectionInternal_enqueueLastDescriptor")?;
Ok(())
}
}
impl Connection {
/// Calls the openDAQ C function `daqConnection_createConnection()`.
pub fn new(input_port: &InputPort, signal: &Signal, context: &Context) -> Result<Connection> {
let mut __obj: *mut sys::daqConnection = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_createConnection)(&mut __obj, input_port.as_raw() as *mut _, signal.as_raw() as *mut _, context.as_raw() as *mut _) };
check(__code, "daqConnection_createConnection")?;
Ok(unsafe { crate::marshal::require_object::<Connection>(__obj as *mut _, "daqConnection_createConnection") }?)
}
/// Removes the packet at the front of the queue and returns it.
///
/// # Returns
/// - `packet`: The removed packet or `nullptr` if the connection has no packets.
///
/// # Errors
/// - `OPENDAQ_NO_MORE_ITEMS`: When the connection does not hold any packets.
///
/// Calls the openDAQ C function `daqConnection_dequeue()`.
pub fn dequeue(&self) -> Result<Option<Packet>> {
let mut __packet: *mut sys::daqPacket = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_dequeue)(self.as_raw() as *mut _, &mut __packet) };
check(__code, "daqConnection_dequeue")?;
Ok(unsafe { crate::marshal::take_object::<Packet>(__packet as *mut _) })
}
/// Removes all packets from the queue.
///
/// # Returns
/// - `packets`: The removed packets. Removing all packets can be more efficient than dequeuing packet by packet in heavily loaded systems.
///
/// Calls the openDAQ C function `daqConnection_dequeueAll()`.
pub fn dequeue_all(&self) -> Result<Vec<Packet>> {
let mut __packets: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_dequeueAll)(self.as_raw() as *mut _, &mut __packets) };
check(__code, "daqConnection_dequeueAll")?;
Ok(unsafe { crate::marshal::take_list::<Packet>(__packets as *mut _, "daqConnection_dequeueAll") }?)
}
/// Places a packet at the back of the queue.
///
/// # Parameters
/// - `packet`: The packet to be enqueued.
///
/// Calls the openDAQ C function `daqConnection_enqueue()`.
pub fn enqueue(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqConnection_enqueue)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqConnection_enqueue")?;
Ok(())
}
/// Places a packet at the back of the queue. The reference of the packet is stolen.
///
/// # Parameters
/// - `packet`: The packet to be enqueued. After calling the method, the packet should not be touched again. The ownership of the packet is taken by underlying connections and it could be destroyed before the function returns.
///
/// Calls the openDAQ C function `daqConnection_enqueueAndStealRef()`.
pub fn enqueue_and_steal_ref(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqConnection_enqueueAndStealRef)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqConnection_enqueueAndStealRef")?;
Ok(())
}
/// Places multiple packets at the back of the queue.
///
/// # Parameters
/// - `packets`: The packets to be enqueued.
///
/// Calls the openDAQ C function `daqConnection_enqueueMultiple()`.
pub fn enqueue_multiple(&self, packets: &[Packet]) -> Result<()> {
let __packets = crate::marshal::list_from_interfaces(packets)?;
let __code = unsafe { (crate::sys::api().daqConnection_enqueueMultiple)(self.as_raw() as *mut _, __packets.as_ptr() as *mut _) };
check(__code, "daqConnection_enqueueMultiple")?;
Ok(())
}
/// Places multiple packets at the back of the queue. The references of the packets are stolen.
///
/// # Parameters
/// - `packets`: The packets to be enqueued. After calling the method, the packets should not be touched again. The ownership of the packets is taken by underlying connections and it could be destroyed before the function returns.
///
/// Calls the openDAQ C function `daqConnection_enqueueMultipleAndStealRef()`.
pub fn enqueue_multiple_and_steal_ref(&self, packets: &[Packet]) -> Result<()> {
let __packets = crate::marshal::list_from_interfaces(packets)?;
let __code = unsafe { (crate::sys::api().daqConnection_enqueueMultipleAndStealRef)(self.as_raw() as *mut _, __packets.as_ptr() as *mut _) };
check(__code, "daqConnection_enqueueMultipleAndStealRef")?;
Ok(())
}
/// Places a packet at the back of the queue.
///
/// # Parameters
/// - `packet`: The packet to be enqueued. The connection notifies the listener on the same thread that this method was called.
///
/// Calls the openDAQ C function `daqConnection_enqueueOnThisThread()`.
pub fn enqueue_on_this_thread(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqConnection_enqueueOnThisThread)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqConnection_enqueueOnThisThread")?;
Ok(())
}
/// Places a packet at the back of the queue.
///
/// # Parameters
/// - `packet`: The packet to be enqueued. The connection schedules the `onPacketReceived` notification.
///
/// Calls the openDAQ C function `daqConnection_enqueueWithScheduler()`.
pub fn enqueue_with_scheduler(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqConnection_enqueueWithScheduler)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqConnection_enqueueWithScheduler")?;
Ok(())
}
/// Gets the number of samples available in the queued packets. The returned value ignores any Sample-Descriptor changes.
///
/// # Returns
/// - `samples`: The total amount of samples currently available in the stored packets.
///
/// Calls the openDAQ C function `daqConnection_getAvailableSamples()`.
pub fn available_samples(&self) -> Result<usize> {
let mut __samples: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqConnection_getAvailableSamples)(self.as_raw() as *mut _, &mut __samples) };
check(__code, "daqConnection_getAvailableSamples")?;
Ok(__samples)
}
/// Gets the Input port to which packets are being sent.
///
/// # Returns
/// - `input_port`: The input port.
///
/// Calls the openDAQ C function `daqConnection_getInputPort()`.
pub fn input_port(&self) -> Result<Option<InputPort>> {
let mut __input_port: *mut sys::daqInputPort = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_getInputPort)(self.as_raw() as *mut _, &mut __input_port) };
check(__code, "daqConnection_getInputPort")?;
Ok(unsafe { crate::marshal::take_object::<InputPort>(__input_port as *mut _) })
}
/// Gets the number of queued packets.
///
/// # Returns
/// - `packet_count`: The number of queued packets.
///
/// Calls the openDAQ C function `daqConnection_getPacketCount()`.
pub fn packet_count(&self) -> Result<usize> {
let mut __packet_count: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqConnection_getPacketCount)(self.as_raw() as *mut _, &mut __packet_count) };
check(__code, "daqConnection_getPacketCount")?;
Ok(__packet_count)
}
/// Gets the number of same-type samples available in the queued packets. The returned value is up-to the next Sample-Descriptor-Changed packet if any.
///
/// # Returns
/// - `samples`: The total amount of same-type samples currently available in the stored packets.
///
/// Calls the openDAQ C function `daqConnection_getSamplesUntilNextDescriptor()`.
pub fn samples_until_next_descriptor(&self) -> Result<usize> {
let mut __samples: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqConnection_getSamplesUntilNextDescriptor)(self.as_raw() as *mut _, &mut __samples) };
check(__code, "daqConnection_getSamplesUntilNextDescriptor")?;
Ok(__samples)
}
/// Gets the number of samples available in the queued packets until the next event packet. The returned value is up-to the next Event packet if any.
///
/// # Returns
/// - `samples`: The total amount of samples currently available in the stored packets until the next event packet.
///
/// Calls the openDAQ C function `daqConnection_getSamplesUntilNextEventPacket()`.
pub fn samples_until_next_event_packet(&self) -> Result<usize> {
let mut __samples: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqConnection_getSamplesUntilNextEventPacket)(self.as_raw() as *mut _, &mut __samples) };
check(__code, "daqConnection_getSamplesUntilNextEventPacket")?;
Ok(__samples)
}
/// Gets the number of samples available in the queued packets until the next gap packet. The returned value is up-to the next Gap packet if any.
///
/// # Returns
/// - `samples`: The total amount of samples currently available in the stored packets until the next gap packet.
///
/// Calls the openDAQ C function `daqConnection_getSamplesUntilNextGapPacket()`.
pub fn samples_until_next_gap_packet(&self) -> Result<usize> {
let mut __samples: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqConnection_getSamplesUntilNextGapPacket)(self.as_raw() as *mut _, &mut __samples) };
check(__code, "daqConnection_getSamplesUntilNextGapPacket")?;
Ok(__samples)
}
/// Gets the Signal that is sending packets through the Connection.
///
/// # Returns
/// - `signal`: The Signal.
///
/// Calls the openDAQ C function `daqConnection_getSignal()`.
pub fn signal(&self) -> Result<Option<Signal>> {
let mut __signal: *mut sys::daqSignal = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_getSignal)(self.as_raw() as *mut _, &mut __signal) };
check(__code, "daqConnection_getSignal")?;
Ok(unsafe { crate::marshal::take_object::<Signal>(__signal as *mut _) })
}
/// Queries if the connection has an event packet.
///
/// # Returns
/// - `has_event_packet`: True if the connection has an event packet.
///
/// Calls the openDAQ C function `daqConnection_hasEventPacket()`.
pub fn has_event_packet(&self) -> Result<bool> {
let mut __has_event_packet: u8 = 0;
let __code = unsafe { (crate::sys::api().daqConnection_hasEventPacket)(self.as_raw() as *mut _, &mut __has_event_packet) };
check(__code, "daqConnection_hasEventPacket")?;
Ok(__has_event_packet != 0)
}
/// Queries if the connection has a gap packet.
///
/// # Returns
/// - `has_gap_packet`: True if the connection has a gap packet.
///
/// Calls the openDAQ C function `daqConnection_hasGapPacket()`.
pub fn has_gap_packet(&self) -> Result<bool> {
let mut __has_gap_packet: u8 = 0;
let __code = unsafe { (crate::sys::api().daqConnection_hasGapPacket)(self.as_raw() as *mut _, &mut __has_gap_packet) };
check(__code, "daqConnection_hasGapPacket")?;
Ok(__has_gap_packet != 0)
}
/// Returns true if the type of connection is remote.
///
/// # Returns
/// - `remote`: True if connection is remote. Remote connections do not pass any packets. They represent the connection between input ports and signals on remote devices.
///
/// Calls the openDAQ C function `daqConnection_isRemote()`.
pub fn is_remote(&self) -> Result<bool> {
let mut __remote: u8 = 0;
let __code = unsafe { (crate::sys::api().daqConnection_isRemote)(self.as_raw() as *mut _, &mut __remote) };
check(__code, "daqConnection_isRemote")?;
Ok(__remote != 0)
}
/// Returns the packet at the front of the queue without removing it.
///
/// # Returns
/// - `packet`: The packet at the front of the queue or `nullptr` if the connection has no packets.
///
/// # Errors
/// - `OPENDAQ_NO_MORE_ITEMS`: When the connection does not hold any packets.
///
/// Calls the openDAQ C function `daqConnection_peek()`.
pub fn peek(&self) -> Result<Option<Packet>> {
let mut __packet: *mut sys::daqPacket = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqConnection_peek)(self.as_raw() as *mut _, &mut __packet) };
check(__code, "daqConnection_peek")?;
Ok(unsafe { crate::marshal::take_object::<Packet>(__packet as *mut _) })
}
}
impl DataDescriptorBuilder {
/// Builds and returns a Data descriptor object using the currently set values of the Builder.
///
/// # Returns
/// - `data_descriptor`: The built Data descriptor.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_build()`.
pub fn build(&self) -> Result<Option<DataDescriptor>> {
let mut __data_descriptor: *mut sys::daqDataDescriptor = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_build)(self.as_raw() as *mut _, &mut __data_descriptor) };
check(__code, "daqDataDescriptorBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<DataDescriptor>(__data_descriptor as *mut _) })
}
/// Data descriptor builder factory that creates a builder object with no parameters configured.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_createDataDescriptorBuilder()`.
pub fn new() -> Result<DataDescriptorBuilder> {
let mut __obj: *mut sys::daqDataDescriptorBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_createDataDescriptorBuilder)(&mut __obj) };
check(__code, "daqDataDescriptorBuilder_createDataDescriptorBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DataDescriptorBuilder>(__obj as *mut _, "daqDataDescriptorBuilder_createDataDescriptorBuilder") }?)
}
/// Data descriptor copy factory that creates a Data descriptor builder object from a different Data descriptor, copying its parameters.
///
/// # Parameters
/// - `descriptor_to_copy`: The Data descriptor of which configuration should be copied.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_createDataDescriptorBuilderFromExisting()`.
pub fn from_existing(descriptor_to_copy: &DataDescriptor) -> Result<DataDescriptorBuilder> {
let mut __obj: *mut sys::daqDataDescriptorBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_createDataDescriptorBuilderFromExisting)(&mut __obj, descriptor_to_copy.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_createDataDescriptorBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<DataDescriptorBuilder>(__obj as *mut _, "daqDataDescriptorBuilder_createDataDescriptorBuilderFromExisting") }?)
}
/// Gets the list of the descriptor's dimension's.
///
/// # Returns
/// - `dimensions`: The list of dimensions.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getDimensions()`.
pub fn dimensions(&self) -> Result<Vec<Dimension>> {
let mut __dimensions: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getDimensions)(self.as_raw() as *mut _, &mut __dimensions) };
check(__code, "daqDataDescriptorBuilder_getDimensions")?;
Ok(unsafe { crate::marshal::take_list::<Dimension>(__dimensions as *mut _, "daqDataDescriptorBuilder_getDimensions") }?)
}
/// Gets any extra metadata defined by the data descriptor.
///
/// # Returns
/// - `metadata`: Additional metadata of the descriptor as a dictionary.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getMetadata()`.
pub fn metadata(&self) -> Result<std::collections::HashMap<String, String>> {
let mut __metadata: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getMetadata)(self.as_raw() as *mut _, &mut __metadata) };
check(__code, "daqDataDescriptorBuilder_getMetadata")?;
Ok(unsafe { crate::marshal::take_dict::<String, String>(__metadata as *mut _, "daqDataDescriptorBuilder_getMetadata") }?)
}
/// Gets a descriptive name for the signal's value.
///
/// # Returns
/// - `name`: The name of the signal value.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqDataDescriptorBuilder_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the absolute origin of a signal value component.
///
/// # Returns
/// - `origin`: The absolute origin.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getOrigin()`.
pub fn origin(&self) -> Result<String> {
let mut __origin: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getOrigin)(self.as_raw() as *mut _, &mut __origin) };
check(__code, "daqDataDescriptorBuilder_getOrigin")?;
Ok(unsafe { crate::marshal::take_string(__origin) })
}
/// Gets the scaling rule that needs to be applied to explicit/implicit data by readers.
///
/// # Returns
/// - `scaling`: The scaling rule.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getPostScaling()`.
pub fn post_scaling(&self) -> Result<Option<Scaling>> {
let mut __scaling: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getPostScaling)(self.as_raw() as *mut _, &mut __scaling) };
check(__code, "daqDataDescriptorBuilder_getPostScaling")?;
Ok(unsafe { crate::marshal::take_object::<Scaling>(__scaling as *mut _) })
}
/// Gets the Reference Domain Info.
///
/// # Returns
/// - `reference_domain_info`: The Reference Domain Info. If set, gives additional information about the reference domain.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getReferenceDomainInfo()`.
pub fn reference_domain_info(&self) -> Result<Option<ReferenceDomainInfo>> {
let mut __reference_domain_info: *mut sys::daqReferenceDomainInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getReferenceDomainInfo)(self.as_raw() as *mut _, &mut __reference_domain_info) };
check(__code, "daqDataDescriptorBuilder_getReferenceDomainInfo")?;
Ok(unsafe { crate::marshal::take_object::<ReferenceDomainInfo>(__reference_domain_info as *mut _) })
}
/// Gets the value Data rule.
///
/// # Returns
/// - `rule`: The value Data rule.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getRule()`.
pub fn rule(&self) -> Result<Option<DataRule>> {
let mut __rule: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getRule)(self.as_raw() as *mut _, &mut __rule) };
check(__code, "daqDataDescriptorBuilder_getRule")?;
Ok(unsafe { crate::marshal::take_object::<DataRule>(__rule as *mut _) })
}
/// Gets the descriptor's sample type.
///
/// # Returns
/// - `sample_type`: The descriptor's sample type.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getSampleType()`.
pub fn sample_type(&self) -> Result<SampleType> {
let mut __sample_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getSampleType)(self.as_raw() as *mut _, &mut __sample_type) };
check(__code, "daqDataDescriptorBuilder_getSampleType")?;
Ok(crate::marshal::enum_out(SampleType::from_raw(__sample_type), "daqDataDescriptorBuilder_getSampleType")?)
}
/// Gets the fields of the struct, forming a recursive value descriptor definition.
///
/// # Returns
/// - `struct_fields`: The list of data descriptors forming the struct fields.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getStructFields()`.
pub fn struct_fields(&self) -> Result<Vec<DataDescriptor>> {
let mut __struct_fields: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getStructFields)(self.as_raw() as *mut _, &mut __struct_fields) };
check(__code, "daqDataDescriptorBuilder_getStructFields")?;
Ok(unsafe { crate::marshal::take_list::<DataDescriptor>(__struct_fields as *mut _, "daqDataDescriptorBuilder_getStructFields") }?)
}
/// Gets the Resolution which scales the an explicit or implicit value to the physical unit defined in `unit`.
///
/// # Returns
/// - `tick_resolution`: The Resolution.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getTickResolution()`.
pub fn tick_resolution(&self) -> Result<Option<Ratio>> {
let mut __tick_resolution: *mut sys::daqRatio = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getTickResolution)(self.as_raw() as *mut _, &mut __tick_resolution) };
check(__code, "daqDataDescriptorBuilder_getTickResolution")?;
Ok(unsafe { crate::value::take_ratio(__tick_resolution, "daqDataDescriptorBuilder_getTickResolution") }?)
}
/// Gets the unit of the data in a signal's packets.
///
/// # Returns
/// - `unit`: The unit specified by the descriptor.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqDataDescriptorBuilder_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Gets the value range of the data in a signal's packets defining the lowest and highest expected values.
///
/// # Returns
/// - `range`: The value range the signal's data.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_getValueRange()`.
pub fn value_range(&self) -> Result<Option<Range>> {
let mut __range: *mut sys::daqRange = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_getValueRange)(self.as_raw() as *mut _, &mut __range) };
check(__code, "daqDataDescriptorBuilder_getValueRange")?;
Ok(unsafe { crate::marshal::take_object::<Range>(__range as *mut _) })
}
/// Sets the list of the descriptor's dimension's.
///
/// # Parameters
/// - `dimensions`: The list of dimensions. The number of dimensions defines the rank of the signal's data (eg. Vector, Matrix).
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setDimensions()`.
pub fn set_dimensions(&self, dimensions: &[Dimension]) -> Result<()> {
let __dimensions = crate::marshal::list_from_interfaces(dimensions)?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setDimensions)(self.as_raw() as *mut _, __dimensions.as_ptr() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setDimensions")?;
Ok(())
}
/// Sets any extra metadata defined by the data descriptor.
///
/// # Parameters
/// - `metadata`: Additional metadata of the descriptor as a dictionary. All objects in the metadata dictionary must be serializable.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setMetadata()`.
pub fn set_metadata(&self, metadata: impl Into<Value>) -> Result<()> {
let __metadata = crate::value::to_daq(&metadata.into())?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setMetadata)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__metadata) as *mut _) };
check(__code, "daqDataDescriptorBuilder_setMetadata")?;
Ok(())
}
/// Sets a descriptive name for the signal's value.
///
/// # Parameters
/// - `name`: The name of the signal value. When, for example, describing the amplitude values of spectrum data, the name would be `Amplitude`.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setName()`.
pub fn set_name(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setName)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setName")?;
Ok(())
}
/// Sets the absolute origin of a signal value component.
///
/// # Parameters
/// - `origin`: The absolute origin. An origin can be an arbitrary string that determines the starting point of the signal data. All explicit or implicit values are multiplied by the resolution and added to the origin to obtain absolute data instead of relative. Most commonly a time epoch is used, in which case it should be formatted according to the ISO 8601 standard.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setOrigin()`.
pub fn set_origin(&self, origin: &str) -> Result<()> {
let __origin = crate::marshal::make_string(origin)?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setOrigin)(self.as_raw() as *mut _, __origin.as_ptr() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setOrigin")?;
Ok(())
}
/// Sets the scaling rule that needs to be applied to explicit/implicit data by readers.
///
/// # Parameters
/// - `scaling`: The scaling rule. The OutputDataType of the rule matches the value descriptor's sample type. The InputDataType defines the sample type of either the explicit data in packet buffers, or the packet's implicit value's sample type.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setPostScaling()`.
pub fn set_post_scaling(&self, scaling: &Scaling) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setPostScaling)(self.as_raw() as *mut _, scaling.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setPostScaling")?;
Ok(())
}
/// Sets the Reference Domain Info.
///
/// # Parameters
/// - `reference_domain_info`: The Reference Domain Info. If set, gives additional information about the reference domain.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setReferenceDomainInfo()`.
pub fn set_reference_domain_info(&self, reference_domain_info: &ReferenceDomainInfo) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setReferenceDomainInfo)(self.as_raw() as *mut _, reference_domain_info.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setReferenceDomainInfo")?;
Ok(())
}
/// Sets the value Data rule.
///
/// # Parameters
/// - `rule`: The value Data rule. If explicit, the values will be contained in the packet buffer. Otherwise they are calculated using the packet parameter as the input into the rule.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setRule()`.
pub fn set_rule(&self, rule: &DataRule) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setRule)(self.as_raw() as *mut _, rule.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setRule")?;
Ok(())
}
/// Sets the descriptor's sample type.
///
/// # Parameters
/// - `sample_type`: The descriptor's sample type.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setSampleType()`.
pub fn set_sample_type(&self, sample_type: SampleType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setSampleType)(self.as_raw() as *mut _, sample_type as u32) };
check(__code, "daqDataDescriptorBuilder_setSampleType")?;
Ok(())
}
/// Sets the fields of the struct, forming a recursive value descriptor definition.
///
/// # Parameters
/// - `struct_fields`: The list of data descriptors forming the struct fields. Contains a list of value descriptors, defining the data layout: the data described by the first DataDescriptor of the list is at the start, followed by the data described by the second and so on.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setStructFields()`.
pub fn set_struct_fields(&self, struct_fields: &[DataDescriptor]) -> Result<()> {
let __struct_fields = crate::marshal::list_from_interfaces(struct_fields)?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setStructFields)(self.as_raw() as *mut _, __struct_fields.as_ptr() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setStructFields")?;
Ok(())
}
/// Sets the Resolution which scales the an explicit or implicit value to the physical unit defined in `unit`.
///
/// # Parameters
/// - `tick_resolution`: The Resolution.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setTickResolution()`.
pub fn set_tick_resolution(&self, tick_resolution: Ratio) -> Result<()> {
let __tick_resolution = crate::value::ratio_to_ref(tick_resolution)?;
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setTickResolution)(self.as_raw() as *mut _, __tick_resolution.as_ptr() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setTickResolution")?;
Ok(())
}
/// Sets the unit of the data in a signal's packets.
///
/// # Parameters
/// - `unit`: The unit specified by the descriptor.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setUnit()`.
pub fn set_unit(&self, unit: &Unit) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setUnit)(self.as_raw() as *mut _, unit.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setUnit")?;
Ok(())
}
/// Sets the value range of the data in a signal's packets defining the lowest and highest expected values.
///
/// # Parameters
/// - `range`: The value range the signal's data. The range is not enforced by openDAQ.
///
/// Calls the openDAQ C function `daqDataDescriptorBuilder_setValueRange()`.
pub fn set_value_range(&self, range: &Range) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataDescriptorBuilder_setValueRange)(self.as_raw() as *mut _, range.as_raw() as *mut _) };
check(__code, "daqDataDescriptorBuilder_setValueRange")?;
Ok(())
}
}
impl DataDescriptor {
/// Creates a Data Descriptor using Builder
///
/// # Parameters
/// - `builder`: Data Descriptor Builder
///
/// Calls the openDAQ C function `daqDataDescriptor_createDataDescriptorFromBuilder()`.
pub fn from_builder(builder: &DataDescriptorBuilder) -> Result<DataDescriptor> {
let mut __obj: *mut sys::daqDataDescriptor = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_createDataDescriptorFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqDataDescriptor_createDataDescriptorFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DataDescriptor>(__obj as *mut _, "daqDataDescriptor_createDataDescriptorFromBuilder") }?)
}
/// Gets the list of the descriptor's dimension's.
///
/// # Returns
/// - `dimensions`: The list of dimensions. The number of dimensions defines the rank of the signal's data (eg. Vector, Matrix).
///
/// Calls the openDAQ C function `daqDataDescriptor_getDimensions()`.
pub fn dimensions(&self) -> Result<Vec<Dimension>> {
let mut __dimensions: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getDimensions)(self.as_raw() as *mut _, &mut __dimensions) };
check(__code, "daqDataDescriptor_getDimensions")?;
Ok(unsafe { crate::marshal::take_list::<Dimension>(__dimensions as *mut _, "daqDataDescriptor_getDimensions") }?)
}
/// Gets any extra metadata defined by the data descriptor.
///
/// # Returns
/// - `metadata`: Additional metadata of the descriptor as a dictionary. All objects in the metadata dictionary must be key value pairs of \<String, String\>.
///
/// Calls the openDAQ C function `daqDataDescriptor_getMetadata()`.
pub fn metadata(&self) -> Result<std::collections::HashMap<String, String>> {
let mut __metadata: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getMetadata)(self.as_raw() as *mut _, &mut __metadata) };
check(__code, "daqDataDescriptor_getMetadata")?;
Ok(unsafe { crate::marshal::take_dict::<String, String>(__metadata as *mut _, "daqDataDescriptor_getMetadata") }?)
}
/// Gets a descriptive name of the signal value.
///
/// # Returns
/// - `name`: The name of the signal value. When, for example, describing the amplitude values of spectrum data, the name would be `Amplitude`.
///
/// Calls the openDAQ C function `daqDataDescriptor_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqDataDescriptor_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the absolute origin of a signal value component.
///
/// # Returns
/// - `origin`: The absolute origin. An origin can be an arbitrary string that determines the starting point of the signal data. All explicit or implicit values are multiplied by the resolution and added to the origin to obtain absolute data instead of relative. Most commonly a time reference is used, in which case it should be formatted according to the ISO 8601 standard.
///
/// Calls the openDAQ C function `daqDataDescriptor_getOrigin()`.
pub fn origin(&self) -> Result<String> {
let mut __origin: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getOrigin)(self.as_raw() as *mut _, &mut __origin) };
check(__code, "daqDataDescriptor_getOrigin")?;
Ok(unsafe { crate::marshal::take_string(__origin) })
}
/// Calls the openDAQ C function `daqDataDescriptor_getPostScaling()`.
pub fn post_scaling(&self) -> Result<Option<Scaling>> {
let mut __scaling: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getPostScaling)(self.as_raw() as *mut _, &mut __scaling) };
check(__code, "daqDataDescriptor_getPostScaling")?;
Ok(unsafe { crate::marshal::take_object::<Scaling>(__scaling as *mut _) })
}
/// Gets the actual sample size in buffer of one sample in bytes.
///
/// # Returns
/// - `sample_size`: The actual size of one sample in buffer in bytes. The actual size of one sample is calculated on constructor of the data descriptor object. Actual sample size is the sample size that is used in buffer. If the data descriptor includes implicitly generated samples, the actual sample size is less than sample size.
///
/// Calls the openDAQ C function `daqDataDescriptor_getRawSampleSize()`.
pub fn raw_sample_size(&self) -> Result<usize> {
let mut __raw_sample_size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getRawSampleSize)(self.as_raw() as *mut _, &mut __raw_sample_size) };
check(__code, "daqDataDescriptor_getRawSampleSize")?;
Ok(__raw_sample_size)
}
/// Gets the Reference Domain Info.
///
/// # Returns
/// - `reference_domain_info`: The Reference Domain Info. If set, gives additional information about the reference domain.
///
/// Calls the openDAQ C function `daqDataDescriptor_getReferenceDomainInfo()`.
pub fn reference_domain_info(&self) -> Result<Option<ReferenceDomainInfo>> {
let mut __reference_domain_info: *mut sys::daqReferenceDomainInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getReferenceDomainInfo)(self.as_raw() as *mut _, &mut __reference_domain_info) };
check(__code, "daqDataDescriptor_getReferenceDomainInfo")?;
Ok(unsafe { crate::marshal::take_object::<ReferenceDomainInfo>(__reference_domain_info as *mut _) })
}
/// Gets the value Data rule.
///
/// # Returns
/// - `rule`: The value Data rule. If explicit, the values will be contained in the packet buffer. Otherwise they are calculated using the offset packet parameter as the input into the rule.
///
/// Calls the openDAQ C function `daqDataDescriptor_getRule()`.
pub fn rule(&self) -> Result<Option<DataRule>> {
let mut __rule: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getRule)(self.as_raw() as *mut _, &mut __rule) };
check(__code, "daqDataDescriptor_getRule")?;
Ok(unsafe { crate::marshal::take_object::<DataRule>(__rule as *mut _) })
}
/// Gets the size of one sample in bytes.
///
/// # Returns
/// - `sample_size`: The size of one sample in bytes. The size of one sample is calculated on constructor of the data descriptor object.
///
/// Calls the openDAQ C function `daqDataDescriptor_getSampleSize()`.
pub fn sample_size(&self) -> Result<usize> {
let mut __sample_size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getSampleSize)(self.as_raw() as *mut _, &mut __sample_size) };
check(__code, "daqDataDescriptor_getSampleSize")?;
Ok(__sample_size)
}
/// Gets the descriptor's sample type.
///
/// # Returns
/// - `sample_type`: The descriptor's sample type.
///
/// Calls the openDAQ C function `daqDataDescriptor_getSampleType()`.
pub fn sample_type(&self) -> Result<SampleType> {
let mut __sample_type: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getSampleType)(self.as_raw() as *mut _, &mut __sample_type) };
check(__code, "daqDataDescriptor_getSampleType")?;
Ok(crate::marshal::enum_out(SampleType::from_raw(__sample_type), "daqDataDescriptor_getSampleType")?)
}
/// Gets the fields of the struct, forming a recursive value descriptor definition.
///
/// # Returns
/// - `struct_fields`: The list of data descriptors forming the struct fields. Contains a list of value descriptors, defining the data layout: the data described by the first DataDescriptor of the list is at the start, followed by the data described by the second and so on.
///
/// Calls the openDAQ C function `daqDataDescriptor_getStructFields()`.
pub fn struct_fields(&self) -> Result<Vec<DataDescriptor>> {
let mut __struct_fields: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getStructFields)(self.as_raw() as *mut _, &mut __struct_fields) };
check(__code, "daqDataDescriptor_getStructFields")?;
Ok(unsafe { crate::marshal::take_list::<DataDescriptor>(__struct_fields as *mut _, "daqDataDescriptor_getStructFields") }?)
}
/// Gets the Resolution which scales the explicit or implicit value to the physical unit defined in `unit`. It is defined as domain (usually time) between two consecutive ticks.
///
/// # Returns
/// - `tick_resolution`: The Resolution.
///
/// Calls the openDAQ C function `daqDataDescriptor_getTickResolution()`.
pub fn tick_resolution(&self) -> Result<Option<Ratio>> {
let mut __tick_resolution: *mut sys::daqRatio = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getTickResolution)(self.as_raw() as *mut _, &mut __tick_resolution) };
check(__code, "daqDataDescriptor_getTickResolution")?;
Ok(unsafe { crate::value::take_ratio(__tick_resolution, "daqDataDescriptor_getTickResolution") }?)
}
/// Gets the unit of the data in a signal's packets.
///
/// # Returns
/// - `unit`: The unit specified by the descriptor.
///
/// Calls the openDAQ C function `daqDataDescriptor_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqDataDescriptor_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Gets the value range of the data in a signal's packets defining the lowest and highest expected values.
///
/// # Returns
/// - `range`: The value range the signal's data. The range is not enforced by openDAQ.
///
/// Calls the openDAQ C function `daqDataDescriptor_getValueRange()`.
pub fn value_range(&self) -> Result<Option<Range>> {
let mut __range: *mut sys::daqRange = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataDescriptor_getValueRange)(self.as_raw() as *mut _, &mut __range) };
check(__code, "daqDataDescriptor_getValueRange")?;
Ok(unsafe { crate::marshal::take_object::<Range>(__range as *mut _) })
}
}
impl DataPacket {
/// Creates a Data packet with a given descriptor, sample count, memory size of each sample, and an optional packet offset.
///
/// # Parameters
/// - `descriptor`: The descriptor of the signal sending the data.
/// - `sample_count`: The number of samples in the packet.
/// - `offset`: Optional packet offset parameter, used to calculate the data of the packet if the Data rule of the Signal descriptor is not explicit.
///
/// Calls the openDAQ C function `daqDataPacket_createDataPacket()`.
pub fn new(descriptor: &DataDescriptor, sample_count: usize, offset: impl Into<Value>) -> Result<DataPacket> {
let __offset = crate::value::to_daq_number(&offset.into())?;
let mut __obj: *mut sys::daqDataPacket = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_createDataPacket)(&mut __obj, descriptor.as_raw() as *mut _, sample_count, crate::value::opt_ref_ptr(&__offset) as *mut _) };
check(__code, "daqDataPacket_createDataPacket")?;
Ok(unsafe { crate::marshal::require_object::<DataPacket>(__obj as *mut _, "daqDataPacket_createDataPacket") }?)
}
/// Creates a Data packet with a given descriptor, sample count, memory size of each sample, and an optional implicit value.
///
/// # Parameters
/// - `domain_packet`: The Data packet carrying domain data.
/// - `descriptor`: The descriptor of the signal sending the data.
/// - `sample_count`: The number of samples in the packet.
/// - `offset`: Optional packet offset parameter, used to calculate the data of the packet if the Data rule of the Signal descriptor is not explicit.
///
/// Calls the openDAQ C function `daqDataPacket_createDataPacketWithDomain()`.
pub fn with_domain(domain_packet: &DataPacket, descriptor: &DataDescriptor, sample_count: usize, offset: impl Into<Value>) -> Result<DataPacket> {
let __offset = crate::value::to_daq_number(&offset.into())?;
let mut __obj: *mut sys::daqDataPacket = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_createDataPacketWithDomain)(&mut __obj, domain_packet.as_raw() as *mut _, descriptor.as_raw() as *mut _, sample_count, crate::value::opt_ref_ptr(&__offset) as *mut _) };
check(__code, "daqDataPacket_createDataPacketWithDomain")?;
Ok(unsafe { crate::marshal::require_object::<DataPacket>(__obj as *mut _, "daqDataPacket_createDataPacketWithDomain") }?)
}
/// Gets the signal descriptor of the signal that sent the packet at the time of sending.
///
/// # Returns
/// - `descriptor`: The signal descriptor.
///
/// Calls the openDAQ C function `daqDataPacket_getDataDescriptor()`.
pub fn data_descriptor(&self) -> Result<Option<DataDescriptor>> {
let mut __descriptor: *mut sys::daqDataDescriptor = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getDataDescriptor)(self.as_raw() as *mut _, &mut __descriptor) };
check(__code, "daqDataPacket_getDataDescriptor")?;
Ok(unsafe { crate::marshal::take_object::<DataDescriptor>(__descriptor as *mut _) })
}
/// Gets size of data buffer in bytes.
///
/// # Returns
/// - `data_size`: the size of data buffer in bytes.
///
/// Calls the openDAQ C function `daqDataPacket_getDataSize()`.
pub fn data_size(&self) -> Result<usize> {
let mut __data_size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDataPacket_getDataSize)(self.as_raw() as *mut _, &mut __data_size) };
check(__code, "daqDataPacket_getDataSize")?;
Ok(__data_size)
}
/// Gets the associated domain Data packet.
///
/// # Returns
/// - `packet`: The domain data packet.
///
/// Calls the openDAQ C function `daqDataPacket_getDomainPacket()`.
pub fn domain_packet(&self) -> Result<Option<DataPacket>> {
let mut __packet: *mut sys::daqDataPacket = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getDomainPacket)(self.as_raw() as *mut _, &mut __packet) };
check(__code, "daqDataPacket_getDomainPacket")?;
Ok(unsafe { crate::marshal::take_object::<DataPacket>(__packet as *mut _) })
}
/// Gets the data packet last value.
///
/// # Parameters
/// - `type_manager`: Optional ITypeManager value can be provided to enable getLastValue for IStruct. If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IString if the type is String, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension. For String type signals in binary data packets, the string data must be encoded as UTF-8 strings. The string length is determined by the sample size, and the string does not need to be null-terminated. The method extracts the string value from the packet data and returns it as an IString object.
///
/// # Returns
/// - `value`: The IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
///
/// Calls the openDAQ C function `daqDataPacket_getLastValue()`.
pub fn last_value(&self) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getLastValue)(self.as_raw() as *mut _, &mut __value, std::ptr::null_mut()) };
check(__code, "daqDataPacket_getLastValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqDataPacket_getLastValue") }?)
}
/// Gets the data packet last value.
///
/// # Parameters
/// - `type_manager`: Optional ITypeManager value can be provided to enable getLastValue for IStruct. If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IString if the type is String, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension. For String type signals in binary data packets, the string data must be encoded as UTF-8 strings. The string length is determined by the sample size, and the string does not need to be null-terminated. The method extracts the string value from the packet data and returns it as an IString object.
///
/// # Returns
/// - `value`: The IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
///
/// Calls the openDAQ C function `daqDataPacket_getLastValue()`.
pub fn last_value_with(&self, type_manager: Option<&TypeManager>) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getLastValue)(self.as_raw() as *mut _, &mut __value, type_manager.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqDataPacket_getLastValue")?;
Ok(unsafe { crate::value::take_value(__value, "daqDataPacket_getLastValue") }?)
}
/// Gets current packet offset. This offset is later applied to the data rule used by a signal to calculate actual data value. This value is usually a time or other domain value. Packet offset is particularly useful when one wants to transfer a gap in otherwise equidistant samples. If we have a linear data rule, defined by equation f(x) = k*x + n, then the data value will be calculated by the equation g(x) = offset + f(x).
///
/// # Returns
/// - `offset`: The packet offset
///
/// Calls the openDAQ C function `daqDataPacket_getOffset()`.
pub fn offset(&self) -> Result<Option<f64>> {
let mut __offset: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getOffset)(self.as_raw() as *mut _, &mut __offset) };
check(__code, "daqDataPacket_getOffset")?;
Ok(unsafe { crate::value::take_number(__offset, "daqDataPacket_getOffset") }?)
}
/// Gets the unique packet id.
///
/// # Returns
/// - `packet_id`: The packet unique id. The packet id is automatically created on packet construction.
///
/// Calls the openDAQ C function `daqDataPacket_getPacketId()`.
pub fn packet_id(&self) -> Result<i64> {
let mut __packet_id: i64 = Default::default();
let __code = unsafe { (crate::sys::api().daqDataPacket_getPacketId)(self.as_raw() as *mut _, &mut __packet_id) };
check(__code, "daqDataPacket_getPacketId")?;
Ok(__packet_id)
}
/// Gets size of raw data buffer in bytes.
///
/// # Returns
/// - `data_size`: the size of raw data buffer in bytes. Raw data size is 0 if signal's data rule is implicit.
///
/// Calls the openDAQ C function `daqDataPacket_getRawDataSize()`.
pub fn raw_data_size(&self) -> Result<usize> {
let mut __raw_data_size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDataPacket_getRawDataSize)(self.as_raw() as *mut _, &mut __raw_data_size) };
check(__code, "daqDataPacket_getRawDataSize")?;
Ok(__raw_data_size)
}
/// Gets the number of samples in the packet.
///
/// # Returns
/// - `sample_count`: the number of samples.
///
/// Calls the openDAQ C function `daqDataPacket_getSampleCount()`.
pub fn sample_count(&self) -> Result<usize> {
let mut __sample_count: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDataPacket_getSampleCount)(self.as_raw() as *mut _, &mut __sample_count) };
check(__code, "daqDataPacket_getSampleCount")?;
Ok(__sample_count)
}
/// Gets the data packet value at the specified index.
///
/// # Parameters
/// - `index`: Index of the sample to obtain.
/// - `type_manager`: Optional ITypeManager value can be provided to enable getLastValue for IStruct. If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IString if the type is String, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension. For String type signals in binary data packets, the string data must be encoded as UTF-8 strings. The string length is determined by the sample size, and the string does not need to be null-terminated. The method extracts the string value from the packet data and returns it as an IString object.
///
/// # Returns
/// - `value`: The IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
///
/// Calls the openDAQ C function `daqDataPacket_getValueByIndex()`.
pub fn value_by_index(&self, index: usize) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getValueByIndex)(self.as_raw() as *mut _, &mut __value, index, std::ptr::null_mut()) };
check(__code, "daqDataPacket_getValueByIndex")?;
Ok(unsafe { crate::value::take_value(__value, "daqDataPacket_getValueByIndex") }?)
}
/// Gets the data packet value at the specified index.
///
/// # Parameters
/// - `index`: Index of the sample to obtain.
/// - `type_manager`: Optional ITypeManager value can be provided to enable getLastValue for IStruct. If a value is assigned, it can be cast based on the signal description to IFloat if the type is Float32 or Float64, to IInteger if the type is Int8 through Int64 or UInt8 through UInt64, to IComplexNumber if the type is ComplexFloat32 or ComplexFloat64, to IRange if the type is RangeInt64, to IString if the type is String, to IStruct if the type is Struct, and to IList of the forementioned types if there is exactly one dimension. For String type signals in binary data packets, the string data must be encoded as UTF-8 strings. The string length is determined by the sample size, and the string does not need to be null-terminated. The method extracts the string value from the packet data and returns it as an IString object.
///
/// # Returns
/// - `value`: The IBaseObject value can be a nullptr if there is no value, or if the data type is not supported by the function.
///
/// Calls the openDAQ C function `daqDataPacket_getValueByIndex()`.
pub fn value_by_index_with(&self, index: usize, type_manager: Option<&TypeManager>) -> Result<Value> {
let mut __value: *mut sys::daqBaseObject = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataPacket_getValueByIndex)(self.as_raw() as *mut _, &mut __value, index, type_manager.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _)) };
check(__code, "daqDataPacket_getValueByIndex")?;
Ok(unsafe { crate::value::take_value(__value, "daqDataPacket_getValueByIndex") }?)
}
}
impl DataRuleBuilder {
/// Adds a string-object pair parameter to the Dictionary of Data rule parameters.
///
/// # Parameters
/// - `name`: The string-type name of the parameter.
/// - `parameter`: The object-type parameter.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_addParameter()`.
pub fn add_parameter(&self, name: &str, parameter: impl Into<Value>) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __parameter = crate::value::to_daq(¶meter.into())?;
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_addParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__parameter) as *mut _) };
check(__code, "daqDataRuleBuilder_addParameter")?;
Ok(())
}
/// Builds and returns a Data rule object using the currently set values of the Builder.
///
/// # Returns
/// - `data_rule`: The built Data rule.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_build()`.
pub fn build(&self) -> Result<Option<DataRule>> {
let mut __data_rule: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_build)(self.as_raw() as *mut _, &mut __data_rule) };
check(__code, "daqDataRuleBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<DataRule>(__data_rule as *mut _) })
}
/// Creates a Data rule builder with no parameters.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_createDataRuleBuilder()`.
pub fn new() -> Result<DataRuleBuilder> {
let mut __obj: *mut sys::daqDataRuleBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_createDataRuleBuilder)(&mut __obj) };
check(__code, "daqDataRuleBuilder_createDataRuleBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DataRuleBuilder>(__obj as *mut _, "daqDataRuleBuilder_createDataRuleBuilder") }?)
}
/// Data rule copy factory that creates a configurable Data rule builder object from a possibly non-configurable Data rule.
///
/// # Parameters
/// - `rule_to_copy`: The rule of which configuration should be copied.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_createDataRuleBuilderFromExisting()`.
pub fn from_existing(rule_to_copy: &DataRule) -> Result<DataRuleBuilder> {
let mut __obj: *mut sys::daqDataRuleBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_createDataRuleBuilderFromExisting)(&mut __obj, rule_to_copy.as_raw() as *mut _) };
check(__code, "daqDataRuleBuilder_createDataRuleBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<DataRuleBuilder>(__obj as *mut _, "daqDataRuleBuilder_createDataRuleBuilderFromExisting") }?)
}
/// Gets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Returns
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqDataRuleBuilder_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqDataRuleBuilder_getParameters") }?)
}
/// Gets the type of the data rule.
///
/// # Returns
/// - `type`: The type of the data rule.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_getType()`.
pub fn type_(&self) -> Result<DataRuleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqDataRuleBuilder_getType")?;
Ok(crate::marshal::enum_out(DataRuleType::from_raw(__type_), "daqDataRuleBuilder_getType")?)
}
/// Removes the parameter with the given name from the Dictionary of Data rule parameters.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_removeParameter()`.
pub fn remove_parameter(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_removeParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqDataRuleBuilder_removeParameter")?;
Ok(())
}
/// Sets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Parameters
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_setParameters()`.
pub fn set_parameters(&self, parameters: impl Into<Value>) -> Result<()> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_setParameters)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqDataRuleBuilder_setParameters")?;
Ok(())
}
/// Sets the type of the data rule.
///
/// # Parameters
/// - `type`: The type of the data rule.
///
/// Calls the openDAQ C function `daqDataRuleBuilder_setType()`.
pub fn set_type(&self, type_: DataRuleType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDataRuleBuilder_setType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqDataRuleBuilder_setType")?;
Ok(())
}
}
impl DataRule {
/// Creates a DataRule with a Constant rule type configuration.
///
/// Calls the openDAQ C function `daqDataRule_createConstantDataRule()`.
pub fn constant() -> Result<DataRule> {
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createConstantDataRule)(&mut __obj) };
check(__code, "daqDataRule_createConstantDataRule")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createConstantDataRule") }?)
}
/// Creates a DataRule with an Explicit rule type configuration and parameters.
///
/// # Parameters
/// - `rule_type`: .
/// - `parameters`: .
///
/// Calls the openDAQ C function `daqDataRule_createDataRule()`.
pub fn new(rule_type: DataRuleType, parameters: impl Into<Value>) -> Result<DataRule> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createDataRule)(&mut __obj, rule_type as u32, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqDataRule_createDataRule")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createDataRule") }?)
}
/// Creates a DataRulePtr from Builder.
///
/// # Parameters
/// - `builder`: DataRule Builder
///
/// Calls the openDAQ C function `daqDataRule_createDataRuleFromBuilder()`.
pub fn from_builder(builder: &DataRuleBuilder) -> Result<DataRule> {
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createDataRuleFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqDataRule_createDataRuleFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createDataRuleFromBuilder") }?)
}
/// Creates a DataRule with an Explicit rule type configuration and no parameters.
///
/// Calls the openDAQ C function `daqDataRule_createExplicitDataRule()`.
pub fn explicit() -> Result<DataRule> {
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createExplicitDataRule)(&mut __obj) };
check(__code, "daqDataRule_createExplicitDataRule")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createExplicitDataRule") }?)
}
/// Creates a DataRule with an Explicit rule type configuration two optional parameters.
///
/// # Parameters
/// - `min_expected_delta`: The lowest expected distance between two samples.
/// - `max_expected_delta`: The highest expected distance between two samples. Most often used for domain signals to specify estimates on how close together/far apart two subsequent samples might be.
///
/// Calls the openDAQ C function `daqDataRule_createExplicitDomainDataRule()`.
pub fn explicit_domain(min_expected_delta: impl Into<Value>, max_expected_delta: impl Into<Value>) -> Result<DataRule> {
let __min_expected_delta = crate::value::to_daq_number(&min_expected_delta.into())?;
let __max_expected_delta = crate::value::to_daq_number(&max_expected_delta.into())?;
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createExplicitDomainDataRule)(&mut __obj, crate::value::opt_ref_ptr(&__min_expected_delta) as *mut _, crate::value::opt_ref_ptr(&__max_expected_delta) as *mut _) };
check(__code, "daqDataRule_createExplicitDomainDataRule")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createExplicitDomainDataRule") }?)
}
/// Creates a DataRule with a Linear rule type configuration.
///
/// # Parameters
/// - `delta`: Coefficient by which the input data is to be multiplied.
/// - `start`: Constant that is added to the \<em\>scale * value\</em\> multiplication result. The scale and offset are stored within the `parameters` member of the Rule object with the scale being at the first position of the list, and the offset at the second.
///
/// Calls the openDAQ C function `daqDataRule_createLinearDataRule()`.
pub fn linear(delta: impl Into<Value>, start: impl Into<Value>) -> Result<DataRule> {
let __delta = crate::value::to_daq_number(&delta.into())?;
let __start = crate::value::to_daq_number(&start.into())?;
let mut __obj: *mut sys::daqDataRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_createLinearDataRule)(&mut __obj, crate::value::opt_ref_ptr(&__delta) as *mut _, crate::value::opt_ref_ptr(&__start) as *mut _) };
check(__code, "daqDataRule_createLinearDataRule")?;
Ok(unsafe { crate::marshal::require_object::<DataRule>(__obj as *mut _, "daqDataRule_createLinearDataRule") }?)
}
/// Gets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Returns
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDataRule_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDataRule_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqDataRule_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqDataRule_getParameters") }?)
}
/// Gets the type of the data rule.
///
/// # Returns
/// - `type`: The type of the data rule.
///
/// Calls the openDAQ C function `daqDataRule_getType()`.
pub fn type_(&self) -> Result<DataRuleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDataRule_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqDataRule_getType")?;
Ok(crate::marshal::enum_out(DataRuleType::from_raw(__type_), "daqDataRule_getType")?)
}
}
impl DimensionBuilder {
/// Builds and returns a Dimension object using the currently set values of the Builder.
///
/// # Returns
/// - `dimension`: The built Dimension.
///
/// Calls the openDAQ C function `daqDimensionBuilder_build()`.
pub fn build(&self) -> Result<Option<Dimension>> {
let mut __dimension: *mut sys::daqDimension = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_build)(self.as_raw() as *mut _, &mut __dimension) };
check(__code, "daqDimensionBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Dimension>(__dimension as *mut _) })
}
/// Creates a Dimension builder object with no configuration parameters.
///
/// Calls the openDAQ C function `daqDimensionBuilder_createDimensionBuilder()`.
pub fn new() -> Result<DimensionBuilder> {
let mut __obj: *mut sys::daqDimensionBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_createDimensionBuilder)(&mut __obj) };
check(__code, "daqDimensionBuilder_createDimensionBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DimensionBuilder>(__obj as *mut _, "daqDimensionBuilder_createDimensionBuilder") }?)
}
/// Creates a builder copy of the dimension object passed as parameter.
///
/// # Parameters
/// - `dimension_to_copy`: The dimension object to be copied.
///
/// Calls the openDAQ C function `daqDimensionBuilder_createDimensionBuilderFromExisting()`.
pub fn from_existing(dimension_to_copy: &Dimension) -> Result<DimensionBuilder> {
let mut __obj: *mut sys::daqDimensionBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_createDimensionBuilderFromExisting)(&mut __obj, dimension_to_copy.as_raw() as *mut _) };
check(__code, "daqDimensionBuilder_createDimensionBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<DimensionBuilder>(__obj as *mut _, "daqDimensionBuilder_createDimensionBuilderFromExisting") }?)
}
/// Gets the name of the dimension.
///
/// # Returns
/// - `name`: The name of the dimension.
///
/// Calls the openDAQ C function `daqDimensionBuilder_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqDimensionBuilder_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the rule that defines the labels and size of the dimension.
///
/// # Returns
/// - `rule`: The dimension rule.
///
/// Calls the openDAQ C function `daqDimensionBuilder_getRule()`.
pub fn rule(&self) -> Result<Option<DimensionRule>> {
let mut __rule: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_getRule)(self.as_raw() as *mut _, &mut __rule) };
check(__code, "daqDimensionBuilder_getRule")?;
Ok(unsafe { crate::marshal::take_object::<DimensionRule>(__rule as *mut _) })
}
/// Gets the unit of the dimension's labels.
///
/// # Returns
/// - `unit`: The unit of the dimension.
///
/// Calls the openDAQ C function `daqDimensionBuilder_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqDimensionBuilder_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
/// Sets the name of the dimension.
///
/// # Parameters
/// - `name`: The name of the dimension. The name that best describes the dimension, in example "Frequency" for spectrum data.
///
/// Calls the openDAQ C function `daqDimensionBuilder_setName()`.
pub fn set_name(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_setName)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqDimensionBuilder_setName")?;
Ok(())
}
/// Sets the rule that defines the labels and size of the dimension.
///
/// # Parameters
/// - `rule`: The dimension rule.
///
/// # Errors
/// - `OPENDAQ_ERR_FROZEN`: if the dimension object is frozen. The rule takes as input the index of data value in a sample and produces a label associated with that index.
///
/// Calls the openDAQ C function `daqDimensionBuilder_setRule()`.
pub fn set_rule(&self, rule: &DimensionRule) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_setRule)(self.as_raw() as *mut _, rule.as_raw() as *mut _) };
check(__code, "daqDimensionBuilder_setRule")?;
Ok(())
}
/// Sets the unit of the dimension's labels.
///
/// # Parameters
/// - `unit`: The unit of the dimension.
///
/// Calls the openDAQ C function `daqDimensionBuilder_setUnit()`.
pub fn set_unit(&self, unit: &Unit) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDimensionBuilder_setUnit)(self.as_raw() as *mut _, unit.as_raw() as *mut _) };
check(__code, "daqDimensionBuilder_setUnit")?;
Ok(())
}
}
impl DimensionRuleBuilder {
/// Adds a string-object pair parameter to the Dictionary of Dimension rule parameters.
///
/// # Parameters
/// - `name`: The string-type name of the parameter.
/// - `parameter`: The object-type parameter.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_addParameter()`.
pub fn add_parameter(&self, name: &str, parameter: impl Into<Value>) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __parameter = crate::value::to_daq(¶meter.into())?;
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_addParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__parameter) as *mut _) };
check(__code, "daqDimensionRuleBuilder_addParameter")?;
Ok(())
}
/// Builds and returns a Dimension rule object using the currently set values of the Builder.
///
/// # Returns
/// - `data_rule`: The built Dimension rule.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_build()`.
pub fn build(&self) -> Result<Option<DimensionRule>> {
let mut __dimension_rule: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_build)(self.as_raw() as *mut _, &mut __dimension_rule) };
check(__code, "daqDimensionRuleBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<DimensionRule>(__dimension_rule as *mut _) })
}
/// Creates a DataRuleConfig with no parameters.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_createDimensionRuleBuilder()`.
pub fn new() -> Result<DimensionRuleBuilder> {
let mut __obj: *mut sys::daqDimensionRuleBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_createDimensionRuleBuilder)(&mut __obj) };
check(__code, "daqDimensionRuleBuilder_createDimensionRuleBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRuleBuilder>(__obj as *mut _, "daqDimensionRuleBuilder_createDimensionRuleBuilder") }?)
}
/// Dimension rule copy factory that creates a builder Rule object from a possibly non-configurable Rule.
///
/// # Parameters
/// - `rule_to_copy`: The rule of which configuration should be copied.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_createDimensionRuleBuilderFromExisting()`.
pub fn from_existing(rule_to_copy: &DimensionRule) -> Result<DimensionRuleBuilder> {
let mut __obj: *mut sys::daqDimensionRuleBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_createDimensionRuleBuilderFromExisting)(&mut __obj, rule_to_copy.as_raw() as *mut _) };
check(__code, "daqDimensionRuleBuilder_createDimensionRuleBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRuleBuilder>(__obj as *mut _, "daqDimensionRuleBuilder_createDimensionRuleBuilderFromExisting") }?)
}
/// Gets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Returns
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqDimensionRuleBuilder_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqDimensionRuleBuilder_getParameters") }?)
}
/// Gets the type of the dimension rule.
///
/// # Returns
/// - `type`: The type of the dimension rule.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_getType()`.
pub fn type_(&self) -> Result<DimensionRuleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqDimensionRuleBuilder_getType")?;
Ok(crate::marshal::enum_out(DimensionRuleType::from_raw(__type_), "daqDimensionRuleBuilder_getType")?)
}
/// Removes the parameter with the given name from the Dictionary of Dimension rule parameters.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_removeParameter()`.
pub fn remove_parameter(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_removeParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqDimensionRuleBuilder_removeParameter")?;
Ok(())
}
/// Sets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Parameters
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_setParameters()`.
pub fn set_parameters(&self, parameters: impl Into<Value>) -> Result<()> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_setParameters)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqDimensionRuleBuilder_setParameters")?;
Ok(())
}
/// Sets the type of the dimension rule. Rule parameters must be configured to match the requirements of the rule type.
///
/// # Parameters
/// - `type`: The type of the dimension rule. The required rule parameters are as follows: - Linear: `delta`, `start`, and `size` number parameters. Calculated as: \<em\>index * delta + start\</em\> for `size` number of elements. - Logarithmic: `delta`, `start`, `base`, and `size` number parameters. Calculated as: \<em\>base ^ (index * delta + start)\</em\> for `size` number of elements. - List: `list` parameter. The list contains all dimension labels.
///
/// Calls the openDAQ C function `daqDimensionRuleBuilder_setType()`.
pub fn set_type(&self, type_: DimensionRuleType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqDimensionRuleBuilder_setType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqDimensionRuleBuilder_setType")?;
Ok(())
}
}
impl DimensionRule {
/// Creates a Rule with a given type and parameters.
///
/// # Parameters
/// - `type`: The type of the Dimension rule
/// - `parameters`: Tha parameters of the Dimension rule
///
/// Calls the openDAQ C function `daqDimensionRule_createDimensionRule()`.
pub fn new(type_: DimensionRuleType, parameters: impl Into<Value>) -> Result<DimensionRule> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let mut __obj: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_createDimensionRule)(&mut __obj, type_ as u32, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqDimensionRule_createDimensionRule")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRule>(__obj as *mut _, "daqDimensionRule_createDimensionRule") }?)
}
/// Creates a DimensionRule using Builder
///
/// # Parameters
/// - `builder`: DimensionRule Builder
///
/// Calls the openDAQ C function `daqDimensionRule_createDimensionRuleFromBuilder()`.
pub fn from_builder(builder: &DimensionRuleBuilder) -> Result<DimensionRule> {
let mut __obj: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_createDimensionRuleFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqDimensionRule_createDimensionRuleFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRule>(__obj as *mut _, "daqDimensionRule_createDimensionRuleFromBuilder") }?)
}
/// Creates a Rule with a Linear rule type configuration.
///
/// # Parameters
/// - `delta`: Coefficient by which the input data is to be multiplied.
/// - `start`: Constant that is added to the \<em\>scale * value\</em\> multiplication result.
/// - `size`: The size of the dimension described by the rule The scale and offset are stored within the `parameters` member of the Rule object with the scale being at the first position of the list, and the offset at the second.
///
/// Calls the openDAQ C function `daqDimensionRule_createLinearDimensionRule()`.
pub fn linear(delta: impl Into<Value>, start: impl Into<Value>, size: usize) -> Result<DimensionRule> {
let __delta = crate::value::to_daq_number(&delta.into())?;
let __start = crate::value::to_daq_number(&start.into())?;
let mut __obj: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_createLinearDimensionRule)(&mut __obj, crate::value::opt_ref_ptr(&__delta) as *mut _, crate::value::opt_ref_ptr(&__start) as *mut _, size) };
check(__code, "daqDimensionRule_createLinearDimensionRule")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRule>(__obj as *mut _, "daqDimensionRule_createLinearDimensionRule") }?)
}
/// Creates a Rule with a List rule type configuration.
///
/// # Parameters
/// - `list`: The list of dimension labels. The list is stored within the `parameters` member of the Rule object.
///
/// Calls the openDAQ C function `daqDimensionRule_createListDimensionRule()`.
pub fn list(list: impl Into<Value>) -> Result<DimensionRule> {
let __list = crate::value::to_daq(&list.into())?;
let mut __obj: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_createListDimensionRule)(&mut __obj, crate::value::opt_ref_ptr(&__list) as *mut _) };
check(__code, "daqDimensionRule_createListDimensionRule")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRule>(__obj as *mut _, "daqDimensionRule_createListDimensionRule") }?)
}
/// Creates a Rule with a Logarithmic rule type configuration.
///
/// # Parameters
/// - `delta`: Coefficient by which the input data is to be multiplied.
/// - `start`: Constant that is added to the \<em\>scale * value\</em\> multiplication result.
/// - `base`: The base of the logarithm.
/// - `size`: The size of the dimension described by the rule.
///
/// Calls the openDAQ C function `daqDimensionRule_createLogarithmicDimensionRule()`.
pub fn logarithmic(delta: impl Into<Value>, start: impl Into<Value>, base: impl Into<Value>, size: usize) -> Result<DimensionRule> {
let __delta = crate::value::to_daq_number(&delta.into())?;
let __start = crate::value::to_daq_number(&start.into())?;
let __base = crate::value::to_daq_number(&base.into())?;
let mut __obj: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_createLogarithmicDimensionRule)(&mut __obj, crate::value::opt_ref_ptr(&__delta) as *mut _, crate::value::opt_ref_ptr(&__start) as *mut _, crate::value::opt_ref_ptr(&__base) as *mut _, size) };
check(__code, "daqDimensionRule_createLogarithmicDimensionRule")?;
Ok(unsafe { crate::marshal::require_object::<DimensionRule>(__obj as *mut _, "daqDimensionRule_createLogarithmicDimensionRule") }?)
}
/// Gets a dictionary of string-object key-value pairs representing the parameters used to evaluate the rule.
///
/// # Returns
/// - `parameters`: The dictionary containing the rule parameter members.
///
/// Calls the openDAQ C function `daqDimensionRule_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimensionRule_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqDimensionRule_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqDimensionRule_getParameters") }?)
}
/// Gets the type of the dimension rule.
///
/// # Returns
/// - `type`: The type of the dimension rule.
///
/// Calls the openDAQ C function `daqDimensionRule_getType()`.
pub fn type_(&self) -> Result<DimensionRuleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqDimensionRule_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqDimensionRule_getType")?;
Ok(crate::marshal::enum_out(DimensionRuleType::from_raw(__type_), "daqDimensionRule_getType")?)
}
}
impl Dimension {
/// Creates a dimension object of which labels and size are defined via rule.
///
/// # Parameters
/// - `rule`: The rule via which labels are defined.
/// - `unit`: The unit of the dimension's labels.
/// - `name`: The name the dimension.
///
/// Calls the openDAQ C function `daqDimension_createDimension()`.
pub fn new(rule: &DimensionRule, unit: &Unit, name: &str) -> Result<Dimension> {
let __name = crate::marshal::make_string(name)?;
let mut __obj: *mut sys::daqDimension = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_createDimension)(&mut __obj, rule.as_raw() as *mut _, unit.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqDimension_createDimension")?;
Ok(unsafe { crate::marshal::require_object::<Dimension>(__obj as *mut _, "daqDimension_createDimension") }?)
}
/// Creates a Dimension using Builder
///
/// # Parameters
/// - `builder`: Dimension Builder
///
/// Calls the openDAQ C function `daqDimension_createDimensionFromBuilder()`.
pub fn from_builder(builder: &DimensionBuilder) -> Result<Dimension> {
let mut __obj: *mut sys::daqDimension = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_createDimensionFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqDimension_createDimensionFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<Dimension>(__obj as *mut _, "daqDimension_createDimensionFromBuilder") }?)
}
/// Gets a list of labels that defines the dimension.
///
/// # Returns
/// - `labels`: The list of labels. The list is obtained from the dimension rule parameters by parsing and evaluating the parameters in conjunction with the rule type.
///
/// Calls the openDAQ C function `daqDimension_getLabels()`.
pub fn labels(&self) -> Result<Vec<Value>> {
let mut __labels: *mut sys::daqList = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_getLabels)(self.as_raw() as *mut _, &mut __labels) };
check(__code, "daqDimension_getLabels")?;
Ok(unsafe { crate::marshal::take_list::<Value>(__labels as *mut _, "daqDimension_getLabels") }?)
}
/// Gets the name of the dimension.
///
/// # Returns
/// - `name`: The name of the dimension. The name that best describes the dimension, in example "Frequency" for spectrum data.
///
/// Calls the openDAQ C function `daqDimension_getName()`.
pub fn name(&self) -> Result<String> {
let mut __name: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_getName)(self.as_raw() as *mut _, &mut __name) };
check(__code, "daqDimension_getName")?;
Ok(unsafe { crate::marshal::take_string(__name) })
}
/// Gets the rule that defines the labels and size of the dimension.
///
/// # Returns
/// - `rule`: The dimension rule. The rule takes as input the index of data value in a sample and produces a label associated with that index.
///
/// Calls the openDAQ C function `daqDimension_getRule()`.
pub fn rule(&self) -> Result<Option<DimensionRule>> {
let mut __rule: *mut sys::daqDimensionRule = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_getRule)(self.as_raw() as *mut _, &mut __rule) };
check(__code, "daqDimension_getRule")?;
Ok(unsafe { crate::marshal::take_object::<DimensionRule>(__rule as *mut _) })
}
/// Gets the size of the dimension.
///
/// # Returns
/// - `size`: The size of the dimension. The size is obtained from the dimension rule parameters - either from the `size` parameter, or the count of elements in the `list` parameter.
///
/// Calls the openDAQ C function `daqDimension_getSize()`.
pub fn size(&self) -> Result<usize> {
let mut __size: usize = Default::default();
let __code = unsafe { (crate::sys::api().daqDimension_getSize)(self.as_raw() as *mut _, &mut __size) };
check(__code, "daqDimension_getSize")?;
Ok(__size)
}
/// Gets the unit of the dimension's labels.
///
/// # Returns
/// - `unit`: The unit of the dimension.
///
/// Calls the openDAQ C function `daqDimension_getUnit()`.
pub fn unit(&self) -> Result<Option<Unit>> {
let mut __unit: *mut sys::daqUnit = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqDimension_getUnit)(self.as_raw() as *mut _, &mut __unit) };
check(__code, "daqDimension_getUnit")?;
Ok(unsafe { crate::marshal::take_object::<Unit>(__unit as *mut _) })
}
}
impl InputPortPrivate {
/// Connects the signal to the input port, forming a Connection.
///
/// # Parameters
/// - `signal`: The signal to be connected to the input port. On connect, an event packet is enqueued in the connection. This method schedules the `onPacketReceived` notification instead of invoking it on the same thread.
///
/// Calls the openDAQ C function `daqInputPortPrivate_connectSignalSchedulerNotification()`.
pub fn connect_signal_scheduler_notification(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInputPortPrivate_connectSignalSchedulerNotification)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqInputPortPrivate_connectSignalSchedulerNotification")?;
Ok(())
}
/// Disconnects the signal without notification to the signal.
///
/// Calls the openDAQ C function `daqInputPortPrivate_disconnectWithoutSignalNotification()`.
pub fn disconnect_without_signal_notification(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqInputPortPrivate_disconnectWithoutSignalNotification)(self.as_raw() as *mut _) };
check(__code, "daqInputPortPrivate_disconnectWithoutSignalNotification")?;
Ok(())
}
}
impl PacketDestructCallback {
/// Called when packet is destroyed.
///
/// Calls the openDAQ C function `daqPacketDestructCallback_onPacketDestroyed()`.
pub fn on_packet_destroyed(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqPacketDestructCallback_onPacketDestroyed)(self.as_raw() as *mut _) };
check(__code, "daqPacketDestructCallback_onPacketDestroyed")?;
Ok(())
}
}
impl Range {
/// Creates a range object with specified low and high boundary values.
///
/// # Parameters
/// - `low_value`: The lower boundary of the range.
/// - `high_value`: The upper boundary of the range.
///
/// # Errors
/// - `OPENDAQ_ERR_RANGE_BOUNDARIES_INVALID`: if lowValue \> highValue.
///
/// Calls the openDAQ C function `daqRange_createRange()`.
pub fn new(low_value: impl Into<Value>, high_value: impl Into<Value>) -> Result<Range> {
let __low_value = crate::value::to_daq_number(&low_value.into())?;
let __high_value = crate::value::to_daq_number(&high_value.into())?;
let mut __obj: *mut sys::daqRange = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqRange_createRange)(&mut __obj, crate::value::opt_ref_ptr(&__low_value) as *mut _, crate::value::opt_ref_ptr(&__high_value) as *mut _) };
check(__code, "daqRange_createRange")?;
Ok(unsafe { crate::marshal::require_object::<Range>(__obj as *mut _, "daqRange_createRange") }?)
}
/// Gets the upper boundary value of the range.
///
/// Calls the openDAQ C function `daqRange_getHighValue()`.
pub fn high_value(&self) -> Result<Option<f64>> {
let mut __value: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqRange_getHighValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqRange_getHighValue")?;
Ok(unsafe { crate::value::take_number(__value, "daqRange_getHighValue") }?)
}
/// Gets the lower boundary value of the range.
///
/// Calls the openDAQ C function `daqRange_getLowValue()`.
pub fn low_value(&self) -> Result<Option<f64>> {
let mut __value: *mut sys::daqNumber = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqRange_getLowValue)(self.as_raw() as *mut _, &mut __value) };
check(__code, "daqRange_getLowValue")?;
Ok(unsafe { crate::value::take_number(__value, "daqRange_getLowValue") }?)
}
}
impl ReferenceDomainInfoBuilder {
/// Builds and returns a Reference Domain Info object using the currently set values of the Builder.
///
/// # Returns
/// - `reference_domain_info`: The built Reference Domain Info.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_build()`.
pub fn build(&self) -> Result<Option<ReferenceDomainInfo>> {
let mut __reference_domain_info: *mut sys::daqReferenceDomainInfo = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_build)(self.as_raw() as *mut _, &mut __reference_domain_info) };
check(__code, "daqReferenceDomainInfoBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<ReferenceDomainInfo>(__reference_domain_info as *mut _) })
}
/// Reference Domain Info builder factory that creates a builder object with no parameters configured.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilder()`.
pub fn new() -> Result<ReferenceDomainInfoBuilder> {
let mut __obj: *mut sys::daqReferenceDomainInfoBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilder)(&mut __obj) };
check(__code, "daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilder")?;
Ok(unsafe { crate::marshal::require_object::<ReferenceDomainInfoBuilder>(__obj as *mut _, "daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilder") }?)
}
/// Reference Domain Info copy factory that creates a Reference Domain Info builder object from a different Reference Domain Info, copying its parameters.
///
/// # Parameters
/// - `reference_domain_info_to_copy`: The Reference Domain Info of which configuration should be copied.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilderFromExisting()`.
pub fn from_existing(reference_domain_info_to_copy: &ReferenceDomainInfo) -> Result<ReferenceDomainInfoBuilder> {
let mut __obj: *mut sys::daqReferenceDomainInfoBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilderFromExisting)(&mut __obj, reference_domain_info_to_copy.as_raw() as *mut _) };
check(__code, "daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<ReferenceDomainInfoBuilder>(__obj as *mut _, "daqReferenceDomainInfoBuilder_createReferenceDomainInfoBuilderFromExisting") }?)
}
/// Gets the Reference Domain ID.
///
/// # Returns
/// - `reference_domain_id`: The Reference Domain ID. If set, gives the common identifier of one domain group. Signals with the same Reference Domain ID share a common synchronization source (all the signals in a group either come from the same device or are synchronized using a protocol, such as PTP, NTP, IRIG, etc.). Those signals can always be read together, implying that a Multi Reader can be used to read the signals if their sampling rates are compatible.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_getReferenceDomainId()`.
pub fn reference_domain_id(&self) -> Result<String> {
let mut __reference_domain_id: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_getReferenceDomainId)(self.as_raw() as *mut _, &mut __reference_domain_id) };
check(__code, "daqReferenceDomainInfoBuilder_getReferenceDomainId")?;
Ok(unsafe { crate::marshal::take_string(__reference_domain_id) })
}
/// Gets the Reference Domain Offset.
///
/// # Returns
/// - `reference_domain_offset`: The Reference Domain Offset. If set, denotes the offset in ticks that must be added to the domain values of the signal for them to be equal to that of the sync source. The sync source will always have an offset of 0. This offset is changed only if the sync source changes and should be kept at 0 otherwise, allowing clients to differentiate between data loss and resync events. Any device can choose to always keep the offset at 0, representing changes in the offset in the domain packet values instead. This implementation prevents clients from differentiating between errors (data loss) and resync events. Additionally, if the offset is not configured, clients have no way of detecting a resync event in the case of asynchronous signals.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_getReferenceDomainOffset()`.
pub fn reference_domain_offset(&self) -> Result<Option<i64>> {
let mut __reference_domain_offset: *mut sys::daqInteger = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_getReferenceDomainOffset)(self.as_raw() as *mut _, &mut __reference_domain_offset) };
check(__code, "daqReferenceDomainInfoBuilder_getReferenceDomainOffset")?;
Ok(unsafe { crate::value::take_boxed_int(__reference_domain_offset, "daqReferenceDomainInfoBuilder_getReferenceDomainOffset") }?)
}
/// Gets the value that indicates the Reference Time Source.
///
/// # Returns
/// - `reference_time_protocol`: The value that indicates the Reference Time Source. If not set to Unknown, the domain quantity is “time”, and the timestamps are absolute according to the chosen time standard. The possible values are Gps, Tai, and Utc. This field is used to determine if two signals with different Domain IDs can be read together. Signals that have configured a Reference Time Source are trusted to have absolute time stamps that correlate to the chosen time standard (eg. two separate PTP networks, both driven through GPS can be read together, as their absolute time is the same).
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_getReferenceTimeProtocol()`.
pub fn reference_time_protocol(&self) -> Result<TimeProtocol> {
let mut __reference_time_protocol: u32 = 0;
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_getReferenceTimeProtocol)(self.as_raw() as *mut _, &mut __reference_time_protocol) };
check(__code, "daqReferenceDomainInfoBuilder_getReferenceTimeProtocol")?;
Ok(crate::marshal::enum_out(TimeProtocol::from_raw(__reference_time_protocol), "daqReferenceDomainInfoBuilder_getReferenceTimeProtocol")?)
}
/// Gets the value that indicates if offset is used.
///
/// # Returns
/// - `uses_offset`: The value that indicates if offset is used. If False, a device will contain time jumps due to resync in the domain signal data.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_getUsesOffset()`.
pub fn uses_offset(&self) -> Result<UsesOffset> {
let mut __uses_offset: u32 = 0;
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_getUsesOffset)(self.as_raw() as *mut _, &mut __uses_offset) };
check(__code, "daqReferenceDomainInfoBuilder_getUsesOffset")?;
Ok(crate::marshal::enum_out(UsesOffset::from_raw(__uses_offset), "daqReferenceDomainInfoBuilder_getUsesOffset")?)
}
/// Sets the Reference Domain ID.
///
/// # Parameters
/// - `reference_domain_id`: The Reference Domain ID. If set, gives the common identifier of one domain group. Signals with the same Reference Domain ID share a common synchronization source (all the signals in a group either come from the same device or are synchronized using a protocol, such as PTP, NTP, IRIG, etc.). Those signals can always be read together, implying that a Multi Reader can be used to read the signals if their sampling rates are compatible.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_setReferenceDomainId()`.
pub fn set_reference_domain_id(&self, reference_domain_id: &str) -> Result<()> {
let __reference_domain_id = crate::marshal::make_string(reference_domain_id)?;
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_setReferenceDomainId)(self.as_raw() as *mut _, __reference_domain_id.as_ptr() as *mut _) };
check(__code, "daqReferenceDomainInfoBuilder_setReferenceDomainId")?;
Ok(())
}
/// Sets the Reference Domain Offset.
///
/// # Parameters
/// - `reference_domain_offset`: The Reference Domain Offset. If set, denotes the offset in ticks that must be added to the domain values of the signal for them to be equal to that of the sync source. The sync source will always have an offset of 0. This offset is changed only if the sync source changes and should be kept at 0 otherwise, allowing clients to differentiate between data loss and resync events. Any device can choose to always keep the offset at 0, representing changes in the offset in the domain packet values instead. This implementation prevents clients from differentiating between errors (data loss) and resync events. Additionally, if the offset is not configured, clients have no way of detecting a resync event in the case of asynchronous signals.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_setReferenceDomainOffset()`.
pub fn set_reference_domain_offset(&self, reference_domain_offset: i64) -> Result<()> {
let __reference_domain_offset = crate::value::int_to_ref(reference_domain_offset)?;
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_setReferenceDomainOffset)(self.as_raw() as *mut _, __reference_domain_offset.as_ptr() as *mut _) };
check(__code, "daqReferenceDomainInfoBuilder_setReferenceDomainOffset")?;
Ok(())
}
/// Sets the value that indicates the Reference Time Source.
///
/// # Parameters
/// - `reference_time_protocol`: The value that indicates the Reference Time Source. If not set to Unknown, the domain quantity is “time”, and the timestamps are absolute according to the chosen time standard. The possible values are Gps, Tai, and Utc. This field is used to determine if two signals with different Domain IDs can be read together. Signals that have configured a Reference Time Source are trusted to have absolute time stamps that correlate to the chosen time standard (eg. two separate PTP networks, both driven through GPS can be read together, as their absolute time is the same).
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_setReferenceTimeProtocol()`.
pub fn set_reference_time_protocol(&self, reference_time_protocol: TimeProtocol) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_setReferenceTimeProtocol)(self.as_raw() as *mut _, reference_time_protocol as u32) };
check(__code, "daqReferenceDomainInfoBuilder_setReferenceTimeProtocol")?;
Ok(())
}
/// Sets the value that indicates if offset is used.
///
/// # Returns
/// - `uses_offset`: The value that indicates if offset is used. If False, a device will contain time jumps due to resync in the domain signal data.
///
/// Calls the openDAQ C function `daqReferenceDomainInfoBuilder_setUsesOffset()`.
pub fn set_uses_offset(&self, uses_offset: UsesOffset) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqReferenceDomainInfoBuilder_setUsesOffset)(self.as_raw() as *mut _, uses_offset as u32) };
check(__code, "daqReferenceDomainInfoBuilder_setUsesOffset")?;
Ok(())
}
}
impl ReusableDataPacket {
/// Calls the openDAQ C function `daqReusableDataPacket_reuse()`.
pub fn reuse(&self, new_descriptor: &DataDescriptor, new_sample_count: usize, new_offset: impl Into<Value>, new_domain_packet: &DataPacket, can_realloc_memory: bool) -> Result<bool> {
let __new_offset = crate::value::to_daq_number(&new_offset.into())?;
let mut __success: u8 = 0;
let __code = unsafe { (crate::sys::api().daqReusableDataPacket_reuse)(self.as_raw() as *mut _, new_descriptor.as_raw() as *mut _, new_sample_count, crate::value::opt_ref_ptr(&__new_offset) as *mut _, new_domain_packet.as_raw() as *mut _, u8::from(can_realloc_memory), &mut __success) };
check(__code, "daqReusableDataPacket_reuse")?;
Ok(__success != 0)
}
}
impl RulePrivate {
/// Checks whether the parameters are valid and returns an appropriate error code if not.
///
/// # Errors
/// - `OPENDAQ_ERR_INVALID_PARAMETERS`: If the parameters are invalid for the specific rule type.
///
/// Calls the openDAQ C function `daqRulePrivate_verifyParameters()`.
pub fn verify_parameters(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqRulePrivate_verifyParameters)(self.as_raw() as *mut _) };
check(__code, "daqRulePrivate_verifyParameters")?;
Ok(())
}
}
impl ScalingBuilder {
/// Adds a string-object pair parameter to the Dictionary of Scaling parameters.
///
/// # Parameters
/// - `name`: The string-type name of the parameter.
/// - `parameter`: The object-type parameter.
///
/// Calls the openDAQ C function `daqScalingBuilder_addParameter()`.
pub fn add_parameter(&self, name: &str, parameter: impl Into<Value>) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __parameter = crate::value::to_daq(¶meter.into())?;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_addParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _, crate::value::opt_ref_ptr(&__parameter) as *mut _) };
check(__code, "daqScalingBuilder_addParameter")?;
Ok(())
}
/// Builds and returns a Scaling object using the currently set values of the Builder.
///
/// # Returns
/// - `scaling`: The built Scaling object.
///
/// Calls the openDAQ C function `daqScalingBuilder_build()`.
pub fn build(&self) -> Result<Option<Scaling>> {
let mut __scaling: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScalingBuilder_build)(self.as_raw() as *mut _, &mut __scaling) };
check(__code, "daqScalingBuilder_build")?;
Ok(unsafe { crate::marshal::take_object::<Scaling>(__scaling as *mut _) })
}
/// Creates a Scaling builder object with no parameters configured.
///
/// Calls the openDAQ C function `daqScalingBuilder_createScalingBuilder()`.
pub fn new() -> Result<ScalingBuilder> {
let mut __obj: *mut sys::daqScalingBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScalingBuilder_createScalingBuilder)(&mut __obj) };
check(__code, "daqScalingBuilder_createScalingBuilder")?;
Ok(unsafe { crate::marshal::require_object::<ScalingBuilder>(__obj as *mut _, "daqScalingBuilder_createScalingBuilder") }?)
}
/// Scaling builder copy factory that creates a configurable Scaling object from a non-configurable one.
///
/// # Parameters
/// - `scaling_to_copy`: The scaling of which configuration should be copied.
///
/// Calls the openDAQ C function `daqScalingBuilder_createScalingBuilderFromExisting()`.
pub fn from_existing(scaling_to_copy: &Scaling) -> Result<ScalingBuilder> {
let mut __obj: *mut sys::daqScalingBuilder = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScalingBuilder_createScalingBuilderFromExisting)(&mut __obj, scaling_to_copy.as_raw() as *mut _) };
check(__code, "daqScalingBuilder_createScalingBuilderFromExisting")?;
Ok(unsafe { crate::marshal::require_object::<ScalingBuilder>(__obj as *mut _, "daqScalingBuilder_createScalingBuilderFromExisting") }?)
}
/// Gets the scaling's input data type.
///
/// # Returns
/// - `type`: The input data type.
///
/// Calls the openDAQ C function `daqScalingBuilder_getInputDataType()`.
pub fn input_data_type(&self) -> Result<SampleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_getInputDataType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScalingBuilder_getInputDataType")?;
Ok(crate::marshal::enum_out(SampleType::from_raw(__type_), "daqScalingBuilder_getInputDataType")?)
}
/// Gets the scaling's output data type.
///
/// # Returns
/// - `type`: The output data type
///
/// Calls the openDAQ C function `daqScalingBuilder_getOutputDataType()`.
pub fn output_data_type(&self) -> Result<ScaledSampleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_getOutputDataType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScalingBuilder_getOutputDataType")?;
Ok(crate::marshal::enum_out(ScaledSampleType::from_raw(__type_), "daqScalingBuilder_getOutputDataType")?)
}
/// Gets the list of parameters that are used to calculate the scaling in conjunction with the input data.
///
/// # Returns
/// - `parameters`: The list of parameters. All elements are Number types.
///
/// Calls the openDAQ C function `daqScalingBuilder_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScalingBuilder_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqScalingBuilder_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqScalingBuilder_getParameters") }?)
}
/// Gets the type of the scaling that determines how the scaling parameters should be interpreted and how the scaling should be calculated.
///
/// # Returns
/// - `type`: The type of the scaling.
///
/// Calls the openDAQ C function `daqScalingBuilder_getScalingType()`.
pub fn scaling_type(&self) -> Result<ScalingType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_getScalingType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScalingBuilder_getScalingType")?;
Ok(crate::marshal::enum_out(ScalingType::from_raw(__type_), "daqScalingBuilder_getScalingType")?)
}
/// Removes the parameter with the given name from the Dictionary of Scaling parameters.
///
/// Calls the openDAQ C function `daqScalingBuilder_removeParameter()`.
pub fn remove_parameter(&self, name: &str) -> Result<()> {
let __name = crate::marshal::make_string(name)?;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_removeParameter)(self.as_raw() as *mut _, __name.as_ptr() as *mut _) };
check(__code, "daqScalingBuilder_removeParameter")?;
Ok(())
}
/// Sets the scaling's input data type.
///
/// # Parameters
/// - `type`: The input data type. The input data type corresponds to the raw data passed through the signal path in data packets.
///
/// Calls the openDAQ C function `daqScalingBuilder_setInputDataType()`.
pub fn set_input_data_type(&self, type_: SampleType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqScalingBuilder_setInputDataType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqScalingBuilder_setInputDataType")?;
Ok(())
}
/// Sets the scaling's output data type.
///
/// # Parameters
/// - `type`: The output data type The output data type corresponds to the type specified in the value descriptor of a signal, and is the type in which said signal's data should be read in after having the scaling applied to it.
///
/// Calls the openDAQ C function `daqScalingBuilder_setOutputDataType()`.
pub fn set_output_data_type(&self, type_: ScaledSampleType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqScalingBuilder_setOutputDataType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqScalingBuilder_setOutputDataType")?;
Ok(())
}
/// Gets the list of parameters that are used to calculate the scaling in conjunction with the input data.
///
/// # Parameters
/// - `parameters`: The list of parameters. All elements are Number types.
///
/// # Errors
/// - `OPENDAQ_ERR_FROZEN`: if the object is frozen.
///
/// Calls the openDAQ C function `daqScalingBuilder_setParameters()`.
pub fn set_parameters(&self, parameters: impl Into<Value>) -> Result<()> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let __code = unsafe { (crate::sys::api().daqScalingBuilder_setParameters)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqScalingBuilder_setParameters")?;
Ok(())
}
/// Sets the type of the scaling that determines how the scaling parameters should be interpreted and how the scaling should be calculated.
///
/// # Parameters
/// - `type`: The type of the scaling.
///
/// Calls the openDAQ C function `daqScalingBuilder_setScalingType()`.
pub fn set_scaling_type(&self, type_: ScalingType) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqScalingBuilder_setScalingType)(self.as_raw() as *mut _, type_ as u32) };
check(__code, "daqScalingBuilder_setScalingType")?;
Ok(())
}
}
impl Scaling {
/// Creates a Scaling with a Linear scaling type configuration. The returned Scaling object is already frozen.
///
/// # Parameters
/// - `scale`: Coefficient by which the input data is to be multiplied.
/// - `offset`: Constant that is added to the \<em\>scale * value\</em\> multiplication result.
/// - `input_data_type`: The scaling's input data type.
/// - `output_data_type`: The scaling's output data type.
///
/// Calls the openDAQ C function `daqScaling_createLinearScaling()`.
pub fn linear(scale: impl Into<Value>, offset: impl Into<Value>, input_data_type: SampleType, output_data_type: ScaledSampleType) -> Result<Scaling> {
let __scale = crate::value::to_daq_number(&scale.into())?;
let __offset = crate::value::to_daq_number(&offset.into())?;
let mut __obj: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScaling_createLinearScaling)(&mut __obj, crate::value::opt_ref_ptr(&__scale) as *mut _, crate::value::opt_ref_ptr(&__offset) as *mut _, input_data_type as u32, output_data_type as u32) };
check(__code, "daqScaling_createLinearScaling")?;
Ok(unsafe { crate::marshal::require_object::<Scaling>(__obj as *mut _, "daqScaling_createLinearScaling") }?)
}
/// Creates a Scaling object with given input/output types, Scaling type and parameters.
///
/// # Parameters
/// - `input_data_type`: The type of input data expected by the rule.
/// - `output_data_type`: The data type output by the rule after calculation.
/// - `scaling_type`: The type of the scaling.
/// - `parameters`: Tha parameters of the Dimension rule.
///
/// Calls the openDAQ C function `daqScaling_createScaling()`.
pub fn new(input_data_type: SampleType, output_data_type: ScaledSampleType, scaling_type: ScalingType, parameters: impl Into<Value>) -> Result<Scaling> {
let __parameters = crate::value::to_daq(¶meters.into())?;
let mut __obj: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScaling_createScaling)(&mut __obj, input_data_type as u32, output_data_type as u32, scaling_type as u32, crate::value::opt_ref_ptr(&__parameters) as *mut _) };
check(__code, "daqScaling_createScaling")?;
Ok(unsafe { crate::marshal::require_object::<Scaling>(__obj as *mut _, "daqScaling_createScaling") }?)
}
/// Creates a Scaling object from Builder
///
/// # Parameters
/// - `builder`: Scaling Builder
///
/// Calls the openDAQ C function `daqScaling_createScalingFromBuilder()`.
pub fn from_builder(builder: &ScalingBuilder) -> Result<Scaling> {
let mut __obj: *mut sys::daqScaling = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScaling_createScalingFromBuilder)(&mut __obj, builder.as_raw() as *mut _) };
check(__code, "daqScaling_createScalingFromBuilder")?;
Ok(unsafe { crate::marshal::require_object::<Scaling>(__obj as *mut _, "daqScaling_createScalingFromBuilder") }?)
}
/// Gets the scaling's input data type.
///
/// # Returns
/// - `type`: The input data type The input data type corresponds to the raw values passed through the signal path in data packets.
///
/// Calls the openDAQ C function `daqScaling_getInputSampleType()`.
pub fn input_sample_type(&self) -> Result<SampleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScaling_getInputSampleType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScaling_getInputSampleType")?;
Ok(crate::marshal::enum_out(SampleType::from_raw(__type_), "daqScaling_getInputSampleType")?)
}
/// Gets the scaling's output data type.
///
/// # Returns
/// - `type`: The output data type The output data type corresponds to the sample type specified in the value descriptor of a signal, and is the type in which said signal's data should be read in after having the scaling applied to it.
///
/// Calls the openDAQ C function `daqScaling_getOutputSampleType()`.
pub fn output_sample_type(&self) -> Result<ScaledSampleType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScaling_getOutputSampleType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScaling_getOutputSampleType")?;
Ok(crate::marshal::enum_out(ScaledSampleType::from_raw(__type_), "daqScaling_getOutputSampleType")?)
}
/// Gets the dictionary of parameters that are used to calculate the scaling in conjunction with the input data.
///
/// # Returns
/// - `parameters`: The dictionary of parameters.
///
/// Calls the openDAQ C function `daqScaling_getParameters()`.
pub fn parameters(&self) -> Result<std::collections::HashMap<String, Value>> {
let mut __parameters: *mut sys::daqDict = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqScaling_getParameters)(self.as_raw() as *mut _, &mut __parameters) };
check(__code, "daqScaling_getParameters")?;
Ok(unsafe { crate::marshal::take_dict::<String, Value>(__parameters as *mut _, "daqScaling_getParameters") }?)
}
/// Gets the type of the scaling that determines how the scaling parameters should be interpreted and how the scaling should be calculated.
///
/// # Returns
/// - `type`: The type of the scaling.
///
/// Calls the openDAQ C function `daqScaling_getType()`.
pub fn type_(&self) -> Result<ScalingType> {
let mut __type_: u32 = 0;
let __code = unsafe { (crate::sys::api().daqScaling_getType)(self.as_raw() as *mut _, &mut __type_) };
check(__code, "daqScaling_getType")?;
Ok(crate::marshal::enum_out(ScalingType::from_raw(__type_), "daqScaling_getType")?)
}
}
impl SignalConfig {
/// Adds a related signal to the list of related signals.
///
/// # Parameters
/// - `signal`: The signal to be added.
///
/// # Errors
/// - `OPENDAQ_ERR_DUPLICATEITEM`: if the signal is already present in the list.
///
/// Calls the openDAQ C function `daqSignalConfig_addRelatedSignal()`.
pub fn add_related_signal(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_addRelatedSignal)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqSignalConfig_addRelatedSignal")?;
Ok(())
}
/// Clears the list of related signals.
///
/// Calls the openDAQ C function `daqSignalConfig_clearRelatedSignals()`.
pub fn clear_related_signals(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_clearRelatedSignals)(self.as_raw() as *mut _) };
check(__code, "daqSignalConfig_clearRelatedSignals")?;
Ok(())
}
/// Calls the openDAQ C function `daqSignalConfig_createSignal()`.
pub fn signal(context: &Context, parent: Option<&Component>, local_id: &str, class_name: Option<&str>) -> Result<SignalConfig> {
let __local_id = crate::marshal::make_string(local_id)?;
let __class_name = match class_name { Some(s) => Some(crate::marshal::make_string(s)?), None => None };
let mut __obj: *mut sys::daqSignalConfig = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSignalConfig_createSignal)(&mut __obj, context.as_raw() as *mut _, parent.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _), __local_id.as_ptr() as *mut _, __class_name.as_ref().map_or(std::ptr::null_mut(), |r| r.as_ptr()) as *mut _) };
check(__code, "daqSignalConfig_createSignal")?;
Ok(unsafe { crate::marshal::require_object::<SignalConfig>(__obj as *mut _, "daqSignalConfig_createSignal") }?)
}
/// Calls the openDAQ C function `daqSignalConfig_createSignalWithDescriptor()`.
pub fn with_descriptor(context: &Context, descriptor: &DataDescriptor, parent: Option<&Component>, local_id: &str, class_name: Option<&str>) -> Result<SignalConfig> {
let __local_id = crate::marshal::make_string(local_id)?;
let __class_name = match class_name { Some(s) => Some(crate::marshal::make_string(s)?), None => None };
let mut __obj: *mut sys::daqSignalConfig = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSignalConfig_createSignalWithDescriptor)(&mut __obj, context.as_raw() as *mut _, descriptor.as_raw() as *mut _, parent.map_or(std::ptr::null_mut(), |o| o.as_raw() as *mut _), __local_id.as_ptr() as *mut _, __class_name.as_ref().map_or(std::ptr::null_mut(), |r| r.as_ptr()) as *mut _) };
check(__code, "daqSignalConfig_createSignalWithDescriptor")?;
Ok(unsafe { crate::marshal::require_object::<SignalConfig>(__obj as *mut _, "daqSignalConfig_createSignalWithDescriptor") }?)
}
/// Removes a signal from the list of related signal.
///
/// # Parameters
/// - `signal`: The signal to be removed.
///
/// # Errors
/// - `OPENDAQ_ERR_NOTFOUND`: if the signal is not part of the list.
///
/// Calls the openDAQ C function `daqSignalConfig_removeRelatedSignal()`.
pub fn remove_related_signal(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_removeRelatedSignal)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqSignalConfig_removeRelatedSignal")?;
Ok(())
}
/// Sends a packet through all connections of the signal.
///
/// # Parameters
/// - `packet`: The packet to be sent.
///
/// Calls the openDAQ C function `daqSignalConfig_sendPacket()`.
pub fn send_packet(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_sendPacket)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqSignalConfig_sendPacket")?;
Ok(())
}
/// Sends a packet through all connections of the signal. Ownership of the packet is transfered.
///
/// # Parameters
/// - `packet`: The packet to be sent. After calling the method, the packet should not be touched again. The ownership of the packet is taken by underlying connections and it could be destroyed before the function returns.
///
/// Calls the openDAQ C function `daqSignalConfig_sendPacketAndStealRef()`.
pub fn send_packet_and_steal_ref(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_sendPacketAndStealRef)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqSignalConfig_sendPacketAndStealRef")?;
Ok(())
}
/// Sends multiple packets through all connections of the signal.
///
/// # Parameters
/// - `packets`: The packets to be sent. Sending multiple packets creates a single notification to input port.
///
/// Calls the openDAQ C function `daqSignalConfig_sendPackets()`.
pub fn send_packets(&self, packets: &[Packet]) -> Result<()> {
let __packets = crate::marshal::list_from_interfaces(packets)?;
let __code = unsafe { (crate::sys::api().daqSignalConfig_sendPackets)(self.as_raw() as *mut _, __packets.as_ptr() as *mut _) };
check(__code, "daqSignalConfig_sendPackets")?;
Ok(())
}
/// Sends multiple packets through all connections of the signal. Ownership of the packets is transfered.
///
/// # Parameters
/// - `packets`: The packets to be sent. After calling the method, the packets should not be touched again. The ownership of the packets is taken by underlying connections and they could be destroyed before the function returns.
///
/// Calls the openDAQ C function `daqSignalConfig_sendPacketsAndStealRef()`.
pub fn send_packets_and_steal_ref(&self, packets: &[Packet]) -> Result<()> {
let __packets = crate::marshal::list_from_interfaces(packets)?;
let __code = unsafe { (crate::sys::api().daqSignalConfig_sendPacketsAndStealRef)(self.as_raw() as *mut _, __packets.as_ptr() as *mut _) };
check(__code, "daqSignalConfig_sendPacketsAndStealRef")?;
Ok(())
}
/// Sets the data descriptor.
///
/// # Parameters
/// - `descriptor`: The data descriptor. Setting the data descriptor triggers a Descriptor changed event packet to be sent to all connections of the signal. If the signal is a domain signal of another, that signal also sends a Descriptor changed event to all its connections.
///
/// Calls the openDAQ C function `daqSignalConfig_setDescriptor()`.
pub fn set_descriptor(&self, descriptor: &DataDescriptor) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_setDescriptor)(self.as_raw() as *mut _, descriptor.as_raw() as *mut _) };
check(__code, "daqSignalConfig_setDescriptor")?;
Ok(())
}
/// Sets the domain signal reference.
///
/// # Parameters
/// - `signal`: The domain signal. Setting a new domain signal triggers a Descriptor changed event packet to be sent to all connections of the signal.
///
/// Calls the openDAQ C function `daqSignalConfig_setDomainSignal()`.
pub fn set_domain_signal(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalConfig_setDomainSignal)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqSignalConfig_setDomainSignal")?;
Ok(())
}
/// Sets the last value of the signal.
///
/// # Parameters
/// - `last_value`: The lastValue. This method is used to manually set the last value of the signal. Useful when automatic calculation of last value is disabled, usually due to performance reasons.
///
/// Calls the openDAQ C function `daqSignalConfig_setLastValue()`.
pub fn set_last_value(&self, last_value: impl Into<Value>) -> Result<()> {
let __last_value = crate::value::to_daq(&last_value.into())?;
let __code = unsafe { (crate::sys::api().daqSignalConfig_setLastValue)(self.as_raw() as *mut _, crate::value::opt_ref_ptr(&__last_value) as *mut _) };
check(__code, "daqSignalConfig_setLastValue")?;
Ok(())
}
/// Sets the list of related signals.
///
/// # Parameters
/// - `signals`: The list of related signals.
///
/// Calls the openDAQ C function `daqSignalConfig_setRelatedSignals()`.
pub fn set_related_signals(&self, signals: &[Signal]) -> Result<()> {
let __signals = crate::marshal::list_from_interfaces(signals)?;
let __code = unsafe { (crate::sys::api().daqSignalConfig_setRelatedSignals)(self.as_raw() as *mut _, __signals.as_ptr() as *mut _) };
check(__code, "daqSignalConfig_setRelatedSignals")?;
Ok(())
}
}
impl SignalEvents {
/// Notifies the signal that it is no longer being used as a domain signal by the signal passed as the function argument.
///
/// # Parameters
/// - `signal`: The callee signal on which the domain signal reference has been removed.
///
/// Calls the openDAQ C function `daqSignalEvents_domainSignalReferenceRemoved()`.
pub fn domain_signal_reference_removed(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalEvents_domainSignalReferenceRemoved)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqSignalEvents_domainSignalReferenceRemoved")?;
Ok(())
}
/// Notifies the signal that it is being used as a domain signal by the signal passed as the function argument.
///
/// # Parameters
/// - `signal`: The callee signal on which the domain signal reference has been set.
///
/// Calls the openDAQ C function `daqSignalEvents_domainSignalReferenceSet()`.
pub fn domain_signal_reference_set(&self, signal: &Signal) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalEvents_domainSignalReferenceSet)(self.as_raw() as *mut _, signal.as_raw() as *mut _) };
check(__code, "daqSignalEvents_domainSignalReferenceSet")?;
Ok(())
}
/// Notifies the signal that it has been connected to an input port forming a new connection.
///
/// # Parameters
/// - `connection`: The formed connection. The data descriptor of the signal is enqueued on the connection, triggering the `onPacketReceived` callback on the same thread.
///
/// Calls the openDAQ C function `daqSignalEvents_listenerConnected()`.
pub fn listener_connected(&self, connection: &Connection) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalEvents_listenerConnected)(self.as_raw() as *mut _, connection.as_raw() as *mut _) };
check(__code, "daqSignalEvents_listenerConnected")?;
Ok(())
}
/// Notifies the signal that it has been connected to an input port forming a new connection.
///
/// # Parameters
/// - `connection`: The formed connection. The data descriptor of the signal is enqueued on the connection, scheduling the `onPacketReceived` callback.
///
/// Calls the openDAQ C function `daqSignalEvents_listenerConnectedScheduled()`.
pub fn listener_connected_scheduled(&self, connection: &Connection) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalEvents_listenerConnectedScheduled)(self.as_raw() as *mut _, connection.as_raw() as *mut _) };
check(__code, "daqSignalEvents_listenerConnectedScheduled")?;
Ok(())
}
/// Notifies the signal that it has been disconnected from an input port with the given connection.
///
/// # Parameters
/// - `connection`: The connection that was broken.
///
/// Calls the openDAQ C function `daqSignalEvents_listenerDisconnected()`.
pub fn listener_disconnected(&self, connection: &Connection) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalEvents_listenerDisconnected)(self.as_raw() as *mut _, connection.as_raw() as *mut _) };
check(__code, "daqSignalEvents_listenerDisconnected")?;
Ok(())
}
}
impl SignalPrivate {
/// Sets the domain signal to null without notifying the domain signal
///
/// Calls the openDAQ C function `daqSignalPrivate_clearDomainSignalWithoutNotification()`.
pub fn clear_domain_signal_without_notification(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalPrivate_clearDomainSignalWithoutNotification)(self.as_raw() as *mut _) };
check(__code, "daqSignalPrivate_clearDomainSignalWithoutNotification")?;
Ok(())
}
/// Enable or disable keeping last data packet which is using by Signal method `getLastValue`
///
/// # Parameters
/// - `enabled`: Option for enabling method getLastValue
///
/// Calls the openDAQ C function `daqSignalPrivate_enableKeepLastValue()`.
pub fn enable_keep_last_value(&self, enabled: bool) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalPrivate_enableKeepLastValue)(self.as_raw() as *mut _, u8::from(enabled)) };
check(__code, "daqSignalPrivate_enableKeepLastValue")?;
Ok(())
}
/// Returns True if last value calculation is enabled on the signal.
///
/// # Returns
/// - `keep_last_value`: True if enabled.
///
/// Calls the openDAQ C function `daqSignalPrivate_getKeepLastValue()`.
pub fn keep_last_value(&self) -> Result<bool> {
let mut __keep_last_value: u8 = 0;
let __code = unsafe { (crate::sys::api().daqSignalPrivate_getKeepLastValue)(self.as_raw() as *mut _, &mut __keep_last_value) };
check(__code, "daqSignalPrivate_getKeepLastValue")?;
Ok(__keep_last_value != 0)
}
/// Gets the signal serilized id. In local device the serilized id matached the signal global id. For remote id it is the signal id in the remote device.
///
/// # Returns
/// - `serialize_id`: The signal serilized id.
///
/// Calls the openDAQ C function `daqSignalPrivate_getSignalSerializeId()`.
pub fn signal_serialize_id(&self) -> Result<String> {
let mut __serialize_id: *mut sys::daqString = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqSignalPrivate_getSignalSerializeId)(self.as_raw() as *mut _, &mut __serialize_id) };
check(__code, "daqSignalPrivate_getSignalSerializeId")?;
Ok(unsafe { crate::marshal::take_string(__serialize_id) })
}
/// Sends a packet through all connections of the signal, acquiring a recursive lock instead of an acquisition lock.
///
/// # Parameters
/// - `packet`: The packet to be sent.
///
/// Calls the openDAQ C function `daqSignalPrivate_sendPacketRecursiveLock()`.
pub fn send_packet_recursive_lock(&self, packet: &Packet) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqSignalPrivate_sendPacketRecursiveLock)(self.as_raw() as *mut _, packet.as_raw() as *mut _) };
check(__code, "daqSignalPrivate_sendPacketRecursiveLock")?;
Ok(())
}
}