Skip to main content

kernel/fixture/
fixture_command.rs

1use std::sync::mpsc::Sender;
2use common::fixture::{ChannelIndex, ChannelValue, FixtureError, PropertyType};
3
4/// Commands sent asynchronously to the fixture engine thread to manage fixture instances
5/// and modify their properties or states.
6pub(super) enum FixtureCommand {
7    /// Spawns a new fixture instance with a given type, start address, and universe.
8    SpawnFixture {
9        /// Unique name for the new fixture instance.
10        name: String,
11        /// Name of the registered [`FixtureType`](common::fixture::FixtureType) template to use.
12        fixture_type_name: String,
13        /// Starting DMX-Channel index within the universe.
14        start_channel: ChannelIndex,
15        /// DMX universe index (0-based) where the fixture resides.
16        start_universe: usize,
17        /// Sender channel used to reply with the success or failure result.
18        reply_to: Sender<Result<(), FixtureError>>,
19    },
20
21    /// Moves an existing fixture to a new DMX channel and/or universe and changes the reserved channels accordingly
22    MoveFixture {
23        /// Name of the fixture to move.
24        name: String,
25        /// New starting DMX channel index.
26        new_channel: ChannelIndex,
27        /// New target DMX universe index.
28        new_universe: usize,
29        /// Sender channel used to reply with the success or failure result.
30        reply_to: Sender<Result<(), FixtureError>>,
31    },
32
33    /// Removes an existing fixture instance and frees its reserved channels.
34    RemoveFixture {
35        /// Name of the fixture to remove.
36        name: String,
37        /// Sender channel used to reply with the success or failure result.
38        reply_to: Sender<Result<(), FixtureError>>,
39    },
40
41    /// Sets a specific property value on a target fixture.
42    SetProperty {
43        /// Name of the target fixture.
44        fixture_name: String,
45        /// The property type to modify (Simple or Color).
46        property: PropertyType,
47        /// The new channel value to assign.
48        value: ChannelValue,
49        /// Sender channel used to reply with the success or failure result.
50        reply_to: Sender<Result<(), FixtureError>>,
51    },
52
53    /// Retrieves the fixture type name for a given fixture.
54    GetType {
55        /// Name of the target fixture.
56        fixture_name: String,
57        /// Sender channel used to reply with the fixture type name string or an error.
58        reply_to: Sender<Result<String, FixtureError>>,
59    }
60}