From 2e11214728be2d739d3ab757d0ed831365462c66 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Fri, 13 Jan 2012 14:43:55 +0400 Subject: [PATCH] motorcontrol: add frontend member and param to select frontend to use; set live frontend to selected for diseqc commands --- src/gui/motorcontrol.cpp | 53 ++++++++++++++++++++++++++-------------- src/gui/motorcontrol.h | 8 +++--- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index 07c6d9c2b..627b4dfc7 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include static int g_sig; static int g_snr; @@ -59,11 +59,21 @@ static int moving = 0; #define BAR_WIDTH 100 #define BAR_HEIGHT 16 //(13 + BAR_BORDER*2) -CMotorControl::CMotorControl() +CMotorControl::CMotorControl(int tnum) { + printf("CMotorControl::CMotorControl: tuner %d\n", tnum); + frontend = CFEManager::getInstance()->getFE(tnum); + if(frontend == NULL) { + printf("CMotorControl::CMotorControl: BUG, invalid tuner number %d, using first\n", tnum); + frontend = CFEManager::getInstance()->getFE(0); + } Init(); } +CMotorControl::~CMotorControl() +{ +printf("CMotorControl::~CMotorControl\n"); +} void CMotorControl::Init(void) { frameBuffer = CFrameBuffer::getInstance(); @@ -120,6 +130,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; +#if 0 /* send satellite list to zapit */ for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) { if(!strcmp(sit->second.name.c_str(),scansettings.satNameNoDiseqc)) { @@ -131,23 +142,28 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) break; } } - origPosition = motorPosition; +#endif + /* send satellite list to zapit */ + sat.position = CServiceManager::getInstance()->GetSatellitePosition(scansettings.satNameNoDiseqc); + strncpy(sat.satName, scansettings.satNameNoDiseqc, 50); + satList.push_back(sat); + satellite_map_t & satmap = frontend->getSatellites(); + sit = satmap.find(sat.position); + if(sit != satmap.end() && sit->second.motor_position) + motorPosition = sit->second.motor_position; + + origPosition = motorPosition; + //FIXME change cZapit live fe + g_Zapit->stopPlayBack(); g_Zapit->setScanSatelliteList( satList); + CZapit::getInstance()->SetLiveFrontend(frontend); TP.feparams.frequency = atoi(scansettings.TP_freq); TP.feparams.u.qpsk.symbol_rate = atoi(scansettings.TP_rate); TP.feparams.u.qpsk.fec_inner = (fe_code_rate_t)scansettings.TP_fec; TP.polarization = scansettings.TP_pol; -#if 0 - CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); - TP.feparams.frequency = si.tsfrequency; - TP.feparams.u.qpsk.symbol_rate = si.rate; - TP.feparams.u.qpsk.fec_inner = si.fec; - TP.polarization = si.polarisation; -#endif - g_Zapit->stopPlayBack(); g_Zapit->tune_TP(TP); paint(); @@ -335,15 +351,16 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) printf("[motorcontrol] 5 key received... store present satellite number: %d\n", motorPosition); if(motorPosition != origPosition) { printf("[motorcontrol] position changed %d -> %d\n", origPosition, motorPosition); - for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) { + for(sit = satmap.begin(); sit != satmap.end(); sit++) { if(sit->second.motor_position == motorPosition) break; } - if(sit != satellitePositions.end()) { - printf("[motorcontrol] new positions configured for %s\n", sit->second.name.c_str()); + if(sit != satmap.end()) { + std::string satname = CServiceManager::getInstance()->GetSatelliteName(sit->first); + printf("[motorcontrol] new positions configured for %s\n", satname.c_str()); std::string buf = g_Locale->getText(LOCALE_MOTORCONTROL_OVERRIDE); buf += " "; - buf += sit->second.name; + buf += satname; buf += " ?"; store = (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); } @@ -414,7 +431,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) } hide(); - CFrontend::getInstance()->setTsidOnid(0); + frontend->setTsidOnid(0); return menu_return::RETURN_REPAINT; } @@ -701,8 +718,8 @@ void CMotorControl::showSNR() int sw; - ssig = CFrontend::getInstance()->getSignalStrength(); - ssnr = CFrontend::getInstance()->getSignalNoiseRatio(); + ssig = frontend->getSignalStrength(); + ssnr = frontend->getSignalNoiseRatio(); snr = (ssnr & 0xFFFF) * 100 / 65535; sig = (ssig & 0xFFFF) * 100 / 65535; diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h index 75854f38f..7ef402417 100644 --- a/src/gui/motorcontrol.h +++ b/src/gui/motorcontrol.h @@ -37,7 +37,7 @@ #include #include #include - +#include #define STEP_MODE_OFF 0 #define STEP_MODE_AUTO 1 @@ -49,6 +49,7 @@ class CMotorControl : public CMenuTarget private: void Init(void); CFrameBuffer *frameBuffer; + CFrontend *frontend; int x; int y; int width; @@ -57,7 +58,7 @@ class CMotorControl : public CMenuTarget int ypos; int ypos_status; int ypos_menue; - + int8_t stepSize; int32_t stepDelay; int stepMode; @@ -81,7 +82,8 @@ class CMotorControl : public CMenuTarget public: - CMotorControl(); + CMotorControl(int tnum = 0); + ~CMotorControl(); void hide(); int exec(CMenuTarget* parent, const std::string & actionKey); };