1 #include <lib/dvb/dvb.h>
2 #include <lib/dvb/sec.h>
3 #include <lib/dvb/rotor_calc.h>
4 #include <lib/dvb/dvbtime.h>
8 #if HAVE_DVB_API_VERSION < 3
9 #define FREQUENCY Frequency
11 #define FREQUENCY frequency
13 #include <lib/base/eerror.h>
18 #define eSecDebug(arg...) eDebug(arg)
20 #define eSecDebug(arg...)
23 DEFINE_REF(eDVBSatelliteEquipmentControl);
25 eDVBSatelliteEquipmentControl *eDVBSatelliteEquipmentControl::instance;
27 int eDVBSatelliteEquipmentControl::m_params[MAX_PARAMS];
29 defaults are set in python lib/python/Components/NimManager.py
30 in InitSecParams function via setParam call
33 void eDVBSatelliteEquipmentControl::setParam(int param, int value)
35 if (param >= 0 && param < MAX_PARAMS)
36 m_params[param]=value;
39 eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends)
40 :m_lnbidx((sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters))-1), m_curSat(m_lnbs[0].m_satellites.end()), m_avail_frontends(avail_frontends), m_avail_simulate_frontends(avail_simulate_frontends), m_rotorMoving(0)
47 #define eSecDebugNoSimulate(x...) \
54 // eDebugNoNewLine("SIMULATE:"); \
58 int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int slot_id, int *highest_score_lnb)
60 bool simulate = ((eDVBFrontend*)fe)->is_simulate();
61 bool direct_connected = m_not_linked_slot_mask & slot_id;
62 int score=0, satcount=0;
63 long linked_prev_ptr=-1, linked_next_ptr=-1, linked_csw=-1, linked_ucsw=-1, linked_toneburst=-1,
64 fe_satpos_depends_ptr=-1, fe_rotor_pos=-1;
65 bool linked_in_use = false;
67 eSecDebugNoSimulate("direct_connected %d", !!direct_connected);
69 fe->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
70 fe->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
71 fe->getData(eDVBFrontend::SATPOS_DEPENDS_PTR, fe_satpos_depends_ptr);
73 // first we search the linkage base frontend and check if any tuner in prev direction is used
74 while (linked_prev_ptr != -1)
76 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
77 if (linked_fe->m_inuse)
79 fe = linked_fe->m_frontend;
80 linked_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
83 fe->getData(eDVBFrontend::ROTOR_POS, fe_rotor_pos);
85 // now check also the linked tuners is in use
86 while (!linked_in_use && linked_next_ptr != -1)
88 eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_next_ptr;
89 if (linked_fe->m_inuse)
91 linked_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, (long&)linked_next_ptr);
94 // when a linked in use tuner is found we get the tuner data...
97 fe->getData(eDVBFrontend::CSW, linked_csw);
98 fe->getData(eDVBFrontend::UCSW, linked_ucsw);
99 fe->getData(eDVBFrontend::TONEBURST, linked_toneburst);
102 if (highest_score_lnb)
103 *highest_score_lnb = -1;
105 eSecDebugNoSimulate("canTune %d", slot_id);
107 for (int idx=0; idx <= m_lnbidx; ++idx )
110 eDVBSatelliteLNBParameters &lnb_param = m_lnbs[idx];
111 bool is_unicable = lnb_param.SatCR_idx != -1;
112 bool is_unicable_position_switch = lnb_param.SatCR_positions > 1;
114 if ( lnb_param.m_slot_mask & slot_id ) // lnb for correct tuner?
117 eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
119 eSecDebugNoSimulate("lnb %d found", idx);
121 satcount += lnb_param.m_satellites.size();
123 std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
124 lnb_param.m_satellites.find(sat.orbital_position);
125 if ( sit != lnb_param.m_satellites.end())
129 satpos_depends_ptr=fe_satpos_depends_ptr,
130 csw = di_param.m_committed_cmd,
131 ucsw = di_param.m_uncommitted_cmd,
132 toneburst = di_param.m_toneburst_param,
133 rotor_pos = fe_rotor_pos;
135 eSecDebugNoSimulate("sat %d found", sat.orbital_position);
137 if ( sat.frequency > lnb_param.m_lof_threshold )
139 if (!(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation_Vertical))
142 if (di_param.m_diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
145 if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
146 csw = 0xF0 | (csw << 2);
148 if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO)
151 if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) // ROTOR
162 if (sat.no_rotor_command_on_tune && !rotor) {
163 eSecDebugNoSimulate("no rotor but no_rotor_command_on_tune is set.. ignore lnb %d", idx);
167 eSecDebugNoSimulate("ret1 %d", ret);
169 if (linked_in_use && !is_unicable)
171 // compare tuner data
172 if ( (csw != linked_csw) ||
173 ( diseqc && (ucsw != linked_ucsw || toneburst != linked_toneburst) ) ||
174 ( rotor && rotor_pos != sat.orbital_position ) )
180 eSecDebugNoSimulate("ret2 %d", ret);
182 else if ((satpos_depends_ptr != -1) && !(is_unicable && is_unicable_position_switch))
184 eSecDebugNoSimulate("satpos depends");
185 eDVBRegisteredFrontend *satpos_depends_to_fe = (eDVBRegisteredFrontend*) satpos_depends_ptr;
186 if (direct_connected) // current fe is direct connected.. (can turn the rotor)
188 if (satpos_depends_to_fe->m_inuse) // if the dependent frontend is in use?
190 if (!rotor || rotor_pos != sat.orbital_position) // new orbital position not equal to current orbital pos?
195 eSecDebugNoSimulate("ret3 %d", ret);
197 else // current fe is dependent of another tuner ... (so this fe can't turn the rotor!)
199 // get current orb pos of the tuner with rotor connection
200 satpos_depends_to_fe->m_frontend->getData(eDVBFrontend::ROTOR_POS, rotor_pos);
201 if (!rotor || rotor_pos == -1 /* we dont know the rotor position yet */
202 || rotor_pos != sat.orbital_position ) // not the same orbital position?
207 eSecDebugNoSimulate("ret4 %d", ret);
210 if (ret && rotor && rotor_pos != -1)
211 ret -= abs(rotor_pos-sat.orbital_position);
213 eSecDebugNoSimulate("ret5 %d", ret);
215 if (ret && lnb_param.SatCR_idx == -1)
217 int lof = sat.frequency > lnb_param.m_lof_threshold ?
218 lnb_param.m_lof_hi : lnb_param.m_lof_lo;
219 int tuner_freq = abs(sat.frequency - lof);
220 if (tuner_freq < 900000 || tuner_freq > 2200000)
224 if (ret && lnb_param.m_prio != -1)
225 ret = lnb_param.m_prio;
227 eSecDebugNoSimulate("ret %d, score old %d", ret, score);
231 if (highest_score_lnb)
232 *highest_score_lnb = idx;
234 eSecDebugNoSimulate("score new %d", score);
238 if (score && satcount)
240 if (score > (satcount-1))
241 score -= (satcount-1);
243 score = 1; // min score
245 if (score && direct_connected)
246 score += 5; // increase score for tuners with direct sat connection
247 eSecDebugNoSimulate("final score %d", score);
251 bool need_turn_fast(int turn_speed)
253 if (turn_speed == eDVBSatelliteRotorParameters::FAST)
255 else if (turn_speed != eDVBSatelliteRotorParameters::SLOW)
257 int begin = turn_speed >> 16; // high word is start time
258 int end = turn_speed&0xFFFF; // low word is end time
259 time_t now_time = ::time(0);
261 localtime_r(&now_time, &nowTime);
262 int now = (nowTime.tm_hour + 1) * 60 + nowTime.tm_min + 1;
263 bool neg = end <= begin;
269 if ((now >= begin && now < end) ^ neg)
275 #define VOLTAGE(x) (lnb_param.m_increased_voltage ? iDVBFrontend::voltage##x##_5 : iDVBFrontend::voltage##x)
277 #define eDebugNoSimulate(x...) \
284 // eDebugNoNewLine("SIMULATE:"); \
288 RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int slot_id, unsigned int tunetimeout)
290 bool simulate = ((eDVBFrontend*)&frontend)->is_simulate();
292 if (canTune(sat, &frontend, slot_id, &lnb_idx))
294 eDVBSatelliteLNBParameters &lnb_param = m_lnbs[lnb_idx];
295 eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
296 eDVBSatelliteRotorParameters &rotor_param = lnb_param.m_rotor_parameters;
298 std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
299 lnb_param.m_satellites.find(sat.orbital_position);
300 if ( sit != lnb_param.m_satellites.end())
302 eSecCommandList sec_sequence;
304 lnb_param.guard_offset = 0; //HACK
306 frontend.setData(eDVBFrontend::SATCR, lnb_param.SatCR_idx);
308 eDVBSatelliteSwitchParameters &sw_param = sit->second;
309 bool doSetFrontend = true;
310 bool doSetVoltageToneFrontend = true;
311 bool forceChanged = false;
312 bool needDiSEqCReset = false;
314 voltage = iDVBFrontend::voltageOff,
315 tone = iDVBFrontend::toneOff,
316 csw = di_param.m_committed_cmd,
317 ucsw = di_param.m_uncommitted_cmd,
318 toneburst = di_param.m_toneburst_param,
324 satposDependPtr = -1;
325 iDVBFrontend *sec_fe=&frontend;
326 eDVBRegisteredFrontend *linked_fe = 0;
327 eDVBSatelliteDiseqcParameters::t_diseqc_mode diseqc_mode = di_param.m_diseqc_mode;
328 eDVBSatelliteSwitchParameters::t_voltage_mode voltage_mode = sw_param.m_voltage_mode;
329 bool diseqc13V = voltage_mode == eDVBSatelliteSwitchParameters::HV_13;
332 voltage_mode = eDVBSatelliteSwitchParameters::HV;
334 frontend.getData(eDVBFrontend::SATPOS_DEPENDS_PTR, satposDependPtr);
336 if (!(m_not_linked_slot_mask & slot_id)) // frontend with direct connection?
338 long linked_prev_ptr;
339 frontend.getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
340 while (linked_prev_ptr != -1)
342 linked_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
343 sec_fe = linked_fe->m_frontend;
344 sec_fe->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
346 if (satposDependPtr != -1) // we dont need uncommitted switch and rotor cmds on second output of a rotor lnb
347 diseqc_mode = eDVBSatelliteDiseqcParameters::V1_0;
349 // in eDVBFrontend::tuneLoop we call closeFrontend and ->inc_use() in this this condition (to put the kernel frontend thread into idle state)
350 // so we must resend all diseqc stuff (voltage is disabled when the frontend is closed)
352 sec_fe->getState(state);
353 if (!linked_fe->m_inuse && state != eDVBFrontend::stateIdle)
358 sec_fe->getData(eDVBFrontend::CSW, lastcsw);
359 sec_fe->getData(eDVBFrontend::UCSW, lastucsw);
360 sec_fe->getData(eDVBFrontend::TONEBURST, lastToneburst);
361 sec_fe->getData(eDVBFrontend::ROTOR_CMD, lastRotorCmd);
362 sec_fe->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
364 if (lastcsw == lastucsw && lastToneburst == lastucsw && lastucsw == -1)
365 needDiSEqCReset = true;
367 if ( sat.frequency > lnb_param.m_lof_threshold )
369 if (!(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation_Vertical))
372 int lof = (band&1)?lnb_param.m_lof_hi:lnb_param.m_lof_lo;
377 if(lnb_param.SatCR_idx == -1)
380 local = abs(sat.frequency
382 parm.FREQUENCY = ((((local * 2) / 125) + 1) / 2) * 125;
383 frontend.setData(eDVBFrontend::FREQ_OFFSET, sat.frequency - parm.FREQUENCY);
385 if ( voltage_mode == eDVBSatelliteSwitchParameters::_14V
386 || ( sat.polarisation & eDVBFrontendParametersSatellite::Polarisation_Vertical
387 && voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
388 voltage = VOLTAGE(13);
389 else if ( voltage_mode == eDVBSatelliteSwitchParameters::_18V
390 || ( !(sat.polarisation & eDVBFrontendParametersSatellite::Polarisation_Vertical)
391 && voltage_mode == eDVBSatelliteSwitchParameters::HV ) )
392 voltage = VOLTAGE(18);
393 if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::ON)
394 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && (band&1) ) )
395 tone = iDVBFrontend::toneOn;
396 else if ( (sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::OFF)
397 || ( sw_param.m_22khz_signal == eDVBSatelliteSwitchParameters::HILO && !(band&1) ) )
398 tone = iDVBFrontend::toneOff;
402 int tmp1 = abs(sat.frequency
406 + lnb_param.guard_offset;
407 int tmp2 = ((((tmp1 * 2) / 4000) + 1) / 2) * 4000;
408 parm.FREQUENCY = lnb_param.SatCRvco - (tmp1-tmp2) + lnb_param.guard_offset;
409 lnb_param.UnicableTuningWord = ((tmp2 / 4000)
410 | ((band & 1) ? 0x400 : 0) //HighLow
411 | ((band & 2) ? 0x800 : 0) //VertHor
412 | ((lnb_param.LNBNum & 1) ? 0 : 0x1000) //Umschaltung LNB1 LNB2
413 | (lnb_param.SatCR_idx << 13)); //Adresse des SatCR
414 eDebug("[prepare] UnicableTuningWord %#04x",lnb_param.UnicableTuningWord);
415 eDebug("[prepare] guard_offset %d",lnb_param.guard_offset);
416 frontend.setData(eDVBFrontend::FREQ_OFFSET, (lnb_param.UnicableTuningWord & 0x3FF) *4000 + 1400000 + lof - (2 * (lnb_param.SatCRvco - (tmp1-tmp2))) );
419 if (diseqc_mode >= eDVBSatelliteDiseqcParameters::V1_0)
421 if ( di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO )
422 csw = 0xF0 | (csw << 2);
424 if (di_param.m_committed_cmd <= eDVBSatelliteDiseqcParameters::SENDNO)
428 (di_param.m_committed_cmd != eDVBSatelliteDiseqcParameters::SENDNO);
429 bool changed_csw = send_csw && (forceChanged || csw != lastcsw);
432 (di_param.m_uncommitted_cmd && diseqc_mode > eDVBSatelliteDiseqcParameters::V1_0);
433 bool changed_ucsw = send_ucsw && (forceChanged || ucsw != lastucsw);
436 (di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO);
437 bool changed_burst = send_burst && (forceChanged || toneburst != lastToneburst);
439 int send_mask = 0; /*
442 4 send toneburst first
443 8 send toneburst at end */
444 if (changed_burst) // toneburst first and toneburst changed
446 if (di_param.m_command_order&1)
460 if ((di_param.m_command_order&4) && send_csw)
462 if (di_param.m_command_order==4 && send_burst)
467 if ( di_param.m_use_fast
468 && di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO
470 && ((csw / 4) == (lastcsw / 4)) )
471 eDebugNoSimulate("dont send committed cmd (fast diseqc)");
475 if (!(di_param.m_command_order&4) && send_ucsw)
477 if (!(di_param.m_command_order&1) && send_burst)
483 eDebugNoNewLine("sendmask: ");
484 for (int i=3; i >= 0; --i)
485 if ( send_mask & (1<<i) )
486 eDebugNoNewLine("1");
488 eDebugNoNewLine("0");
491 if (doSetVoltageToneFrontend)
494 bool useGotoXX = false;
495 if ( diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2
496 && !sat.no_rotor_command_on_tune )
498 if (sw_param.m_rotorPosNum) // we have stored rotor pos?
499 RotorCmd=sw_param.m_rotorPosNum;
500 else // we must calc gotoxx cmd
502 eDebugNoSimulate("Entry for %d,%d? not in Rotor Table found... i try gotoXX?", sat.orbital_position / 10, sat.orbital_position % 10 );
505 double SatLon = abs(sat.orbital_position)/10.00,
506 SiteLat = rotor_param.m_gotoxx_parameters.m_latitude,
507 SiteLon = rotor_param.m_gotoxx_parameters.m_longitude;
509 if ( rotor_param.m_gotoxx_parameters.m_la_direction == eDVBSatelliteRotorParameters::SOUTH )
512 if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST )
513 SiteLon = 360 - SiteLon;
515 eDebugNoSimulate("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
516 double satHourAngle =
517 calcSatHourangle( SatLon, SiteLat, SiteLon );
518 eDebugNoSimulate("PolarmountHourAngle=%lf", satHourAngle );
520 static int gotoXTable[10] =
521 { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
523 if (SiteLat >= 0) // Northern Hemisphere
525 int tmp=(int)round( fabs( 180 - satHourAngle ) * 10.0 );
526 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
528 if (satHourAngle < 180) // the east
533 else // Southern Hemisphere
535 if (satHourAngle < 180) // the east
537 int tmp=(int)round( fabs( satHourAngle ) * 10.0 );
538 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
543 int tmp=(int)round( fabs( 360 - satHourAngle ) * 10.0 );
544 RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ];
548 eDebugNoSimulate("RotorCmd = %04x", RotorCmd);
554 int vlt = iDVBFrontend::voltageOff;
555 eSecCommand::pair compare;
557 compare.tone = iDVBFrontend::toneOff;
558 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
559 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
560 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC]) );
563 vlt = iDVBFrontend::voltage13;
564 else if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
566 if (rotor_param.m_inputpower_parameters.m_use)
567 vlt = VOLTAGE(18); // in input power mode set 18V for measure input power
569 vlt = VOLTAGE(13); // in normal mode start turning with 13V
574 // check if voltage is already correct..
575 compare.voltage = vlt;
577 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
579 // check if voltage is disabled
580 compare.voltage = iDVBFrontend::voltageOff;
582 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
584 // voltage is changed... use DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS
585 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, vlt) );
586 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS]) );
587 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +3) );
589 // voltage was disabled.. use DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS
590 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, vlt) );
591 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS]) );
593 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS) );
596 eDVBDiseqcCommand diseqc;
597 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
599 diseqc.data[0] = 0xE0;
603 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
604 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_DISEQC_RESET_CMD]) );
606 // diseqc peripherial powersupply on
607 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
608 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_DISEQC_PERIPHERIAL_POWERON_CMD]) );
611 for (int seq_repeat = 0; seq_repeat < (di_param.m_seq_repeat?2:1); ++seq_repeat)
615 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
616 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_TONEBURST]) );
626 loops <<= di_param.m_repeats;
628 for ( int i = 0; i < loops;) // fill commands...
630 eDVBDiseqcCommand diseqc;
631 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
633 diseqc.data[0] = i ? 0xE1 : 0xE0;
634 diseqc.data[1] = 0x10;
635 if ( (send_mask & 2) && (di_param.m_command_order & 4) )
637 diseqc.data[2] = 0x39;
638 diseqc.data[3] = ucsw;
640 else if ( send_mask & 1 )
642 diseqc.data[2] = 0x38;
643 diseqc.data[3] = csw;
645 else // no committed command confed.. so send uncommitted..
647 diseqc.data[2] = 0x39;
648 diseqc.data[3] = ucsw;
650 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
656 if (diseqc.data[2] == 0x38 && (send_mask & 2))
658 else if (diseqc.data[2] == 0x39 && (send_mask & 1))
660 int tmp = m_params[DELAY_BETWEEN_DISEQC_REPEATS];
663 int delay = di_param.m_repeats ? (tmp - 54) / 2 : tmp; // standard says 100msek between two repeated commands
664 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, delay) );
666 diseqc.data[3]=(cmd==0x38) ? csw : ucsw;
667 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
670 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, delay ) );
672 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
674 else // delay 120msek when no command is in repeat gap
675 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, tmp) );
678 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
681 if ( send_mask & 8 ) // toneburst at end of sequence
683 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
684 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_TONEBURST]) );
687 if (di_param.m_seq_repeat && seq_repeat == 0)
688 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_BEFORE_SEQUENCE_REPEAT]) );
692 eDebugNoSimulate("RotorCmd %02x, lastRotorCmd %02lx", RotorCmd, lastRotorCmd);
693 if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
695 eSecCommand::pair compare;
696 if (!send_mask && lnb_param.SatCR_idx == -1)
699 compare.tone = iDVBFrontend::toneOff;
700 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
701 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
702 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC]) );
704 compare.voltage = iDVBFrontend::voltageOff;
706 // the next is a check if voltage is switched off.. then we first set a voltage :)
707 // else we set voltage after all diseqc stuff..
708 sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
710 if (rotor_param.m_inputpower_parameters.m_use)
711 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) ); // set 18V for measure input power
713 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) ); // in normal mode start turning with 13V
715 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_MOTOR_CMD]) ); // wait 750ms when voltage was disabled
716 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +9) ); // no need to send stop rotor cmd and recheck voltage
719 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_BETWEEN_SWITCH_AND_MOTOR_CMD]) ); // wait 700ms when diseqc changed
721 eDVBDiseqcCommand diseqc;
722 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
724 diseqc.data[0] = 0xE0;
725 diseqc.data[1] = 0x31; // positioner
726 diseqc.data[2] = 0x60; // stop
727 sec_sequence.push_back( eSecCommand(eSecCommand::IF_ROTORPOS_VALID_GOTO, +5) );
728 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
729 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) );
730 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
731 // wait 150msec after send rotor stop cmd
732 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_MOTOR_STOP_CMD]) );
734 diseqc.data[0] = 0xE0;
735 diseqc.data[1] = 0x31; // positioner
739 diseqc.data[2] = 0x6E; // drive to angular position
740 diseqc.data[3] = ((RotorCmd & 0xFF00) / 0x100);
741 diseqc.data[4] = RotorCmd & 0xFF;
746 diseqc.data[2] = 0x6B; // goto stored sat position
747 diseqc.data[3] = RotorCmd;
748 diseqc.data[4] = 0x00;
750 // if(lnb_param.SatCR_idx == -1)
752 int mrt = m_params[MOTOR_RUNNING_TIMEOUT]; // in seconds!
753 if ( rotor_param.m_inputpower_parameters.m_use || lnb_param.SatCR_idx == -1)
754 { // use measure rotor input power to detect rotor state
755 bool turn_fast = need_turn_fast(rotor_param.m_inputpower_parameters.m_turning_speed);
756 eSecCommand::rotor cmd;
757 eSecCommand::pair compare;
759 compare.voltage = VOLTAGE(18);
761 compare.voltage = VOLTAGE(13);
763 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
764 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
765 // measure idle power values
768 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER]) ); // wait 150msec after voltage change
769 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 1) );
771 sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
772 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) );
774 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MEASURE_IDLE_INPUTPOWER]) ); // wait 150msec before measure
775 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER, 0) );
777 sec_sequence.push_back( eSecCommand(eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO, compare) );
778 ////////////////////////////
779 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_DISEQC_RETRYS, m_params[MOTOR_COMMAND_RETRIES]) ); // 2 retries
780 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_ROTORPARMS) );
781 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
782 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, 40) ); // 2 seconds rotor start timout
784 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) ); // 50msec delay
785 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
786 cmd.direction=1; // check for running rotor
787 cmd.deltaA=rotor_param.m_inputpower_parameters.m_delta;
790 sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) ); // check if rotor has started
791 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +2 ) ); // timeout .. we assume now the rotor is already at the correct position
792 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) ); // goto loop start
793 sec_sequence.push_back( eSecCommand(eSecCommand::IF_NO_MORE_ROTOR_DISEQC_RETRYS_GOTO, turn_fast ? 10 : 9 ) ); // timeout .. we assume now the rotor is already at the correct position
794 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -8) ); // goto loop start
796 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_MOVING) );
798 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) );
799 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, mrt*20) ); // mrt is in seconds... our SLEEP time is 50ms.. so * 20
800 // rotor running loop
801 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 50) ); // wait 50msec
802 sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_RUNNING_INPUTPOWER) );
803 cmd.direction=0; // check for stopped rotor
805 sec_sequence.push_back( eSecCommand(eSecCommand::IF_INPUTPOWER_DELTA_GOTO, cmd ) );
806 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +2 ) ); // timeout ? this should never happen
807 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -4) ); // running loop start
808 /////////////////////
809 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
810 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_STOPPED) );
813 { // use normal turning mode
814 if (curRotorPos != -1)
816 mrt = abs(curRotorPos - sat.orbital_position);
820 mrt += 10; // round a little bit
821 mrt *= 2000; // (we assume a very slow rotor with just 0.5 degree per second here)
823 mrt += 3; // a little bit overhead
825 doSetVoltageToneFrontend=false;
827 eSecCommand::rotor cmd;
828 eSecCommand::pair compare;
829 compare.voltage = VOLTAGE(13);
831 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
832 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
833 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD]) ); // wait 150msec after voltage change
835 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_ROTORPARMS) );
836 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_MOVING) );
837 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
838 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 1000) ); // sleep one second before change voltage or tone
840 compare.voltage = voltage;
842 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) ); // correct final voltage?
843 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 2000) ); // wait 2 second before set high voltage
844 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
847 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
848 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
849 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) );
850 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 0) );
852 cmd.direction=1; // check for running rotor
856 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TIMEOUT, mrt*4) ); // mrt is in seconds... our SLEEP time is 250ms.. so * 4
857 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 250) ); // 250msec delay
858 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TUNER_LOCKED_GOTO, cmd ) );
859 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TIMEOUT_GOTO, +5 ) );
860 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -3) ); // goto loop start
861 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_ROTORPARAMS) );
862 sec_sequence.push_back( eSecCommand(eSecCommand::SET_ROTOR_STOPPED) );
863 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +4) );
864 sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, tunetimeout) );
865 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
866 sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, -5) );
868 eDebug("set rotor timeout to %d seconds", mrt);
869 sec_fe->setData(eDVBFrontend::NEW_ROTOR_CMD, RotorCmd);
870 sec_fe->setData(eDVBFrontend::NEW_ROTOR_POS, sat.orbital_position);
877 sec_sequence.push_back( eSecCommand(eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS) );
881 sec_fe->setData(eDVBFrontend::NEW_CSW, csw);
882 sec_fe->setData(eDVBFrontend::NEW_UCSW, ucsw);
883 sec_fe->setData(eDVBFrontend::NEW_TONEBURST, di_param.m_toneburst_param);
885 if ((doSetVoltageToneFrontend) && (lnb_param.SatCR_idx == -1))
887 eSecCommand::pair compare;
888 compare.voltage = voltage;
890 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) ); // voltage already correct ?
891 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, voltage) );
892 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_VOLTAGE_CHANGE]) );
894 sec_sequence.push_back( eSecCommand(eSecCommand::IF_TONE_GOTO, compare) );
895 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, tone) );
896 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_FINAL_CONT_TONE_CHANGE]) );
899 sec_sequence.push_back( eSecCommand(eSecCommand::UPDATE_CURRENT_SWITCHPARMS) );
901 if(lnb_param.SatCR_idx != -1)
903 // check if voltage is disabled
904 eSecCommand::pair compare;
906 compare.voltage = iDVBFrontend::voltageOff;
907 sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
908 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
909 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS] ) );
911 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18_5) );
912 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
913 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS]) ); // wait 20 ms after voltage change
915 eDVBDiseqcCommand diseqc;
916 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
918 diseqc.data[0] = 0xE0;
919 diseqc.data[1] = 0x10;
920 diseqc.data[2] = 0x5A;
921 diseqc.data[3] = lnb_param.UnicableTuningWord >> 8;
922 diseqc.data[4] = lnb_param.UnicableTuningWord;
924 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
925 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
926 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
931 sec_sequence.push_back( eSecCommand(eSecCommand::START_TUNE_TIMEOUT, tunetimeout) );
932 sec_sequence.push_back( eSecCommand(eSecCommand::SET_FRONTEND, 1) );
935 sec_sequence.push_front( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeStatic) );
936 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 500) );
937 sec_sequence.push_back( eSecCommand(eSecCommand::SET_POWER_LIMITING_MODE, eSecCommand::modeDynamic) );
939 frontend.setSecSequence(sec_sequence);
944 eDebugNoSimulate("found no useable satellite configuration for %s freq %d%s %s on orbital position (%d)",
945 sat.system ? "DVB-S2" : "DVB-S",
947 sat.polarisation == eDVBFrontendParametersSatellite::Polarisation_Horizontal ? "H" :
948 eDVBFrontendParametersSatellite::Polarisation_Vertical ? "V" :
949 eDVBFrontendParametersSatellite::Polarisation_CircularLeft ? "CL" : "CR",
950 sat.modulation == eDVBFrontendParametersSatellite::Modulation_Auto ? "AUTO" :
951 eDVBFrontendParametersSatellite::Modulation_QPSK ? "QPSK" :
952 eDVBFrontendParametersSatellite::Modulation_8PSK ? "8PSK" : "QAM16",
953 sat.orbital_position );
957 void eDVBSatelliteEquipmentControl::prepareTurnOffSatCR(iDVBFrontend &frontend, int satcr)
959 eSecCommandList sec_sequence;
961 // check if voltage is disabled
962 eSecCommand::pair compare;
963 compare.steps = +9; //only close frontend
964 compare.voltage = iDVBFrontend::voltageOff;
966 sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
967 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
968 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_ENABLE_VOLTAGE_BEFORE_SWITCH_CMDS]) );
970 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage18_5) );
971 sec_sequence.push_back( eSecCommand(eSecCommand::SET_TONE, iDVBFrontend::toneOff) );
972 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_SWITCH_CMDS]) );
974 eDVBDiseqcCommand diseqc;
975 memset(diseqc.data, 0, MAX_DISEQC_LENGTH);
977 diseqc.data[0] = 0xE0;
978 diseqc.data[1] = 0x10;
979 diseqc.data[2] = 0x5A;
980 diseqc.data[3] = satcr << 5;
981 diseqc.data[4] = 0x00;
983 sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) );
984 sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) );
985 sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, iDVBFrontend::voltage13) );
986 sec_sequence.push_back( eSecCommand(eSecCommand::DELAYED_CLOSE_FRONTEND) );
988 frontend.setSecSequence(sec_sequence);
991 RESULT eDVBSatelliteEquipmentControl::clear()
993 eSecDebug("eDVBSatelliteEquipmentControl::clear()");
994 for (int i=0; i <= m_lnbidx; ++i)
996 m_lnbs[i].m_satellites.clear();
997 m_lnbs[i].m_slot_mask = 0;
998 m_lnbs[i].m_prio = -1; // auto
1002 m_not_linked_slot_mask=0;
1004 //reset some tuner configuration
1005 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
1007 it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
1008 it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
1009 it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
1010 it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
1011 it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
1012 it->m_frontend->setData(eDVBFrontend::SATCR, -1);
1015 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
1017 it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
1018 it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
1019 it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
1020 it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
1021 it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
1022 it->m_frontend->setData(eDVBFrontend::SATCR, -1);
1028 /* LNB Specific Parameters */
1029 RESULT eDVBSatelliteEquipmentControl::addLNB()
1031 if ( (m_lnbidx+1) < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)))
1032 m_curSat=m_lnbs[++m_lnbidx].m_satellites.end();
1035 eDebug("no more LNB free... cnt is %d", m_lnbidx);
1038 eSecDebug("eDVBSatelliteEquipmentControl::addLNB(%d)", m_lnbidx);
1042 RESULT eDVBSatelliteEquipmentControl::setLNBSlotMask(int slotmask)
1044 eSecDebug("eDVBSatelliteEquipmentControl::setLNBSlotMask(%d)", slotmask);
1045 if ( currentLNBValid() )
1046 m_lnbs[m_lnbidx].m_slot_mask = slotmask;
1052 RESULT eDVBSatelliteEquipmentControl::setLNBLOFL(int lofl)
1054 eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFL(%d)", lofl);
1055 if ( currentLNBValid() )
1056 m_lnbs[m_lnbidx].m_lof_lo = lofl;
1062 RESULT eDVBSatelliteEquipmentControl::setLNBLOFH(int lofh)
1064 eSecDebug("eDVBSatelliteEquipmentControl::setLNBLOFH(%d)", lofh);
1065 if ( currentLNBValid() )
1066 m_lnbs[m_lnbidx].m_lof_hi = lofh;
1072 RESULT eDVBSatelliteEquipmentControl::setLNBThreshold(int threshold)
1074 eSecDebug("eDVBSatelliteEquipmentControl::setLNBThreshold(%d)", threshold);
1075 if ( currentLNBValid() )
1076 m_lnbs[m_lnbidx].m_lof_threshold = threshold;
1082 RESULT eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(bool onoff)
1084 eSecDebug("eDVBSatelliteEquipmentControl::setLNBIncreasedVoltage(%d)", onoff);
1085 if ( currentLNBValid() )
1086 m_lnbs[m_lnbidx].m_increased_voltage = onoff;
1092 RESULT eDVBSatelliteEquipmentControl::setLNBPrio(int prio)
1094 eSecDebug("eDVBSatelliteEquipmentControl::setLNBPrio(%d)", prio);
1095 if ( currentLNBValid() )
1096 m_lnbs[m_lnbidx].m_prio = prio;
1102 RESULT eDVBSatelliteEquipmentControl::setLNBNum(int LNBNum)
1104 eSecDebug("eDVBSatelliteEquipmentControl::setLNBNum(%d)", LNBNum);
1105 if(!((LNBNum >= 1) && (LNBNum <= MAX_LNBNUM)))
1107 if ( currentLNBValid() )
1108 m_lnbs[m_lnbidx].LNBNum = LNBNum;
1114 /* DiSEqC Specific Parameters */
1115 RESULT eDVBSatelliteEquipmentControl::setDiSEqCMode(int diseqcmode)
1117 eSecDebug("eDVBSatelliteEquipmentControl::setDiSEqcMode(%d)", diseqcmode);
1118 if ( currentLNBValid() )
1119 m_lnbs[m_lnbidx].m_diseqc_parameters.m_diseqc_mode = (eDVBSatelliteDiseqcParameters::t_diseqc_mode)diseqcmode;
1125 RESULT eDVBSatelliteEquipmentControl::setToneburst(int toneburst)
1127 eSecDebug("eDVBSatelliteEquipmentControl::setToneburst(%d)", toneburst);
1128 if ( currentLNBValid() )
1129 m_lnbs[m_lnbidx].m_diseqc_parameters.m_toneburst_param = (eDVBSatelliteDiseqcParameters::t_toneburst_param)toneburst;
1135 RESULT eDVBSatelliteEquipmentControl::setRepeats(int repeats)
1137 eSecDebug("eDVBSatelliteEquipmentControl::setRepeats(%d)", repeats);
1138 if ( currentLNBValid() )
1139 m_lnbs[m_lnbidx].m_diseqc_parameters.m_repeats=repeats;
1145 RESULT eDVBSatelliteEquipmentControl::setCommittedCommand(int command)
1147 eSecDebug("eDVBSatelliteEquipmentControl::setCommittedCommand(%d)", command);
1148 if ( currentLNBValid() )
1149 m_lnbs[m_lnbidx].m_diseqc_parameters.m_committed_cmd=command;
1155 RESULT eDVBSatelliteEquipmentControl::setUncommittedCommand(int command)
1157 eSecDebug("eDVBSatelliteEquipmentControl::setUncommittedCommand(%d)", command);
1158 if ( currentLNBValid() )
1159 m_lnbs[m_lnbidx].m_diseqc_parameters.m_uncommitted_cmd = command;
1165 RESULT eDVBSatelliteEquipmentControl::setCommandOrder(int order)
1167 eSecDebug("eDVBSatelliteEquipmentControl::setCommandOrder(%d)", order);
1168 if ( currentLNBValid() )
1169 m_lnbs[m_lnbidx].m_diseqc_parameters.m_command_order=order;
1175 RESULT eDVBSatelliteEquipmentControl::setFastDiSEqC(bool onoff)
1177 eSecDebug("eDVBSatelliteEquipmentControl::setFastDiSEqc(%d)", onoff);
1178 if ( currentLNBValid() )
1179 m_lnbs[m_lnbidx].m_diseqc_parameters.m_use_fast=onoff;
1185 RESULT eDVBSatelliteEquipmentControl::setSeqRepeat(bool onoff)
1187 eSecDebug("eDVBSatelliteEquipmentControl::setSeqRepeat(%d)", onoff);
1188 if ( currentLNBValid() )
1189 m_lnbs[m_lnbidx].m_diseqc_parameters.m_seq_repeat = onoff;
1195 /* Rotor Specific Parameters */
1196 RESULT eDVBSatelliteEquipmentControl::setLongitude(float longitude)
1198 eSecDebug("eDVBSatelliteEquipmentControl::setLongitude(%f)", longitude);
1199 if ( currentLNBValid() )
1200 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_longitude=longitude;
1206 RESULT eDVBSatelliteEquipmentControl::setLatitude(float latitude)
1208 eSecDebug("eDVBSatelliteEquipmentControl::setLatitude(%f)", latitude);
1209 if ( currentLNBValid() )
1210 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_latitude=latitude;
1216 RESULT eDVBSatelliteEquipmentControl::setLoDirection(int direction)
1218 eSecDebug("eDVBSatelliteEquipmentControl::setLoDirection(%d)", direction);
1219 if ( currentLNBValid() )
1220 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_lo_direction=direction;
1226 RESULT eDVBSatelliteEquipmentControl::setLaDirection(int direction)
1228 eSecDebug("eDVBSatelliteEquipmentControl::setLaDirection(%d)", direction);
1229 if ( currentLNBValid() )
1230 m_lnbs[m_lnbidx].m_rotor_parameters.m_gotoxx_parameters.m_la_direction=direction;
1236 RESULT eDVBSatelliteEquipmentControl::setUseInputpower(bool onoff)
1238 eSecDebug("eDVBSatelliteEquipmentControl::setUseInputpower(%d)", onoff);
1239 if ( currentLNBValid() )
1240 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_use=onoff;
1246 RESULT eDVBSatelliteEquipmentControl::setInputpowerDelta(int delta)
1248 eSecDebug("eDVBSatelliteEquipmentControl::setInputpowerDelta(%d)", delta);
1249 if ( currentLNBValid() )
1250 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_delta=delta;
1256 /* Unicable Specific Parameters */
1257 RESULT eDVBSatelliteEquipmentControl::setLNBSatCR(int SatCR_idx)
1259 eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCR(%d)", SatCR_idx);
1260 if(!((SatCR_idx >=-1) && (SatCR_idx < MAX_SATCR)))
1262 if ( currentLNBValid() )
1263 m_lnbs[m_lnbidx].SatCR_idx = SatCR_idx;
1269 RESULT eDVBSatelliteEquipmentControl::setLNBSatCRvco(int SatCRvco)
1271 eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCRvco(%d)", SatCRvco);
1272 if(!((SatCRvco >= 950*1000) && (SatCRvco <= 2150*1000)))
1274 if(!((m_lnbs[m_lnbidx].SatCR_idx >= 0) && (m_lnbs[m_lnbidx].SatCR_idx < MAX_SATCR)))
1276 if ( currentLNBValid() )
1277 m_lnbs[m_lnbidx].SatCRvco = SatCRvco;
1283 RESULT eDVBSatelliteEquipmentControl::setLNBSatCRpositions(int SatCR_positions)
1285 eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCRpositions(%d)", SatCR_positions);
1286 if(SatCR_positions < 1 || SatCR_positions > 2)
1288 if ( currentLNBValid() )
1289 m_lnbs[m_lnbidx].SatCR_positions = SatCR_positions;
1295 RESULT eDVBSatelliteEquipmentControl::getLNBSatCRpositions()
1297 if ( currentLNBValid() )
1298 return m_lnbs[m_lnbidx].SatCR_positions;
1302 RESULT eDVBSatelliteEquipmentControl::getLNBSatCR()
1304 if ( currentLNBValid() )
1305 return m_lnbs[m_lnbidx].SatCR_idx;
1309 RESULT eDVBSatelliteEquipmentControl::getLNBSatCRvco()
1311 if ( currentLNBValid() )
1312 return m_lnbs[m_lnbidx].SatCRvco;
1316 /* Satellite Specific Parameters */
1317 RESULT eDVBSatelliteEquipmentControl::addSatellite(int orbital_position)
1319 eSecDebug("eDVBSatelliteEquipmentControl::addSatellite(%d)", orbital_position);
1320 if ( currentLNBValid() )
1322 std::map<int, eDVBSatelliteSwitchParameters>::iterator it =
1323 m_lnbs[m_lnbidx].m_satellites.find(orbital_position);
1324 if ( it == m_lnbs[m_lnbidx].m_satellites.end() )
1326 std::pair<std::map<int, eDVBSatelliteSwitchParameters>::iterator, bool > ret =
1327 m_lnbs[m_lnbidx].m_satellites.insert(
1328 std::pair<int, eDVBSatelliteSwitchParameters>(orbital_position, eDVBSatelliteSwitchParameters())
1331 m_curSat = ret.first;
1343 RESULT eDVBSatelliteEquipmentControl::setVoltageMode(int mode)
1345 eSecDebug("eDVBSatelliteEquipmentControl::setVoltageMode(%d)", mode);
1346 if ( currentLNBValid() && m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1347 m_curSat->second.m_voltage_mode = (eDVBSatelliteSwitchParameters::t_voltage_mode)mode;
1354 RESULT eDVBSatelliteEquipmentControl::setToneMode(int mode)
1356 eSecDebug("eDVBSatelliteEquipmentControl::setToneMode(%d)", mode);
1357 if ( currentLNBValid() )
1359 if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1360 m_curSat->second.m_22khz_signal = (eDVBSatelliteSwitchParameters::t_22khz_signal)mode;
1369 RESULT eDVBSatelliteEquipmentControl::setRotorPosNum(int rotor_pos_num)
1371 eSecDebug("eDVBSatelliteEquipmentControl::setRotorPosNum(%d)", rotor_pos_num);
1372 if ( currentLNBValid() )
1374 if ( m_curSat != m_lnbs[m_lnbidx].m_satellites.end() )
1375 m_curSat->second.m_rotorPosNum=rotor_pos_num;
1384 RESULT eDVBSatelliteEquipmentControl::setRotorTurningSpeed(int speed)
1386 eSecDebug("eDVBSatelliteEquipmentControl::setRotorTurningSpeed(%d)", speed);
1387 if ( currentLNBValid() )
1388 m_lnbs[m_lnbidx].m_rotor_parameters.m_inputpower_parameters.m_turning_speed = speed;
1396 int orb_pos, lofl, lofh;
1397 sat_compare(int o, int lofl, int lofh)
1398 :orb_pos(o), lofl(lofl), lofh(lofh)
1400 sat_compare(const sat_compare &x)
1401 :orb_pos(x.orb_pos), lofl(x.lofl), lofh(x.lofh)
1403 bool operator < (const sat_compare & cmp) const
1405 if (orb_pos == cmp.orb_pos)
1407 if ( abs(lofl-cmp.lofl) < 200000 )
1409 if (abs(lofh-cmp.lofh) < 200000)
1411 return lofh<cmp.lofh;
1413 return lofl<cmp.lofl;
1415 return orb_pos < cmp.orb_pos;
1419 RESULT eDVBSatelliteEquipmentControl::setTunerLinked(int tu1, int tu2)
1421 eSecDebug("eDVBSatelliteEquipmentControl::setTunerLinked(%d, %d)", tu1, tu2);
1424 eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
1425 eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin());
1426 for (; it != m_avail_frontends.end(); ++it)
1428 if (it->m_frontend->getSlotID() == tu1)
1430 else if (it->m_frontend->getSlotID() == tu2)
1436 p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
1437 p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
1441 it=m_avail_simulate_frontends.begin();
1442 for (; it != m_avail_simulate_frontends.end(); ++it)
1444 if (it->m_frontend->getSlotID() == tu1)
1446 else if (it->m_frontend->getSlotID() == tu2)
1451 p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
1452 p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
1459 RESULT eDVBSatelliteEquipmentControl::setTunerDepends(int tu1, int tu2)
1461 eSecDebug("eDVBSatelliteEquipmentControl::setTunerDepends(%d, %d)", tu1, tu2);
1465 eDVBRegisteredFrontend *p1=NULL, *p2=NULL;
1467 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_frontends.begin()); it != m_avail_frontends.end(); ++it)
1469 if (it->m_frontend->getSlotID() == tu1)
1471 else if (it->m_frontend->getSlotID() == tu2)
1476 p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
1477 p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
1481 for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
1483 if (it->m_frontend->getSlotID() == tu1)
1485 else if (it->m_frontend->getSlotID() == tu2)
1490 p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
1491 p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
1498 void eDVBSatelliteEquipmentControl::setSlotNotLinked(int slot_no)
1500 eSecDebug("eDVBSatelliteEquipmentControl::setSlotNotLinked(%d)", slot_no);
1501 m_not_linked_slot_mask |= (1 << slot_no);
1504 bool eDVBSatelliteEquipmentControl::isRotorMoving()
1506 return m_rotorMoving;
1509 void eDVBSatelliteEquipmentControl::setRotorMoving(int slot_no, bool b)
1512 m_rotorMoving |= (1 << slot_no);
1514 m_rotorMoving &= ~(1 << slot_no);