-
Notifications
You must be signed in to change notification settings - Fork 9
/
client.py
1119 lines (954 loc) · 45.9 KB
/
client.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
# Python Imports
import wx.lib.agw.floatspin as FS
from datetime import datetime
import re
import time
from threading import Thread
# Local Imports
import globals
from yamaha import *
from helpers import *
class SmartVolumeFinished(eg.ActionBase):
def __call__(self):
self.plugin.smart_vol_up_start = None
self.plugin.smart_vol_down_start = None
class SmartVolumeUp(eg.ActionBase):
def __call__(self, zone, step1, step2, wait):
izone = convert_zone_to_int(self.plugin, zone)
if self.plugin.smart_vol_up_start is None:
self.plugin.smart_vol_up_start = datetime.now()
diff = datetime.now() - self.plugin.smart_vol_up_start
if diff.seconds < float(wait):
#print "Volume Up:", step1
increase_volume(self.plugin, izone, step1)
else:
#print "Volume Up:", step2
increase_volume(self.plugin, izone, step2)
def Configure(self, zone='Active Zone', step1=0.5, step2=2.0, wait=2.0):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Increase Amount (Step 1): ", pos=(10, 60))
fs_step1 = FS.FloatSpin(panel, -1, pos=(170, 57), min_val=0.5, max_val=10,
increment=0.5, value=float(step1), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="dB", pos=(270, 60))
fs_step1.SetFormat("%f")
fs_step1.SetDigits(1)
wx.StaticText(panel, label="Time between Step 1 to Step 2: ", pos=(10, 100))
fs_wait = FS.FloatSpin(panel, -1, pos=(170, 97), min_val=0.5, max_val=999,
increment=0.1, value=float(wait), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="Seconds", pos=(270, 100))
fs_wait.SetFormat("%f")
fs_wait.SetDigits(1)
wx.StaticText(panel, label="Increase Amount (Step 2): ", pos=(10, 140))
fs_step2 = FS.FloatSpin(panel, -1, pos=(170, 137), min_val=0.5, max_val=10,
increment=0.5, value=float(step2), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="dB", pos=(270, 140))
fs_step2.SetFormat("%f")
fs_step2.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], fs_step1.GetValue(), fs_step2.GetValue(), fs_wait.GetValue())
class SmartVolumeDown(eg.ActionBase):
def __call__(self, zone, step1, step2, wait):
izone = convert_zone_to_int(self.plugin, zone)
if self.plugin.smart_vol_down_start is None:
self.plugin.smart_vol_down_start = datetime.now()
diff = datetime.now() - self.plugin.smart_vol_down_start
if diff.seconds < float(wait):
decrease_volume(self.plugin, izone, step1)
else:
decrease_volume(self.plugin, izone, step2)
def Configure(self, zone='Active Zone', step1=0.5, step2=2.0, wait=2.0):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Decrease Amount (Step 1): ", pos=(10, 60))
fs_step1 = FS.FloatSpin(panel, -1, pos=(170, 57), min_val=0.5, max_val=10,
increment=0.5, value=float(step1), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="dB", pos=(270, 60))
fs_step1.SetFormat("%f")
fs_step1.SetDigits(1)
wx.StaticText(panel, label="Time between Step 1 to Step 2: ", pos=(10, 100))
fs_wait = FS.FloatSpin(panel, -1, pos=(170, 97), min_val=0.5, max_val=999,
increment=0.1, value=float(wait), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="Seconds", pos=(270, 100))
fs_wait.SetFormat("%f")
fs_wait.SetDigits(1)
wx.StaticText(panel, label="Decrease Amount (Step 2): ", pos=(10, 140))
fs_step2 = FS.FloatSpin(panel, -1, pos=(170, 137), min_val=0.5, max_val=10,
increment=0.5, value=float(step2), agwStyle=FS.FS_LEFT)
wx.StaticText(panel, label="dB", pos=(270, 140))
fs_step2.SetFormat("%f")
fs_step2.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], fs_step1.GetValue(), fs_step2.GetValue(), fs_wait.GetValue())
class IncreaseVolume(eg.ActionBase):
def __call__(self, zone, step):
increase_volume(self.plugin, convert_zone_to_int(self.plugin, zone), float(step))
def Configure(self, zone='Active Zone', step=0.5):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Increase Amount (Step): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=0.5, max_val=10,
increment=0.5, value=float(step), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class DecreaseVolume(eg.ActionBase):
def __call__(self, zone, step):
decrease_volume(self.plugin, convert_zone_to_int(self.plugin, zone), float(step))
def Configure(self, zone='Active Zone', step=0.5):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Decrease Amount (Step): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=0.5, max_val=10,
increment=0.5, value=float(step), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class SetVolume(eg.ActionBase):
def __call__(self, zone, vol):
set_volume(self.plugin, convert_zone_to_int(self.plugin, zone), float(vol))
def Configure(self, zone='Active Zone', vol=-50.0):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Exact Volume (dB): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=-100.0, max_val=50.0,
increment=0.5, value=float(vol), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class SetMaxVolume(eg.ActionBase):
def __call__(self, zone, vol):
set_max_volume(self.plugin, convert_zone_to_int(self.plugin, zone), float(vol))
def Configure(self, zone='Active Zone', vol=16.5):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Max Volume (dB): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=-30.0, max_val=16.5,
increment=0.5, value=float(vol), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class SetInitVolume(eg.ActionBase):
def __call__(self, zone, vol, mode):
set_init_volume(self.plugin, convert_zone_to_int(self.plugin, zone), float(vol), mode)
def Configure(self, zone='Active Zone', vol=-50.0, mode="Off"):
panel = eg.ConfigPanel()
modes = ["Off", "On"]
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Mode: ", pos=(10, 60))
choice_mode = wx.Choice(panel, -1, (10, 80), choices=modes)
choice_mode.SetStringSelection(mode)
wx.StaticText(panel, label="Exact Volume (dB): ", pos=(10, 110))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 130), min_val=-100.0, max_val=50.0,
increment=0.5, value=float(vol), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue(), modes[choice_mode.GetCurrentSelection()])
class SetBass(eg.ActionBase):
def __call__(self, zone, val):
set_bass(self.plugin, convert_zone_to_int(self.plugin, zone), float(val))
def Configure(self, zone='Active Zone', val=0.0):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Exact Value (dB): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=-6.0, max_val=6.0,
increment=0.5, value=float(val), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class SetTreble(eg.ActionBase):
def __call__(self, zone, val):
set_treble(self.plugin, convert_zone_to_int(self.plugin, zone), float(val))
def Configure(self, zone='Active Zone', val=0.0):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Exact Value (dB): ", pos=(10, 60))
floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=-6.0, max_val=6.0,
increment=0.5, value=float(val), agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(1)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], floatspin.GetValue())
class SetPattern1(eg.ActionBase):
def __call__(self, levels):
set_pattern1(self.plugin, levels)
def Configure(self, levels=None):
panel = eg.ConfigPanel()
if levels == None:
levels = get_system_pattern_1(self.plugin) #gets levels from receiver
adjpos = (10, 10)
floatspin = []
for speaker in levels:
wx.StaticText(panel, label=speaker[0] + " Exact Value (dB): ", pos=adjpos)
adjpos = (10, adjpos[1] + 20)
floatspin.append(FS.FloatSpin(panel, -1, pos=adjpos, min_val=-10.0, max_val=10.0,
increment=0.5, value=float(speaker[1]), agwStyle=FS.FS_LEFT))
floatspin[-1].SetFormat("%f")
floatspin[-1].SetDigits(1)
adjpos = (10, adjpos[1] + 30)
while panel.Affirmed():
for i in range(0,len(floatspin)):
levels[i] = [levels[i][0], floatspin[i].GetValue()]
panel.SetResult(levels)
class SetActiveZone(eg.ActionBase):
def __call__(self, zone):
set_active_zone(self.plugin, convert_zone_to_int(self.plugin, zone))
def Configure(self, zone='Main Zone'):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, False, self.plugin.AVAILABLE_ZONES) # Don't include active zone!
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()])
class SetScene(eg.ActionBase):
def __call__(self, scene):
set_scene(self.plugin, int(scene))
def Configure(self, scene=1):
panel = eg.ConfigPanel()
wx.StaticText(panel, label="Scene Number: ", pos=(10, 10))
spin = wx.SpinCtrl(panel, -1, "", (10, 30), (80, -1))
spin.SetRange(1,12)
spin.SetValue(int(scene))
while panel.Affirmed():
panel.SetResult(spin.GetValue())
class SetSourceInput(eg.ActionBase):
def __call__(self, zone, source):
izone = convert_zone_to_int(self.plugin, zone)
if source =="Tuner": #special case. I don't know why
source = "TUNER"
change_source(self.plugin, source, izone)
def Configure(self, zone="Active Zone", source="HDMI1"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
inputs = self.plugin.AVAILABLE_SOURCES
wx.StaticText(panel, label="Source Input: ", pos=(10, 60))
choice_input = wx.Choice(panel, -1, (10, 80), choices=inputs)
if source in inputs:
choice_input.SetStringSelection(source)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], inputs[choice_input.GetCurrentSelection()])
class SetPowerStatus(eg.ActionBase):
def __call__(self, zone, status):
izone = convert_zone_to_int(self.plugin, zone)
if status == 'Toggle On/Standby':
toggle_on_standby(self.plugin, izone)
elif status == 'On':
power_on(self.plugin, izone)
elif status == 'Standby':
power_standby(self.plugin, izone)
def Configure(self, zone="Active Zone", status="Toggle On/Standby"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
statuses = [ 'Toggle On/Standby', 'On', 'Standby' ]
wx.StaticText(panel, label="Power Status: ", pos=(10, 60))
choice = wx.Choice(panel, -1, (10, 80), choices=statuses)
if status in statuses:
choice.SetStringSelection(status)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], statuses[choice.GetCurrentSelection()])
class SetSleepStatus(eg.ActionBase):
def __call__(self, zone, status):
izone = convert_zone_to_int(self.plugin, zone)
set_sleep(self.plugin, status, izone)
def Configure(self, zone="Active Zone", status="Off"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
statuses = [ 'Off', '30 min', '60 min', '90 min', '120 min', 'Last' ]
wx.StaticText(panel, label="Sleep Status: ", pos=(10, 60))
choice = wx.Choice(panel, -1, (10, 80), choices=statuses)
if status in statuses:
choice.SetStringSelection(status)
while panel.Affirmed():
panel.SetResult(zones[choice_zone.GetCurrentSelection()], statuses[choice.GetCurrentSelection()])
class SetSurroundMode(eg.ActionBase):
def __call__(self, mode):
if mode == 'Toggle Straight/Surround Decode':
toggle_straight_decode(self.plugin)
elif mode == 'Straight':
straight(self.plugin)
elif mode == 'Surround Decode':
surround_decode(self.plugin)
def Configure(self, mode='Toggle Straight/Surround Decode'):
panel = eg.ConfigPanel()
modes = [ 'Toggle Straight/Surround Decode', 'Straight', 'Surround Decode' ]
wx.StaticText(panel, label="Surround Mode: ", pos=(10, 10))
choice = wx.Choice(panel, -1, (10, 30), choices=modes)
if mode in modes:
choice.SetStringSelection(mode)
while panel.Affirmed():
panel.SetResult(modes[choice.GetCurrentSelection()])
class Set7ChannelMode(eg.ActionBase): # McB 1/11/2014 - Turn 7-channel mode on and off
def __call__(self, mode):
if mode == 'On':
channel7_on(self.plugin)
elif mode == 'Off':
channel7_off(self.plugin)
def Configure(self, mode='On'):
panel = eg.ConfigPanel()
modes = [ 'On', 'Off' ]
wx.StaticText(panel, label="7-Channel Mode: ", pos=(10, 10))
choice = wx.Choice(panel, -1, (10, 30), choices=modes)
if mode in modes:
choice.SetStringSelection(mode)
while panel.Affirmed():
panel.SetResult(modes[choice.GetCurrentSelection()])
class CursorAction(eg.ActionBase):
def __call__(self, action, zone):
code = None
izone = convert_zone_to_int(self.plugin, zone, convert_active=True)
if izone in [0,1]:
code = globals.CURSOR_CODES[1][action]
if izone == 2:
# Not all of the actions are supported for zone 2
code = globals.CURSOR_CODES[2].get(action, None)
if code is not None:
send_code(self.plugin, code)
else:
# It is possible the user's active zone is not yet supported
eg.PrintError("Zone {0} is not yet supported for this action".format(izone if izone > -1 else chr(-1 * izone)))
def Configure(self, action="Up", zone="Active Zone"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, globals.All_ZONES_PLUS_ACTIVE, limit=2)
actions = globals.CURSOR_CODES[1].keys()
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Cursor Action: ", pos=(10, 60))
choice_action = wx.Choice(panel, -1, (10, 80), choices=actions)
if action in actions:
choice_action.SetStringSelection(action)
while panel.Affirmed():
panel.SetResult(actions[choice_action.GetCurrentSelection()], zones[choice_zone.GetCurrentSelection()])
class OperationAction(eg.ActionBase):
def __call__(self, action, zone):
code = None
izone = convert_zone_to_int(self.plugin, zone, convert_active=True)
if izone in [0,1]:
code = globals.OPERATION_CODES[1][action]
if izone == 2:
code = globals.OPERATION_CODES[2][action]
if code is not None:
send_code(self.plugin, code)
else:
# It is possible the user's active zone is not yet supported
eg.PrintError("Zone {0} is not yet supported for this action".format(izone if izone > -1 else chr(-1 * izone)))
def Configure(self, action="Play", zone="Active Zone"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, globals.ALL_ZONES_PLUS_ACTIVE, limit=2)
actions = globals.OPERATION_CODES[1].keys()
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Operation: ", pos=(10, 60))
choice_action = wx.Choice(panel, -1, (10, 80), choices=actions)
if action in actions:
choice_action.SetStringSelection(action)
while panel.Affirmed():
panel.SetResult(actions[choice_action.GetCurrentSelection()], zones[choice_zone.GetCurrentSelection()])
class NumCharAction(eg.ActionBase):
def __call__(self, action, zone):
code = None
izone = convert_zone_to_int(self.plugin, zone, convert_active=True)
if izone in [0,1]:
code = globals.NUMCHAR_CODES[1][action]
if izone == 2:
code = globals.NUMCHAR_CODES[2][action]
if code is not None:
send_code(self.plugin, code)
else:
# It is possible the user's active zone is not yet supported
eg.PrintError("Zone {0} is not yet supported for this action".format(izone if izone > -1 else chr(-1 * izone)))
def Configure(self, action="1", zone="Main Zone"):
panel = eg.ConfigPanel()
zones = get_available_zones(self.plugin, True, globals.ALL_ZONES_PLUS_ACTIVE, limit=2)
actions = sorted(globals.NUMCHAR_CODES[1].keys(), key=lambda k: int(k) if len(k) == 1 else 10 + len(k))
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
wx.StaticText(panel, label="Action: ", pos=(10, 60))
choice_action = wx.Choice(panel, -1, (10, 80), choices=actions)
if action in actions:
choice_action.SetStringSelection(action)
while panel.Affirmed():
panel.SetResult(actions[choice_action.GetCurrentSelection()], zones[choice_zone.GetCurrentSelection()])
class GetInfo(eg.ActionBase):
def __call__(self, object, cat):
if object == "Active Speakers":
return get_system_pattern_1(self.plugin, object)
if object == "PreOut Levels":
return get_system_pattern_1(self.plugin, object)
zone = None
#zone specific objects
if object == "Input Selection":
object = "Input_Sel"
if object == "Scene":
return "not complete"
if object == "Sound Program":
object = "Sound_Program"
if cat == "Main Zone":
zone = 1
if cat.startswith("Zone"):
zone = convert_zone_to_int(self.plugin, cat)
if object == "Volume Level":
val, unit = get_status_strings(self.plugin, ["Val", "Unit"], zone)
return "{0} {1}".format(float(val) / 10.0, unit)
if object == "Treble":
val = get_sound_video_string(self.plugin, "Val", zone, "Treble")
return "{0} ".format(float(val) / 10.0) + "dB"
if object == "Bass":
val = get_sound_video_string(self.plugin, "Val", zone, "Bass")
return "{0} ".format(float(val) / 10.0) + "dB"
if object == "Init Volume Mode":
return get_volume_string(self.plugin, "Mode", zone, "Init_Lvl")
if object == "Init Volume Level":
val = get_volume_string(self.plugin, "Val", zone, "Init_Lvl")
return "{0} ".format(float(val) / 10.0) + "dB"
if object == "Max Volume Level":
val = get_volume_string(self.plugin, "Val", zone, "Max_Lvl")
return "{0} ".format(float(val) / 10.0) + "dB"
if zone is not None:
return get_status_string(self.plugin, object,zone)
#all the rest are zone agnostic
#object, input, location to get_device_string
section = "List_Info"
if object in ["Menu Layer", "Menu Name", "Current Line", "Max Line"] \
or object in ['Line {0}'.format(i) for i in range(9)]:
object = object.replace(' ', '_')
else:
section = "Play_Info"
if object == "FM Mode":
object = "FM_Mode"
elif object == "Frequency":
try:
val, unit, band, exp = get_device_strings(self.plugin, ["Val", "Unit", "Band", "Exp"], cat, section)
if int(exp) == 0:
real_val = int(val)
else:
real_val = float(val) / pow(10, int(exp))
return "{0} {1}".format(real_val, unit)
except:
eg.PrintError("Input not active or unavailable with your model.")
return None
elif object == "Audio Mode":
object = "Current"
elif object == "Antenna Strength":
object = "Antenna_Lvl"
elif object == "Channel Number":
object = "Ch_Number"
elif object == "Channel Name":
object = "Ch_Name"
elif object == "Playback Info":
object = "Playback_Info"
elif object == "Repeat Mode":
object = "Repeat"
elif object == "Connect Information":
object = "Connect_Info"
try:
return get_device_string(self.plugin, object, cat, section)
except:
eg.PrintError("Input not active or unavailable with your model.")
def Configure(self, object="Power", cat="Main Zone"):
panel = eg.ConfigPanel()
self.cats = ["System"] + self.plugin.AVAILABLE_ZONES + self.plugin.AVAILABLE_INFO_SOURCES
wx.StaticText(panel, label="Category: ", pos=(10, 10))
self.choice_cat = wx.Choice(panel, -1, (10, 30), choices=self.cats)
if cat in self.cats:
self.choice_cat.SetStringSelection(cat)
self.choice_cat.Bind(wx.EVT_CHOICE, self.CategoryChanged)
self.objects = [ 'Power', 'Sleep', 'Volume Level', 'Mute', 'Input Selection', 'Scene', 'Straight', 'Enhancer', 'Sound Program']
wx.StaticText(panel, label="Object: ", pos=(10, 60))
self.choice_object = wx.Choice(panel, -1, (10, 80), choices=self.objects)
self.CategoryChanged()
if object in self.objects:
self.choice_object.SetStringSelection(object)
while panel.Affirmed():
panel.SetResult(self.objects[self.choice_object.GetCurrentSelection()], self.cats[self.choice_cat.GetCurrentSelection()])
def CategoryChanged(self, event=None):
cat = self.cats[self.choice_cat.GetCurrentSelection()]
if cat == "System":
self.objects = globals.SYSTEM_OBJECTS
elif cat == "Main Zone":
self.objects = globals.MAIN_ZONE_OBJECTS
elif cat.startswith("Zone"):
self.objects = globals.ZONE_OBJECTS
elif cat == "Tuner" or cat == "TUNER":
self.objects = [ 'Band', 'Frequency', 'FM Mode']
elif cat == "HD Radio":
self.objects = [ 'Band', 'Frequency', 'Audio Mode']
elif cat == "SIRIUS" or cat == "SiriusXM" or cat == "Spotify":
self.objects = globals.SIRIUS_OBJECTS
elif cat == "iPod":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
elif cat == "Bluetooth":
self.objects = [ 'Connect Information']
elif cat == "Rhapsody":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
elif cat == "SIRIUSInternetRadio":
self.objects = globals.SIRIUS_IR_OBJECTS
elif cat == "Pandora":
self.objects = globals.PANDORA_OBJECTS
elif cat == "PC" or "SERVER":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
elif cat == "NET RADIO" or cat == "NET_RADIO":
self.objects = globals.NET_RADIO_OBJECTS
elif cat == "Napster":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
elif cat == "USB":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
elif cat == "iPod (USB)" or cat == "iPod_USB" or cat == "Airplay":
self.objects = globals.GENERIC_PLAYBACK_OBJECTS
else:
eg.PrintError("Unknown Category!")
self.choice_object.Clear()
self.choice_object.AppendItems(self.objects)
self.choice_object.SetSelection(0)
class GetAvailability(eg.ActionBase):
def __call__(self, **kwargs):
setup_availability(self.plugin, **kwargs)
return list(self.plugin.AVAILABLE_SOURCES)
class AutoDetectIP(eg.ActionBase):
def __call__(self):
ip = auto_detect_ip_threaded(self.plugin)
if ip is not None:
setup_availability(self.plugin)
return ip
class VerifyStaticIP(eg.ActionBase):
def __call__(self):
if self.plugin.ip_auto_detect:
eg.PrintError('Static IP is not enabled!')
return False
else:
ip = setup_ip(self.plugin)
if ip is not None:
setup_availability(self.plugin)
return ip is not None
class NextInput(eg.ActionBase):
def __call__(self, zone, inputs):
print inputs
izone = convert_zone_to_int(self.plugin, zone, convert_active=True)
src = get_source_name(self.plugin, izone)
index = inputs.index(src) if src in inputs else -1
self._next_input(izone, index, inputs)
def _next_input(self, izone, cur_index, inputs):
next_index = 0
if cur_index != -1:
if cur_index < len(inputs) - 1:
next_index = cur_index + 1
else:
next_index = 0
else:
# Current source not in the user's list. Change to the first item?
next_index = 0
print "Warning: Current source was not in the list of sources. Changing to first source in list."
print "Switching input to", inputs[next_index]
change_source(self.plugin, inputs[next_index], izone)
t = Thread(target=self._verify_input, args=[izone, next_index, inputs])
t.start()
def _verify_input(self, izone, index, inputs, wait=0.3):
time.sleep(wait)
src = get_source_name(self.plugin, izone)
if src != inputs[index]:
eg.PrintError("Source input did not change! Your receiver may not have this input.")
print "Skipping to next input."
self._next_input(izone, index, inputs)
def Configure(self, zone='Active Zone', inputs=['HDMI1']):
panel = eg.ConfigPanel()
#reset "TUNER" to "Tuner"
newinputs = []
for source in inputs:
if source == "TUNER":
source = "Tuner"
newinputs.append(source)
inputs = newinputs
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (45, 7), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
y = 45
x_start = 10
x = x_start
num_per_row = 5
x_padding = 80
y_padding = 20
sources = self.plugin.AVAILABLE_SOURCES
self.cbs = []
for i in range(len(sources)):
if i > 0 and i % num_per_row == 0:
x = x_start
y += y_padding
cb = wx.CheckBox(panel, -1, sources[i], (x, y))
cb.SetValue(sources[i] in inputs)
self.cbs.append(cb)
x += x_padding
# Futile attempt at setting a scrollbar, not working
# panel.SetScrollbar(wx.VERTICAL, 0, 95, 100)
while panel.Affirmed():
res = []
for i in range(len(self.cbs)):
if self.cbs[i].GetValue():
if sources[i] == "Tuner":
res.append("TUNER")
else:
res.append(sources[i])
panel.SetResult(zones[choice_zone.GetCurrentSelection()], res)
class PreviousInput(eg.ActionBase):
def __call__(self, zone, inputs):
izone = convert_zone_to_int(self.plugin, zone, convert_active=True)
src = get_source_name(self.plugin, izone)
index = inputs.index(src) if src in inputs else -1
self._prev_input(izone, index, inputs)
def _prev_input(self, izone, cur_index, inputs):
prev_index = 0
if cur_index != -1:
if cur_index > 0:
prev_index = cur_index - 1
else:
prev_index = len(inputs) - 1
else:
# Current source not in the user's list. Change to the first item?
prev_index = 0
print "Warning: Current source was not in the list of sources. Changing to first source in list."
print "Switching input to", inputs[prev_index]
change_source(self.plugin, inputs[prev_index], izone)
t = Thread(target=self._verify_input, args=[izone, prev_index, inputs])
t.start()
def _verify_input(self, izone, index, inputs, wait=0.3):
time.sleep(wait)
src = get_source_name(self.plugin, izone)
if src != inputs[index]:
eg.PrintError("Source input did not change! Your receiver may not have this input.")
print "Skipping to previous input."
self._prev_input(izone, index, inputs)
def Configure(self, zone='Active Zone', inputs=['HDMI1']):
panel = eg.ConfigPanel()
#reset "TUNER" to "Tuner"
newinputs = []
for source in inputs:
if source == "TUNER":
source = "Tuner"
newinputs.append(source)
inputs = newinputs
zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES)
wx.StaticText(panel, label="Zone: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (45, 7), choices=zones)
if zone in zones:
choice_zone.SetStringSelection(zone)
y = 45
x_start = 10
x = x_start
num_per_row = 5
x_padding = 80
y_padding = 20
sources = self.plugin.AVAILABLE_SOURCES
self.cbs = []
for i in range(len(sources)):
if i > 0 and i % num_per_row == 0:
x = x_start
y += y_padding
cb = wx.CheckBox(panel, -1, sources[i], (x, y))
cb.SetValue(sources[i] in inputs)
self.cbs.append(cb)
x += x_padding
# Futile attempt at setting a scrollbar, not working
# panel.SetScrollbar(wx.VERTICAL, 0, 95, 100)
while panel.Affirmed():
res = []
for i in range(len(self.cbs)):
if self.cbs[i].GetValue():
if sources[i] == "Tuner":
res.append("TUNER")
else:
res.append(sources[i])
panel.SetResult(zones[choice_zone.GetCurrentSelection()], res)
class InputVolumeTrim(eg.ActionBase):
def __call__(self, sources):
#sources = get_system_io_vol_trim(self.plugin)
#print sources
#sources = [['TUNER', '0'], ['HDMI_1', '0'], ['HDMI_2', '0'], ['HDMI_3', '0'], ['HDMI_4', '0'], ['HDMI_5', '0'], ['AV_1', '0'], ['AV_2', '0'], ['AV_3', '0'], ['AV_4', '0'], ['AV_5', '0'], ['AV_6', '0'], ['V_AUX', '0'], ['AUDIO_1', '0'], ['AUDIO_2', '0'], ['Rhapsody', '0'], ['SiriusXM', '0'], ['Spotify', '0'], ['Pandora', u'0'], ['SERVER', u'0'], ['NET_RADIO', '0'], ['USB', '0'], ['AirPlay', '0']]
set_system_io_vol_trim(self.plugin, sources)
def Configure(self, sources=None):
panel = eg.ConfigPanel()
if sources == None:
sources = get_system_io_vol_trim(self.plugin)
y = 10
x_start = 10
x = x_start
num_per_row = 3
x_padding = 110
y_padding = 45
self.fss = []
for i in range(len(sources)):
print sources[i][0]
if i > 0 and i % num_per_row == 0:
x = x_start
y += y_padding
wx.StaticText(panel, label=sources[i][0], pos=(x, y))
fs = FS.FloatSpin(panel, -1, min_val=-6.0, max_val=6.0, increment=0.5, pos=(x, y+15), value=float(sources[i][1]/10), agwStyle=FS.FS_LEFT)
fs.SetFormat("%f")
fs.SetDigits(1)
self.fss.append(fs)
x += x_padding
while panel.Affirmed():
res = []
for i in range(len(self.fss)):
res.append([sources[i][0], int(self.fss[i].GetValue()*10)])
panel.SetResult(res)
class ToggleMute(eg.ActionBase):
def __call__(self):
toggle_mute(self.plugin)
class ToggleEnhancer(eg.ActionBase):
def __call__(self):
toggle_enhancer(self.plugin)
class NextRadioPreset(eg.ActionBase):
def __call__(self):
next_radio_preset(self.plugin)
class PreviousRadioPreset(eg.ActionBase):
def __call__(self):
prev_radio_preset(self.plugin)
class ToggleRadioAMFM(eg.ActionBase):
def __call__(self):
toggle_radio_amfm(self.plugin)
class RadioAutoFreqUp(eg.ActionBase):
def __call__(self):
radio_freq(self.plugin, 'Auto Up')
class RadioAutoFreqDown(eg.ActionBase):
def __call__(self):
radio_freq(self.plugin, 'Auto Down')
class RadioFreqUp(eg.ActionBase):
def __call__(self):
radio_freq(self.plugin, 'Up')
class RadioFreqDown(eg.ActionBase):
def __call__(self):
radio_freq(self.plugin, 'Down')
class RadioSetExact(eg.ActionBase):
def __call__(self, freq, band):
set_radio_freq(self.plugin, freq, band)
def Configure(self, freq="87.5", band="FM"):
panel = eg.ConfigPanel()
self.freq = freq
self.bands = ['AM', 'FM']
wx.StaticText(panel, label="Band: ", pos=(10, 10))
self.choice_band = wx.Choice(panel, -1, (10, 30), choices=self.bands)
if band in self.bands:
self.choice_band.SetStringSelection(band)
self.choice_band.Bind(wx.EVT_CHOICE, self.BandChanged)
wx.StaticText(panel, label="Frequency: ", pos=(10, 60))
self.floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=87.5, max_val=107.9,
increment=0.2, value=float(freq), agwStyle=FS.FS_LEFT)
self.floatspin.SetFormat("%f")
self.floatspin.SetDigits(1)
#self.objects = [ 'Power', 'Sleep', 'Volume Level', 'Mute', 'Input Selection', 'Scene', 'Straight', 'Enhancer', 'Sound Program']
#wx.StaticText(panel, label="Object: ", pos=(10, 60))
#self.choice_object = wx.Choice(panel, -1, (10, 80), choices=self.objects)
self.BandChanged()
#if object in self.objects:
# self.choice_object.SetStringSelection(object)
while panel.Affirmed():
panel.SetResult(self.floatspin.GetValue(), self.bands[self.choice_band.GetCurrentSelection()])
def BandChanged(self, event=None):
band = self.bands[self.choice_band.GetCurrentSelection()]
if band == "FM":
self.floatspin.SetRange(min_val=87.5, max_val=107.9)
if 87.5 <= float(self.freq) and float(self.freq) <= 107.9:
self.floatspin.SetValue(float(self.freq))
else:
self.floatspin.SetValue(float(87.5))
self.floatspin.SetIncrement(0.2)
else:
self.floatspin.SetRange(min_val=530, max_val=1710)
if 530 <= float(self.freq) and float(self.freq) <= 1710:
self.floatspin.SetValue(float(self.freq))
else:
self.floatspin.SetValue(float(530))
self.floatspin.SetIncrement(10)
class SetFeatureVideoOut(eg.ActionBase):
def __call__(self, Feature, Source):
feature_video_out(self.plugin, Feature, Source)
def Configure(self, Feature="Tuner", Source="Off"):
panel = eg.ConfigPanel()
self.Source = Source
if Feature == "TUNER":
Feature = "Tuner"
wx.StaticText(panel, label="Feature Input: ", pos=(10, 10))
choice_zone = wx.Choice(panel, -1, (95, 7), choices=self.plugin.AVAILABLE_INFO_SOURCES)
if Feature in self.plugin.AVAILABLE_INFO_SOURCES:
choice_zone.SetStringSelection(Feature)
y = 45
x_start = 10
x = x_start
num_per_row = 5
x_padding = 80
y_padding = 20
sources = ['Off'] + self.plugin.AVAILABLE_INPUT_SOURCES
self.cbs = []
for i in range(len(sources)):
if i > 0 and i % num_per_row == 0:
x = x_start
y += y_padding
cb = wx.CheckBox(panel, -1, sources[i], (x, y))
if Source == sources[i]:
cb.SetValue(True)
else:
cb.SetValue(False)
cb.Bind(wx.EVT_CHECKBOX, lambda evt, temp=i: self.SourceChanged(evt, temp))