#![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;
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Channel(pub(crate) FunctionBlock);
impl std::ops::Deref for Channel {
type Target = FunctionBlock;
fn deref(&self) -> &FunctionBlock { &self.0 }
}
impl crate::sealed::Sealed for Channel {}
unsafe impl Interface for Channel {
const NAME: &'static str = "daqChannel";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqChannel_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 Channel {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Channel(FunctionBlock::__from_ref(r)) }
}
impl std::fmt::Display for Channel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Channel> for Value {
fn from(value: &Channel) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Channel> for Value {
fn from(value: Channel) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Channel {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct FunctionBlockType(pub(crate) ComponentType);
impl std::ops::Deref for FunctionBlockType {
type Target = ComponentType;
fn deref(&self) -> &ComponentType { &self.0 }
}
impl crate::sealed::Sealed for FunctionBlockType {}
unsafe impl Interface for FunctionBlockType {
const NAME: &'static str = "daqFunctionBlockType";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqFunctionBlockType_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 FunctionBlockType {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { FunctionBlockType(ComponentType::__from_ref(r)) }
}
impl std::fmt::Display for FunctionBlockType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&FunctionBlockType> for Value {
fn from(value: &FunctionBlockType) -> Value { Value::Object(value.to_base_object()) }
}
impl From<FunctionBlockType> for Value {
fn from(value: FunctionBlockType) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for FunctionBlockType {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
#[repr(transparent)]
#[derive(Clone, Debug)]
pub struct Recorder(pub(crate) BaseObject);
impl std::ops::Deref for Recorder {
type Target = BaseObject;
fn deref(&self) -> &BaseObject { &self.0 }
}
impl crate::sealed::Sealed for Recorder {}
unsafe impl Interface for Recorder {
const NAME: &'static str = "daqRecorder";
fn interface_id() -> Option<crate::IntfID> {
let mut id = crate::IntfID { Data1: 0, Data2: 0, Data3: 0, Data4: 0 };
unsafe { (crate::sys::api().daqRecorder_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 Recorder {
#[doc(hidden)]
pub(crate) fn __from_ref(r: Ref) -> Self { Recorder(BaseObject(r)) }
}
impl std::fmt::Display for Recorder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.as_base_object(), f)
}
}
impl From<&Recorder> for Value {
fn from(value: &Recorder) -> Value { Value::Object(value.to_base_object()) }
}
impl From<Recorder> for Value {
fn from(value: Recorder) -> Value { Value::Object(value.to_base_object()) }
}
impl crate::value::FromDaqOwned for Recorder {
unsafe fn from_daq_owned(ptr: *mut std::ffi::c_void, op: &'static str) -> Result<Self> {
crate::value::cast_owned(ptr, op)
}
}
impl FunctionBlockType {
pub fn new(id: &str, name: &str, description: &str, default_config: &PropertyObject) -> Result<FunctionBlockType> {
let __id = crate::marshal::make_string(id)?;
let __name = crate::marshal::make_string(name)?;
let __description = crate::marshal::make_string(description)?;
let mut __obj: *mut sys::daqFunctionBlockType = std::ptr::null_mut();
let __code = unsafe { (crate::sys::api().daqFunctionBlockType_createFunctionBlockType)(&mut __obj, __id.as_ptr() as *mut _, __name.as_ptr() as *mut _, __description.as_ptr() as *mut _, default_config.as_raw() as *mut _) };
check(__code, "daqFunctionBlockType_createFunctionBlockType")?;
Ok(unsafe { crate::marshal::require_object::<FunctionBlockType>(__obj as *mut _, "daqFunctionBlockType_createFunctionBlockType") }?)
}
}
impl Recorder {
pub fn is_recording(&self) -> Result<bool> {
let mut __is_recording: u8 = 0;
let __code = unsafe { (crate::sys::api().daqRecorder_getIsRecording)(self.as_raw() as *mut _, &mut __is_recording) };
check(__code, "daqRecorder_getIsRecording")?;
Ok(__is_recording != 0)
}
pub fn start_recording(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqRecorder_startRecording)(self.as_raw() as *mut _) };
check(__code, "daqRecorder_startRecording")?;
Ok(())
}
pub fn stop_recording(&self) -> Result<()> {
let __code = unsafe { (crate::sys::api().daqRecorder_stopRecording)(self.as_raw() as *mut _) };
check(__code, "daqRecorder_stopRecording")?;
Ok(())
}
}