2022-07-09 12:24:19 +01:00
|
|
|
import vban_cmd
|
|
|
|
|
|
|
|
|
|
|
|
class Observer:
|
|
|
|
def __init__(self, vban):
|
|
|
|
self.vban = vban
|
2022-08-02 09:31:41 +01:00
|
|
|
# register your app as event observer
|
|
|
|
self.vban.subject.add(self)
|
|
|
|
# add level updates, since they are disabled by default.
|
|
|
|
self.vm.event.add("ldirty")
|
2022-07-09 12:24:19 +01:00
|
|
|
|
2022-08-02 09:31:41 +01:00
|
|
|
# define an 'on_update' callback function to receive event updates
|
2022-07-09 12:24:19 +01:00
|
|
|
def on_update(self, subject):
|
|
|
|
if subject == "pdirty":
|
|
|
|
print("pdirty!")
|
2022-08-02 09:31:41 +01:00
|
|
|
elif subject == "ldirty":
|
2022-07-09 12:24:19 +01:00
|
|
|
info = (
|
2022-08-02 09:31:41 +01:00
|
|
|
f"[{self.vban.bus[0]} {self.vban.bus[0].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[1]} {self.vban.bus[1].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[2]} {self.vban.bus[2].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[3]} {self.vban.bus[3].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[4]} {self.vban.bus[4].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[5]} {self.vban.bus[5].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[6]} {self.vban.bus[6].levels.isdirty}]",
|
|
|
|
f"[{self.vban.bus[7]} {self.vban.bus[7].levels.isdirty}]",
|
2022-07-09 12:24:19 +01:00
|
|
|
)
|
|
|
|
print(" ".join(info))
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
with vban_cmd.api(kind_id, **opts) as vban:
|
|
|
|
obs = Observer(vban)
|
|
|
|
|
|
|
|
while cmd := input("Press <Enter> to exit\n"):
|
|
|
|
if not cmd:
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
kind_id = "potato"
|
|
|
|
opts = {
|
|
|
|
"ip": "<ip address>",
|
|
|
|
"streamname": "Command1",
|
|
|
|
"port": 6980,
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|