-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimple_ui.py
1106 lines (968 loc) · 39.3 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
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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
import controlflow
import actions
import logging
from rdm_menu import RDMMenu
from rdm_dialog import RDMDialog
import PIDDict
'''
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:
- get_basic_information()
- get_dmx_information()
- GetSensorInformation()
Each of these send the necessary to build a dictionary (pid_info) for the tab.
For example, get_basic_information() 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.render_basic_information(pid_info)
which then updates all the widgets.
'''
# ==============================================================================
# ============================ Controller Class ================================
# ==============================================================================
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 get_basic_information(self):
self._app.get_basic_information()
def get_dmx_information(self):
self._app.get_dmx_information()
def get_sensor_value(self, sensor_number):
self._app.get_sensor_value(sensor_number)
def get_sensor_definitions(self):
self._app.get_sensor_definitions()
def get_setting_information(self):
self._app.get_setting_information()
def get_config_information(self):
self._app.get_config_information()
def set_device_label(self, label):
self._app.set_device_label(label)
def set_start_address(self, start_address):
self._app.set_start_address(start_address)
def set_dmx_personality(self, index):
self._app.set_dmx_personality(index)
def set_lamp_state(self, state):
self._app.set_lamp_state(state)
def set_lamp_on_mode(self, mode):
self._app.set_lamp_on_mode(mode)
def set_power_state(self, state):
self._app.set_power_state(state)
def set_language(self, language):
self._app.set_language(language)
def set_display_invert(self, invert):
self._app.set_display_invert(invert)
def set_display_level(self, level):
self._app.set_display_level(level)
def set_pan_invert(self, invert):
self._app.set_pan_invert(invert)
def set_tilt_invert(self, invert):
self._app.set_tilt_invert(invert)
def set_pan_tilt_swap(self, swap):
self._app.set_pan_tilt_swap(swap)
def record_sensor(self, sensor_number):
self._app.record_sensor(sensor_number)
def clear_sensor(self, sensor_number):
self._app.clear_sensor(sensor_number)
# ==============================================================================
# ============================ Universe Class ==================================
# ==============================================================================
class UniverseObj(object):
''' The UniverseObj class is used to access infromation for each Universe as
the user fetches new universes or switches between Universes in the GUI
'''
def __init__(self, uni_id, name):
self._id = uni_id
self._name = name
self._discover = False
self._uids = set()
@property
def name(self):
return self._name
@property
def id(self):
return self._id
@property
def discovery_run(self):
return self._discover
@property
def uids(self):
return self._uids
def set_uids(self, uid_list):
self._uids = set(uid_list)
self._discover = True
# ==============================================================================
# ============================ Display App Class ===============================
# ==============================================================================
class DisplayApp(object):
''' 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()
# ================== Initialize Variables and Ola Thread ===================
self.universe = tk.IntVar(self.root)
self.universe_dict = {}
self._cur_uid = None
self._uid_dict = {}
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)
# ================== Call Fetch Universes ==================================
self.fetch_universes(self.fetch_universes_complete)
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
'''
tk.Label(self.cntrl_frame, text = 'Select\nUniverse:').pack(side = tk.LEFT)
self.universe_menu = RDMMenu(self.cntrl_frame, 'No Universes Available',
'Select Universe')
self.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.device_menu = RDMMenu(self.cntrl_frame, "No Devices", "Select Device")
self.device_menu.pack(side = tk.LEFT)
self.id_state = tk.IntVar(self.root)
self.id_state.set(0)
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 = tk.BooleanVar(self.root)
self.auto_disc.set(False)
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
self._cur_uid = uid
pid_key = 'DEVICE_LABEL'
self.ola_thread.rdm_get(self.universe.get(), uid, 0, 'IDENTIFY_DEVICE',
lambda b, s, uid = uid:self._get_identify_complete(uid, b, s))
data = self._uid_dict[uid]
flow = controlflow.RDMControlFlow(
self.universe.get(), uid, [
actions.GetSupportedParams(data, self.ola_thread.rdm_get),
actions.GetDeviceInfo(data, self.ola_thread.rdm_get)
],
self._device_changed_complete)
flow.run()
def _device_changed_complete(self):
'''called once the control flow created in device_selected completes
'''
self._uid_dict[self._cur_uid]['PARAM_NAMES'] = set()
for pid_key in self._uid_dict[self._cur_uid]['SUPPORTED_PARAMETERS']:
pid = self._pid_store.GetPid(pid_key)
if pid is not None:
self._uid_dict[self._cur_uid]['PARAM_NAMES'].add(pid.name)
print 'Device selected: %s' % self._uid_dict[self._cur_uid]
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 fetch_universes(self, callback):
self.ola_thread.fetch_universes(self.fetch_universes_complete)
def fetch_universes_complete(self, succeeded, universes):
if succeeded:
for universe in universes:
self.universe_dict[universe.id] = UniverseObj(universe.id, universe.name)
self.universe_menu.add_item(universe.name,
lambda i = universe.id: self._set_universe(i))
else:
print 'could not find active universe'
def _set_universe(self, universe_id):
' sets the int var self.universe to the value of i '
print universe_id
self.universe.set(universe_id)
self.device_menu.clear_menu()
if not self.universe_dict[universe_id].discovery_run:
self.discover()
else:
for uid in self.universe_dict[universe_id].uids:
self._add_device_to_menu(uid)
def discover(self):
' runs discovery for the current universe. '
universe_id = self.universe.get()
self.ola_thread.run_discovery(universe_id,
lambda status, uids:self._upon_discover(status, uids, universe_id))
if self.auto_disc.get():
self.ola_thread.add_event(5000, self.discover)
else:
print 'Automatic discovery is off.'
def _upon_discover(self, status, uids, universe_id):
' callback for client.runRDMDiscovery. '
if self.universe.get() != universe_id:
return
self.universe_dict[universe_id].set_uids(uids)
if not uids:
self.device_menu.clear_menu()
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 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._set_identify_complete(uid, b, s),
[self.id_state.get()])
def _add_device(self, uid, error, data):
''' callback for the rdm_get in upon_discover.
populates self.device_menu
'''
if error is None:
self._uid_dict.setdefault(uid, {})['DEVICE_LABEL'] = data['label']
else:
self._uid_dict.setdefault(uid, {})['DEVICE_LABEL'] = ''
self._add_device_to_menu(uid)
def _set_identify_complete(self, uid, succeded, value):
''' callback for the rdm_set in identify. '''
print 'identify %s' % value
self._uid_dict[self._cur_uid] = value
# ============================================================================
# ============================ RDM Gets ======================================
def get_basic_information(self):
''' creates and calls the action flow for retrieving information for the
first tab of the notebook.
Triggered by: the control flow class, originally from the notebook
initialization and "Device Information" tab selection.
'''
if self._cur_uid is None:
print 'you need to select a device'
return
data = self._uid_dict[self._cur_uid]
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
[
actions.GetProductDetailIds(data, self.ola_thread.rdm_get),
actions.GetDeviceModel(data, self.ola_thread.rdm_get),
actions.GetManufacturerLabel(data, self.ola_thread.rdm_get),
actions.GetFactoryDefaults(data, self.ola_thread.rdm_get),
actions.GetSoftwareVersion(data, self.ola_thread.rdm_get),
actions.GetBootSoftwareLabel(data, self.ola_thread.rdm_get),
actions.GetBootSoftwareVersion(data, self.ola_thread.rdm_get)
],
self.update_basic_information)
flow.run()
def get_dmx_information(self):
''' creates and calls the action flow for retrieving information for the
second tab of the notebook.
Triggered by: the control flow class, originally from the notebook
initialization and "DMX512 Information" tab selection.
'''
if self._cur_uid is None:
print 'you need to select a device.'
return
dmx_actions = []
data = self._uid_dict[self._cur_uid]
dmx_actions.append(actions.GetDmxPersonality(data, self.ola_thread.rdm_get))
for i in xrange(data['DEVICE_INFO']['personality_count']):
dmx_actions.append(actions.GetPersonalityDescription(
data,
self.ola_thread.rdm_get,
[i + 1]))
dmx_actions.append(actions.GetStartAddress(data, self.ola_thread.rdm_get))
dmx_actions.append(actions.GetSlotInfo(data, self.ola_thread.rdm_get))
print 'dmx_footprint: %d' % data['DEVICE_INFO']['dmx_footprint']
for i in xrange(data['DEVICE_INFO']['dmx_footprint']):
dmx_actions.append(actions.GetSlotDescription(
data,
self.ola_thread.rdm_get,
[i]))
dmx_actions.append(
actions.GetDefaultSlotValue(data, self.ola_thread.rdm_get))
print i
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
dmx_actions,
self.update_dmx_information)
flow.run()
def get_sensor_definitions(self):
''' gets the sensor definition for each sensor in the sensor count
'''
if self._cur_uid is None:
return
sensor_actions = []
data = self._uid_dict[self._cur_uid]
for i in xrange(data['DEVICE_INFO']['sensor_count']):
sensor_actions.append(actions.GetSensorDefinition(data,
self.ola_thread.rdm_get,
[i]))
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
sensor_actions,
self.update_sensor_information)
flow.run()
def get_sensor_value(self, sensor_number):
""" gets the sensor value for the currently selected sensor
Args: sensor_number: the number associated with the currently selected
sensor.
call originates in render_sensor_information in the notebook class.
"""
if self._cur_uid is None:
return
sensor_actions = []
data = self._uid_dict[self._cur_uid]
sensor_actions = [actions.GetSensorValue(data,
self.ola_thread.rdm_get,
[sensor_number])]
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
sensor_actions,
lambda: self.display_sensor_data(sensor_number))
flow.run()
def get_setting_information(self):
''' creates and calls the action flow for retrieving information for the
forth tab of the notebook.
Triggered by: the control flow class, originally from the notebook
initialization and "Power and Lamp Settings" tab selection.
'''
if self._cur_uid is None:
print 'you need to select a device'
return
data = self._uid_dict[self._cur_uid]
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
[
actions.GetDeviceHours(data, self.ola_thread.rdm_get),
actions.GetLampHours(data, self.ola_thread.rdm_get),
actions.GetLampState(data, self.ola_thread.rdm_get),
actions.GetLampStrikes(data, self.ola_thread.rdm_get),
actions.GetLampOnMode(data, self.ola_thread.rdm_get),
actions.GetPowerCycles(data, self.ola_thread.rdm_get),
actions.GetPowerState(data, self.ola_thread.rdm_get),
],
self.update_setting_information)
flow.run()
def get_config_information(self):
''' creates and calls the action flow for retrieving information for the
fifth tab of the notebook.
Triggered by: the control flow class, originally from the notebook
initialization and "Configure" tab selection.
'''
if self._cur_uid is None:
print 'you need to select a device'
return
data = self._uid_dict[self._cur_uid]
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
[
actions.GetLanguageCapabilities(data, self.ola_thread.rdm_get),
actions.GetLanguage(data, self.ola_thread.rdm_get),
actions.GetDisplayInvert(data, self.ola_thread.rdm_get),
actions.GetDisplayLevel(data, self.ola_thread.rdm_get),
actions.GetPanInvert(data, self.ola_thread.rdm_get),
actions.GetTiltInvert(data, self.ola_thread.rdm_get),
actions.GetPanTiltSwap(data, self.ola_thread.rdm_get),
actions.GetRealTimeClock(data, self.ola_thread.rdm_get)
],
self.update_config_information)
flow.run()
# ============================ Notebook Updates ==============================
# The following methods call into the notebook class and popluate the
# associted tab with RDM information
def update_basic_information(self):
# print "uid_dict: %s" % self._uid_dict[self._cur_uid]
self._notebook.render_basic_information(self._uid_dict[self._cur_uid])
def update_dmx_information(self):
self._notebook.render_dmx_information(self._uid_dict[self._cur_uid])
def update_setting_information(self):
self._notebook.render_setting_information(self._uid_dict[self._cur_uid])
def update_config_information(self):
self._notebook.render_config_information(self._uid_dict[self._cur_uid])
# the sensor tab is slightly different that those above. The first method
# populates (update_sensor_information) the RDM menu on the sensor tab and the
# second method displays the values being recorded/sensed by the sensor device
def update_sensor_information(self):
self._notebook.render_sensor_information(self._uid_dict[self._cur_uid])
def display_sensor_data(self,sensor_number):
self._notebook.display_sensor_data(
self._uid_dict[self._cur_uid],sensor_number)
# ============================ RDM Sets ======================================
def set_start_address(self, start_address):
''' RDM set call for DMX_START_ADDRESS
call originates from the start address button in the notebook class
Args:
start_address: INT 16 bit; the DMX address that is set as the start
address.
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._set_address_complete(start_address, b, s)
self.ola_thread.rdm_set(
self.universe.get(), uid, 0, 'DMX_START_ADDRESS', callback,
[start_address])
def _set_address_complete(self, start_address, error, data):
''' Callback method from DMX_START_ADDRESS RDM set.
Args:
start_address: INT 16 bit; the new DMX start address of the RDM
device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
print 'set start address callback'
if error is None:
pid_dict = self._uid_dict[self._cur_uid]
pid_dict['DEVICE_INFO']['dmx_start_address'] = start_address
pid_dict['DMX_START_ADDRESS'] = start_address
print 'DMX start address set to %s' % start_address
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_dmx_personality(self, personality):
''' RDM set call for DMX_PERSONALITY
call originates from an optionMenu in the DMX tab in the notebook class
Args:
personaility: INT 8 bit; the new personality for the current device
'''
print "setting DMX persaonality..."
if self._cur_uid is None:
return
data = self._uid_dict[self._cur_uid]
flow_actions = [actions.SetDMXPersonality(data, self.ola_thread.rdm_set,
[personality])]
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
flow_actions,
lambda: self._get_slot_info(personality, None, data))
flow.run()
def _get_slot_info(self, personality, error, data):
'''
Args:
personality: INT 8 bit; the personality of the current device
error: the error returned if the previous ola call fails, otherwise
this will be None
data: 16 bit slot number, data to be passed to the ola thread
'''
print 'getting slot info...'
if error is None:
data = self._uid_dict[self._cur_uid]
flow_actions = []
for slot in xrange(self._uid_dict[self._cur_uid]
['DMX_PERSONALITY_DESCRIPTION']
[personality]['slots_required']):
flow_actions.append(actions.GetSlotDescription(
data, self.ola_thread.rdm_get, [slot]))
flow_actions.append(actions.GetSlotInfo(data, self.ola_thread.rdm_get))
flow_actions.append(actions.GetDefaultSlotValue(
data, self.ola_thread.rdm_get))
flow = controlflow.RDMControlFlow(
self.universe.get(),
self._cur_uid,
flow_actions,
lambda: self._set_dmx_personality_complete(None, data))
flow.run()
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def _set_dmx_personality_complete(self, error, data):
''' Callback method from DMX_PERSONALITY RDM set.
Args:
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
#print self._uid_dict[self._cur_uid]
if error is None:
self._notebook.set_dmx_personality_complete(self._uid_dict[self._cur_uid])
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
def set_display_level(self, level):
''' RDM set call for DISPLAY_LEVEL
call originates from a scale in the config tab of the notebook class
Args:
level: INT 8 bit; the new display level for the current device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._display_level_complete(uid, level, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'DISPLAY_LEVEL',
callback,
[level])
def _display_level_complete(self, uid, level, error, data):
''' Callback method from DISPLAY_LEVEL RDM set.
Args:
uid: The uid of the current uid
level: INT 8 bit, the new display level of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['DISPLAY_LEVEL'] = level
self._notebook.set_display_level_complete(level)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_lamp_state(self, state):
''' RDM set call for LAMP_STATE
call originates from an optionMenu in the lamp/power settings tab of the
notebook class
Args:
state: INT [0, 3]; the new lamp state for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._set_lamp_state_complete(uid, state, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'LAMP_STATE',
callback,
[state])
def _set_lamp_state_complete(self, uid, state, error, data):
'''Callback method from LAMP_STATE RDM set.
Args:
uid: The uid of the RDM device
state: INT [0, 3]; the new lamp state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['LAMP_STATE'] = state
self._notebook.set_lamp_state_complete(state)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_lamp_on_mode(self, mode):
''' RDM set call for LAMP_ON_MODE
call originates from an optionMenu in the lamp/power settings tab of the
notebook class
Args:
mode: INT [0, 3]; the new lamp on mode for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._set_lamp_on_mode_complete(uid, mode, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'LAMP_ON_MODE',
callback,
[mode])
def _set_lamp_on_mode_complete(self, uid, mode, error, data):
'''Callback method from LAMP_ON_MODE RDM set.
Args:
uid: The uid of the RDM device
mode: INT [0, 3]; the new lamp on mode of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['LAMP_ON_MODE'] = mode
self._notebook.set_lamp_on_mode_complete(mode)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_power_state(self, state):
''' RDM set call for POWER_STATE
call originates from an optionMenu in the lamp/power settings tab of the
notebook class
Args:
state: INT {[0,2], 255}; the new power state for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._set_power_state_complete(uid, state, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'POWER_STATE',
callback,
[state])
def _set_power_state_complete(self, uid, state, error, data):
'''Callback method from POWER_STATE RDM set.
Args:
uid: The uid of the RDM device
state: INT {[0,2], 255}; the new power state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['POWER_STATE'] = state
self._notebook.set_power_state_complete(state)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_language(self, language):
''' RDM set call for LANGUAGE
call originates from an optionMenu in the config tab of the notebook
class
Args:
language: STRING length 2; the new language for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._language_complete(uid, language, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'LANGUAGE',
callback,
[language])
def _language_complete(self, uid, language, error, data):
'''Callback method from LANGUAGE RDM set.
Args:
uid: The uid of the RDM device
language: STRING length 2; the new language of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['LANGUAGE'] = language
self._notebook.set_language_complete(language)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_display_invert(self, invert):
''' RDM set call for DISPLAY_INVERT
call originates from an optionMenu in the config tab of the notebook
class
Args:
invert: INT [0,2]; the new invert state for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._display_invert_complete(uid, invert, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'DISPLAY_INVERT',
callback,
[invert])
def _display_invert_complete(self, uid, invert, error, data):
'''Callback method from DISPLAY_INVERT RDM set.
Args:
uid: The uid of the RDM device
invert: INT [0,2]; the new invert state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['DISPLAY_INVERT'] = invert
self._notebook.set_display_invert_complete(invert)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_pan_invert(self, invert):
''' RDM set call for PAN_INVERT
call originates from a checkbox in the config tab of the notebook
class
Args:
invert: BOOL; the new pan invert state for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._pan_invert_complete(uid, invert, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'PAN_INVERT',
callback,
[invert])
def _pan_invert_complete(self, uid, invert, error, data):
'''Callback method from PAN_INVERT RDM set.
Args:
uid: The uid of the RDM device
invert: BOOL; the new pan invert state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['PAN_INVERT'] = invert
self._notebook.set_pan_invert_complete(invert)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_tilt_invert(self, invert):
''' RDM set call for TILT_INVERT
call originates from a checkbox in the config tab of the notebook
class
Args:
invert: BOOL; the new tilt invert state for the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._tilt_invert_complete(uid, invert, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'TILT_INVERT',
callback,
[invert])
def _tilt_invert_complete(self, uid, invert, error, data):
'''Callback method from TILT_INVERT RDM set.
Args:
uid: The uid of the RDM device
invert: BOOL; the new tilt invert state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['TILT_INVERT'] = invert
self._notebook.set_tilt_invertComplete(invert)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def set_pan_tilt_swap(self, swap):
''' RDM set call for PAN_TILT_SWAP
call originates from a checkbox in the config tab of the notebook
class
Args:
swap: BOOL; the new pan/tilt swap state of the RDM device
'''
if self._cur_uid is None:
return
uid = self._cur_uid
callback = lambda b, s: self._pan_tilt_swap_complete(uid, swap, b, s)
self.ola_thread.rdm_set(self.universe.get(),
uid,
0,
'PAN_TILT_SWAP',
callback,
[swap])
def _pan_tilt_swap_complete(self, uid, swap, error, data):
'''Callback method from PAN_TILT_SWAP RDM set.
Args:
uid: The uid of the RDM device
swap: BOOL; the new pan/tilt swap state of the RDM device
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
self._uid_dict[uid]['PAN_TILT_SWAP'] = swap
self._notebook.set_pan_tilt_swap_complete(swap)
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()
def record_sensor(self, sensor_number):
''' RDM set call for RECORD_SENSORS
call originates from a button in the sensor tab of the notebook
class
Args:
sensor_number: INT; the number of the sensor whose values are being
recorded
'''
self.ola_thread.rdm_set(self.universe.get(),
self._cur_uid,
0,
'RECORD_SENSORS',
lambda b, s: self._record_sensor_complete(b, s),
[sensor_number])
def _record_sensor_complete(self, error, data):
''' Callback method from RECORD_SENSORS RDM set.
Args:
error: If the RDM set fails, this will be the error returned by OLA
otherwise this value will be None
data: Not Present
'''
if error is None:
pass
else:
d = RDMDialog(self.root, error)
self.root.wait_window(d.top)
self._notebook.update()