21-peripherals-settings #22

Merged
thinkode merged 5 commits from 21-peripherals-settings into develop 2025-01-25 17:43:46 +00:00
2 changed files with 27 additions and 19 deletions
Showing only changes of commit 3fbf4b5df4 - Show all commits

View File

@@ -21,30 +21,32 @@ const (
// FTDIPeripheral contains the data of an FTDI peripheral
type FTDIPeripheral struct {
name string // The name of the peripheral
serialNumber string // The S/N of the FTDI peripheral
location int // The location of the peripheral
universesNumber int // The number of DMX universes handled by this peripheral
programName string // The temp file name of the executable
dmxSender *exec.Cmd // The command to pilot the DMX sender program
stdin io.WriteCloser // For writing in the DMX sender
stdout io.ReadCloser // For reading from the DMX sender
stderr io.ReadCloser // For reading the errors
disconnectChan chan struct{} // Channel to cancel the connection
errorsChan chan error // Channel to get the errors
name string // The name of the peripheral
serialNumber string // The S/N of the FTDI peripheral
location int // The location of the peripheral
programName string // The temp file name of the executable
settings map[string]interface{} // The settings of the peripheral
dmxSender *exec.Cmd // The command to pilot the DMX sender program
stdin io.WriteCloser // For writing in the DMX sender
stdout io.ReadCloser // For reading from the DMX sender
stderr io.ReadCloser // For reading the errors
disconnectChan chan struct{} // Channel to cancel the connection
errorsChan chan error // Channel to get the errors
}
// NewFTDIPeripheral creates a new FTDI peripheral
func NewFTDIPeripheral(name string, serialNumber string, location int) (*FTDIPeripheral, error) {
log.Info().Str("file", "FTDIPeripheral").Str("name", name).Str("s/n", serialNumber).Int("location", location).Msg("FTDI peripheral created")
settings := make(map[string]interface{})
settings["universesNumber"] = uint64(1)
return &FTDIPeripheral{
name: name,
dmxSender: nil,
serialNumber: serialNumber,
location: location,
universesNumber: 1,
disconnectChan: make(chan struct{}),
errorsChan: make(chan error, 1),
name: name,
dmxSender: nil,
serialNumber: serialNumber,
location: location,
settings: settings,
disconnectChan: make(chan struct{}),
errorsChan: make(chan error, 1),
}, nil
}
@@ -186,6 +188,11 @@ func (p *FTDIPeripheral) SetDeviceProperty(ctx context.Context, uint32, channelN
return fmt.Errorf("unable to set device property: not connected")
}
// GetSettings gets the peripheral settings
func (p *FTDIPeripheral) GetSettings() map[string]interface{} {
return p.settings
}
// GetInfo gets all the peripheral information
func (p *FTDIPeripheral) GetInfo() PeripheralInfo {
return PeripheralInfo{

View File

@@ -10,7 +10,8 @@ type Peripheral interface {
Deactivate(context.Context) error // Deactivate the peripheral
SetDeviceProperty(context.Context, uint32, uint32, byte) error // Update a device property
GetInfo() PeripheralInfo // Get the peripheral information
GetInfo() PeripheralInfo // Get the peripheral information
GetSettings() map[string]interface{} // Get the peripheral settings
}
// PeripheralInfo represents a peripheral information