update json_data and model so more than one address can be revieved from server
This commit is contained in:
@@ -10,8 +10,12 @@ func (d *ArtNetDriver) Publish(pubs ...json_dataModels.Publish) error {
|
||||
}
|
||||
|
||||
for _, pub := range pubs {
|
||||
if drv, ok := (d.Subscriptions)[pub.Uuid]; ok {
|
||||
d.SetValue(drv.Bus, drv.Address, uint8(pub.Value.(float64)))
|
||||
if subs, ok := (d.Subscriptions)[pub.Uuid]; ok {
|
||||
for _, sub := range subs {
|
||||
for _, address := range sub.Address {
|
||||
d.SetValue(sub.Bus, address, uint8(pub.Value.(float64)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
d.SendData()
|
||||
|
@@ -14,7 +14,12 @@ func (d *ArtNetDriver) Subscribe(subs ...json_dataModels.Subscription) {
|
||||
for _, sub := range subs {
|
||||
if drv, ok := (*sub.Drivers)[sub.Driver]; ok {
|
||||
d.Subscriptions.AddSubscription(sub.Uuid, drv)
|
||||
d.SetValue(drv.Bus, drv.Address, uint8(sub.Value.(float64)))
|
||||
for _, bus := range drv.Buses {
|
||||
for _, address := range bus.Address {
|
||||
d.SetValue(bus.Name, address, uint8(sub.Value.(float64)))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
d.SendData()
|
||||
|
2
go.mod
2
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e
|
||||
github.com/tecamino/tecamino-json_data v0.0.20
|
||||
github.com/tecamino/tecamino-json_data v0.0.30
|
||||
github.com/tecamino/tecamino-logger v0.2.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@@ -65,8 +65,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls=
|
||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e/go.mod h1:B4+Kq1u5FlULTjFSM707Q6e/cOHFv0z/6QRoxubDIQ8=
|
||||
github.com/tecamino/tecamino-json_data v0.0.20 h1:0YHjcGq4T37Z0mu24CMbFA5zgYiUXZNrI5C44nvWexU=
|
||||
github.com/tecamino/tecamino-json_data v0.0.20/go.mod h1:LLlyD7Wwqplb2BP4PeO86EokEcTRidlW5MwgPd1T2JY=
|
||||
github.com/tecamino/tecamino-json_data v0.0.30 h1:MRx2POR2VmkAvbl1EZRUZeU4ygccuu5Gw6El74RbF+U=
|
||||
github.com/tecamino/tecamino-json_data v0.0.30/go.mod h1:LLlyD7Wwqplb2BP4PeO86EokEcTRidlW5MwgPd1T2JY=
|
||||
github.com/tecamino/tecamino-logger v0.2.0 h1:NPH/Gg9qRhmVoW8b39i1eXu/LEftHc74nyISpcRG+XU=
|
||||
github.com/tecamino/tecamino-logger v0.2.0/go.mod h1:0M1E9Uei/qw3e3WA1x3lBo1eP3H5oeYE7GjYrMahnj8=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
|
@@ -216,6 +216,7 @@ func (b *Bus) ParsePayload(c *gin.Context) error {
|
||||
}
|
||||
|
||||
func (b *Bus) SetDMXData(channel uint, value uint8) error {
|
||||
fmt.Println(100, channel, value)
|
||||
b.DMX.SetValue(channel, value)
|
||||
b.Send = true
|
||||
return nil
|
||||
|
@@ -5,11 +5,11 @@ import (
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
type Subscriptions map[uuid.UUID]Subscription
|
||||
type Subscriptions map[uuid.UUID][]Subscription
|
||||
|
||||
type Subscription struct {
|
||||
Bus string
|
||||
Address uint
|
||||
Address []uint
|
||||
}
|
||||
|
||||
func NewSubscriptions() Subscriptions {
|
||||
@@ -17,8 +17,11 @@ func NewSubscriptions() Subscriptions {
|
||||
}
|
||||
|
||||
func (s *Subscriptions) AddSubscription(uid uuid.UUID, drv *json_dataModels.Driver) {
|
||||
(*s)[uid] = Subscription{
|
||||
Bus: drv.Bus,
|
||||
Address: drv.Address,
|
||||
subs := []Subscription{}
|
||||
for _, bus := range drv.Buses {
|
||||
sub := Subscription{Bus: bus.Name}
|
||||
sub.Address = append(sub.Address, bus.Address...)
|
||||
subs = append(subs, sub)
|
||||
}
|
||||
(*s)[uid] = subs
|
||||
}
|
||||
|
Reference in New Issue
Block a user