forked from vtrainor/ola-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimple_ui.py
953 lines (843 loc) · 33.6 KB
/
simple_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
import Tkinter as tk
from ola.ClientWrapper import ClientWrapper
import time
import threading
import thread
import Queue
import olathread
from ola import PidStore
import ttk
import notebook
"""
General control flow:
On startup:
- fetch the list of UIDS
- for each UID, fetch the DEVICE_LABEL
- add each UID & add UID (+ optional label) to the drop down
When a UID is selected:
- fetch supported params if we don't already have it
- fetch device info if we don't already have it
- call notebook.Update()
- notebook.Update looks at the current selected tab, and then calls one of:
- GetBasicInformation()
- GetDMXInformation()
- GetSensorInformation()
Each of these send the necessary to build a dictionary (pid_info) for the tab.
For example, GetBasicInformation() would do:
GET PRODUCT_DETAIL_ID_LIST
GET -PRODUCT_DETAIL_ID_LIST
GET MANUFACTURER_LABEL
GET SOFTWARE_VERSION_LABEL
GET BOOT_SOFTWARE_VERSION_ID
GET BOOT_SOFTWARE_VERSION_LABEL
Once the dict is built, we call notebook.RenderBasicInformation(pid_info)
which then updates all the widgets.
"""
class Controller(object):
"""The controller will act as the glue between the notebook (display) the the
DisplayApp (data). This keeps us honest by not leaking RDM information
into the notebook.
"""
def __init__(self, app):
self._app = app
def GetBasicInformation(self):
"""
"""
self._app.GetBasicInformation()
def GetDMXInformation(self):
"""
"""
self._app.GetDMXInformation()
def GetSensorsInformation(self):
self._app.GetSensorsInformation()
def GetSettingInformation(self):
self._app.GetSettingInformation()
def GetConfigInformation(self):
self._app.GetConfigInformation()
def SetDeviceLabel(self, label):
"""
"""
self._app.set_device_label(label)
def SetSetStartAddress(self, index):
pass
def SetPersonality(self, index):
pass
# Additional methods will be added later
class DisplayApp:
""" Creates the GUI for sending and receiving RDM messages through the
ola thread.
"""
def __init__(self, width, height):
""" initializes the GUI and the ola thread
Args:
width: the int value of the width of the tkinter window
height: the int value of the height of the tkinter window
"""
# Initialize the tk root window
self._controller = Controller(self)
self.root = tk.Tk()
self.init_dx = width
self.init_dy = height
self.root.geometry("%dx%d+50+30"%(self.init_dx, self.init_dy))
self.root.title("RDM user interface version: 1.0")
self.root.maxsize(1600, 900)
self.root.lift()
self.root.update_idletasks()
# Assigning fields
self.universe = tk.IntVar(self.root)
self.universe.set(1)
self.universe_list = [1, 2, 3, 4, 5]
self.cur_uid = None
self.id_state = tk.IntVar(self.root)
self.auto_disc = tk.BooleanVar(self.root)
self.id_state.set(0)
# self.state = 0
self._uid_dict = {}
# Call initialing functions
self._pid_store = PidStore.GetStore()
self.ola_thread = olathread.OLAThread(self._pid_store)
self.ola_thread.start()
self.build_frames()
self.build_cntrl()
self._notebook = notebook.RDMNotebook(self.root, self._controller)
self.discover()
self.auto_disc.set(False)
print "currently in thread: %d"%threading.currentThread().ident
time.sleep(1)
print "back from sleep"
def build_frames(self):
""" builds the two tkinter frames that are used as parents for the
tkinter widgets that both control and display the RDM messages.
"""
self.cntrl_frame = tk.PanedWindow(self.root)
self.cntrl_frame.pack(side = tk.TOP, padx = 1, pady = 1, fill = tk.Y)
self.info_frame_1 = tk.PanedWindow(self.root)
self.info_frame_1.pack(side = tk.TOP, padx = 1, pady = 2, fill = tk.Y)
def build_cntrl(self):
""" Builds the top bar of the GUI.
Initializes all the general tkinter control widgets, including:
dev_label: tk string variable for the currently selected device
id_box:
device_menu:
"""
tk.Label(self.cntrl_frame, text = "Select\nUniverse:").pack(side = tk.LEFT)
menu = tk.OptionMenu(self.cntrl_frame, self.universe, *self.universe_list,
command = self.set_universe)
menu.pack(side = tk.LEFT)
discover_button = tk.Button(self.cntrl_frame, text = "Discover",
command = self.discover)
discover_button.pack(side = tk.LEFT)
self.dev_label = tk.StringVar(self.root)
self.dev_label.set("Devices")
self.device_menu = tk.OptionMenu(self.cntrl_frame, self.dev_label, [])
# self.device_menu["menu"].config(tearoff = 0)
self.device_menu.pack(side = tk.LEFT)
self.id_box = tk.Checkbutton(self.cntrl_frame, text = "Identify",
variable = self.id_state,
command = self.identify)
self.id_box.pack(side = tk.LEFT)
self.auto_disc_box = tk.Checkbutton(self.cntrl_frame,
text = "Automatic\nDiscovery",
variable = self.auto_disc,
command = self.discover)
self.auto_disc_box.pack(side = tk.LEFT)
def device_selected(self, uid):
""" called when a new device is chosen from dev_menu.
Args:
uid: the uid of the newly selected device
"""
if uid == self.cur_uid:
print "Already Selected"
return
# This line is going to return "DEVICE_LABEL" so you may as well skip it
pid_key = "DEVICE_LABEL"
self.dev_label.set("%s (%s)"%(self._uid_dict[uid][pid_key]["label"], uid))
self.ola_thread.rdm_get(self.universe.get(), uid, 0, "IDENTIFY_DEVICE",
lambda b, s, uid = uid:self._get_identify_complete(uid, b, s))
if "SUPPORTED_PARAMETERS" not in self._uid_dict[uid]:
self.ola_thread.rdm_get(
self.universe.get(), uid, 0, "SUPPORTED_PARAMETERS",
lambda b, l, uid = uid:self._get_pids_complete(uid, b, l))
else:
self._notebook.Update()
self.cur_uid = uid
def set_universe(self, i):
""" sets the int var self.universe to the value of i """
self.universe.set(i)
def discover(self):
""" runs discovery for the current universe. """
self.ola_thread.run_discovery(self.universe.get(), self._upon_discover)
if self.auto_disc.get():
self.ola_thread.add_event(5000, self.discover)
else:
print "auto_disc is off"
def identify(self):
""" Command is called by id_box.
sets the value of the device"s identify field based on the value of
id_box.
"""
if self.cur_uid is None:
return
self.ola_thread.rdm_set(self.universe.get(), self.cur_uid, 0,
"IDENTIFY_DEVICE",
lambda b, s, uid = self.cur_uid:self._rdm_set_complete(uid, b, s),
[self.id_state.get()])
def _upon_discover(self, status, uids):
""" callback for client.RunRDMDiscovery. """
if len(self._uid_dict.keys()) == 0:
self.device_menu["menu"].delete(0, "end")
for uid in uids:
if uid not in self._uid_dict.keys():
self._uid_dict[uid] = {}
self.ola_thread.rdm_get(self.universe.get(), uid, 0, "DEVICE_LABEL",
lambda b, s, uid = uid:self._add_device(uid, b, s),
[])
def _add_device(self, uid, succeeded, data):
""" callback for the rdm_get in upon_discover.
populates self.device_menu
"""
# TODO: Bug: on discover the label in the label in the device option menu
# doesn't change and if you try to select the first device it tells
# you that it is already selected
if succeeded:
self._uid_dict.setdefault(uid, {})["DEVICE_LABEL"] = data
self.device_menu["menu"].add_command( label = "%s (%s)"%(
self._uid_dict[uid]["DEVICE_LABEL"]["label"], uid),
command = lambda:self.device_selected(uid))
else:
self._uid_dict.setdefault(uid, {})["DEVICE_LABEL"] = {"label":""}
self.device_menu["menu"].add_command( label = "%s" % uid,
command = lambda:self.device_selected(uid))
self._uid_dict[uid]["index"] = self.device_menu["menu"].index(tk.END)
def _get_pids_complete(self, uid, succeeded, params):
""" Callback for get_supported_pids.
Args:
succeeded: bool, whether or not the get was a success
params: packed list of 16-bit pids
"""
if not succeeded:
return
else:
device = self._uid_dict[uid]
device['SUPPORTED_PARAMETERS'] = set(p['param_id'] for p in params['params'])
# TODO: 6 fetch DEVICE_INFO and a call _get_device_info_complete (added
# below)
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0,
"DEVICE_INFO",
lambda b, s, uid =
self.cur_uid:self._get_device_info_complete(uid, b, s))
def _get_device_info_complete(self, uid, succeeded, value) :
self._uid_dict[uid]["DEVICE_INFO"] = value
# at this point we now have the list of supported parameters & the device
# info for the pid selected.
print "uid_dict: %s" % self._uid_dict
self._notebook.Update()
def _get_identify_complete(self, uid, succeeded, value):
""" Callback for rdm_get in device_selected.
Sets the checkbox"s state to that of the currently selected device
"""
if succeeded:
self.id_state.set(value["identify_state"])
def _rdm_set_complete(self, uid, succeded, value):
""" callback for the rdm_set in identify. """
print "value: %s" % value
print "rdm set complete"
def GetBasicInformation(self):
"""
We want the following
"DEVICE_INFO"
"PRODUCT_DETAIL_ID_LIST"
"DEVICE_MODEL_DESCRIPTION"
"MANUFACTURER_LABEL"
"DEVICE_LABEL"
"FACTORY_DEFAULTS"
"SOFTWARE_VERSION_LABEL"
"BOOT_SOFTWARE_VERSION_ID"
"BOOT_SOFTWARE_VERSION_LABEL"
"""
if self.cur_uid is None:
return
self._get_product_detail_id()
def _get_product_detail_id(self):
pid_key = self._pid_store.GetName("PRODUCT_DETAIL_ID_LIST")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "PRODUCT_DETAIL_ID_LIST" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_product_detail_id_complete(b, s))
else:
self._get_device_model()
def _get_product_detail_id_complete(self, succeeded, data):
if succeeded:
print "got product detail ids"
self._uid_dict[self.cur_uid]["PRODUCT_DETAIL_ID_LIST"] = set(
value['detail_id'] for value in data['detail_ids'])
else:
print "failed"
# store the results in the uid dict
self._get_device_model()
def _get_device_model (self):
pid_key = self._pid_store.GetName("DEVICE_MODEL_DESCRIPTION")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DEVICE_MODEL_DESCRIPTION" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_device_model_complete(b, s))
else:
self._get_manufacturer_label()
def _get_device_model_complete(self, succeeded, data):
if succeeded:
print "got device model"
self._uid_dict[self.cur_uid]["DEVICE_MODEL_DESCRIPTION"] = data["description"]
else:
print "failed"
# store the results in the uid dict
self._get_manufacturer_label()
def _get_manufacturer_label(self):
pid_key = self._pid_store.GetName("MANUFACTURER_LABEL")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "MANUFACTURER_LABEL" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(),
self.cur_uid,
0,
pid_key.name,
lambda b, s: self._get_manufacturer_label_complete(b, s))
else:
self._get_factory_defaults()
def _get_manufacturer_label_complete(self, succeeded, data):
if succeeded:
print "got device model description"
self._uid_dict[self.cur_uid]["MANUFACTURER_LABEL"] = data["label"]
else:
print "failed"
# store the results in the uid dict
self._get_factory_defaults()
def _get_factory_defaults(self):
pid_key = self._pid_store.GetName("FACTORY_DEFAULTS")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "FACTORY_DEFAULTS" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_factory_defaults_complete(b, s))
else:
self._get_software_version()
def _get_factory_defaults_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["FACTORY_DEFAULTS"] = data["using_defaults"]
else:
print "failed"
# store the results in the uid dict
self._get_software_version()
def _get_software_version(self):
pid_key = self._pid_store.GetName("SOFTWARE_VERSION_LABEL")
if "SOFTWARE_VERSION_LABEL" not in self._uid_dict[self.cur_uid]:
self.ola_thread.rdm_get(self.universe.get(),
self.cur_uid,
0,
pid_key.name,
lambda b, s: self._get_software_version_complete(b, s)
)
else:
self._get_boot_version()
def _get_software_version_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["SOFTWARE_VERSION_LABEL"] = data["label"]
else:
print "failed"
# store the results in the uid dict
self._get_boot_version()
def _get_boot_version(self):
pid_key = self._pid_store.GetName("BOOT_SOFTWARE_VERSION")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "BOOT_SOFTWARE_VERSION" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(),
self.cur_uid,
0,
pid_key.name,
lambda b, s: self._get_boot_version_complete(b, s)
)
else:
self._get_boot_label()
def _get_boot_version_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["BOOT_SOFTWARE_VERSION"] = data["version"]
else:
print "failed"
# store the results in the uid dict
self._get_boot_label()
def _get_boot_label(self):
pid_key = self._pid_store.GetName("BOOT_SOFTWARE_LABEL")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "BOOT_SOFTWARE_LABEL" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_boot_label_complete(b, s))
else:
self._notebook.RenderBasicInformation(self._uid_dict[self.cur_uid])
def _get_boot_label_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["BOOT_SOFTWARE_LABEL"] = data["label"]
else:
print "failed"
# store the results in the uid dict
self._notebook.RenderBasicInformation(self._uid_dict[self.cur_uid])
def GetDMXInformation(self):
"""
// "DEVICE_INFO"
"DMX_PERSONALITY"
"DMX_PERSONALITY_DESCRIPTION"
"DMX_START_ADDRESS"
"SLOT_INFO"
"SLOT_DESCRIPTION"
"DEFAULT_SLOT_VALUE"
"""
if self.cur_uid is None:
return
self._get_dmx_personality()
def _get_dmx_personality(self):
pid_key = self._pid_store.GetName("DMX_PERSONALITY")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DMX_PERSONALITY" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_dmx_personality_complete(b, s))
else:
self._get_personality_description()
def _get_dmx_personality_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DMX_PERSONALITY"] = data
else:
print "failed"
# store the results in the uid dict
self._get_personality_description()
def _get_personality_description(self):
pid_key = self._pid_store.GetName("DMX_PERSONALITY_DESCRIPTION")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DMX_PERSONALITY" not in self._uid_dict[self.cur_uid]):
data = [self._uid_dict[self.cur_uid]["DMX_PERSONALITY_DESCRIPTION"]
["current_personality"]]
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_personality_description_complete(b, s), data)
else:
self._get_start_address()
def _get_personality_description_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DMX_PERSONALITY_DESCRIPTION"] = data
else:
print "failed"
# store the results in the uid dict
self._get_start_address()
def _get_start_address(self):
pid_key = self._pid_store.GetName("DMX_START_ADDRESS")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DMX_START_ADDRESS" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_start_address_complete(b, s))
else:
self._get_slot_info()
def _get_start_address_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DMX_START_ADDRESS"] = data["dmx_address"]
else:
print "failed"
# store the results in the uid dict
self._get_slot_info()
def _get_slot_info(self):
pid_key = self._pid_store.GetName("SLOT_INFO")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "SLOT_INFO" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_slot_info_complete(b, s))
else:
self._get_slot_description()
def _get_slot_info_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["SLOT_INFO"] = data
else:
print "failed"
# store the results in the uid dict
self._get_slot_description()
def _get_slot_description(self):
pid_key = self._pid_store.GetName("SLOT_DESCRIPTION")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "SLOT_DESCRIPTION" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_slot_description_complete(b, s))
else:
self._get_default_slot_value()
def _get_slot_description_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["SLOT_DESCRIPTION"] = data
else:
print "failed"
# store the results in the uid dict
self._get_defalut_slot_value()
def _get_default_slot_value(self):
pid_key = self._pid_store.GetName("DEFAULT_SLOT_VALUE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DEFAULT_SLOT_VALUE" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_default_value_complete(b, s))
else:
self._notebook.RenderDMXInformation(self._uid_dict[self.cur_uid])
def _get_default_slot_value_complete(self, succeeded, data):
if succeeded:
print ""
# this needs to be a set
self._uid_dict[self.cur_uid]["DEFAULT_SLOT_VALUE"] = data
else:
print "failed"
# store the results in the uid dict
self._notebook.RenderDMXInformation(self._uid_dict[self.cur_uid])
def GetSensorsInformation(self):
"""
"SENSOR_DEFINITION"
"SENSOR_VALUE"
"RECORD_SENSORS"
"""
if self.cur_uid is None:
return
self._get_sensor_definition()
def _get_sensor_definition(self):
pid_key = self._pid_store.GetName("SENSOR_DEFINITION")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "SENSOR_DEFINITION" not in self._uid_dict[self.cur_uid]):
data = [1]
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_sensor_definition_complete(b, s), data)
else:
self._get_sensor_value()
def _get_sensor_definition_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["SENSOR_DEFINITION"] = data
else:
print "failed"
# store the results in the uid dict
self._get_sensor_value()
def _get_sensor_value(self):
pid_key = self._pid_store.GetName("SENSOR_VALUE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "SENSOR_VALUE" not in self._uid_dict[self.cur_uid]):
data = [1]
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_sensor_value_complete(b, s), data)
else:
self._notebook.RenderSensorInformation(self._uid_dict[self.cur_uid])
# do I need to do anything with record sensors here?
def _get_sensor_value_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["SENSOR_VALUE"] = data
else:
print "failed"
# store the results in the uid dict
self._notebook.RenderSensorInformation(self._uid_dict[self.cur_uid])
def GetSettingInformation(self):
"""
"DEVICE_HOURS"
"LAMP_HOURS"
"LAMP_STRIKES"
"LAMP_STATE"
"LAMP_ON_MODE"
"DEVICE_POWER_CYCLES"
"POWER_STATE"
"""
if self.cur_uid is None:
return
self._get_device_hours()
def _get_device_hours(self):
pid_key = self._pid_store.GetName("DEVICE_HOURS")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DEVICE_HOURS" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_device_hours_complete(b, s))
else:
self._get_lamp_hours()
def _get_device_hours_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DEVICE_HOURS"] = data["hours"]
else:
print "failed"
# store the results in the uid dict
self._get_lamp_hours()
def _get_lamp_hours(self):
pid_key = self._pid_store.GetName("LAMP_HOURS")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LAMP_HOURS" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_lamp_hours_complete(b, s))
else:
self._get_lamp_strikes()
def _get_lamp_hours_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LAMP_HOURS"] = data["hours"]
else:
print "failed"
# store the results in the uid dict
self._get_lamp_strikes()
def _get_lamp_strikes(self):
pid_key = self._pid_store.GetName("LAMP_STRIKES")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LAMP_STRIKES" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_lamp_strikes_complete(b, s))
else:
self._get_lamp_state()
def _get_lamp_strikes_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LAMP_STRIKES"] = data["strikes"]
else:
print "failed"
# store the results in the uid dict
self._get_lamp_state()
def _get_lamp_state(self):
pid_key = self._pid_store.GetName("LAMP_STATE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LAMP_STATE" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_lamp_state_complete(b, s))
else:
self._get_lamp_on_mode()
def _get_lamp_state_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LAMP_STATE"] = data["state"]
else:
print "failed"
# store the results in the uid dict
self._get_lamp_on_mode()
def _get_lamp_on_mode(self):
pid_key = self._pid_store.GetName("LAMP_ON_MODE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LAMP_ON_MODE" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_lamp_on_mode_complete(b, s))
else:
self._get_power_cycles()
def _get_lamp_on_mode_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LAMP_ON_MODE"] = data["mode"]
else:
print "failed"
# store the results in the uid dict
self._get_power_cycles()
def _get_power_cycles(self):
pid_key = self._pid_store.GetName("DEVICE_POWER_CYCLES")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DEVICE_POWER_CYCLES" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_power_cycles_complete(b, s))
else:
self._get_power_state()
def _get_power_cycles_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DEVICE_POWER_CYCLES"] = data["power_cycles"]
else:
print "failed"
# store the results in the uid dict
self._get_power_state()
def _get_power_state(self):
pid_key = self._pid_store.GetName("POWER_STATE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "POWER_STATE" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_power_state_complete(b, s))
else:
self._notebook.RenderSettingInformation(self._uid_dict[self.cur_uid])
def _get_power_state_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["POWER_STATE"] = data["power_state"]
else:
print "failed"
# store the results in the uid dict
self._notebook.RenderSettingInformation(self._uid_dict[self.cur_uid])
def GetConfigInformation(self):
"""
"LANGUAGE_CAPABILITIES"
"LANGUAGE"
"DISPLAY_INVERT"
"DISPLAY_LEVEL"
"PAN_INVERT"
"TILT_INVERT"
"PAN_TILT_SWAP"
"REAL_TIME_CLOCK"
"""
if self.cur_uid is None:
return
def _get_language_capabilities(self):
pid_key = self._pid_store.GetName("LANGUAGE_CAPABILITIES")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LANGUAGE_CAPABILITIES" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_language_capabilities_complete(b, s))
else:
self._get_language()
def _get_language_capabilities_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LANGUAGE_CAPABILITIES"] = data
else:
print "failed"
# store the results in the uid dict
self._get_language()
def _get_language(self):
pid_key = self._pid_store.GetName("LANGUAGE")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "LANGUAGE" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_language_complete(b, s))
else:
self._get_display_invert()
def _get_language_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["LANGUAGE"] = data["language"]
else:
print "failed"
# store the results in the uid dict
self._get_display_invert()
def _get_display_invert(self):
pid_key = self._pid_store.GetName("DISPLAY_INVERT")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DISPLAY_INVERT" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_display_invert_complete(b, s))
else:
self._get_display_level()
def _get_display_invert_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DISPLAY_INVERT"] = data["invert_status"]
else:
print "failed"
# store the results in the uid dict
self._get_display_level()
def _get_display_level(self):
pid_key = self._pid_store.GetName("DISPLAY_LEVEL")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "DISPLAY_LEVEL" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_display_level_complete(b, s))
else:
self._get_pan_invert()
def _get_display_level_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["DISPLAY_LEVEL"] = data["level"]
else:
print "failed"
# store the results in the uid dict
self._get_pan_invert()
def _get_pan_invert(self):
pid_key = self._pid_store.GetName("PAN_INVERT")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "PAN_INVERT" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_pan_invert_complete(b, s))
else:
self._get_tilt_invert()
def _get_pan_invert_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["PAN_INVERT"] = data["invert"]
else:
print "failed"
# store the results in the uid dict
self._get_tilt_invert()
def _get_tilt_invert(self):
pid_key = self._pid_store.GetName("TILT_INVERT")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "TILT_INVERT" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_tilt_invert_complete(b, s))
else:
self._get_pan_tilt_swap()
def _get_tilt_invert_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["TILT_INVERT"] = data["invert"]
else:
print "failed"
# store the results in the uid dict
self._get_pan_tilt_swap()
def _get_pan_tilt_swap(self):
pid_key = self._pid_store.GetName("PAN_TILT_SWAP")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "PAN_TILT_SWAP" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(), self.cur_uid, 0, pid_key.name,
lambda b, s: self._get_pan_tilt_swap_complete(b, s))
else:
self._get_real_time()
def _get_pan_tilt_swap_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["PAN_TILT_SWAP"] = data["swap"]
else:
print "failed"
# store the results in the uid dict
self._get_real_time()
def _get_real_time(self):
pid_key = self._pid_store.GetName("REAL_TIME_CLOCK")
if (pid_key.value in self._uid_dict[self.cur_uid]['SUPPORTED_PARAMETERS']
and "REAL_TIME_CLOCK" not in self._uid_dict[self.cur_uid]):
self.ola_thread.rdm_get(self.universe.get(),
self.cur_uid,
0,
pid_key.name,
lambda b, s: self._get_real_time_complete(b, s)
)
else:
self._notebook.RenderConfigInformation(self._uid_dict[self.cur_uid])
def _get_real_time_complete(self, succeeded, data):
if succeeded:
print ""
self._uid_dict[self.cur_uid]["REAL_TIME_CLOCK"] = data
else:
print "failed"
# store the results in the uid dict
self._notebook.RenderConfigInformation(self._uid_dict[self.cur_uid])
def set_device_label(self, label):
"""
"""
uid = self.cur_uid
callback = lambda b, s, label = label, uid = uid:self.set_device_label_complete(uid, label, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
"DEVICE_LABEL",
callback,
[label]
)
def set_device_label_complete(self, uid, label, succeeded, data):
"""
"""
if succeeded:
index = self._uid_dict[self.cur_uid]["index"]
self._uid_dict[self.cur_uid]["DEVICE_LABEL"]["label"] = label
self.device_menu["menu"].entryconfigure(index, label = "%s (%s)"%(
self._uid_dict[uid]["DEVICE_LABEL"]["label"], uid))
else:
print "failed"
# store the results in the uid dict
self._notebook.Update()
def Update(self, index):
if self.cur_uid is None:
print "Error: No device selected."
return
def main(self):
print "Entering main loop"
self.root.mainloop()
if __name__ == "__main__":
display = DisplayApp(800, 600)
display.main()