fix faulty data send to artNet with new chan queue
This commit is contained in:
@@ -82,7 +82,7 @@ func (d *ArtNetDriver) SetValue(bus string, address uint, value uint8) error {
|
||||
return fmt.Errorf("no dmx data on bus '%s' found", bus)
|
||||
}
|
||||
d.Buses[bus].Data.SetValue(address, value)
|
||||
return d.Buses[bus].SendData()
|
||||
return nil
|
||||
}
|
||||
|
||||
// connect to websocket server and listen to subscriptions
|
||||
@@ -134,3 +134,10 @@ func (d *ArtNetDriver) Connect(ip, id string, port uint) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// send data to all buses that the send flage is true
|
||||
func (d *ArtNetDriver) SendData() {
|
||||
for _, bus := range d.Buses {
|
||||
bus.Send <- bus.Data
|
||||
}
|
||||
}
|
||||
|
@@ -8,10 +8,12 @@ func (d *ArtNetDriver) Publish(pubs ...json_dataModels.Publish) error {
|
||||
if d.Subscriptions == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, pub := range pubs {
|
||||
if drv, ok := (d.Subscriptions)[pub.Uuid]; ok {
|
||||
d.SetValue(drv.Bus, drv.Address, uint8(pub.Value.(float64)))
|
||||
}
|
||||
}
|
||||
d.SendData()
|
||||
return nil
|
||||
}
|
||||
|
@@ -17,4 +17,5 @@ func (d *ArtNetDriver) Subscribe(subs ...json_dataModels.Subscription) {
|
||||
d.SetValue(drv.Bus, drv.Address, uint8(sub.Value.(float64)))
|
||||
}
|
||||
}
|
||||
d.SendData()
|
||||
}
|
||||
|
Reference in New Issue
Block a user