Add amqp support

This commit is contained in:
2023-10-14 19:37:39 +03:00
parent 7b7c419f03
commit 234a50adb2
8 changed files with 168 additions and 11 deletions
+21 -1
View File
@@ -1,6 +1,10 @@
package yabl
import "fmt"
import (
"encoding/json"
"fmt"
"time"
)
func (t BooleanType) String() string {
switch t {
@@ -211,3 +215,19 @@ func (t SignedAirTemp8BitType) String() string {
func (c ConnectedOut8bitType) String() string {
return fmt.Sprintf("%d", c)
}
func (u *Event) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Unit uint
ActionName AName
Field FName
Updated *time.Time
Value string
}{
Unit: u.GetUnitId(),
ActionName: u.ActionName,
Field: u.Field,
Updated: u.Updated,
Value: fmt.Sprintf("%v", u.Value),
})
}