Files
tecamino-json_data/models/set.go
2025-04-26 23:14:50 +02:00

40 lines
871 B
Go

package models
import "github.com/google/uuid"
type Set struct {
Uuid uuid.UUID `json:"uuid,omitempty"`
Path string `json:"path"`
Driver *Driver `json:"driver,omitempty"`
Drivers *Drivers `json:"drivers,omitempty"`
Type Type `json:"type,omitempty"`
Value any `json:"value,omitempty"`
Rights Rights `json:"rights,omitempty"`
Updated bool `json:"-"`
}
func (s *Set) ValueByPath(path string, value any) {
s.Path = path
s.Value = value
}
func (s *Set) ValueByUuid(uid string, value any) {
s.Uuid = uuid.MustParse(uid)
s.Value = value
}
func (s *Set) New(path string, typ Type, value any, rights Rights) {
s.Path = path
s.Type = typ
s.Value = value
s.Rights = rights.GetRights()
}
func (s *Set) NewDriver(typ, bus string, address uint) {
s.Driver = &Driver{
Type: typ,
Bus: bus,
Address: address,
}
}