diff --git a/data/unicable.xml b/data/unicable.xml index e41d845a49..bda7aa6344 100644 --- a/data/unicable.xml +++ b/data/unicable.xml @@ -1,180 +1,319 @@ - - - + - - + + + + + + + + + + + + + - - + + + + + + + + - + - - + + + + + - + - + - - + - + + + + + + + + + + + + + - + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - - + + + + + + + + + - - - - + + + + + + diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 67f4f8abe0..85193edce8 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -713,7 +713,7 @@ int eDVBFrontend::closeFrontend(bool force, bool no_delayed) { if (!no_delayed) { - m_sec->prepareTurnOffSatCR(*this, m_data[SATCR]); + m_sec->prepareTurnOffSatCR(*this); m_tuneTimer->start(0, true); if(!m_tuneTimer->isActive()) { diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index c23c81eb7a..df779faa8c 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -69,6 +69,7 @@ class eDVBFrontend: public iDVBFrontend, public Object CUR_VOLTAGE, // current voltage CUR_TONE, // current continuous tone SATCR, // current SatCR + DICTION, // current "diction" (0 = normal, 1 = Unicable, 2 = JESS) NUM_DATA_ENTRIES }; Signal1 m_stateChanged; diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index 3f20374ad9..e03a9f97c7 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -544,7 +544,7 @@ class iDVBSatelliteEquipmentControl: public iObject { public: virtual RESULT prepare(iDVBFrontend &frontend, const eDVBFrontendParametersSatellite &sat, int &frequency, int frontend_id, unsigned int timeout)=0; - virtual void prepareTurnOffSatCR(iDVBFrontend &frontend, int satcr)=0; + virtual void prepareTurnOffSatCR(iDVBFrontend &frontend)=0; virtual int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *fe, int frontend_id, int *highest_score_lnb=0)=0; virtual void setRotorMoving(int slotid, bool)=0; }; diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index fbd3ad7639..90bf67b68d 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -103,7 +103,7 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite { bool rotor=false; eDVBSatelliteLNBParameters &lnb_param = m_lnbs[idx]; - bool is_unicable = lnb_param.SatCR_idx != -1; + bool is_unicable = lnb_param.SatCR_format != SatCR_format_none; bool is_unicable_position_switch = lnb_param.SatCR_positions > 1; if ( lnb_param.m_slot_mask & slot_id ) // lnb for correct tuner? @@ -324,7 +324,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB eDVBSatelliteDiseqcParameters::t_diseqc_mode diseqc_mode = di_param.m_diseqc_mode; eDVBSatelliteSwitchParameters::t_voltage_mode voltage_mode = sw_param.m_voltage_mode; bool diseqc13V = voltage_mode == eDVBSatelliteSwitchParameters::HV_13; - bool is_unicable = lnb_param.SatCR_idx != -1; + bool is_unicable = lnb_param.SatCR_format != SatCR_format_none; bool useGotoXX = false; int RotorCmd=-1; @@ -722,12 +722,113 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB eDVBDiseqcCommand diseqc; memset(diseqc.data, 0, MAX_DISEQC_LENGTH); - diseqc.len = 5; - diseqc.data[0] = 0xE0; - diseqc.data[1] = 0x10; - diseqc.data[2] = 0x5A; - diseqc.data[3] = lnb_param.UnicableTuningWord >> 8; - diseqc.data[4] = lnb_param.UnicableTuningWord; + + switch(lnb_param.SatCR_format) + { + case(SatCR_format_unicable): + { + // Unicable ODU_channel_change command + // + // data[0] framing: 0xe0 + // data[1] addressing: 0x10 + // data[2] command: ODU_channel_change 0x5a + // data[3] "data1": data[3][7..5]: user band, data[3][4..2]: bank, data[3][1..0]: T[9..8] + // data[4] "data2": data[4][7..0]: T[7..0] + + unsigned int ub = lnb_param.SatCR_idx & 0x07; + unsigned int ub_mhz = lnb_param.SatCRvco / 1000; + unsigned int frequency_mhz = sat.frequency / 1000; + unsigned int lof_mhz = lof / 1000; + unsigned int mode = band & 0x03; + unsigned int position = (lnb_param.SatCR_position - 1) & 0x01; + unsigned int bank = (position << 2) | (mode << 0); + unsigned int t1, t2, t3, t4, t5, t6; + unsigned int encoded_frequency_T; + + /* calculate "T" value */ + + t1 = (absdiff(frequency_mhz, lof_mhz) + ub_mhz) * 10; /* multiply "T" base by ten for proper rounding to nearest integer */ + t2 = t1 / 4; // divide by 4 MHz (per Unicable specification) + t3 = t2 / 10; // divide by 10 to correct earlier multiplication by 10, now integer*10 truncated + t4 = t3 * 10; // multiply again by 10 to get actual integer result + t5 = t2 - t4; // calculate difference between result and result integer*10 truncated, the fraction + t6 = t3 + (t5 >= 5 ? 1 : 0); // round the result + encoded_frequency_T = t6 - 350; + + diseqc.len = 5; + diseqc.data[0] = 0xe0; + diseqc.data[1] = 0x10; + diseqc.data[2] = 0x5a; + diseqc.data[3] = (unsigned char)((ub << 5) | (bank << 2) | ((encoded_frequency_T & 0x300) >> 8)); + diseqc.data[4] = (unsigned char)(encoded_frequency_T & 0xff); + //diseqc.data[3] = (lnb_param.UnicableTuningWord >> 8) & 0xff; + //diseqc.data[4] = (lnb_param.UnicableTuningWord >> 0) & 0xff; + + frontend.setData(eDVBFrontend::SATCR, lnb_param.SatCR_idx); + frontend.setData(eDVBFrontend::DICTION, SatCR_format_unicable); + + eDebug("**** Tuning Unicable"); + eDebug("**** frequency_mhz: %u", frequency_mhz); + eDebug("**** lo_mhz: %u", lof_mhz); + eDebug("**** ub_mhz: %u", ub_mhz); + eDebug("**** T: %u", encoded_frequency_T); + eDebug("**** ub: %u", ub); + eDebug("**** position: %u", position); + eDebug("**** mode: %u", mode); + eDebug("**** bank: %u", bank); + eDebug("**** Unicable: %02x %02x %02x %02x %02x", diseqc.data[0], diseqc.data[1], + diseqc.data[2], diseqc.data[3], diseqc.data[4]); + eDebug("**** Calculated tuningword: %04x", (diseqc.data[3] << 8) | (diseqc.data[4] << 0)); + eDebug("**** Stored tuningword: %04x", lnb_param.UnicableTuningWord); + + break; + } + + case(SatCR_format_jess): + { + // JESS ODU_channel_change command + // + // data[0] framing: 0x70 + // data[1] data[1][7..3]: ub, data[1][2..0:] T [10..8] + // data[2] data[2][7..0]: T [7..0] + // data[3] data[3][7..2]: position, data[3][1]: polarity, data[3][0]: band + + unsigned int ub = lnb_param.SatCR_idx & 0x1f; + unsigned int frequency_mhz = sat.frequency / 1000; + unsigned int lof_mhz = lof / 1000; + unsigned int encoded_frequency_T = frequency_mhz - lof_mhz - 100; + unsigned int mode = band & 0x03; + unsigned int position = (lnb_param.SatCR_position - 1) & 0x3f; + + diseqc.len = 4; + diseqc.data[0] = 0x70; + diseqc.data[1] = (unsigned char)((ub << 3) | ((encoded_frequency_T & 0x700) >> 8)); + diseqc.data[2] = (unsigned char)(encoded_frequency_T & 0xff); + diseqc.data[3] = (unsigned char)((position << 2) | mode); + + frontend.setData(eDVBFrontend::SATCR, lnb_param.SatCR_idx); + frontend.setData(eDVBFrontend::DICTION, SatCR_format_jess); + + eDebug("**** Tuning JESS"); + eDebug("**** frequency_mhz: %u", frequency_mhz); + eDebug("**** lo_mhz: %u", lof_mhz); + eDebug("**** T: %u", encoded_frequency_T); + eDebug("**** position: %u", position); + eDebug("**** ub: %u", ub); + eDebug("**** mode: %u", mode); + eDebug("**** JESS: %02x %02x %02x %02x", diseqc.data[0], diseqc.data[1], diseqc.data[2], diseqc.data[3]); + + break; + } + + default: + { + frontend.setData(eDVBFrontend::SATCR, 0); + frontend.setData(eDVBFrontend::DICTION, SatCR_format_none); + + eDebug("**** SatCR_format neither Unicable nor JESS!"); + } + } sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) ); sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) ); @@ -735,6 +836,11 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB if ( RotorCmd != -1 && RotorCmd != lastRotorCmd && !rotor_param.m_inputpower_parameters.m_use) sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_VOLTAGE_CHANGE_BEFORE_MOTOR_CMD]) ); // wait 150msec after voltage change } + else + { + frontend.setData(eDVBFrontend::SATCR, 0); + frontend.setData(eDVBFrontend::DICTION, SatCR_format_none); + } eDebugNoSimulate("[eDVBSatelliteEquipmentControl] RotorCmd %02x, lastRotorCmd %02lx", RotorCmd, lastRotorCmd); if ( RotorCmd != -1 && RotorCmd != lastRotorCmd ) @@ -964,9 +1070,13 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, const eDVB return -1; } -void eDVBSatelliteEquipmentControl::prepareTurnOffSatCR(iDVBFrontend &frontend, int satcr) +void eDVBSatelliteEquipmentControl::prepareTurnOffSatCR(iDVBFrontend &frontend) { eSecCommandList sec_sequence; + long userband, diction; + + frontend.getData(eDVBFrontend::SATCR, userband); + frontend.getData(eDVBFrontend::DICTION, diction); // check if voltage is disabled eSecCommand::pair compare; @@ -983,12 +1093,67 @@ void eDVBSatelliteEquipmentControl::prepareTurnOffSatCR(iDVBFrontend &frontend, eDVBDiseqcCommand diseqc; memset(diseqc.data, 0, MAX_DISEQC_LENGTH); - diseqc.len = 5; - diseqc.data[0] = 0xE0; - diseqc.data[1] = 0x10; - diseqc.data[2] = 0x5A; - diseqc.data[3] = satcr << 5; - diseqc.data[4] = 0x00; + + switch((SatCR_format_t)diction) + { + case(SatCR_format_unicable): + { + // Unicable ODU_channel_change command, T = 0 means shutdown UB + // + // data[0] framing: 0xe0 + // data[1] addressing: 0x10 + // data[2] command: ODU_channel_change 0x5a + // data[3] "data1": data[3][7..5]: user band, data[3][4..2]: bank, data[3][1..0]: T[9..8] + // data[4] "data2": data[4][7..0]: T[7..0] + + unsigned int ub = userband & 0x01; + unsigned int encoded_frequency_T = 0; + unsigned int mode = 0; + unsigned int position = 0; + unsigned int bank = (position << 2) | (mode << 0); + + diseqc.len = 5; + diseqc.data[0] = 0xe0; + diseqc.data[1] = 0x10; + diseqc.data[2] = 0x5a; + diseqc.data[3] = (unsigned char)((ub << 5) | (bank << 2) | ((encoded_frequency_T & 0x300) >> 8)); + diseqc.data[4] = (unsigned char)(encoded_frequency_T & 0xff); + + eDebug("**** shutdown unicable ub %u", ub); + + break; + } + + case(SatCR_format_jess): + { + // JESS ODU_channel_change command, T = 0 means shutdown UB + // + // data[0] framing: 0x70 + // data[1] data[1][7..3]: ub, data[1][2..0:] T [10..8] + // data[2] data[2][7..0]: T [7..0] + // data[3] data[3][7..2]: position, data[3][1]: polarity, data[3][0]: band + + unsigned int ub = userband & 0x1f; + unsigned int encoded_frequency_T = 0; + unsigned int mode = 0; + unsigned int position = 0; + + diseqc.len = 4; + diseqc.data[0] = 0x70; + diseqc.data[1] = (unsigned char)((ub << 3) | ((encoded_frequency_T & 0x700) >> 8)); + diseqc.data[2] = (unsigned char)(encoded_frequency_T & 0xff); + diseqc.data[3] = (unsigned char)((position << 2) | mode); + + eDebug("**** shutdown JESS ub %d", ub); + + break; + } + + default: + { + eDebug("**** shutdown unknown unicable type ub %d!", (int)userband); + } + } sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) ); sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_LAST_DISEQC_CMD]) ); @@ -1270,6 +1435,14 @@ RESULT eDVBSatelliteEquipmentControl::setInputpowerDelta(int delta) } /* Unicable Specific Parameters */ + +RESULT eDVBSatelliteEquipmentControl::getLNBSatCR() +{ + if ( currentLNBValid() ) + return m_lnbs[m_lnbidx].SatCR_idx; + return -ENOENT; +} + RESULT eDVBSatelliteEquipmentControl::setLNBSatCR(int SatCR_idx) { eSecDebug("[eDVBSatelliteEquipmentControl::setLNBSatCR] idx=%d", SatCR_idx); @@ -1282,6 +1455,13 @@ RESULT eDVBSatelliteEquipmentControl::setLNBSatCR(int SatCR_idx) return 0; } +RESULT eDVBSatelliteEquipmentControl::getLNBSatCRvco() +{ + if ( currentLNBValid() ) + return m_lnbs[m_lnbidx].SatCRvco; + return -ENOENT; +} + RESULT eDVBSatelliteEquipmentControl::setLNBSatCRvco(int SatCRvco) { eSecDebug("[eDVBSatelliteEquipmentControl::setLNBSatCRvco] vco=%d", SatCRvco); @@ -1296,6 +1476,13 @@ RESULT eDVBSatelliteEquipmentControl::setLNBSatCRvco(int SatCRvco) return 0; } +RESULT eDVBSatelliteEquipmentControl::getLNBSatCRpositions() +{ + if ( currentLNBValid() ) + return m_lnbs[m_lnbidx].SatCR_positions; + return -ENOENT; +} + RESULT eDVBSatelliteEquipmentControl::setLNBSatCRpositions(int SatCR_positions) { eSecDebug("[eDVBSatelliteEquipmentControl::setLNBSatCRpositions] positions=%d", SatCR_positions); @@ -1308,27 +1495,49 @@ RESULT eDVBSatelliteEquipmentControl::setLNBSatCRpositions(int SatCR_positions) return 0; } -RESULT eDVBSatelliteEquipmentControl::getLNBSatCRpositions() +RESULT eDVBSatelliteEquipmentControl::getLNBSatCRformat() { - if ( currentLNBValid() ) - return m_lnbs[m_lnbidx].SatCR_positions; + if (currentLNBValid()) + return m_lnbs[m_lnbidx].SatCR_format; + return -ENOENT; } -RESULT eDVBSatelliteEquipmentControl::getLNBSatCR() +RESULT eDVBSatelliteEquipmentControl::setLNBSatCRformat(SatCR_format_t SatCR_format) { - if ( currentLNBValid() ) - return m_lnbs[m_lnbidx].SatCR_idx; - return -ENOENT; + eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatCRformat(%d)", (int)SatCR_format); + + if(SatCR_format > SatCR_format_jess) + return -EPERM; + + if (currentLNBValid()) + m_lnbs[m_lnbidx].SatCR_format = SatCR_format; + else + return -ENOENT; + + return 0; } -RESULT eDVBSatelliteEquipmentControl::getLNBSatCRvco() +RESULT eDVBSatelliteEquipmentControl::getLNBSatCRPositionNumber() { - if ( currentLNBValid() ) - return m_lnbs[m_lnbidx].SatCRvco; + if (currentLNBValid()) + return m_lnbs[m_lnbidx].SatCR_position; + return -ENOENT; } +RESULT eDVBSatelliteEquipmentControl::setLNBSatCRPositionNumber(unsigned int position_number) +{ + eSecDebug("eDVBSatelliteEquipmentControl::setLNBSatPositionNumber(%u)", position_number); + + if (currentLNBValid()) + m_lnbs[m_lnbidx].SatCR_position = position_number; + else + return -ENOENT; + + return 0; +} + /* Satellite Specific Parameters */ RESULT eDVBSatelliteEquipmentControl::addSatellite(int orbital_position) { diff --git a/lib/dvb/sec.h b/lib/dvb/sec.h index 9d6de652a7..f951667b81 100644 --- a/lib/dvb/sec.h +++ b/lib/dvb/sec.h @@ -6,6 +6,13 @@ #include +typedef enum +{ + SatCR_format_none = 0, + SatCR_format_unicable = 1, + SatCR_format_jess = 2 +} SatCR_format_t; + #ifndef SWIG class eSecCommand { @@ -235,11 +242,14 @@ class eDVBSatelliteRotorParameters class eDVBSatelliteLNBParameters { + public: + eDVBSatelliteLNBParameters() + { + SatCR_format = SatCR_format_none; + } #ifdef SWIG - eDVBSatelliteLNBParameters(); - ~eDVBSatelliteLNBParameters(); + ~eDVBSatelliteLNBParameters(); #endif -public: enum t_12V_relais_state { OFF=0, ON }; #ifndef SWIG t_12V_relais_state m_12V_relais_state; // 12V relais output on/off @@ -265,7 +275,9 @@ class eDVBSatelliteLNBParameters #define MAX_SATCR 8 #define MAX_LNBNUM 32 + SatCR_format_t SatCR_format; int SatCR_positions; + int SatCR_position; int SatCR_idx; unsigned int SatCRvco; unsigned int UnicableTuningWord; @@ -326,7 +338,7 @@ class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl #ifndef SWIG eDVBSatelliteEquipmentControl(eSmartPtrList &avail_frontends, eSmartPtrList &avail_simulate_frontends); RESULT prepare(iDVBFrontend &frontend, const eDVBFrontendParametersSatellite &sat, int &frequency, int frontend_id, unsigned int tunetimeout); - void prepareTurnOffSatCR(iDVBFrontend &frontend, int satcr); // used for unicable + void prepareTurnOffSatCR(iDVBFrontend &frontend); int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *, int frontend_id, int *highest_score_lnb=0); bool currentLNBValid() { return m_lnbidx > -1 && m_lnbidx < (int)(sizeof(m_lnbs) / sizeof(eDVBSatelliteLNBParameters)); } #endif @@ -363,9 +375,13 @@ class eDVBSatelliteEquipmentControl: public iDVBSatelliteEquipmentControl RESULT setLNBSatCR(int SatCR_idx); RESULT setLNBSatCRvco(int SatCRvco); RESULT setLNBSatCRpositions(int SatCR_positions); + RESULT setLNBSatCRformat(SatCR_format_t SatCR_format); + RESULT setLNBSatCRPositionNumber(unsigned int position_number); RESULT getLNBSatCR(); RESULT getLNBSatCRvco(); RESULT getLNBSatCRpositions(); + RESULT getLNBSatCRformat(); + RESULT getLNBSatCRPositionNumber(); /* Satellite Specific Parameters */ RESULT addSatellite(int orbital_position); RESULT setVoltageMode(int mode); diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 1600e617e6..bf8498c404 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -20,6 +20,8 @@ from Tools import Directories import xml.etree.cElementTree +config.unicable = ConfigSubsection() + def getConfigSatlist(orbpos, satlist): default_orbpos = None for x in satlist: @@ -313,39 +315,19 @@ def updateAdvanced(self, sec, slotid): tunermask |= (1 << slot) if currLnb.lof.value != "unicable": - sec.setLNBSatCR(-1) - + sec.setLNBSatCRformat(0) # Unicable / JESS disabled, 0 = SatCR_format_none if currLnb.lof.value == "universal_lnb": sec.setLNBLOFL(9750000) sec.setLNBLOFH(10600000) sec.setLNBThreshold(11700000) elif currLnb.lof.value == "unicable": - def setupUnicable(configManufacturer, ProductDict): - manufacturer_name = configManufacturer.value - manufacturer = ProductDict[manufacturer_name] - product_name = manufacturer.product.value - sec.setLNBSatCR(manufacturer.scr[product_name].index) - sec.setLNBSatCRvco(manufacturer.vco[product_name][manufacturer.scr[product_name].index].value*1000) - sec.setLNBSatCRpositions(manufacturer.positions[product_name][0].value) - sec.setLNBLOFL(manufacturer.lofl[product_name][0].value * 1000) - sec.setLNBLOFH(manufacturer.lofh[product_name][0].value * 1000) - sec.setLNBThreshold(manufacturer.loft[product_name][0].value * 1000) - configManufacturer.save_forced = True - manufacturer.product.save_forced = True - manufacturer.vco[product_name][manufacturer.scr[product_name].index].save_forced = True - - if currLnb.unicable.value == "unicable_user": -#TODO satpositions for satcruser - sec.setLNBLOFL(currLnb.lofl.value * 1000) - sec.setLNBLOFH(currLnb.lofh.value * 1000) - sec.setLNBThreshold(currLnb.threshold.value * 1000) - sec.setLNBSatCR(currLnb.satcruser.index) - sec.setLNBSatCRvco(currLnb.satcrvcouser[currLnb.satcruser.index].value*1000) - sec.setLNBSatCRpositions(1) #HACK - elif currLnb.unicable.value == "unicable_matrix": - setupUnicable(currLnb.unicableMatrixManufacturer, currLnb.unicableMatrix) - elif currLnb.unicable.value == "unicable_lnb": - setupUnicable(currLnb.unicableLnbManufacturer, currLnb.unicableLnb) + sec.setLNBLOFL(currLnb.lofl.value * 1000) + sec.setLNBLOFH(currLnb.lofh.value * 1000) + sec.setLNBThreshold(currLnb.threshold.value * 1000) + sec.setLNBSatCR(currLnb.scrList.index) + sec.setLNBSatCRvco(currLnb.scrfrequency.value * 1000) + sec.setLNBSatCRPositionNumber(int(currLnb.positionNumber.value) + int(currLnb.positionsOffset.value)) + sec.setLNBSatCRformat(currLnb.format.value == "jess" and 2 or 1) elif currLnb.lof.value == "c_band": sec.setLNBLOFL(5150000) sec.setLNBLOFH(5150000) @@ -1161,69 +1143,6 @@ def InitNimManager(nimmgr, update_slots = []): lnb_choices_default = "universal_lnb" - unicablelnbproducts = {} - unicablematrixproducts = {} - doc = xml.etree.cElementTree.parse(eEnv.resolve("${datadir}/enigma2/unicable.xml")) - root = doc.getroot() - - entry = root.find("lnb") - for manufacturer in entry.getchildren(): - m={} - for product in manufacturer.getchildren(): - scr=[] - lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8") - for i in range(len(lscr)): - scr.append(product.get(lscr[i],"0")) - for i in range(len(lscr)): - if scr[len(lscr)-i-1] == "0": - scr.pop() - else: - break; - lof=[] - lof.append(int(product.get("positions",1))) - lof.append(int(product.get("lofl",9750))) - lof.append(int(product.get("lofh",10600))) - lof.append(int(product.get("threshold",11700))) - scr.append(tuple(lof)) - m.update({product.get("name"):tuple(scr)}) - unicablelnbproducts.update({manufacturer.get("name"):m}) - - entry = root.find("matrix") - for manufacturer in entry.getchildren(): - m={} - for product in manufacturer.getchildren(): - scr=[] - lscr=("scr1","scr2","scr3","scr4","scr5","scr6","scr7","scr8") - for i in range(len(lscr)): - scr.append(product.get(lscr[i],"0")) - for i in range(len(lscr)): - if scr[len(lscr)-i-1] == "0": - scr.pop() - else: - break; - lof=[] - lof.append(int(product.get("positions",1))) - lof.append(int(product.get("lofl",9750))) - lof.append(int(product.get("lofh",10600))) - lof.append(int(product.get("threshold",11700))) - scr.append(tuple(lof)) - m.update({product.get("name"):tuple(scr)}) - unicablematrixproducts.update({manufacturer.get("name"):m}) - - UnicableLnbManufacturers = unicablelnbproducts.keys() - UnicableLnbManufacturers.sort() - UnicableMatrixManufacturers = unicablematrixproducts.keys() - UnicableMatrixManufacturers.sort() - - unicable_choices = { - "unicable_lnb": _("Unicable LNB"), - "unicable_matrix": _("Unicable Matrix"), - "unicable_user": "Unicable "+_("User defined")} - unicable_choices_default = "unicable_lnb" - - advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"), - ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")] - prio_list = [ ("-1", _("Auto")) ] for prio in range(65)+range(14000,14065)+range(19000,19065): description = "" @@ -1280,79 +1199,78 @@ def configLOFChanged(configElement): lnbs = nim.advanced.lnb section = lnbs[lnb] if isinstance(section.unicable, ConfigNothing): - if lnb == 1: - section.unicable = ConfigSelection(unicable_choices, unicable_choices_default) - elif lnb == 2: - section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Matrix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix") - else: - section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user") - - def fillUnicableConf(sectionDict, unicableproducts, vco_null_check): - for y in unicableproducts: - products = unicableproducts[y].keys() - products.sort() - tmp = ConfigSubsection() - tmp.product = ConfigSelection(choices = products, default = products[0]) - tmp.scr = ConfigSubDict() - tmp.vco = ConfigSubDict() - tmp.lofl = ConfigSubDict() - tmp.lofh = ConfigSubDict() - tmp.loft = ConfigSubDict() - tmp.positions = ConfigSubDict() - for z in products: - scrlist = [] - vcolist = unicableproducts[y][z] - tmp.vco[z] = ConfigSubList() - for cnt in range(1,1+len(vcolist)-1): - vcofreq = int(vcolist[cnt-1]) - if vcofreq == 0 and vco_null_check: - scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used"))) - else: - scrlist.append(("%d" %cnt,"SCR %d" %cnt)) - tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) - tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) - - positions = int(vcolist[len(vcolist)-1][0]) - tmp.positions[z] = ConfigSubList() - tmp.positions[z].append(ConfigInteger(default=positions, limits = (positions, positions))) - - lofl = vcolist[len(vcolist)-1][1] - tmp.lofl[z] = ConfigSubList() - tmp.lofl[z].append(ConfigInteger(default=lofl, limits = (lofl, lofl))) - - lofh = int(vcolist[len(vcolist)-1][2]) - tmp.lofh[z] = ConfigSubList() - tmp.lofh[z].append(ConfigInteger(default=lofh, limits = (lofh, lofh))) - - loft = int(vcolist[len(vcolist)-1][3]) - tmp.loft[z] = ConfigSubList() - tmp.loft[z].append(ConfigInteger(default=loft, limits = (loft, loft))) - sectionDict[y] = tmp - - if lnb < 3: - print "[InitNimManager] MATRIX" - section.unicableMatrix = ConfigSubDict() - section.unicableMatrixManufacturer = ConfigSelection(UnicableMatrixManufacturers, UnicableMatrixManufacturers[0]) - fillUnicableConf(section.unicableMatrix, unicablematrixproducts, True) - - if lnb < 2: - print "[InitNimManager] LNB" - section.unicableLnb = ConfigSubDict() - section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0]) - fillUnicableConf(section.unicableLnb, unicablelnbproducts, False) - -#TODO satpositions for satcruser - section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1") - tmp = ConfigSubList() - tmp.append(ConfigInteger(default=1284, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1400, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1516, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1632, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1748, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1864, limits = (950, 2150))) - tmp.append(ConfigInteger(default=1980, limits = (950, 2150))) - tmp.append(ConfigInteger(default=2096, limits = (950, 2150))) - section.satcrvcouser = tmp + def positionsChanged(configEntry): + section.positionNumber = ConfigSelection(["%d" % (x+1) for x in range(configEntry.value)], default="%d" % min(lnb, configEntry.value)) + def scrListChanged(productparameters, srcfrequencylist, configEntry): + section.format = ConfigSelection([("unicable", _("Unicable")), ("jess", _("JESS"))], default=productparameters.get("format", "unicable")) + section.scrfrequency = ConfigInteger(default=int(srcfrequencylist[configEntry.index])) + section.positions = ConfigInteger(default=int(productparameters.get("positions", 1))) + section.positions.addNotifier(positionsChanged) + section.positionsOffset = ConfigInteger(default=int(productparameters.get("positionsoffset", 0))) + section.lofl = ConfigInteger(default=int(productparameters.get("lofl", 9750))) + section.lofh = ConfigInteger(default=int(productparameters.get("lofh", 10600))) + section.threshold = ConfigInteger(default=int(productparameters.get("threshold", 11700))) + def unicableProductChanged(manufacturer, lnb_or_matrix, configEntry): + config.unicable.unicableProduct.value = configEntry.value + config.unicable.unicableProduct.save() + productparameters = [p for p in [m.getchildren() for m in unicable_xml.find(lnb_or_matrix) if m.get("name") == manufacturer][0] if p.get("name") == configEntry.value][0] + srcfrequencylist = productparameters.get("scrs").split(",") + section.scrList = ConfigSelection([("%d" % (x + 1), "SCR %d (%s)" % ((x + 1), srcfrequencylist[x])) for x in range(len(srcfrequencylist))]) + section.scrList.save_forced = True + section.scrList.addNotifier(boundFunction(scrListChanged, productparameters, srcfrequencylist)) + def unicableManufacturerChanged(lnb_or_matrix, configEntry): + config.unicable.unicableManufacturer.value = configEntry.value + config.unicable.unicableManufacturer.save() + productslist = [p.get("name") for p in [m.getchildren() for m in unicable_xml.find(lnb_or_matrix) if m.get("name") == configEntry.value][0]] + if not config.unicable.content.items.get("unicableProduct", False) or config.unicable.unicableProduct.value not in productslist: + config.unicable.unicableProduct = ConfigSelection(productslist) + config.unicable.unicableProduct.save_forced = True + section.unicableProduct = ConfigSelection(productslist, default=config.unicable.unicableProduct.value) + section.unicableProduct.save_forced = True + section.unicableProduct.addNotifier(boundFunction(unicableProductChanged, configEntry.value, lnb_or_matrix)) + def userScrListChanged(srcfrequencyList, configEntry): + section.scrfrequency = ConfigInteger(default=int(srcfrequencyList[configEntry.index]), limits=(950, 2150)) + section.lofl = ConfigInteger(default=9750, limits=(950, 2150)) + section.lofh = ConfigInteger(default=10600, limits=(950, 2150)) + section.threshold = ConfigInteger(default=11700, limits=(950, 2150)) + def formatChanged(configEntry): + section.positions = ConfigInteger(default=configEntry.value == "jess" and 64 or 2) + section.positions.addNotifier(positionsChanged) + section.positionsOffset = ConfigInteger(default=0) + section.scrList = ConfigSelection([("%d" % (x + 1), "SCR %d" % (x + 1)) for x in range(configEntry.value == "jess" and 32 or 8)]) + section.scrList.save_forced = True + srcfrequencyList = configEntry.value=="jess" and (1210, 1420, 1680, 2040, 984, 1020, 1056, 1092, 1128, 1164, 1256, 1292, 1328, 1364, 1458, 1494, 1530, 1566, 1602,\ + 1638, 1716, 1752, 1788, 1824, 1860, 1896, 1932, 1968, 2004, 2076, 2112, 2148) or (1284, 1400, 1516, 1632, 1748, 1864, 1980, 2096) + section.scrList.addNotifier(boundFunction(userScrListChanged, srcfrequencyList)) + def unicableChanged(configEntry): + config.unicable.unicable.value = configEntry.value + config.unicable.unicable.save() + if configEntry.value == "unicable_matrix": + manufacturerlist = [m.get("name") for m in unicable_xml.find("matrix")] + if not config.unicable.content.items.get("unicableManufacturer", False) or config.unicable.unicableManufacturer.value not in manufacturerlist: + config.unicable.unicableManufacturer = ConfigSelection(manufacturerlist) + section.unicableManufacturer = ConfigSelection(manufacturerlist, default=config.unicable.unicableManufacturer.value) + section.unicableManufacturer.save_forced = True + config.unicable.unicableManufacturer.save_forced = True + section.unicableManufacturer.addNotifier(boundFunction(unicableManufacturerChanged, "matrix")) + elif configEntry.value == "unicable_lnb": + manufacturerlist = [m.get("name") for m in unicable_xml.find("lnb")] + if not config.unicable.content.items.get("unicableManufacturer", False) or config.unicable.unicableManufacturer.value not in manufacturerlist: + config.unicable.unicableManufacturer = ConfigSelection(manufacturerlist) + section.unicableManufacturer = ConfigSelection(manufacturerlist, default=config.unicable.unicableManufacturer.value) + section.unicableManufacturer.save_forced = True + config.unicable.unicableManufacturer.save_forced = True + section.unicableManufacturer.addNotifier(boundFunction(unicableManufacturerChanged, "lnb")) + else: + section.format = ConfigSelection([("unicable", _("Unicable")), ("jess", _("JESS"))]) + section.format.addNotifier(formatChanged) + + unicable_xml = xml.etree.cElementTree.parse(eEnv.resolve("${datadir}/enigma2/unicable.xml")).getroot() + unicableList = [("unicable_lnb", _("Unicable LNB")), ("unicable_matrix", _("Unicable switch")), ("unicable_user", "Unicable "+_("User defined"))] + if not config.unicable.content.items.get("unicable", False): + config.unicable.unicable = ConfigSelection(unicableList) + section.unicable = ConfigSelection(unicableList, default=config.unicable.unicable.value) + section.unicable.addNotifier(unicableChanged) nim.advanced.unicableconnected = ConfigYesNo(default=False) nim.advanced.unicableconnectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x]) diff --git a/lib/python/Screens/Satconfig.py b/lib/python/Screens/Satconfig.py index 77ab5f01da..ddfadadc5f 100644 --- a/lib/python/Screens/Satconfig.py +++ b/lib/python/Screens/Satconfig.py @@ -116,6 +116,8 @@ def createSetup(self): self.cableConfigScanDetails = None self.have_advanced = False self.advancedUnicable = None + self.advancedFormat = None + self.advancedPosition = None self.advancedType = None self.advancedManufacturer = None self.advancedSCR = None @@ -252,23 +254,17 @@ def createSetup(self): def newConfig(self): self.setTextKeyBlue() - checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, \ - self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, \ - self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, \ - self.advancedType, self.advancedSCR, self.advancedManufacturer, self.advancedUnicable, self.advancedConnected, \ - self.toneburst, self.committedDiseqcCommand, self.uncommittedDiseqcCommand, self.singleSatEntry, \ - self.commandOrder, self.showAdditionalMotorOptions, self.cableScanType, self.cableConfigScanDetails, self.multiType) if self["config"].getCurrent() == self.multiType: update_slots = [self.slotid] from Components.NimManager import InitNimManager InitNimManager(nimmanager, update_slots) self.nim = nimmanager.nim_slots[self.slotid] self.nimConfig = self.nim.config - - for x in checkList: - if self["config"].getCurrent() == x: - self.createSetup() - break + if self["config"].getCurrent() in (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry,\ + self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, self.advancedType, self.advancedSCR, self.advancedPosition, self.advancedFormat, self.advancedManufacturer,\ + self.advancedUnicable, self.advancedConnected, self.toneburst, self.committedDiseqcCommand, self.uncommittedDiseqcCommand, self.singleSatEntry, self.commandOrder,\ + self.showAdditionalMotorOptions, self.cableScanType, self.multiType): + self.createSetup() def run(self): if self.nimConfig.configMode.value == "simple": @@ -324,8 +320,7 @@ def fillListWithAdvancedSatEntrys(self, Sat): if currLnb: if self.nim.isFBCLink(): - if currLnb.lof.value != "unicable": - currLnb.lof.value = "unicable" + currLnb.lof.value = "unicable" self.list.append(getConfigListEntry(_("Priority"), currLnb.prio)) self.advancedLof = getConfigListEntry("LOF", currLnb.lof) self.list.append(self.advancedLof) @@ -338,35 +333,26 @@ def fillListWithAdvancedSatEntrys(self, Sat): self.advancedUnicable = getConfigListEntry("Unicable "+_("Configuration mode"), currLnb.unicable) self.list.append(self.advancedUnicable) if currLnb.unicable.value == "unicable_user": - self.advancedSCR = getConfigListEntry(_("Channel"), currLnb.satcruser) + self.advancedFormat = getConfigListEntry(_("Format"), currLnb.format) + self.advancedPosition = getConfigListEntry(_("Position"), currLnb.positionNumber) + self.advancedSCR = getConfigListEntry(_("Channel"), currLnb.scrList) + self.list.append(self.advancedFormat) + self.list.append(self.advancedPosition) self.list.append(self.advancedSCR) - self.list.append(getConfigListEntry(_("Frequency"), currLnb.satcrvcouser[currLnb.satcruser.index])) + self.list.append(getConfigListEntry(_("Frequency"), currLnb.scrfrequency)) self.list.append(getConfigListEntry("LOF/L", currLnb.lofl)) self.list.append(getConfigListEntry("LOF/H", currLnb.lofh)) self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold)) - elif currLnb.unicable.value == "unicable_matrix": - manufacturer_name = currLnb.unicableMatrixManufacturer.value - manufacturer = currLnb.unicableMatrix[manufacturer_name] - product_name = manufacturer.product.value - self.advancedManufacturer = getConfigListEntry(_("Manufacturer"), currLnb.unicableMatrixManufacturer) - self.advancedType = getConfigListEntry(_("Type"), manufacturer.product) - self.advancedSCR = getConfigListEntry(_("Channel"), manufacturer.scr[product_name]) - self.list.append(self.advancedManufacturer) - self.list.append(self.advancedType) - self.list.append(self.advancedSCR) - self.list.append(getConfigListEntry(_("Frequency"), manufacturer.vco[product_name][manufacturer.scr[product_name].index])) - elif currLnb.unicable.value == "unicable_lnb": - manufacturer_name = currLnb.unicableLnbManufacturer.value - manufacturer = currLnb.unicableLnb[manufacturer_name] - product_name = manufacturer.product.value - self.advancedManufacturer = getConfigListEntry(_("Manufacturer"), currLnb.unicableLnbManufacturer) - self.advancedType = getConfigListEntry(_("Type"), manufacturer.product) - self.advancedSCR = getConfigListEntry(_("Channel"), manufacturer.scr[product_name]) + else: + self.advancedManufacturer = getConfigListEntry(_("Manufacturer"), currLnb.unicableManufacturer) + self.advancedType = getConfigListEntry(_("Type"), currLnb.unicableProduct) + self.advancedSCR = getConfigListEntry(_("Channel"), currLnb.scrList) + self.advancedPosition = getConfigListEntry(_("Position"), currLnb.positionNumber) self.list.append(self.advancedManufacturer) self.list.append(self.advancedType) + if currLnb.positions.value > 1: + self.list.append(self.advancedPosition) self.list.append(self.advancedSCR) - self.list.append(getConfigListEntry(_("Frequency"), manufacturer.vco[product_name][manufacturer.scr[product_name].index])) - choices = [] connectable = nimmanager.canConnectTo(self.slotid) for id in connectable: @@ -554,11 +540,8 @@ def __init__(self, session, slotid): self.setTitle(_("Setup") + " " + self.nim.friendly_full_description) def keyLeft(self): - if self.nim.isFBCLink(): - checkList = (self.advancedLof, self.advancedConnected) - curEntry = self["config"].getCurrent() - if curEntry in checkList: - return + if self.nim.isFBCLink() and self["config"].getCurrent() in (self.advancedLof, self.advancedConnected): + return ConfigListScreen.keyLeft(self) if self["config"].getCurrent() in (self.advancedSelectSatsEntry, self.selectSatsEntry): self.keyOk() @@ -572,11 +555,8 @@ def setTextKeyBlue(self): self["key_blue"].setText(self["config"].isChanged() and _("Set default") or "") def keyRight(self): - if self.nim.isFBCLink(): - checkList = (self.advancedLof, self.advancedConnected) - curEntry = self["config"].getCurrent() - if curEntry in checkList: - return + if self.nim.isFBCLink() and self["config"].getCurrent() in (self.advancedLof, self.advancedConnected): + return ConfigListScreen.keyRight(self) if self["config"].getCurrent() in (self.advancedSelectSatsEntry, self.selectSatsEntry): self.keyOk()