modify and add new fields for drivers

This commit is contained in:
Adrian Zuercher
2025-07-29 12:05:03 +02:00
parent 2d6db85b8c
commit eabac1b11b
5 changed files with 110 additions and 23 deletions

25
models/driver.go Normal file
View File

@@ -0,0 +1,25 @@
package models
// driver model
type Driver struct {
Type string `json:"type"` // driver type name of driver in collection
Buses map[string]*Bus `json:"buses"` // name of driver bus
}
func (d *Driver) AddBus(name string) *Bus {
if d.Buses == nil {
d.Buses = make(map[string]*Bus)
}
if b, ok := d.Buses[name]; ok {
return b
}
d.Buses[name] = &Bus{Name: name}
return d.Buses[name]
}
func (d *Driver) GetBus(name string) *Bus {
if b, ok := d.Buses[name]; ok {
return b
}
return nil
}