opendaq 0.1.0

Safe Rust bindings for openDAQ, the open-source data acquisition SDK
Documentation
// 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;

/// Interface representing a Synchronization Component in a Test & Measurement system. A SynchronizationComponent ensures synchronization among measurement devices in the system. It can act as a sync source and/or as a sync output, with each component having one sync input and 0 to n sync outputs.
/// SynchronizationComponents are configured via interfaces, which can include PTP, IRIQ, GPS,
/// and CLK sync interfaces, among others.
/// @note Every SynchronizationComponent has at least one interface. Only one interface can be set
/// as an input, while others can be used as sync outputs to synchronize other devices.
/// The configuration of these interfaces and the reading of their status is defined in Part 4.
/// @note Depending on the setup, some interfaces may be switched off, and some interfaces may
/// act as sync sources or outputs.
/// @note A CLK interface can be used to let a device run in Fre-Run mode, where the device
/// syncs internally to an internal quartz.
/// Wrapper over the openDAQ `daqSyncComponentPrivate` interface.
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct SyncComponentPrivate(pub(crate) BaseObject);

impl std::ops::Deref for SyncComponentPrivate {
    type Target = BaseObject;
    fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for SyncComponentPrivate {}
unsafe impl Interface for SyncComponentPrivate {
    const NAME: &'static str = "daqSyncComponentPrivate";
    fn interface_id() -> Option<crate::IntfID> {
        let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
        unsafe { (crate::sys::api().daqSyncComponentPrivate_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 SyncComponentPrivate {
    #[doc(hidden)]
    pub(crate) fn __from_ref(r: Ref) -> Self { SyncComponentPrivate(BaseObject(r)) }
}
impl std::fmt::Display for SyncComponentPrivate {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(self.as_base_object(), f)
    }
}
impl From<&SyncComponentPrivate> for Value {
    fn from(value: &SyncComponentPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl From<SyncComponentPrivate> for Value {
    fn from(value: SyncComponentPrivate) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for SyncComponentPrivate {
    unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
        crate::value::cast_owned(ptr, op)
    }
}

impl SyncComponentPrivate {
    /// Adds an interface to the synchronization component.
    /// @param interface The interface to be added.
    /// Calls the openDAQ C function `daqSyncComponentPrivate_addInterface()`.
    pub fn add_interface(&self, sync_interface: &PropertyObject) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqSyncComponentPrivate_addInterface)(self.as_raw() as *mut _, sync_interface.as_raw() as *mut _) };
        check(__code, "daqSyncComponentPrivate_addInterface")?;
        Ok(())
    }

    /// Removes an interface from the synchronization component.
    /// @param interfaceName The name of the interface to be removed.
    /// Calls the openDAQ C function `daqSyncComponentPrivate_removeInterface()`.
    pub fn remove_interface(&self, sync_interface_name: &str) -> Result<()> {
        let __sync_interface_name = crate::marshal::make_string(sync_interface_name)?;
        let __code = unsafe { (crate::sys::api().daqSyncComponentPrivate_removeInterface)(self.as_raw() as *mut _, __sync_interface_name.as_ptr() as *mut _) };
        check(__code, "daqSyncComponentPrivate_removeInterface")?;
        Ok(())
    }

    /// Sets the synchronization lock status.
    /// @param synchronizationLocked True if synchronization is locked; false otherwise.
    /// Calls the openDAQ C function `daqSyncComponentPrivate_setSyncLocked()`.
    pub fn set_sync_locked(&self, synchronization_locked: bool) -> Result<()> {
        let __code = unsafe { (crate::sys::api().daqSyncComponentPrivate_setSyncLocked)(self.as_raw() as *mut _, u8::from(synchronization_locked)) };
        check(__code, "daqSyncComponentPrivate_setSyncLocked")?;
        Ok(())
    }

}