trunk 20080912
[gitenigma.git] / src / rotorconfig.cpp
blob31b4e3b7d86e1631764eb090723ddc4a6d1d1a41
1 #include <rotorconfig.h>
3 #include <lib/base/i18n.h>
4 #include <lib/system/init_num.h>
5 #include <lib/gui/eskin.h>
6 #include <lib/gui/ebutton.h>
7 #include <lib/gui/emessage.h>
8 #include <lib/gui/echeckbox.h>
9 #include <lib/gui/actions.h>
10 #include <lib/dvb/edvb.h>
11 #include <lib/dvb/dvbservice.h>
12 #include <lib/dvb/frontend.h>
13 #include <lib/dvb/dvbwidgets.h>
14 #include <lib/dvb/edvb.h>
15 #include <lib/system/info.h>
17 RotorConfig::RotorConfig(eLNB *lnb )
18 :lnb(lnb)
20 init_RotorConfig(lnb);
23 void RotorConfig::init_RotorConfig(eLNB *lnb )
25 #ifndef DISABLE_LCD
26 LCDTitle=parent->LCDTitle;
27 LCDElement=parent->LCDElement;
28 #endif
29 useRotorInPower = new eCheckbox(this);
30 useRotorInPower->setName("useRotorInPower");
32 lDeltaA = new eLabel(this);
33 lDeltaA->setName("lDeltaA");
34 lDeltaA->hide();
35 DeltaA = new eNumber( this, 1, 0, 200, 3, 0, 0, lDeltaA);
36 DeltaA->setName("DeltaA");
37 DeltaA->hide();
39 useGotoXX = new eCheckbox(this);
40 useGotoXX->setName("useGotoXX");
42 lLongitude = new eLabel(this);
43 lLongitude->setName("lLongitude");
44 lLongitude->hide();
46 Longitude = new eNumber(this, 2, 0, 360, 3, 0, 0, lLongitude );
47 Longitude->setFlags( eNumber::flagFixedNum );
48 Longitude->setName("Longitude");
49 Longitude->hide();
51 LoDirection = new eComboBox( this, 2 );
52 LoDirection->setName("LoDirection");
53 LoDirection->hide();
54 new eListBoxEntryText( *LoDirection, _("East"), (void*)eDiSEqC::EAST, 0, _("East") );
55 new eListBoxEntryText( *LoDirection, _("West"), (void*)eDiSEqC::WEST, 0, _("West") );
57 lLatitude = new eLabel(this);
58 lLatitude->setName("lLatitude");
59 lLatitude->hide();
61 Latitude = new eNumber(this, 2, 0, 360, 3, 0, 0, lLatitude );
62 Latitude->setFlags( eNumber::flagFixedNum );
63 Latitude->setName("Latitude");
64 Latitude->hide();
66 LaDirection = new eComboBox( this, 2 );
67 LaDirection->setName("LaDirection");
68 LaDirection->hide();
69 new eListBoxEntryText( *LaDirection, _("North"), (void*)eDiSEqC::NORTH, 0, _("North") );
70 new eListBoxEntryText( *LaDirection, _("South"), (void*)eDiSEqC::SOUTH, 0, _("South") );
72 positions = new eListBox< eListBoxEntryText >( this );
73 positions->setFlags( eListBoxBase::flagLostFocusOnFirst|eListBoxBase::flagLostFocusOnLast );
74 positions->setName("positions");
75 positions->hide();
77 lStoredRotorNo = new eLabel(this);
78 lStoredRotorNo->setName("lStoredRotorNo");
79 lStoredRotorNo->hide();
80 number = new eNumber( this, 1, 0, 255, 3, 0, 0, lStoredRotorNo);
81 number->setName("StoredRotorNo");
82 number->hide();
84 lOrbitalPosition = new eLabel(this);
85 lOrbitalPosition->setName("lOrbitalPosition");
86 lOrbitalPosition->hide();
87 orbital_position = new eNumber( this, 1, 0, 3600, 4, 0, 0, lOrbitalPosition);
89 orbital_position->setName("OrbitalPosition");
90 orbital_position->hide();
92 lDirection = new eLabel(this);
93 lDirection->setName("lDirection");
94 lDirection->hide();
95 direction = new eComboBox( this, 2, lDirection );
96 direction->setName("Direction");
97 direction->hide();
98 new eListBoxEntryText( *direction, _("East"), (void*)0, 0, _("East") );
99 new eListBoxEntryText( *direction, _("West"), (void*)1, 0, _("West") );
101 add = new eButton( this );
102 add->setName("add");
103 add->hide();
105 remove = new eButton ( this, 0, 0 );
106 remove->setName("remove");
107 remove->hide();
109 save = new eButton(this);
110 save->setName("save");
112 next = new eButton(this);
113 next->setName("next");
115 eSkin *skin=eSkin::getActive();
116 if (skin->build(this, "RotorConfig"))
117 eFatal("skin load of \"RotorConfig\" failed");
119 orbital_position->setHelpText(_("enter orbital position without dot (19.2\xC2\xB0 = 192)"));
120 CONNECT( orbital_position->selected, RotorConfig::numSelected );
121 CONNECT( Longitude->selected, RotorConfig::numSelected );
122 CONNECT( Latitude->selected, RotorConfig::numSelected );
123 CONNECT( number->selected, RotorConfig::numSelected );
124 CONNECT( DeltaA->selected, RotorConfig::numSelected );
125 CONNECT( add->selected, RotorConfig::onAdd );
126 CONNECT( remove->selected, RotorConfig::onRemove );
127 CONNECT( positions->selchanged, RotorConfig::posChanged );
128 CONNECT( useGotoXX->checked, RotorConfig::gotoXXChanged );
129 CONNECT( useRotorInPower->checked, RotorConfig::useRotorInPowerChanged );
131 CONNECT( save->selected, RotorConfig::onSavePressed );
132 CONNECT( next->selected, RotorConfig::onNextPressed );
134 addActionMap(&i_focusActions->map);
136 if (lnb)
137 setLNBData(lnb);
139 if ( !eSystemInfo::getInstance()->canMeasureLNBCurrent() )
141 eDebug("useRotorInputPower can only used on dreambox");
142 useRotorInPower->hide();
146 struct savePosition
148 std::map<int,int,Orbital_Position_Compare> &map;
150 savePosition(std::map<int,int,Orbital_Position_Compare> &map): map(map)
154 bool operator()(eListBoxEntryText& s)
156 if ( (int)s.getKey() == 0xFFFF )
157 return 0; // ignore sample Entry... delete me...
159 int num = atoi( s.getText().left( s.getText().find('/') ).c_str() );
160 map[ (int)s.getKey() ] = num;
161 return 0;
165 void RotorConfig::onSavePressed()
167 lnb->getDiSEqC().useGotoXX = useGotoXX->isChecked();
168 lnb->getDiSEqC().useRotorInPower = useRotorInPower->isChecked()?1:0;
169 lnb->getDiSEqC().useRotorInPower |= DeltaA->getNumber()<<8;
170 lnb->getDiSEqC().gotoXXLaDirection = (int) LaDirection->getCurrent()->getKey();
171 lnb->getDiSEqC().gotoXXLoDirection = (int) LoDirection->getCurrent()->getKey();
172 lnb->getDiSEqC().gotoXXLatitude = Latitude->getFixedNum();
173 lnb->getDiSEqC().gotoXXLongitude = Longitude->getFixedNum();
174 lnb->getDiSEqC().RotorTable.clear();
175 positions->forEachEntry( savePosition( lnb->getDiSEqC().RotorTable ) );
176 eTransponderList::getInstance()->writeLNBData();
177 eConfig::getInstance()->flush();
178 close(0);
181 void RotorConfig::useRotorInPowerChanged( int state )
183 eDebug("useRotorInPowerChanged to %d", state);
184 if (state)
186 lDeltaA->show();
187 DeltaA->show();
189 else
191 lDeltaA->hide();
192 DeltaA->hide();
196 void RotorConfig::gotoXXChanged( int state )
198 eDebug("gotoXXChanged to %d", state);
199 if ( state )
201 add->hide();
202 remove->hide();
203 lOrbitalPosition->hide();
204 orbital_position->hide();
205 lStoredRotorNo->hide();
206 number->hide();
207 lDirection->hide();
208 direction->hide();
209 positions->hide();
211 lLongitude->show();
212 Longitude->show();
213 LoDirection->show();
214 lLatitude->show();
215 Latitude->show();
216 LaDirection->show();
218 else
220 lLongitude->hide();
221 Longitude->hide();
222 LoDirection->hide();
223 lLatitude->hide();
224 Latitude->hide();
225 LaDirection->hide();
227 add->show();
228 remove->show();
229 lOrbitalPosition->show();
230 orbital_position->show();
231 lStoredRotorNo->show();
232 number->show();
233 lDirection->show();
234 direction->show();
235 positions->show();
239 void RotorConfig::setLNBData( eLNB *lnb )
241 positions->beginAtomic();
242 positions->clearList();
243 eDiSEqC &DiSEqC = lnb->getDiSEqC();
245 if ( lnb )
247 for ( std::map<int, int>::iterator it ( DiSEqC.RotorTable.begin() ); it != DiSEqC.RotorTable.end(); it++ )
248 new eListBoxEntryText( positions, eString().sprintf(" %d / %d.%d%c", it->second, abs(it->first)/10, abs(it->first)%10, it->first > 0 ? 'E' : 'W'), (void*) it->first );
250 useGotoXX->setCheck( (int) (lnb->getDiSEqC().useGotoXX & 1 ? 1 : 0) );
251 gotoXXChanged( (int) lnb->getDiSEqC().useGotoXX & 1 );
252 if ( eSystemInfo::getInstance()->canMeasureLNBCurrent() )
254 useRotorInPower->setCheck( (int) lnb->getDiSEqC().useRotorInPower & 1 );
255 useRotorInPowerChanged( (int) lnb->getDiSEqC().useRotorInPower & 1 );
257 else
259 useRotorInPower->setCheck( 0 );
260 useRotorInPowerChanged( 0 );
263 Latitude->setFixedNum( lnb->getDiSEqC().gotoXXLatitude );
264 LaDirection->setCurrent( (void*) lnb->getDiSEqC().gotoXXLaDirection );
265 Longitude->setFixedNum( lnb->getDiSEqC().gotoXXLongitude );
266 LoDirection->setCurrent( (void*) lnb->getDiSEqC().gotoXXLoDirection );
267 DeltaA->setNumber( (lnb->getDiSEqC().useRotorInPower & 0x0000FF00) >> 8 );
269 else
271 Latitude->setFixedNum(0);
272 LaDirection->setCurrent(0);
273 Longitude->setFixedNum(0);
274 LoDirection->setCurrent(0);
275 DeltaA->setNumber(40);
276 useGotoXX->setCheck( 1 );
277 useRotorInPower->setCheck( 0 );
280 if ( positions->getCount() )
282 positions->sort();
283 positions->moveSelection(eListBox<eListBoxEntryText>::dirFirst);
285 else
287 new eListBoxEntryText( positions, _("delete me"), (void*) 0xFFFF );
288 posChanged(0);
291 positions->endAtomic();
294 void RotorConfig::posChanged( eListBoxEntryText *e )
296 if ( e && (int)e->getKey() != 0xFFFF )
298 direction->setCurrent( e->getText().right( 1 ) == "E" ? 0 : 1 );
299 orbital_position->setNumber( (int) e->getKey() );
300 number->setNumber( atoi( e->getText().mid( 1 , e->getText().find('/')-1 ).c_str()) );
302 else
304 orbital_position->setNumber( 0 );
305 number->setNumber( 0 );
306 direction->setCurrent( 0 );
310 void RotorConfig::numSelected(int*)
312 focusNext( eWidget::focusDirNext );
315 void RotorConfig::onAdd()
317 positions->beginAtomic();
319 new eListBoxEntryText( positions,eString().sprintf(" %d / %d.%d%c",
320 number->getNumber(),
321 orbital_position->getNumber()/10,
322 orbital_position->getNumber()%10,
323 direction->getCurrent()->getKey() ? 'W':'E'
325 (void*) ( direction->getCurrent()->getKey()
326 ? - orbital_position->getNumber()
327 : orbital_position->getNumber() )
330 positions->sort();
331 positions->invalidateContent();
332 positions->endAtomic();
335 void RotorConfig::onRemove()
337 positions->beginAtomic();
339 if (positions->getCurrent())
340 positions->remove( positions->getCurrent() );
342 if (!positions->getCount())
344 new eListBoxEntryText( positions, _("delete me"), (void*) 0xFFFF );
345 posChanged(0);
348 positions->invalidate();
349 positions->endAtomic();
352 void RotorConfig::onNextPressed()
354 if (lnb)
356 hide();
357 eRotorManual c(lnb);
358 #ifndef DISABLE_LCD
359 c.setLCD( LCDTitle, LCDElement );
360 #endif
361 c.show();
362 c.exec();
363 if (c.changed)
365 setLNBData(lnb);
366 useGotoXX->setCheck(0);
367 positions->forEachEntry( savePosition( lnb->getDiSEqC().RotorTable ) );
368 eTransponderList::getInstance()->writeLNBData();
370 c.hide();
371 show();
375 struct rotorMenuActions
377 eActionMap map;
378 eAction east, eastFine, eastStop, west, westFine, westStop;
379 rotorMenuActions():
380 map("rotorMenu", "rotorMenu"),
381 east(map, "driveEast", _("drive Motor East"), eAction::prioWidget),
382 eastFine(map, "driveEastStep", _("drive Motor East.. one step"), eAction::prioWidget),
383 eastStop(map, "driveEastStop", _("stop Motor drive East"), eAction::prioWidget),
384 west(map, "driveWest", _("drive Motor East"), eAction::prioWidget),
385 westFine(map, "driveWestStep", _("drive Motor West.. one step"), eAction::prioWidget),
386 westStop(map, "driveWestStop", _("stop Motor drive West"), eAction::prioWidget)
391 eAutoInitP0<rotorMenuActions> i_rotorMenuActions(eAutoInitNumbers::actions, "rotor menu actions");
393 eRotorManual::eRotorManual(eLNB *lnb)
394 :lnb(lnb), retuneTimer(new eTimer(eApp)), transponder(0), changed(0)
396 init_eRotorManual(lnb);
399 void eRotorManual::init_eRotorManual(eLNB *lnb)
401 lMode = new eLabel(this);
402 lMode->setName("lMode");
404 lSat = new eLabel(this);
405 lSat->setName("lSat");
407 lTransponder = new eLabel(this);
408 lTransponder->setName("lTransponder");
410 lDirection = new eLabel(this);
411 lDirection->setName("lDirection");
413 lCounter = new eLabel(this);
414 lCounter->setName("lCounter");
416 running=false;
418 Mode = new eComboBox(this, 4, lMode );
419 Mode->setName("Mode");
420 CONNECT(Mode->selchanged, eRotorManual::modeChanged);
422 num = new eNumber( this, 1, 1, 80, 2, 0, 0, lSat );
423 num->setName("num");
424 num->setNumber(1);
426 // send no more DiSEqC Commands on transponder::tune to Rotor
427 eFrontend::getInstance()->disableRotor();
429 Sat = new eComboBox( this, 7, lSat );
430 Sat->setName("Sat");
431 CONNECT(Sat->selchanged, eRotorManual::satChanged );
433 Transponder = new eComboBox(this, 5 );
434 Transponder->setName("Transponder");
435 CONNECT(Transponder->selchanged, eRotorManual::tpChanged);
437 Direction = new eButton(this);
438 Direction->setName("Direction");
440 Exit = new eButton(this);
441 Exit->setName("Exit");
442 CONNECT( Exit->selected, eRotorManual::reject );
444 Save = new eButton(this);
445 Save->setName("Save");
446 CONNECT(Save->selected, eRotorManual::onButtonPressed );
448 Search = new eButton(this);
449 Search->setName("Search");
450 CONNECT( Search->selected, eRotorManual::onScanPressed );
452 status = new eFEStatusWidget( this, eFrontend::getInstance() );
453 status->setName("Status");
455 if ( eSkin::getActive()->build(this, "RotorManual"))
456 eFatal("skin load of \"RotorManual\" failed");
458 Direction->setText("< Stop >");
460 eTransponderList::getInstance()->reloadNetworks();
462 new eListBoxEntryText(*Mode, _("position"), (void*) 0, 0, _("store new sat positions"));
463 new eListBoxEntryText(*Mode, _("drive to stored pos"), (void*) 1, 0, _("drive to stored position"));
464 new eListBoxEntryText(*Mode, _("drive to satellite"), (void*) 8, 0, _("drive to stored satellite"));
465 new eListBoxEntryText(*Mode, _("drive to 0\xC2\xB0"), (void*) 2, 0, _("drives to 0\xB0"));
466 new eListBoxEntryText(*Mode, _("recalculate"), (void*) 3, 0, _("recalculate stored positions rel. to current pos"));
467 new eListBoxEntryText(*Mode, _("set east limit"), (void*) 4, 0, _("set east soft limit"));
468 new eListBoxEntryText(*Mode, _("set west limit"), (void*) 5, 0, _("set west soft limit"));
469 new eListBoxEntryText(*Mode, _("disable limits"), (void*) 6, 0, _("disable soft limits"));
470 new eListBoxEntryText(*Mode, _("enable limits"), (void*) 7, 0, _("enable soft limits"));
471 Mode->setCurrent(0,true);
473 eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI();
475 if (sapi && sapi->transponder)
476 transponder = sapi->transponder;
478 eListBoxEntryText *sel=0;
480 for ( std::list<eLNB>::iterator it( eTransponderList::getInstance()->getLNBs().begin() ); it != eTransponderList::getInstance()->getLNBs().end(); it++)
481 if ( it->getDiSEqC().DiSEqCMode == eDiSEqC::V1_2 )
482 for ( ePtrList<eSatellite>::iterator s ( it->getSatelliteList().begin() ); s != it->getSatelliteList().end(); s++)
483 if ( transponder && s->getOrbitalPosition() == transponder->satellite.orbital_position )
484 sel = new eListBoxEntryText(*Sat, s->getDescription().c_str(), (void*) *s);
485 else
486 new eListBoxEntryText(*Sat, s->getDescription().c_str(), (void*) *s);
488 if ( sel )
489 Sat->setCurrent(sel,true);
490 else
491 Sat->setCurrent(0,true);
493 CONNECT( retuneTimer->timeout, eRotorManual::retune );
494 addActionMap(&i_rotorMenuActions->map);
496 CONNECT(num->selected, eRotorManual::nextfield);
499 void eRotorManual::modeChanged( eListBoxEntryText *e)
501 eString buttonText, helpText;
503 switch((int)e->getKey())
505 default:
506 case 0:
507 helptext=_("store current pos in motor");
508 buttonText=_("store");
509 break;
510 case 1:
511 helptext=_("drive motor to stored pos");
512 buttonText=_("go");
513 break;
514 case 2:
515 helptext=_("drive motor to reference position");
516 buttonText=_("go");
517 break;
518 case 3:
519 helptext=_("recalculate all stored positions");
520 buttonText=_("recalc");
521 break;
522 case 4:
523 helptext=_("store current pos as east soft limit");
524 buttonText=_("store");
525 break;
526 case 5:
527 helptext=_("store current pos as west soft limit");
528 buttonText=_("store");
529 break;
530 case 6:
531 helptext=_("disable soft limits");
532 buttonText=_("do it");
533 break;
534 case 7:
535 helptext=_("enable soft limits");
536 buttonText=_("do it");
537 break;
538 case 8:
539 helptext=_("drive motor to satellite");
540 buttonText=_("go");
541 break;
543 Save->setHelpText(helptext);
544 Save->setText(buttonText);
546 switch((int)e->getKey())
548 default:
550 case 0: // store new positions
551 case 4: // set east limit
552 case 5: // set west limit
553 /* lRecalcParams->hide();
554 num1->hide();
555 num2->hide();
556 num3->hide();*/
557 case 3: // recalculate
558 num->hide();
559 break;
561 case 6: // clear limits
562 case 7: // set limits
563 case 2: // goto ref pos
564 /* lRecalcParams->hide();
565 num1->hide();
566 num2->hide();
567 num3->hide();*/
568 num->hide();
569 case 1: // go to stored pos
570 lSat->hide();
571 Sat->hide();
572 case 8: // goto satellite
573 lTransponder->hide();
574 Transponder->hide();
575 Direction->hide();
576 lDirection->hide();
577 break;
580 switch((int)e->getKey())
582 default:
583 case 3: // recalculate
584 /* lRecalcParams->show();
585 num1->show();
586 num2->show();
587 num3->show();*/
588 case 0: // store new positions
589 case 4: // set east limit
590 case 5: // set west limit
591 lTransponder->show();
592 Transponder->show();
593 Direction->show();
594 lDirection->show();
595 case 8: // goto sat pos
596 num->hide();
597 lSat->setText(_("Satellite:"));
598 lSat->show();
599 Sat->show();
600 break;
602 case 1: // go to stored pos
603 lSat->show();
604 lSat->setText("Position:");
605 num->show();
606 case 6: // clear limits
607 case 7: // set limits
608 case 2: // goto ref pos
609 break;
613 void eRotorManual::retune()
615 if( transponder && !eFrontend::getInstance()->Locked() )
616 transponder->tune();
619 void eRotorManual::satChanged( eListBoxEntryText *sat)
621 Transponder->clear();
622 if (sat && sat->getKey())
624 eListBoxEntryText *sel=0;
626 eSatellite *Sat = (eSatellite*) (sat->getKey());
628 for ( std::list<tpPacket>::const_iterator i( eTransponderList::getInstance()->getNetworks().begin() ); i != eTransponderList::getInstance()->getNetworks().end(); i++ )
630 if ( i->orbital_position == Sat->getOrbitalPosition() )
632 for (std::list<eTransponder>::const_iterator it( i->possibleTransponders.begin() ); it != i->possibleTransponders.end(); it++)
633 if ( transponder && *transponder == *it )
634 sel = new eListBoxEntryText( *Transponder, eString().sprintf("%d / %d / %c", it->satellite.frequency/1000, it->satellite.symbol_rate/1000, it->satellite.polarisation?'V':'H' ), (void*)&(*it) );
635 else
636 new eListBoxEntryText( *Transponder, eString().sprintf("%d / %d / %c", it->satellite.frequency/1000, it->satellite.symbol_rate/1000, it->satellite.polarisation?'V':'H' ), (void*)&(*it) );
640 if (Transponder->getCount())
642 if ( sel )
643 Transponder->setCurrent(sel,true);
644 else
645 Transponder->setCurrent(0,true);
650 void eRotorManual::tpChanged( eListBoxEntryText *tp )
652 if (tp && tp->getKey() )
654 if ( transponder && *transponder == *((eTransponder*)tp->getKey()))
655 return;
656 transponder = (eTransponder*)(tp->getKey());
657 transponder->tune();
659 else
660 transponder = 0;
663 void eRotorManual::onButtonPressed()
665 switch((int)Mode->getCurrent()->getKey())
667 default:
668 case 0: // store current pos in Rotor
670 eStoreWindow w( lnb, ((eSatellite*) Sat->getCurrent()->getKey())->getOrbitalPosition() );
671 hide();
672 w.show();
673 int ret = w.exec();
674 if (ret && ret != -1)
676 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6A, eString().sprintf("%02x",ret) );
677 changed=1;
679 w.hide();
680 show();
682 break;
683 case 1: //drive rotor to stored pos
684 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6B, eString().sprintf("%02x",num->getNumber()).c_str() );
685 break;
686 case 2: //driver rotor to reference position
687 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6B, "00");
688 break;
689 case 3: //recalculate all stored positions
691 eMessageBox mb( _("Wrong use of this function can corrupt all stored sat positions.\n"
692 "Are you sure you want to use this function?"), _("Warning"), eMessageBox::iconWarning|eMessageBox::btYes|eMessageBox::btNo, eMessageBox::btNo );
693 hide();
694 mb.show();
695 switch( mb.exec() )
697 case eMessageBox::btYes:
698 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6F, "00");
699 mb.hide();
700 show();
701 break;
702 case eMessageBox::btNo:
703 mb.hide();
704 show();
705 return;
706 break;
709 break;
710 case 4: //store current pos as east soft limit
711 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x66 );
712 break;
713 case 5: //store current pos as west soft limit
714 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x67 );
715 break;
716 case 6: //disable soft limits
717 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x63 );
718 break;
719 case 7: //enable soft limits
720 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6A, "00");
721 break;
722 case 8: //goto sat pos
723 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x6B, eString().sprintf("%02x", lnb->getDiSEqC().RotorTable[ ((eSatellite*)Sat->getCurrent()->getKey())->getOrbitalPosition()] ) );
724 break;
726 retune();
729 void eRotorManual::onScanPressed()
731 #ifndef DISABLE_LCD
732 TransponderScan setup(LCDTitle, LCDElement);
733 #else
734 TransponderScan setup;
735 #endif
736 hide();
737 setup.exec();
738 show();
741 int eRotorManual::eventHandler( const eWidgetEvent& e)
743 switch (e.type)
745 case eWidgetEvent::execDone:
746 // enable send DiSEqC Commands to Rotor on eTransponder::tune
747 eFrontend::getInstance()->enableRotor();
748 break;
750 case eWidgetEvent::evtAction:
751 if ( focus == Direction )
753 if (e.action == &i_rotorMenuActions->eastFine)
755 if (!running)
757 Direction->setText(_("one step East..."));
758 eDebug("east Fine");
759 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x68, "FF" );
762 else if (e.action == &i_rotorMenuActions->westFine)
764 if (!running)
766 Direction->setText(_("one step west..."));
767 eDebug("west fine");
768 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x69, "FF" );
771 else if (e.action == &i_rotorMenuActions->east)
773 if ( !running )
775 running=true;
776 eDebug("east");
777 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x68, "00" );
778 retuneTimer->start(500, false);
780 Direction->setText(_("turning to east..."));
782 else if (e.action == &i_rotorMenuActions->west)
784 if ( !running )
786 running=true;
787 eDebug("west");
788 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x69, "00" );
789 retuneTimer->start(500, false);
791 Direction->setText(_("turning to west..."));
793 else if (e.action == &i_rotorMenuActions->eastStop || e.action == &i_rotorMenuActions->westStop )
795 if (running)
797 eDebug("send stop");
798 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x60 );
799 eFrontend::getInstance()->sendDiSEqCCmd( 0x31, 0x60 );
800 running=false;
801 retuneTimer->stop();
803 retune();
804 Direction->setText(_("< Stop >"));
806 else
807 break;
809 else
810 break;
811 return 1;
813 default:
814 break;
816 return eWindow::eventHandler(e);
819 eRotorManual::~eRotorManual()
821 if (retuneTimer)
822 delete retuneTimer;
825 void eRotorManual::nextfield(int*)
827 eDebug("focusDirNext");
828 focusNext(eWidget::focusDirNext);
832 eStoreWindow::eStoreWindow(eLNB *lnb, int orbital_pos)
833 :lnb(lnb), orbital_pos(orbital_pos)
835 cresize(eSize(360,140));
836 cmove(ePoint(150,150));
837 setText("Store Satellite");
838 lStorageLoc = new eLabel(this);
839 lStorageLoc->resize(eSize(250, 35));
840 lStorageLoc->move(ePoint(10,10));
841 lStorageLoc->setText(_("Storage Location:"));
842 StorageLoc = new eNumber( this, 1, 1, 80, 2, 0, 0, lStorageLoc );
843 StorageLoc->setHelpText(_("change storage Location or store"));
844 StorageLoc->resize(eSize(80, 35));
845 StorageLoc->move(ePoint(270, 10));
846 StorageLoc->loadDeco();
847 CONNECT(StorageLoc->selected, eStoreWindow::nextfield );
848 Store = new eButton(this);
849 Store->setShortcut("green");
850 Store->setShortcutPixmap("green");
851 Store->move(ePoint(10,60));
852 Store->resize(eSize(220,40));
853 Store->setText(_("store"));
854 Store->loadDeco();
855 CONNECT( Store->selected, eStoreWindow::onStorePressed );
856 eStatusBar *sbar = new eStatusBar(this);
857 sbar->move( ePoint(0, getClientSize().height()-30) );
858 sbar->resize( eSize( getClientSize().width(), 30) );
859 sbar->loadDeco();
860 int i = 0;
861 while (1)
863 i++;
864 std::map<int,int>::iterator it(lnb->getDiSEqC().RotorTable.begin());
865 for ( ; it != lnb->getDiSEqC().RotorTable.end(); it++ )
866 if ( it->second == i )
867 break;
869 if (it != lnb->getDiSEqC().RotorTable.end() )
871 if ( it->first != orbital_pos )
872 continue;
875 StorageLoc->setNumber(i);
876 break;
880 void eStoreWindow::nextfield(int*)
882 focusNext(eWidget::focusDirNext);
885 void eStoreWindow::onStorePressed()
887 std::map<int,int>::iterator it = lnb->getDiSEqC().RotorTable.find( orbital_pos );
888 if ( it != lnb->getDiSEqC().RotorTable.end() )
890 int ret = eMessageBox::btYes;
891 if ( StorageLoc->getNumber() != it->second )
893 eMessageBox mb( eString().sprintf(_("%d.%d\xC2\xB0%c is currently stored at location %d!\nWhen you store this now at Location %d, we must remove the old Location.\nAre you sure you want to do this?"),abs(orbital_pos)/10, abs(orbital_pos)%10, orbital_pos>0?'E':'W', it->second, StorageLoc->getNumber() ), _("Warning"), eMessageBox::iconWarning|eMessageBox::btYes|eMessageBox::btNo, eMessageBox::btNo );
894 hide();
895 mb.show();
896 ret = mb.exec();
897 mb.hide();
898 show();
900 switch( ret )
902 case eMessageBox::btYes:
903 lnb->getDiSEqC().RotorTable.erase(it);
904 lnb->getDiSEqC().useGotoXX=0;
905 lnb->getDiSEqC().RotorTable[orbital_pos] = StorageLoc->getNumber();
906 close(StorageLoc->getNumber());
907 break;
908 case eMessageBox::btNo:
909 default:
910 break;
913 else
915 eMessageBox mb( eString().sprintf(_("Store %d.%d\xC2\xB0%c at location %d.\n"
916 "If you want another location, then say no and change the location manually.\n"
917 "Are you sure you want to store at this location?"),abs(orbital_pos)/10, abs(orbital_pos)%10, orbital_pos>0?'E':'W', StorageLoc->getNumber() ), _("Information"), eMessageBox::iconWarning|eMessageBox::btYes|eMessageBox::btNo, eMessageBox::btNo );
918 hide();
919 mb.show();
920 switch( mb.exec() )
922 case eMessageBox::btYes:
923 lnb->getDiSEqC().useGotoXX=0;
924 lnb->getDiSEqC().RotorTable[orbital_pos] = StorageLoc->getNumber();
925 mb.hide();
926 show();
927 close(StorageLoc->getNumber());
928 break;
929 default:
930 case eMessageBox::btNo:
931 mb.hide();
932 show();
933 return;
934 break;