pub struct FixtureEngine {
fixtures: HashMap<String, Fixture>,
dmx_config: Vec<[ChannelReservation; 512]>,
receiver: Receiver<FixtureCommand>,
}Expand description
The core engine managing fixture instances, thread synchronization, and DMX channel reservations.
Fields§
§fixtures: HashMap<String, Fixture>§dmx_config: Vec<[ChannelReservation; 512]>§receiver: Receiver<FixtureCommand>Implementations§
Source§impl FixtureEngine
impl FixtureEngine
Sourcepub fn spawn() -> Result<Receiver<(usize, Vec<Fixture>)>, &'static str>
pub fn spawn() -> Result<Receiver<(usize, Vec<Fixture>)>, &'static str>
Spawns the fixture engine actor thread and returns an interface receiver channel for updates.
§Errors
Returns an error if the engine has already been started (preventing multiple instances).
Sourcefn run(&mut self, interface_sender: Sender<(usize, Vec<Fixture>)>)
fn run(&mut self, interface_sender: Sender<(usize, Vec<Fixture>)>)
Main event loop processing incoming commands and triggering state notifications.
§Arguments
interface_sender- Channel used to broadcast updated fixture lists and universe counts to the runtime.
Sourcefn new_fixture(
&mut self,
name: String,
fixture_type_name: String,
start_channel: ChannelIndex,
start_universe: usize,
) -> Result<(), FixtureError>
fn new_fixture( &mut self, name: String, fixture_type_name: String, start_channel: ChannelIndex, start_universe: usize, ) -> Result<(), FixtureError>
Creates and registers a new fixture instance, verifying and reserving its DMX channels.
§Arguments
name- Unique name for the fixture instancefixture_type_name- Template name of the registered fixture typestart_channel- DMX channel offset within the universestart_universe- Target DMX universe index (0-based)
§Errors
FixtureNameAlreadyInUse– if the name is already takenInvalidFixtureType- iffixture_type_nameis not registered- [
ChannelAlreadyInUse] – if required channels overlap with existing ChannelOutOfRange- if any required channel is out of bounds ([MAX_CHANNEL]).- [
UniverseOutOfRange] - if the fixture is in a non-existent universe - [
DmxStateDesync] - if the DMX-State and the fixture registry are out of sync
Sourcefn move_fixture(
&mut self,
name: String,
new_channel: ChannelIndex,
new_universe: usize,
) -> Result<(), FixtureError>
fn move_fixture( &mut self, name: String, new_channel: ChannelIndex, new_universe: usize, ) -> Result<(), FixtureError>
Relocates an existing fixture to a new channel and/or universe.
§Arguments
name- Name of the fixture to movenew_channel- New starting DMX channel indexnew_universe- New target DMX universe index (0-based)
§Errors
- [
InvalidFixture] – if the fixture name is not found - [
ChannelAlreadyInUse] – if the new target channels are blocked ChannelOutOfRange- if the new channel range is out of bounds- [
UniverseOutOfRange] - if the fixture is in a non-existent universe - [
DmxStateDesync] - if the DMX-State and the fixture registry are out of sync
Sourcefn remove_fixture(&mut self, name: String) -> Result<(), FixtureError>
fn remove_fixture(&mut self, name: String) -> Result<(), FixtureError>
Removes a fixture instance and frees its associated DMX channel reservations.
§Arguments
name- Name of the fixture to remove
§Errors
- [
InvalidFixture] – if the fixture does not exist - [
UniverseOutOfRange] - if the fixture is in a non-existent universe - [
DmxStateDesync] - if the DMX-State and the fixture registry are out of sync
Sourcefn set_property(
&mut self,
name: String,
property: PropertyType,
value: ChannelValue,
) -> Result<(), FixtureError>
fn set_property( &mut self, name: String, property: PropertyType, value: ChannelValue, ) -> Result<(), FixtureError>
Updates a specific property value on an active fixture.
§Arguments
name- Name of the target fixtureproperty- Property type to updatevalue- New raw channel value
§Errors
- [
InvalidFixture] – if the fixture is not found MissingProperty– if the fixture lacks the specified property
Sourcefn get_fixture_type_from_string(
&self,
name: String,
) -> Result<String, FixtureError>
fn get_fixture_type_from_string( &self, name: String, ) -> Result<String, FixtureError>
Sourcefn ensure_universe_size(&mut self, size: usize)
fn ensure_universe_size(&mut self, size: usize)
Ensures that the internal DMX configuration vector has at least the given size (universes).
§Arguments
size- Required minimum number of universes
Sourcefn remove_reservations(
&mut self,
fixture: &mut Fixture,
) -> Result<(), FixtureError>
fn remove_reservations( &mut self, fixture: &mut Fixture, ) -> Result<(), FixtureError>
Sourcefn get_dmx_config_for_client(&self) -> DMXConfigForClientState
fn get_dmx_config_for_client(&self) -> DMXConfigForClientState
Generates a snapshot of the current DMX configuration mapped for client subscription updates.