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.

51 lines
1.2 KiB

2 years ago
2 years ago
2 years ago
  1. package events
  2. import (
  3. "fmt"
  4. lucifer3 "git.aiterp.net/lucifer3/server"
  5. "git.aiterp.net/lucifer3/server/internal/gentools"
  6. "github.com/google/uuid"
  7. "strings"
  8. )
  9. type AssignmentCreated struct {
  10. ID uuid.UUID
  11. Match string
  12. Effect lucifer3.Effect
  13. }
  14. func (e AssignmentCreated) EventDescription() string {
  15. return fmt.Sprintf("AssignmentCreated(id=%s, match=%s, effect=%s)", e.ID, e.Match, e.Effect.EffectDescription())
  16. }
  17. type AssignmentRemoved struct {
  18. ID uuid.UUID
  19. }
  20. func (e AssignmentRemoved) EventDescription() string {
  21. return fmt.Sprintf("AssignmentRemoved(id=%s)", e.ID)
  22. }
  23. type DeviceAssigned struct {
  24. DeviceID string `json:"deviceId"`
  25. AssignmentID *uuid.UUID `json:"assignmentId"`
  26. }
  27. func (e DeviceAssigned) EventDescription() string {
  28. return fmt.Sprintf("DeviceAssigned(device=%s, %s)", e.DeviceID, e.AssignmentID)
  29. }
  30. type AssignmentVariables struct {
  31. ID uuid.UUID
  32. Map map[string]float64
  33. }
  34. func (e AssignmentVariables) VerboseKey() string {
  35. return "AssignmentVariables"
  36. }
  37. func (e AssignmentVariables) EventDescription() string {
  38. return fmt.Sprintf("AssignmentVariables(id=%s, keys=[%s])",
  39. e.ID, strings.Join(gentools.MapKeys(e.Map), ","),
  40. )
  41. }