You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.0 KiB
72 lines
3.0 KiB
package uistate
|
|
|
|
import (
|
|
"fmt"
|
|
"git.aiterp.net/lucifer3/server/device"
|
|
"git.aiterp.net/lucifer3/server/effects"
|
|
"git.aiterp.net/lucifer3/server/events"
|
|
"git.aiterp.net/lucifer3/server/internal/color"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Patch struct {
|
|
Assignment *AssignmentPatch `json:"assignment,omitempty"`
|
|
Device *DevicePatch `json:"device,omitempty"`
|
|
}
|
|
|
|
func (e Patch) VerboseKey() string {
|
|
return "uistate.Patch"
|
|
}
|
|
|
|
func (e Patch) EventDescription() string {
|
|
if e.Device != nil {
|
|
switch {
|
|
case e.Device.Name != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, name=%s)", e.Device.ID, e.Device.Name)
|
|
case e.Device.DesiredState != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, desiredState=%s)", e.Device.ID, e.Device.DesiredState.String())
|
|
case e.Device.HWState != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, hwState)", e.Device.ID)
|
|
case e.Device.HWMetadata != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, hwMetadata)", e.Device.ID)
|
|
case e.Device.AddAlias != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, addAlias=%s)", e.Device.ID, *e.Device.AddAlias)
|
|
case e.Device.RemoveAlias != nil:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, removeAlias=%s)", e.Device.ID, *e.Device.RemoveAlias)
|
|
case e.Device.ActiveColorRGB != nil:
|
|
col := color.Color{RGB: e.Device.ActiveColorRGB}
|
|
return fmt.Sprintf("uistate.Patch(device=%s, activeColorRgb=%s)", e.Device.ID, col.String())
|
|
default:
|
|
return fmt.Sprintf("uistate.Patch(device=%s, ...other)", e.Device.ID)
|
|
}
|
|
} else if e.Assignment != nil {
|
|
return fmt.Sprintf("uistate.Patch(assignment=%s)", e.Assignment.ID)
|
|
} else {
|
|
return "uistate.Patch"
|
|
}
|
|
}
|
|
|
|
type DevicePatch struct {
|
|
ID string `json:"id,omitempty"`
|
|
Name *string `json:"name,omitempty"`
|
|
HWMetadata *events.HardwareMetadata `json:"hwMetadata,omitempty"`
|
|
HWState *events.HardwareState `json:"hwState,omitempty"`
|
|
DesiredState *device.State `json:"desiredState,omitempty"`
|
|
SetAliases []string `json:"setAliases,omitempty"`
|
|
AddAlias *string `json:"addAlias,omitempty"`
|
|
RemoveAlias *string `json:"removeAlias,omitempty"`
|
|
Assignment *uuid.UUID `json:"assignment,omitempty"`
|
|
ClearAssignment bool `json:"clearAssignment,omitempty"`
|
|
ActiveColorRGB *color.RGB `json:"activeColorRgb,omitempty"`
|
|
ClearActiveColorRGB bool `json:"clearActiveColorRGB,omitempty"`
|
|
Sensors *DeviceSensors `json:"sensors,omitempty"`
|
|
Delete bool `json:"delete,omitempty"`
|
|
}
|
|
|
|
type AssignmentPatch struct {
|
|
ID uuid.UUID `json:"id"`
|
|
AddDeviceID *string `json:"addDeviceId"`
|
|
RemoveDeviceID *string `json:"removeDeviceId"`
|
|
Effect *effects.Serializable `json:"effect"`
|
|
Delete bool `json:"delete"`
|
|
}
|