Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
49dff4f609 | ||
![]() |
3704edebd5 |
@@ -10,8 +10,12 @@ func (d *ArtNetDriver) Publish(pubs ...json_dataModels.Publish) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pub := range pubs {
|
for _, pub := range pubs {
|
||||||
if drv, ok := (d.Subscriptions)[pub.Uuid]; ok {
|
if subs, ok := (d.Subscriptions)[pub.Uuid]; ok {
|
||||||
d.SetValue(drv.Bus, drv.Address, uint8(pub.Value.(float64)))
|
for _, sub := range subs {
|
||||||
|
for _, address := range sub.Address {
|
||||||
|
d.SetValue(sub.Bus, address, uint8(pub.Value.(float64)))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.SendData()
|
d.SendData()
|
||||||
|
@@ -14,7 +14,12 @@ func (d *ArtNetDriver) Subscribe(subs ...json_dataModels.Subscription) {
|
|||||||
for _, sub := range subs {
|
for _, sub := range subs {
|
||||||
if drv, ok := (*sub.Drivers)[sub.Driver]; ok {
|
if drv, ok := (*sub.Drivers)[sub.Driver]; ok {
|
||||||
d.Subscriptions.AddSubscription(sub.Uuid, drv)
|
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()
|
d.SendData()
|
||||||
|
2
go.mod
2
go.mod
@@ -9,7 +9,7 @@ require (
|
|||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e
|
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
|
github.com/tecamino/tecamino-logger v0.2.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
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/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 h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls=
|
||||||
github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e/go.mod h1:B4+Kq1u5FlULTjFSM707Q6e/cOHFv0z/6QRoxubDIQ8=
|
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.30 h1:MRx2POR2VmkAvbl1EZRUZeU4ygccuu5Gw6El74RbF+U=
|
||||||
github.com/tecamino/tecamino-json_data v0.0.20/go.mod h1:LLlyD7Wwqplb2BP4PeO86EokEcTRidlW5MwgPd1T2JY=
|
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 h1:NPH/Gg9qRhmVoW8b39i1eXu/LEftHc74nyISpcRG+XU=
|
||||||
github.com/tecamino/tecamino-logger v0.2.0/go.mod h1:0M1E9Uei/qw3e3WA1x3lBo1eP3H5oeYE7GjYrMahnj8=
|
github.com/tecamino/tecamino-logger v0.2.0/go.mod h1:0M1E9Uei/qw3e3WA1x3lBo1eP3H5oeYE7GjYrMahnj8=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
|
@@ -157,6 +157,7 @@ func (b *Bus) Start(log *logging.Logger) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
|
|
||||||
if !b.Send {
|
if !b.Send {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -165,7 +166,7 @@ func (b *Bus) Start(log *logging.Logger) error {
|
|||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
data := NewDMXUniverse()
|
data := NewDMXUniverse()
|
||||||
copy(data.Data, data.GetDMXData())
|
copy(data.Data, b.DMX.GetDMXData())
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
_, err = conn.Write(NewArtNetPackage(data))
|
_, err = conn.Write(NewArtNetPackage(data))
|
||||||
@@ -174,6 +175,7 @@ func (b *Bus) Start(log *logging.Logger) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -214,7 +216,9 @@ func (b *Bus) ParsePayload(c *gin.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bus) SetDMXData(channel uint, value uint8) error {
|
func (b *Bus) SetDMXData(channel uint, value uint8) error {
|
||||||
|
fmt.Println(100, channel, value)
|
||||||
b.DMX.SetValue(channel, value)
|
b.DMX.SetValue(channel, value)
|
||||||
|
b.Send = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
type DMX struct {
|
type DMX struct {
|
||||||
Data []byte
|
Data []byte
|
||||||
@@ -17,7 +19,7 @@ func (d *DMX) GetDMXData() (data []byte) {
|
|||||||
d.mu.Lock()
|
d.mu.Lock()
|
||||||
data = d.Data
|
data = d.Data
|
||||||
d.mu.Unlock()
|
d.mu.Unlock()
|
||||||
return data
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DMX) SetValue(channel uint, value uint8) {
|
func (d *DMX) SetValue(channel uint, value uint8) {
|
||||||
|
@@ -5,11 +5,11 @@ import (
|
|||||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Subscriptions map[uuid.UUID]Subscription
|
type Subscriptions map[uuid.UUID][]Subscription
|
||||||
|
|
||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
Bus string
|
Bus string
|
||||||
Address uint
|
Address []uint
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSubscriptions() Subscriptions {
|
func NewSubscriptions() Subscriptions {
|
||||||
@@ -17,8 +17,11 @@ func NewSubscriptions() Subscriptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Subscriptions) AddSubscription(uid uuid.UUID, drv *json_dataModels.Driver) {
|
func (s *Subscriptions) AddSubscription(uid uuid.UUID, drv *json_dataModels.Driver) {
|
||||||
(*s)[uid] = Subscription{
|
subs := []Subscription{}
|
||||||
Bus: drv.Bus,
|
for _, bus := range drv.Buses {
|
||||||
Address: drv.Address,
|
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