pub struct DeviceObject { /* private fields */ }Expand description
Device Object that manages all object types and instances
The Device Object maintains a registry of object function handlers and provides centralized dispatch for all object operations.
Implementations§
Source§impl DeviceObject
impl DeviceObject
Sourcepub fn find_object_functions(
&self,
object_type: ObjectType,
) -> Option<&ObjectFunctions>
pub fn find_object_functions( &self, object_type: ObjectType, ) -> Option<&ObjectFunctions>
Find object functions for a specific object type
Returns a reference to the ObjectFunctions for the specified type,
or None if no handler is registered for that type.
This mirrors the C reference implementation’s Device_Object_Functions_Find()
§Example
if let Some(funcs) = device.find_object_functions(ObjectType::AnalogInput) {
let count = (funcs.count)();
println!("Found {} analog inputs", count);
}Sourcepub fn object_functions(&self) -> &[ObjectFunctions]
pub fn object_functions(&self) -> &[ObjectFunctions]
Get the entire object function table
Returns a slice containing all registered object function handlers.
This mirrors the C reference implementation’s Device_Object_Functions()
§Example
for funcs in device.object_functions() {
let count = (funcs.count)();
println!("{:?}: {} instances", funcs.object_type, count);
}Sourcepub fn register_object_functions(&mut self, functions: ObjectFunctions)
pub fn register_object_functions(&mut self, functions: ObjectFunctions)
Register object functions for a specific object type
Adds or replaces the object function handler for the specified type. This allows for custom object implementations and overriding default behavior.
§Arguments
functions- The object function handlers to register
§Example
// Register custom Analog Input implementation
device.register_object_functions(ObjectFunctions {
object_type: ObjectType::AnalogInput,
count: my_ai_count,
index_to_instance: my_ai_index,
valid_instance: my_ai_valid,
object_name: my_ai_name,
read_property: my_ai_read,
write_property: my_ai_write,
is_property_writable: my_ai_writable,
property_list: my_ai_props,
});Sourcepub fn device_instance(&self) -> u32
pub fn device_instance(&self) -> u32
Get the device instance number
Sourcepub fn device_name(&self) -> &str
pub fn device_name(&self) -> &str
Get the device name
Sourcepub fn device_identifier(&self) -> &str
pub fn device_identifier(&self) -> &str
Get the device identifier string
Sourcepub fn application_software_version(&self) -> &str
pub fn application_software_version(&self) -> &str
Get the application software version
Sourcepub fn protocol_version(&self) -> u8
pub fn protocol_version(&self) -> u8
Get the protocol version
Sourcepub fn protocol_revision(&self) -> u8
pub fn protocol_revision(&self) -> u8
Get the protocol revision
Sourcepub fn set_device_description(&mut self, description: String)
pub fn set_device_description(&mut self, description: String)
Set the device description
Sourcepub fn set_vendor_info(&mut self, vendor_id: u16, vendor_name: String)
pub fn set_vendor_info(&mut self, vendor_id: u16, vendor_name: String)
Set vendor information
Sourcepub fn set_model_info(&mut self, model_name: String, firmware_revision: String)
pub fn set_model_info(&mut self, model_name: String, firmware_revision: String)
Set model information
Sourcepub fn read_object_property(
&self,
object_id: ObjectIdentifier,
property: PropertyIdentifier,
) -> Result<PropertyValue>
pub fn read_object_property( &self, object_id: ObjectIdentifier, property: PropertyIdentifier, ) -> Result<PropertyValue>
Sourcepub fn write_object_property(
&self,
object_id: ObjectIdentifier,
property: PropertyIdentifier,
value: PropertyValue,
) -> Result<()>
pub fn write_object_property( &self, object_id: ObjectIdentifier, property: PropertyIdentifier, value: PropertyValue, ) -> Result<()>
Sourcepub fn total_object_count(&self) -> usize
pub fn total_object_count(&self) -> usize
Get the total object count across all types
Trait Implementations§
Source§impl Clone for DeviceObject
impl Clone for DeviceObject
Source§fn clone(&self) -> DeviceObject
fn clone(&self) -> DeviceObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more