MythTV master
diseqcsettings.cpp
Go to the documentation of this file.
1/*
2 * \file diseqcsettings.cpp
3 * \brief DVB-S Device Tree Configuration Classes.
4 * \author Copyright (C) 2006, Yeasah Pell
5 */
6
7// Std C headers
8#include <array>
9#include <cmath>
10#include <utility>
11
12// MythTV headers
14#include "diseqcsettings.h"
15
16/* Lat/Long items relocated from videosource.cpp */
17
19{
20 auto *gc = new GlobalTextEditSetting("latitude");
21 gc->setLabel("Latitude");
22 gc->setHelpText(
23 DeviceTree::tr("The Cartesian latitude for your location. "
24 "Use negative numbers for southern coordinates."));
25 return gc;
26}
27
29{
30 auto *gc = new GlobalTextEditSetting("longitude");
31 gc->setLabel("Longitude");
32 gc->setHelpText(
33 DeviceTree::tr("The Cartesian longitude for your location. "
34 "Use negative numbers for western coordinates."));
35 return gc;
36}
37
39
41{
42 public:
44 {
45 setLabel(DeviceTree::tr("Device Type"));
46 addSelection(DeviceTree::tr("Unconnected"),
47 QString::number((uint) 0xFFFF));
48 addSelection(DeviceTree::tr("Switch"),
49 QString::number((uint) DiSEqCDevDevice::kTypeSwitch));
50 addSelection(DeviceTree::tr("Rotor"),
51 QString::number((uint) DiSEqCDevDevice::kTypeRotor));
52 addSelection(DeviceTree::tr("Unicable"),
53 QString::number((uint) DiSEqCDevDevice::kTypeSCR));
54 addSelection(DeviceTree::tr("LNB"),
55 QString::number((uint) DiSEqCDevDevice::kTypeLNB));
56 }
57
58 void Load(void) override // StandardSetting
59 {
60 if (m_device)
61 {
62 QString tmp = QString::number((uint) m_device->GetDeviceType());
64 }
65 setChanged(false);
66 }
67
69 {
70 m_device = dev;
71 }
72
74 {
75 SetDevice(nullptr);
77 }
78
80 {
81 return m_device;
82 }
83
84 private:
86};
87
89
91{
92 public:
94 m_device(device)
95 {
96 setLabel(DeviceTree::tr("Description"));
97 QString help = DeviceTree::tr(
98 "Optional descriptive name for this device, to "
99 "make it easier to configure settings later.");
101 }
102
103 void Load(void) override // StandardSetting
104 {
106 setChanged(false);
107 }
108
109 void Save(void) override // StandardSetting
110 {
112 }
113
114 private:
116};
117
118
120
122{
123 public:
125 TransMythUISpinBoxSetting(0, 15, 1), m_device(device)
126 {
127 setLabel(DeviceTree::tr("Repeat Count"));
128 QString help = DeviceTree::tr(
129 "Number of repeat (command with repeat flag ON) or resend (the same command) DiSEqC commands. "
130 "If value is higher than 10, command will be resend N-10 times. "
131 "If value is lower than 10, command will be repeated N times. "
132 "Repeat useful for unreliable DiSEqC equipment; resend useful when unreliable DiSEqC equipment has broken/unsupported repeat flag support.");
134 }
135
136 void Load(void) override // StandardSetting
137 {
139 setChanged(false);
140 }
141
142 void Save(void) override // StandardSetting
143 {
144 m_device.SetRepeatCount(getValue().toUInt());
145 }
146
147 private:
149};
150
152
154{
155 public:
156 explicit SwitchTypeSetting(DiSEqCDevSwitch &switch_dev) :
157 m_switch(switch_dev)
158 {
159 setLabel(DeviceTree::tr("Switch Type"));
160 setHelpText(DeviceTree::tr("Select the type of switch from the list."));
161
162 addSelection(DeviceTree::tr("Tone"),
163 QString::number((uint) DiSEqCDevSwitch::kTypeTone));
164 addSelection(DeviceTree::tr("Voltage"),
165 QString::number((uint) DiSEqCDevSwitch::kTypeVoltage));
166 addSelection(DeviceTree::tr("Mini DiSEqC"),
167 QString::number((uint) DiSEqCDevSwitch::kTypeMiniDiSEqC));
168 addSelection(DeviceTree::tr("DiSEqC"),
169 QString::number((uint)
171 addSelection(DeviceTree::tr("DiSEqC (Uncommitted)"),
172 QString::number((uint)
174 addSelection(DeviceTree::tr("Legacy SW21"),
175 QString::number((uint) DiSEqCDevSwitch::kTypeLegacySW21));
176 addSelection(DeviceTree::tr("Legacy SW42"),
177 QString::number((uint) DiSEqCDevSwitch::kTypeLegacySW42));
178 addSelection(DeviceTree::tr("Legacy SW64"),
179 QString::number((uint) DiSEqCDevSwitch::kTypeLegacySW64));
180 }
181
182 void Load(void) override // StandardSetting
183 {
184 setValue(getValueIndex(QString::number((uint) m_switch.GetType())));
185 setChanged(false);
186 }
187
188 void Save(void) override // StandardSetting
189 {
191 getValue().toUInt());
192 }
193
194 private:
196};
197
199
201{
202 public:
203 explicit SwitchAddressSetting(DiSEqCDevSwitch &switch_dev) :
204 m_switch(switch_dev)
205 {
206 setLabel(DeviceTree::tr("Address of switch"));
207 setHelpText(DeviceTree::tr("The DiSEqC address of the switch."));
208 }
209
210 void Load(void) override // StandardSetting
211 {
212 setValue(QString("0x%1").arg(m_switch.GetAddress(), 0, 16));
213 setChanged(false);
214 }
215
216 void Save(void) override // StandardSetting
217 {
218 m_switch.SetAddress(getValue().toUInt(nullptr, 16));
219 }
220
221 private:
223};
224
226
228{
229 public:
230 explicit SwitchPortsSetting(DiSEqCDevSwitch &switch_dev) :
231 m_switch(switch_dev)
232 {
233 setLabel(DeviceTree::tr("Number of ports"));
234 setHelpText(DeviceTree::tr("The number of ports this switch has."));
235 }
236
237 void Load(void) override // StandardSetting
238 {
239 setValue(QString::number(m_switch.GetNumPorts()));
240 setChanged(false);
241 }
242
243 void Save(void) override // StandardSetting
244 {
245 m_switch.SetNumPorts(getValue().toUInt());
246 }
247
248 private:
250};
251
253
255 : m_deviceDescr(new DeviceDescrSetting(switch_dev)),
256 m_type(new SwitchTypeSetting(switch_dev)),
257 m_ports(new SwitchPortsSetting(switch_dev)),
258 m_address(new SwitchAddressSetting(switch_dev))
259{
260 setLabel(DeviceTree::tr("Switch Configuration"));
261
262 parent = this;
263 parent->addChild(m_deviceDescr);
264 parent->addChild(new DeviceRepeatSetting(switch_dev));
265 parent->addChild(m_type);
266 parent->addChild(m_address);
267 parent->addChild(m_ports);
268
269 connect(m_type, qOverload<const QString&>(&StandardSetting::valueChanged),
270 this, qOverload<const QString&>(&SwitchConfig::update));
271 connect(m_deviceDescr, qOverload<const QString&>(&StandardSetting::valueChanged),
272 this, qOverload<const QString&>(&StandardSetting::setValue));
273}
274
276{
279 update();
280 setChanged(false);
281}
282
284{
286 {
292 m_address->setValue(QString("0x10"));
293 m_address->setEnabled(false);
294 m_ports->setValue("2");
295 m_ports->setEnabled(false);
296 break;
298 m_address->setValue(QString("0x10"));
299 m_address->setEnabled(false);
300 m_ports->setValue("3");
301 m_ports->setEnabled(false);
302 break;
305 m_address->setEnabled(true);
306 m_ports->setEnabled(true);
307 break;
308 }
309}
310
311void SwitchConfig::update(const QString &/*value*/)
312{
313 update();
314}
315
317{
318 QStringList actions;
319 if (GetMythMainWindow()->TranslateKeyPress("Global", e, actions))
320 return true;
321
322 if (actions.contains("DELETE"))
323 {
324 emit DeleteClicked();
325 return true;
326 }
327
328 return false;
329}
330
332
334{
335 public:
337 m_rotor(rotor)
338 {
339 setLabel(DeviceTree::tr("Rotor Type"));
340 setHelpText(DeviceTree::tr("Select the type of rotor from the list."));
341 addSelection(DeviceTree::tr("DiSEqC 1.2"),
342 QString::number((uint) DiSEqCDevRotor::kTypeDiSEqC_1_2));
343 addSelection(DeviceTree::tr("DiSEqC 1.3 (GotoX/USALS)"),
344 QString::number((uint) DiSEqCDevRotor::kTypeDiSEqC_1_3));
345 }
346
347 void Load(void) override // StandardSetting
348 {
349 setValue(getValueIndex(QString::number((uint)m_rotor.GetType())));
350 setChanged(false);
351 }
352
353 void Save(void) override // StandardSetting
354 {
356 }
357
358 private:
360};
361
363
365{
366 public:
368 m_rotor(rotor)
369 {
370 setLabel(DeviceTree::tr("Rotor Low Speed (deg/sec)"));
371 QString help = DeviceTree::tr(
372 "To allow the approximate monitoring of rotor movement, enter "
373 "the rated angular speed of the rotor when powered at 13V.");
375 }
376
377 void Load(void) override // StandardSetting
378 {
379 setValue(QString::number(m_rotor.GetLoSpeed()));
380 setChanged(false);
381 }
382
383 void Save(void) override // StandardSetting
384 {
385 m_rotor.SetLoSpeed(getValue().toDouble());
386 }
387
388 private:
390};
391
393
395{
396 public:
398 m_rotor(rotor)
399 {
400 setLabel(DeviceTree::tr("Rotor High Speed (deg/sec)"));
401 QString help = DeviceTree::tr(
402 "To allow the approximate monitoring of rotor movement, enter "
403 "the rated angular speed of the rotor when powered at 18V.");
405 }
406
407 void Load(void) override // StandardSetting
408 {
409 setValue(QString::number(m_rotor.GetHiSpeed()));
410 setChanged(false);
411 }
412
413 void Save(void) override // StandardSetting
414 {
415 m_rotor.SetHiSpeed(getValue().toDouble());
416 }
417
418 private:
420};
421
423
424static QString AngleToString(double angle)
425{
426 QString str;
427 if (angle >= 0.0)
428 {
429 str = QString::number(angle) +
430 DeviceTree::tr("E", "Eastern Hemisphere");
431 }
432 else /* if (angle < 0.0) */
433 {
434 str = QString::number(-angle) +
435 DeviceTree::tr("W", "Western Hemisphere");
436 }
437 return str;
438}
439
440static double AngleToEdit(double angle, QString &hemi)
441{
442 if (angle > 0.0)
443 {
444 hemi = "E";
445 return angle;
446 }
447
448 hemi = "W";
449 return -angle;
450}
451
452static double AngleToFloat(const QString &angle, bool translated = true)
453{
454 if (angle.length() < 2)
455 return 0.0;
456
457 double pos = __builtin_nan("");
458 QChar postfix = angle.at(angle.length() - 1);
459 if (postfix.isLetter())
460 {
461 pos = angle.left(angle.length() - 1).toDouble();
462 if ((translated &&
463 (postfix.toUpper() ==
464 DeviceTree::tr("W", "Western Hemisphere").at(0))) ||
465 (!translated && (postfix.toUpper() == 'W')))
466 {
467 pos = -pos;
468 }
469 }
470 else
471 {
472 pos = angle.toDouble();
473 }
474
475 return pos;
476}
477
479{
481 PopulateList();
482}
483
485{
487}
488
490{
491public:
492 RotorPosTextEdit(const QString &label, uint id, const QString &value) :
493 m_id(id)
494 {
495 setLabel(label);
496 setValue(value);
497 }
498
499 void updateButton(MythUIButtonListItem *item) override // MythUITextEditSetting
500 {
502 if (getValue().isEmpty())
503 item->SetText(DeviceTree::tr("None"), "value");
504 }
505
507};
508
510{
511 auto *posEdit = dynamic_cast<RotorPosTextEdit*>(setting);
512 if (posEdit == nullptr)
513 return;
514 QString value = posEdit->getValue();
515 if (value.isEmpty())
516 m_posmap.erase(m_posmap.find(posEdit->m_id));
517 else
518 m_posmap[posEdit->m_id] = AngleToFloat(posEdit->getValue());
519}
520
522{
523 uint num_pos = 64;
524 for (uint pos = 1; pos < num_pos; pos++)
525 {
526 uint_to_dbl_t::const_iterator it = m_posmap.constFind(pos);
527 QString posval;
528 if (it != m_posmap.constEnd())
529 posval = AngleToString(*it);
530
531 auto *posEdit =
532 new RotorPosTextEdit(DeviceTree::tr("Position #%1").arg(pos),
533 pos,
534 posval);
535 connect(posEdit, qOverload<StandardSetting*>(&StandardSetting::valueChanged),
536 this, &RotorPosMap::newValue);
537 addChild(posEdit);
538 }
539}
540
542
544 : m_rotor(rotor),
545 m_pos(new RotorPosMap(rotor))
546{
547 setLabel(DeviceTree::tr("Rotor Configuration"));
548 setValue(rotor.GetDescription());
549
550 parent = this;
551 parent->addChild(new DeviceDescrSetting(rotor));
552 parent->addChild(new DeviceRepeatSetting(rotor));
553
554 auto *rtype = new RotorTypeSetting(rotor);
555 connect(rtype, qOverload<const QString&>(&StandardSetting::valueChanged),
556 this, &RotorConfig::SetType);
557 parent->addChild(rtype);
558
559 m_pos->setLabel(DeviceTree::tr("Positions"));
560 m_pos->setHelpText(DeviceTree::tr("Rotor position setup."));
561 parent->addChild(m_pos);
562
563 parent->addChild(new RotorLoSpeedSetting(rotor));
564 parent->addChild(new RotorHiSpeedSetting(rotor));
565 parent->addChild(DiSEqCLatitude());
566 parent->addChild(DiSEqCLongitude());
567}
568
570{
573}
574
575void RotorConfig::SetType(const QString &type)
576{
577 auto rtype = (DiSEqCDevRotor::dvbdev_rotor_t) type.toUInt();
579}
580
582
584{
585 public:
587 TransMythUISpinBoxSetting(0, 7, 1), m_scr(scr)
588 {
589 setLabel(DeviceTree::tr("Userband"));
590 setHelpText(DeviceTree::tr(
591 "Unicable userband ID (0-7). The Unicable userband channels "
592 "are often numbered starting at 1 but MythTV starts at 0."));
593 }
594
595 void Load(void) override // StandardSetting
596 {
598 setChanged(false);
599 }
600
601 void Save(void) override // StandardSetting
602 {
604 }
605
606 private:
608};
609
611
613{
614 public:
616 {
617 setLabel(DeviceTree::tr("Frequency (MHz)"));
618 setHelpText(DeviceTree::tr("Unicable userband frequency (usually 1210, 1420, 1680 and 2040 MHz)"));
619 }
620
621 void Load(void) override // StandardSetting
622 {
623 setValue(QString::number(m_scr.GetFrequency()));
624 setChanged(false);
625 }
626
627 void Save(void) override // StandardSetting
628 {
629 m_scr.SetFrequency(getValue().toUInt());
630 }
631
632 private:
634};
635
637
639{
640 public:
641 explicit SCRPINSetting(DiSEqCDevSCR &scr) : m_scr(scr)
642 {
643 setLabel(DeviceTree::tr("PIN code"));
644 setHelpText(DeviceTree::tr("Unicable PIN code (-1 disabled, 0 - 255)"));
645 }
646
647 void Load(void) override // StandardSetting
648 {
649 setValue(QString::number(m_scr.GetPIN()));
650 setChanged(false);
651 }
652
653 void Save(void) override // StandardSetting
654 {
655 m_scr.SetPIN(getValue().toInt());
656 }
657
658 private:
660};
661
663
665{
666 setLabel(DeviceTree::tr("Unicable Configuration"));
667
668 parent = this;
669 parent->addChild(new SCRUserBandSetting(scr));
670 parent->addChild(new SCRFrequencySetting(scr));
671 parent->addChild(new SCRPINSetting(scr));
672 parent->addChild(new DeviceRepeatSetting(scr));
673}
674
676
678{
679 public:
681 uint _lof_sw = 0, uint _lof_lo = 0,
682 uint _lof_hi = 0, bool _pol_inv = false) :
683 m_name(std::move(_name)), m_type(_type),
684 m_lofSw(_lof_sw), m_lofLo(_lof_lo),
685 m_lofHi(_lof_hi), m_polInv(_pol_inv) {}
686
687 public:
688 QString m_name;
694};
695
696static const std::array<const lnb_preset,7> lnb_presets
697{
698
699 /* description, type, LOF switch, LOF low, LOF high, inverted polarity */
700 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "Universal (Europe)"),
702 11700000, 9750000, 10600000),
703 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "Single (Europe)"),
705 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "Circular (N. America)"),
707 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "Linear (N. America)"),
709 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "C Band"),
711 lnb_preset(QT_TRANSLATE_NOOP("DeviceTree", "DishPro Bandstacked"),
712 DiSEqCDevLNB::kTypeBandstacked, 0, 11250000, 14350000),
714};
715
716static uint FindPreset(const DiSEqCDevLNB &lnb)
717{
718 uint i = 0;
719 for ( ; !lnb_presets[i].m_name.isEmpty(); i++)
720 {
721 if (lnb_presets[i].m_type == lnb.GetType() &&
722 lnb_presets[i].m_lofSw == lnb.GetLOFSwitch() &&
723 lnb_presets[i].m_lofLo == lnb.GetLOFLow() &&
724 lnb_presets[i].m_lofHi == lnb.GetLOFHigh() &&
725 lnb_presets[i].m_polInv== lnb.IsPolarityInverted())
726 {
727 break;
728 }
729 }
730 return i;
731}
732
734{
735 public:
736 explicit LNBPresetSetting(DiSEqCDevLNB &lnb) : m_lnb(lnb)
737 {
738 setLabel(DeviceTree::tr("LNB Preset"));
739 QString help = DeviceTree::tr(
740 "Select the LNB preset from the list, or choose "
741 "'Custom' and set the advanced settings below.");
743
744 uint i = 0;
745 for (; !lnb_presets[i].m_name.isEmpty(); i++)
746 addSelection(DeviceTree::tr( lnb_presets[i].m_name.toUtf8().constData() ),
747 QString::number(i));
748 addSelection(DeviceTree::tr("Custom"), QString::number(i));
749 }
750
751 void Load(void) override // StandardSetting
752 {
754 setChanged(false);
755 }
756
757 void Save(void) override // StandardSetting
758 {
759 }
760
761 private:
763};
764
766
768{
769 public:
770 explicit LNBTypeSetting(DiSEqCDevLNB &lnb) : m_lnb(lnb)
771 {
772 setLabel(DeviceTree::tr("LNB Type"));
773 setHelpText(DeviceTree::tr("Select the type of LNB from the list."));
774 addSelection(DeviceTree::tr("Legacy (Fixed)"),
775 QString::number((uint) DiSEqCDevLNB::kTypeFixed));
776 addSelection(DeviceTree::tr("Standard (Voltage)"),
777 QString::number((uint) DiSEqCDevLNB::
778 kTypeVoltageControl));
779 addSelection(DeviceTree::tr("Universal (Voltage & Tone)"),
780 QString::number((uint) DiSEqCDevLNB::
781 kTypeVoltageAndToneControl));
782 addSelection(DeviceTree::tr("Bandstacked"),
783 QString::number((uint) DiSEqCDevLNB::kTypeBandstacked));
784 }
785
786 void Load(void) override // StandardSetting
787 {
788 setValue(getValueIndex(QString::number((uint) m_lnb.GetType())));
789 setChanged(false);
790 }
791
792 void Save(void) override // StandardSetting
793 {
795 }
796
797 private:
799};
800
802
804{
805 public:
807 {
808 setLabel(DeviceTree::tr("LNB LOF Switch (MHz)"));
809 QString help = DeviceTree::tr(
810 "This defines at what frequency the LNB will do a "
811 "switch from high to low setting, and vice versa.");
813 }
814
815 void Load(void) override // StandardSetting
816 {
817 setValue(QString::number(m_lnb.GetLOFSwitch() / 1000));
818 setChanged(false);
819 }
820
821 void Save(void) override // StandardSetting
822 {
823 m_lnb.SetLOFSwitch(getValue().toUInt() * 1000);
824 }
825
826 private:
828};
829
831
833{
834 public:
835 explicit LNBLOFLowSetting(DiSEqCDevLNB &lnb) : m_lnb(lnb)
836 {
837 setLabel(DeviceTree::tr("LNB LOF Low (MHz)"));
838 QString help = DeviceTree::tr(
839 "This defines the offset the frequency coming "
840 "from the LNB will be in low setting. For bandstacked "
841 "LNBs this is the vertical/right polarization band.");
843 }
844
845 void Load(void) override // StandardSetting
846 {
847 setValue(QString::number(m_lnb.GetLOFLow() / 1000));
848 setChanged(false);
849 }
850
851 void Save(void) override // StandardSetting
852 {
853 m_lnb.SetLOFLow(getValue().toUInt() * 1000);
854 }
855
856 private:
858};
859
861
863{
864 public:
866 {
867 setLabel(DeviceTree::tr("LNB LOF High (MHz)"));
868 QString help = DeviceTree::tr(
869 "This defines the offset the frequency coming from "
870 "the LNB will be in high setting. For bandstacked "
871 "LNBs this is the horizontal/left polarization band.");
873 }
874
875 void Load(void) override // StandardSetting
876 {
877 setValue(QString::number(m_lnb.GetLOFHigh() / 1000));
878 setChanged(false);
879 }
880
881 void Save(void) override // StandardSetting
882 {
883 m_lnb.SetLOFHigh(getValue().toUInt() * 1000);
884 }
885
886 private:
888};
889
891{
892 public:
894 m_lnb(lnb)
895 {
896 setLabel(DeviceTree::tr("LNB Reversed"));
897 QString help = DeviceTree::tr(
898 "This defines whether the signal reaching the LNB "
899 "is reversed from normal polarization. This happens "
900 "to circular signals bouncing twice on a toroidal "
901 "dish.");
903 }
904
905 void Load(void) override // StandardSetting
906 {
908 setChanged(false);
909 }
910
911 void Save(void) override // StandardSetting
912 {
914 }
915
916 private:
918};
919
921
923 : m_preset(new LNBPresetSetting(lnb)),
924 m_type(new LNBTypeSetting(lnb)),
925 m_lofSwitch(new LNBLOFSwitchSetting(lnb)),
926 m_lofLo(new LNBLOFLowSetting(lnb)),
927 m_lofHi(new LNBLOFHighSetting(lnb)),
928 m_polInv(new LNBPolarityInvertedSetting(lnb))
929{
930 setLabel(DeviceTree::tr("LNB Configuration"));
932
933 parent = this;
934 auto *deviceDescr = new DeviceDescrSetting(lnb);
935 parent->addChild(deviceDescr);
936 parent->addChild(m_preset);
937 parent->addChild(m_type);
938 parent->addChild(m_lofSwitch);
939 parent->addChild(m_lofLo);
940 parent->addChild(m_lofHi);
941 parent->addChild(m_polInv);
942 connect(m_type, qOverload<const QString&>(&StandardSetting::valueChanged),
943 this, qOverload<const QString&>(&LNBConfig::UpdateType));
944 connect(m_preset, qOverload<const QString&>(&StandardSetting::valueChanged),
945 this, &LNBConfig::SetPreset);
946 connect(deviceDescr, qOverload<const QString&>(&StandardSetting::valueChanged),
947 this, qOverload<const QString&>(&StandardSetting::setValue));
948}
949
951{
954}
955
956void LNBConfig::SetPreset(const QString &value)
957{
958 uint index = value.toUInt();
959 if (index >= (sizeof(lnb_presets) / sizeof(lnb_preset)))
960 return;
961
962 const lnb_preset &preset = lnb_presets[index];
963 if (preset.m_name.isEmpty())
964 {
965 m_type->setEnabled(true);
966 UpdateType();
967 }
968 else
969 {
971 QString::number((uint)preset.m_type)));
972 m_lofSwitch->setValue(QString::number(preset.m_lofSw / 1000));
973 m_lofLo->setValue(QString::number(preset.m_lofLo / 1000));
974 m_lofHi->setValue(QString::number(preset.m_lofHi / 1000));
975 m_polInv->setValue(preset.m_polInv);
976 m_type->setEnabled(false);
977 m_lofSwitch->setEnabled(false);
978 m_lofHi->setEnabled(false);
979 m_lofLo->setEnabled(false);
980 m_polInv->setEnabled(false);
981 }
982}
983
985{
986 if (!m_type->isEnabled())
987 return;
988
989 switch ((DiSEqCDevLNB::dvbdev_lnb_t) m_type->getValue().toUInt())
990 {
993 m_lofSwitch->setEnabled(false);
994 m_lofHi->setEnabled(false);
995 m_lofLo->setEnabled(true);
996 m_polInv->setEnabled(true);
997 break;
999 m_lofSwitch->setEnabled(true);
1000 m_lofHi->setEnabled(true);
1001 m_lofLo->setEnabled(true);
1002 m_polInv->setEnabled(true);
1003 break;
1005 m_lofSwitch->setEnabled(false);
1006 m_lofHi->setEnabled(true);
1007 m_lofLo->setEnabled(true);
1008 m_polInv->setEnabled(true);
1009 break;
1010 }
1011}
1012
1013void LNBConfig::UpdateType(const QString &/*value*/)
1014{
1015 UpdateType();
1016}
1018
1020{
1021 PopulateTree();
1023}
1024
1026{
1027 DiSEqCDevDevice *dev = devtype->GetDevice();
1028 if (dev)
1029 {
1030 DiSEqCDevDevice *parent = dev->GetParent();
1031 if (parent)
1032 parent->SetChild(dev->GetOrdinal(), nullptr);
1033 else
1034 m_tree.SetRoot(nullptr);
1035 }
1036
1037 devtype->DeleteDevice();
1038}
1039
1041{
1042 clearSettings();
1044}
1045
1047 StandardSetting *parent)
1048{
1049 DiseqcConfigBase *setting = nullptr;
1050 switch (dev->GetDeviceType())
1051 {
1053 {
1054 auto *sw = dynamic_cast<DiSEqCDevSwitch*>(dev);
1055 if (sw)
1056 setting = new SwitchConfig(*sw, parent);
1057 }
1058 break;
1059
1061 {
1062 auto *rotor = dynamic_cast<DiSEqCDevRotor*>(dev);
1063 if (rotor)
1064 setting = new RotorConfig(*rotor, parent);
1065 }
1066 break;
1067
1069 {
1070 auto *scr = dynamic_cast<DiSEqCDevSCR*>(dev);
1071 if (scr)
1072 setting = new SCRConfig(*scr, parent);
1073 }
1074 break;
1075
1077 {
1078 auto *lnb = dynamic_cast<DiSEqCDevLNB*>(dev);
1079 if (lnb)
1080 setting = new LNBConfig(*lnb, parent);
1081 }
1082 break;
1083
1084 default:
1085 break;
1086 }
1087
1088 return setting;
1089}
1090
1092 DiSEqCDevDevice *parent,
1093 uint childnum,
1094 GroupSetting *parentSetting)
1095{
1096 if (node)
1097 {
1098 auto *devtype = new DeviceTypeSetting();
1099 devtype->SetDevice(node);
1100 devtype->Load();
1102 devtype);
1103
1104 if (setting)
1105 {
1106 setting->Load();
1107 devtype->addChild(setting);
1108 PopulateChildren(node, setting);
1109
1110 AddDeviceTypeSetting(devtype, parent, childnum, parentSetting);
1111 }
1112 else
1113 {
1114 delete devtype;
1115 }
1116 }
1117 else
1118 {
1119 auto *devtype = new DeviceTypeSetting();
1120 AddDeviceTypeSetting(devtype, parent, childnum, parentSetting);
1121 }
1122}
1123
1125 DiSEqCDevDevice *parent,
1126 uint childnum,
1127 GroupSetting *parentSetting)
1128{
1129 if (parentSetting)
1130 parentSetting->addChild(devtype);
1131 else // Root node
1132 addChild(devtype);
1133
1134 ConnectToValueChanged(devtype, parent, childnum);
1135}
1136
1138 DiSEqCDevDevice *parent,
1139 uint childnum)
1140{
1141 auto slot = [devtype, parent, childnum, this](const QString &value)
1142 {
1143 ValueChanged(value, devtype, parent, childnum);
1144 };
1145
1146 connect(devtype,
1147 qOverload<const QString&>(&StandardSetting::valueChanged),
1148 this,
1149 slot);
1150}
1151
1153 GroupSetting *parentSetting)
1154{
1155 uint num_ch = node->GetChildCount();
1156 for (uint ch = 0; ch < num_ch; ch++)
1157 {
1158 PopulateTree(node->GetChild(ch), node, ch, parentSetting);
1159 }
1160}
1161
1162void DeviceTree::ValueChanged(const QString &value,
1163 DeviceTypeSetting *devtype,
1164 DiSEqCDevDevice *parent,
1165 uint childnum)
1166{
1167 // Remove old setting from m_tree
1168 DeleteDevice(devtype);
1169
1170 const auto type = static_cast<DiSEqCDevDevice::dvbdev_t>(value.toUInt());
1171
1173 if (dev)
1174 {
1175 if (!parent)
1176 {
1177 m_tree.SetRoot(dev);
1178 PopulateTree();
1179 }
1180 else if (parent->SetChild(childnum, dev))
1181 {
1182 DiseqcConfigBase *newConfig =
1183 DiseqcConfigBase::CreateByType(dev, devtype);
1184 newConfig->Load();
1185
1186 PopulateChildren(dev, newConfig);
1187
1188 devtype->addChild(newConfig);
1189 devtype->SetDevice(dev);
1190 }
1191 else
1192 {
1193 delete dev;
1194 }
1195 }
1196
1197 emit settingsChanged(this);
1198}
1199
1201
1203{
1204 public:
1206 : m_node(node), m_settings(settings)
1207 {
1208 setLabel(node.GetDescription());
1209 setHelpText(DeviceTree::tr("Choose a port to use for this switch."));
1210
1211 uint num_children = node.GetChildCount();
1212 for (uint ch = 0; ch < num_children; ch++)
1213 {
1214 QString val = QString("%1").arg(ch);
1215 QString descr = DeviceTree::tr("Port %1").arg(ch+1);
1216 DiSEqCDevDevice *child = node.GetChild(ch);
1217 if (child)
1218 descr += QString(" (%2)").arg(child->GetDescription());
1219 addSelection(descr, val);
1220 }
1221 }
1222
1223 void Load(void) override // StandardSetting
1224 {
1225 double value = m_settings.GetValue(m_node.GetDeviceID());
1226 setValue((uint)value);
1227 setChanged(false);
1228 }
1229
1230 void Save(void) override // StandardSetting
1231 {
1233 }
1234
1235 private:
1238};
1239
1241
1243{
1244 public:
1246 : m_node(node), m_settings(settings)
1247 {
1248 setLabel(node.GetDescription());
1249 setHelpText(DeviceTree::tr("Choose a satellite position."));
1250
1251 auto *rotor = dynamic_cast<DiSEqCDevRotor*>(&m_node);
1252 if (rotor)
1253 m_posmap = rotor->GetPosMap();
1254 }
1255
1256 void Load(void) override // StandardSetting
1257 {
1259
1260 for (double d : std::as_const(m_posmap))
1261 addSelection(AngleToString(d), QString::number(d));
1262
1263 double angle = m_settings.GetValue(m_node.GetDeviceID());
1264 setValue(getValueIndex(QString::number(angle)));
1265 setChanged(false);
1266 }
1267
1268 void Save(void) override // StandardSetting
1269 {
1271 }
1272
1273 private:
1277};
1278
1280
1282{
1283 public:
1287 m_node(node), m_settings(settings)
1288 {
1289 QString help =
1290 DeviceTree::tr(
1291 "Locates the satellite you wish to point to "
1292 "with the longitude along the Clarke Belt of "
1293 "the satellite [-180..180] and its hemisphere.");
1294
1295 m_numeric->setLabel(DeviceTree::tr("Longitude (degrees)"));
1297 m_hemisphere->setLabel(DeviceTree::tr("Hemisphere"));
1298 m_hemisphere->addSelection(DeviceTree::tr("Eastern"), "E", false);
1299 m_hemisphere->addSelection(DeviceTree::tr("Western"), "W", true);
1301
1304
1305 addChild(new RotorConfig(dynamic_cast<DiSEqCDevRotor&>(m_node), this));
1306 }
1307
1308 void Load(void) override // StandardSetting
1309 {
1310 double val = m_settings.GetValue(m_node.GetDeviceID());
1311 QString hemi;
1312 double eval = AngleToEdit(val, hemi);
1313 m_numeric->setValue(QString::number(eval));
1316 }
1317
1318 void Save(void) override // StandardSetting
1319 {
1320 QString val = QString::number(m_numeric->getValue().toDouble());
1321 val += m_hemisphere->getValue();
1323 }
1324
1325 private:
1330};
1331
1333
1335{
1336 public:
1338 : m_node(node), m_settings(settings)
1339 {
1340 setLabel("Position");
1341 setHelpText(DeviceTree::tr("Unicable satellite position (A/B)"));
1343 QString::number((uint)DiSEqCDevSCR::kTypeScrPosA), true);
1345 QString::number((uint)DiSEqCDevSCR::kTypeScrPosB), false);
1346 }
1347
1348 void Load(void) override // StandardSetting
1349 {
1350 double value = m_settings.GetValue(m_node.GetDeviceID());
1351 setValue(getValueIndex(QString::number((uint)value)));
1352 setChanged(false);
1353 }
1354
1355 void Save(void) override // StandardSetting
1356 {
1358 }
1359
1360 private:
1363};
1364
1366
1368 DiSEqCDevSettings &settings, uint cardid, bool switches_enabled) :
1369 m_settings(settings), m_switchesEnabled(switches_enabled)
1370{
1371 setLabel(DeviceTree::tr("DTV Device Configuration"));
1372
1373 // load
1374 m_tree.Load(cardid);
1375
1376 // initial UI setup
1377 AddNodes(this, QString(), m_tree.Root());
1378}
1379
1381 StandardSetting *group, const QString &trigger, DiSEqCDevDevice *node)
1382{
1383 if (!node)
1384 return;
1385
1386 StandardSetting *setting = nullptr;
1387 switch (node->GetDeviceType())
1388 {
1390 setting = new SwitchSetting(*node, m_settings);
1391 setting->setEnabled(m_switchesEnabled);
1392 break;
1394 {
1395 auto *rotor = dynamic_cast<DiSEqCDevRotor*>(node);
1396 if (rotor && (rotor->GetType() == DiSEqCDevRotor::kTypeDiSEqC_1_2))
1397 setting = new RotorSetting(*node, m_settings);
1398 else
1399 setting = new USALSRotorSetting(*node, m_settings);
1400 break;
1401 }
1403 {
1404 setting = new SCRPositionSetting(*node, m_settings);
1405 break;
1406 }
1407 default:
1408 break;
1409 }
1410
1411 if (!setting)
1412 return;
1413
1414 m_devs[node->GetDeviceID()] = setting;
1415
1416 uint num_ch = node->GetChildCount();
1418 {
1419 for (uint i = 0; i < num_ch; i++)
1420 AddNodes(setting, QString::number(i), node->GetChild(i));
1421
1422 AddChild(group, trigger, setting);
1423 return;
1424 }
1425
1426 if (!num_ch)
1427 {
1428 AddChild(group, trigger, setting);
1429 return;
1430 }
1431
1432 AddChild(group, trigger, setting);
1433 for (uint i = 0; i < num_ch; i++)
1434 AddNodes(group, trigger, node->GetChild(i));
1435}
1436
1438 StandardSetting *group, const QString &trigger, StandardSetting *setting)
1439{
1440 if (!trigger.isEmpty())
1441 group->addTargetedChild(trigger, setting);
1442 else
1443 group->addChild(setting);
1444}
DiSEqCDevTree m_tree
devid_to_setting_t m_devs
DTVDeviceConfigGroup(DiSEqCDevSettings &settings, uint cardid, bool switches_enabled)
static void AddChild(StandardSetting *group, const QString &trigger, StandardSetting *setting)
void AddNodes(StandardSetting *group, const QString &trigger, DiSEqCDevDevice *node)
DiSEqCDevSettings & m_settings
void Save(void) override
DiSEqCDevDevice & m_device
void Load(void) override
DeviceDescrSetting(DiSEqCDevDevice &device)
void Load(void) override
DiSEqCDevDevice & m_device
void Save(void) override
DeviceRepeatSetting(DiSEqCDevDevice &device)
DiSEqCDevTree & m_tree
void ValueChanged(const QString &value, DeviceTypeSetting *devtype, DiSEqCDevDevice *parent, uint childnum)
void DeleteDevice(DeviceTypeSetting *devtype)
void Load(void) override
void AddDeviceTypeSetting(DeviceTypeSetting *devtype, DiSEqCDevDevice *parent, uint childnum, GroupSetting *parentSetting)
void PopulateTree(void)
void PopulateChildren(DiSEqCDevDevice *node, GroupSetting *parentSetting)
void ConnectToValueChanged(DeviceTypeSetting *devtype, DiSEqCDevDevice *parent, uint childnum)
void Load(void) override
void SetDevice(DiSEqCDevDevice *dev)
DiSEqCDevDevice * m_device
DiSEqCDevDevice * GetDevice()
Represents a node in a DVB-S device network.
Definition: diseqc.h:140
uint GetDeviceID(void) const
Definition: diseqc.h:170
void SetRepeatCount(uint repeat)
Definition: diseqc.h:164
virtual uint GetChildCount(void) const
Retrieves the proper number of children for this node.
Definition: diseqc.h:177
virtual DiSEqCDevDevice * GetChild(uint)
Retrieves the nth child of this node.
Definition: diseqc.h:188
uint GetOrdinal(void) const
Definition: diseqc.h:174
QString GetDescription(void) const
Definition: diseqc.h:175
void SetDescription(const QString &desc)
Definition: diseqc.h:163
uint GetRepeatCount(void) const
Definition: diseqc.h:176
static DiSEqCDevDevice * CreateByType(DiSEqCDevTree &tree, dvbdev_t type, uint dev_id=0)
Definition: diseqc.cpp:942
virtual bool SetChild(uint, DiSEqCDevDevice *)
Changes the nth child of this node.
Definition: diseqc.h:165
dvbdev_t GetDeviceType(void) const
Definition: diseqc.h:169
DiSEqCDevDevice * GetParent(void) const
Definition: diseqc.h:173
LNB Class.
Definition: diseqc.h:447
dvbdev_lnb_t GetType(void) const
Definition: diseqc.h:472
bool IsPolarityInverted(void) const
Definition: diseqc.h:476
uint GetLOFHigh(void) const
Definition: diseqc.h:474
uint GetLOFSwitch(void) const
Definition: diseqc.h:473
void SetLOFLow(uint lof_lo)
Definition: diseqc.h:468
void SetType(dvbdev_lnb_t type)
Definition: diseqc.h:465
void SetPolarityInverted(bool inv)
Definition: diseqc.h:469
@ kTypeFixed
Definition: diseqc.h:460
@ kTypeVoltageAndToneControl
Definition: diseqc.h:462
@ kTypeBandstacked
Definition: diseqc.h:463
@ kTypeVoltageControl
Definition: diseqc.h:461
uint GetLOFLow(void) const
Definition: diseqc.h:475
void SetLOFSwitch(uint lof_switch)
Definition: diseqc.h:466
void SetLOFHigh(uint lof_hi)
Definition: diseqc.h:467
Rotor class.
Definition: diseqc.h:303
double GetLoSpeed(void) const
Definition: diseqc.h:326
double GetHiSpeed(void) const
Definition: diseqc.h:327
@ kTypeDiSEqC_1_3
Definition: diseqc.h:316
@ kTypeDiSEqC_1_2
Definition: diseqc.h:316
void SetHiSpeed(double speed)
Definition: diseqc.h:319
uint_to_dbl_t GetPosMap(void) const
Definition: diseqc.cpp:1985
void SetType(dvbdev_rotor_t type)
Definition: diseqc.h:317
void SetPosMap(const uint_to_dbl_t &posmap)
Definition: diseqc.cpp:1995
dvbdev_rotor_t GetType(void) const
Definition: diseqc.h:325
void SetLoSpeed(double speed)
Definition: diseqc.h:318
Unicable / SCR Class.
Definition: diseqc.h:383
int GetPIN(void) const
Definition: diseqc.h:410
uint GetFrequency(void) const
Definition: diseqc.h:409
void SetPIN(int pin)
Definition: diseqc.h:404
static QString SCRPositionToString(dvbdev_pos_t pos)
Definition: diseqc.h:427
void SetFrequency(uint freq)
Definition: diseqc.h:403
@ kTypeScrPosB
Definition: diseqc.h:400
@ kTypeScrPosA
Definition: diseqc.h:399
uint GetUserBand(void) const
Definition: diseqc.h:408
void SetUserBand(uint userband)
Definition: diseqc.h:402
DVB-S device settings class.
Definition: diseqc.h:37
double GetValue(uint devid) const
Retrieves a value from this configuration chain by device id.
Definition: diseqc.cpp:207
void SetValue(uint devid, double value)
Sets a value for this configuration chain by device id.
Definition: diseqc.cpp:222
Switch class, including tone, legacy and DiSEqC switches.
Definition: diseqc.h:224
void SetAddress(uint address)
Definition: diseqc.h:249
void SetType(dvbdev_switch_t type)
Definition: diseqc.h:248
dvbdev_switch_t GetType(void) const
Definition: diseqc.h:254
uint GetAddress(void) const
Definition: diseqc.h:255
@ kTypeDiSEqCUncommitted
Definition: diseqc.h:241
@ kTypeDiSEqCCommitted
Definition: diseqc.h:240
void SetNumPorts(uint num_ports)
Definition: diseqc.cpp:1346
uint GetNumPorts(void) const
Definition: diseqc.h:256
bool Load(const QString &device)
Loads the device tree from the database.
Definition: diseqc.cpp:314
void SetRoot(DiSEqCDevDevice *root)
Changes the root node of the tree.
Definition: diseqc.cpp:638
DiSEqCDevDevice * Root(void)
Retrieves the root node in the tree.
Definition: diseqc.h:93
static DiseqcConfigBase * CreateByType(DiSEqCDevDevice *dev, StandardSetting *parent)
void DeleteClicked(void)
bool keyPressEvent(QKeyEvent *event) override
void UpdateType(void)
void SetPreset(const QString &value)
LNBPolarityInvertedSetting * m_polInv
LNBPresetSetting * m_preset
LNBTypeSetting * m_type
void Load(void) override
LNBLOFSwitchSetting * m_lofSwitch
LNBConfig(DiSEqCDevLNB &lnb, StandardSetting *parent)
LNBLOFLowSetting * m_lofLo
LNBLOFHighSetting * m_lofHi
DiSEqCDevLNB & m_lnb
LNBLOFHighSetting(DiSEqCDevLNB &lnb)
void Load(void) override
void Save(void) override
void Save(void) override
LNBLOFLowSetting(DiSEqCDevLNB &lnb)
DiSEqCDevLNB & m_lnb
void Load(void) override
void Load(void) override
DiSEqCDevLNB & m_lnb
LNBLOFSwitchSetting(DiSEqCDevLNB &lnb)
void Save(void) override
LNBPolarityInvertedSetting(DiSEqCDevLNB &lnb)
void Save(void) override
void Load(void) override
LNBPresetSetting(DiSEqCDevLNB &lnb)
void Save(void) override
DiSEqCDevLNB & m_lnb
void Load(void) override
void Load(void) override
LNBTypeSetting(DiSEqCDevLNB &lnb)
DiSEqCDevLNB & m_lnb
void Save(void) override
void setValue(const QString &newValue) override
virtual void addSelection(const QString &label, QString value=QString(), bool select=false)
void setValue(int value) override
int getValueIndex(const QString &value) const
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
RotorPosMap * m_pos
void Load() override
RotorConfig(DiSEqCDevRotor &rotor, StandardSetting *parent)
void SetType(const QString &type)
DiSEqCDevRotor & m_rotor
RotorHiSpeedSetting(DiSEqCDevRotor &rotor)
void Save(void) override
void Load(void) override
DiSEqCDevRotor & m_rotor
void Save(void) override
void Load(void) override
DiSEqCDevRotor & m_rotor
RotorLoSpeedSetting(DiSEqCDevRotor &rotor)
void PopulateList(void)
void Save(void) override
void newValue(StandardSetting *setting)
void Load(void) override
DiSEqCDevRotor & m_rotor
uint_to_dbl_t m_posmap
RotorPosTextEdit(const QString &label, uint id, const QString &value)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
uint_to_dbl_t m_posmap
DiSEqCDevDevice & m_node
DiSEqCDevSettings & m_settings
RotorSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
void Load(void) override
void Save(void) override
void Load(void) override
DiSEqCDevRotor & m_rotor
void Save(void) override
RotorTypeSetting(DiSEqCDevRotor &rotor)
SCRConfig(DiSEqCDevSCR &scr, StandardSetting *parent)
void Save(void) override
DiSEqCDevSCR & m_scr
SCRFrequencySetting(DiSEqCDevSCR &scr)
void Load(void) override
void Load(void) override
void Save(void) override
SCRPINSetting(DiSEqCDevSCR &scr)
DiSEqCDevSCR & m_scr
DiSEqCDevSettings & m_settings
DiSEqCDevDevice & m_node
SCRPositionSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
void Save(void) override
void Load(void) override
void Save(void) override
void Load(void) override
SCRUserBandSetting(DiSEqCDevSCR &scr)
DiSEqCDevSCR & m_scr
virtual void addChild(StandardSetting *child)
virtual void Load(void)
bool isEnabled() const
void addTargetedChild(const QString &value, StandardSetting *setting)
virtual void clearSettings()
void settingsChanged(StandardSetting *selectedSetting=nullptr)
virtual void setHelpText(const QString &str)
virtual void setValue(const QString &newValue)
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
virtual void setLabel(QString str)
void setChanged(bool changed)
SwitchAddressSetting(DiSEqCDevSwitch &switch_dev)
DiSEqCDevSwitch & m_switch
void Load(void) override
void Save(void) override
DeviceDescrSetting * m_deviceDescr
SwitchConfig(DiSEqCDevSwitch &switch_dev, StandardSetting *parent)
SwitchAddressSetting * m_address
void Load(void) override
void update(void)
SwitchPortsSetting * m_ports
SwitchTypeSetting * m_type
SwitchPortsSetting(DiSEqCDevSwitch &switch_dev)
void Save(void) override
DiSEqCDevSwitch & m_switch
void Load(void) override
SwitchSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
DiSEqCDevDevice & m_node
void Save(void) override
void Load(void) override
DiSEqCDevSettings & m_settings
void Load(void) override
void Save(void) override
SwitchTypeSetting(DiSEqCDevSwitch &switch_dev)
DiSEqCDevSwitch & m_switch
DiSEqCDevDevice & m_node
void Save(void) override
TransTextEditSetting * m_numeric
void Load(void) override
USALSRotorSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings)
DiSEqCDevSettings & m_settings
TransMythUIComboBoxSetting * m_hemisphere
lnb_preset(QString _name, DiSEqCDevLNB::dvbdev_lnb_t _type, uint _lof_sw=0, uint _lof_lo=0, uint _lof_hi=0, bool _pol_inv=false)
DiSEqCDevLNB::dvbdev_lnb_t m_type
unsigned int uint
Definition: compat.h:60
QMap< uint, double > uint_to_dbl_t
Definition: diseqc.h:30
static const std::array< const lnb_preset, 7 > lnb_presets
static QString AngleToString(double angle)
static uint FindPreset(const DiSEqCDevLNB &lnb)
static double AngleToEdit(double angle, QString &hemi)
static double AngleToFloat(const QString &angle, bool translated=true)
static GlobalTextEditSetting * DiSEqCLongitude(void)
static GlobalTextEditSetting * DiSEqCLatitude(void)
static const iso6937table * d
MythMainWindow * GetMythMainWindow(void)