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.

54 lines
2.0 KiB

  1. package uistate
  2. import (
  3. "fmt"
  4. "git.aiterp.net/lucifer3/server/device"
  5. "git.aiterp.net/lucifer3/server/effects"
  6. "git.aiterp.net/lucifer3/server/events"
  7. "git.aiterp.net/lucifer3/server/internal/color"
  8. "github.com/google/uuid"
  9. )
  10. type Patch struct {
  11. Assignment *AssignmentPatch `json:"assignment,omitempty"`
  12. Device *DevicePatch `json:"device,omitempty"`
  13. }
  14. func (e Patch) EventDescription() string {
  15. if e.Device != nil {
  16. switch {
  17. case e.Device.DesiredState != nil:
  18. return fmt.Sprintf("uistate.Patch(device=%s, desired state)", e.Device.ID)
  19. default:
  20. return fmt.Sprintf("uistate.Patch(device=%s)", e.Device.ID)
  21. }
  22. } else if e.Assignment != nil {
  23. return fmt.Sprintf("uistate.Patch(assignment=%s)", e.Assignment.ID)
  24. } else {
  25. return "uistate.Patch"
  26. }
  27. }
  28. type DevicePatch struct {
  29. ID string `json:"id,omitempty"`
  30. Name *string `json:"name,omitempty"`
  31. HWMetadata *events.HardwareMetadata `json:"hwMetadata,omitempty"`
  32. HWState *events.HardwareState `json:"hwState,omitempty"`
  33. DesiredState *device.State `json:"desiredState,omitempty"`
  34. SetAliases []string `json:"setAliases,omitempty"`
  35. AddAlias *string `json:"addAlias,omitempty"`
  36. RemoveAlias *string `json:"removeAlias,omitempty"`
  37. Assignment *uuid.UUID `json:"assignment,omitempty"`
  38. ClearAssignment bool `json:"clearAssignment,omitempty"`
  39. ActiveColorRGB *color.RGB `json:"activeColorRgb"`
  40. ClearActiveColorRGB bool `json:"clearActiveColorRGB"`
  41. Delete bool `json:"delete,omitempty"`
  42. }
  43. type AssignmentPatch struct {
  44. ID uuid.UUID `json:"id"`
  45. AddDeviceID *string `json:"addDeviceId"`
  46. RemoveDeviceID *string `json:"removeDeviceId"`
  47. Effect *effects.Serializable `json:"effect"`
  48. Delete bool `json:"delete"`
  49. }