Device

Trait Device 

Source
pub trait Device {
    // Required methods
    fn power_kw(&mut self, context: &DeviceContext) -> f32;
    fn device_type(&self) -> &'static str;
}
Expand description

Trait defining a device that can produce or consume electricity.

This trait provides a common interface for all devices in the simulation, allowing them to be used interchangeably in power flow calculations.

Required Methods§

Source

fn power_kw(&mut self, context: &DeviceContext) -> f32

Returns the power value at the specified time step.

Positive values indicate power consumption (load), negative values indicate power generation.

§Arguments
  • context - Contextual information about the device and simulation state, like:
  • timestep: Current simulation time step
  • setpoint_kw: Optional power setpoint for controllable devices
§Returns

Power in kilowatts (kW) at the specified time step

Source

fn device_type(&self) -> &'static str

Returns a human-readable type name for the device.

Implementors§