2025-01-18 14:53:29 +00:00
|
|
|
package hardware
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
// Peripheral represents the methods used to manage a peripheral (input or output hardware)
|
|
|
|
|
type Peripheral interface {
|
|
|
|
|
Connect(context.Context) error // Connect the peripheral
|
|
|
|
|
Disconnect(context.Context) error // Disconnect the peripheral
|
|
|
|
|
Activate(context.Context) error // Activate the peripheral
|
|
|
|
|
Deactivate(context.Context) error // Deactivate the peripheral
|
2025-01-25 16:00:02 +01:00
|
|
|
SetPeripheralSetting(string, interface{}) error // Set a peripheral setting
|
2025-01-18 14:53:29 +00:00
|
|
|
SetDeviceProperty(context.Context, uint32, uint32, byte) error // Update a device property
|
|
|
|
|
|
2025-01-18 16:25:09 +01:00
|
|
|
GetInfo() PeripheralInfo // Get the peripheral information
|
|
|
|
|
GetSettings() map[string]interface{} // Get the peripheral settings
|
2025-01-18 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PeripheralInfo represents a peripheral information
|
|
|
|
|
type PeripheralInfo struct {
|
2025-01-25 11:06:03 +01:00
|
|
|
Name string `yaml:"name"` // Name of the peripheral
|
|
|
|
|
SerialNumber string `yaml:"sn"` // S/N of the peripheral
|
|
|
|
|
ProtocolName string `yaml:"protocol"` // Protocol name of the peripheral
|
|
|
|
|
Settings map[string]interface{} `yaml:"settings"` // Number of DMX universes handled by the peripheral
|
2025-01-18 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PeripheralFinder represents how compatible peripheral drivers are implemented
|
|
|
|
|
type PeripheralFinder interface {
|
|
|
|
|
Initialize() error // Initializes the protocol
|
|
|
|
|
Start(context.Context) error // Start the detection
|
|
|
|
|
Stop() error // Stop the detection
|
|
|
|
|
ForceScan() // Explicitly scans for peripherals
|
|
|
|
|
CreatePeripheral(ctx context.Context) (Peripheral, error) // Creates a new peripheral
|
|
|
|
|
DeletePeripheral(serialNumber string) error // Removes a peripheral
|
|
|
|
|
GetName() string // Get the name of the finder
|
|
|
|
|
GetPeripheral(string) (Peripheral, bool) // Get the peripheral
|
|
|
|
|
}
|