{
avail = 1;
busy = 0;
- m_sec = new eDVBSatelliteEquipmentControl(m_frontend);
+ m_sec = new eDVBSatelliteEquipmentControl(m_frontend, m_simulate_frontend);
+
if (!instance)
instance = this;
num_adapter++;
}
- eDebug("found %d adapter, %d frontends and %d demux",
- m_adapter.size(), m_frontend.size(), m_demux.size());
+ eDebug("found %d adapter, %d frontends(%d sim) and %d demux",
+ m_adapter.size(), m_frontend.size(), m_simulate_frontend.size(), m_demux.size());
eDVBCAService::registerChannelCallback(this);
break;
ePtr<eDVBFrontend> fe;
- int ok = 0;
- fe = new eDVBFrontend(m_nr, num_fe, ok);
- if (ok)
- m_frontend.push_back(fe);
+ {
+ int ok = 0;
+ fe = new eDVBFrontend(m_nr, num_fe, ok);
+ if (ok)
+ m_frontend.push_back(fe);
+ }
+ {
+ int ok = 0;
+ fe = new eDVBFrontend(m_nr, num_fe, ok, true);
+ if (ok)
+ m_simulate_frontend.push_back(fe);
+ }
++num_fe;
}
return m_frontend.size();
}
-RESULT eDVBAdapterLinux::getFrontend(ePtr<eDVBFrontend> &fe, int nr)
+RESULT eDVBAdapterLinux::getFrontend(ePtr<eDVBFrontend> &fe, int nr, bool simulate)
{
- eSmartPtrList<eDVBFrontend>::iterator i(m_frontend.begin());
+ eSmartPtrList<eDVBFrontend>::iterator i(simulate ? m_simulate_frontend.begin() : m_frontend.begin());
while (nr && (i != m_frontend.end()))
{
--nr;
}
}
}
+
+ prev_dvbt_frontend = 0;
+ for (i=0; i<num_fe; ++i)
+ {
+ ePtr<eDVBFrontend> frontend;
+ if (!adapter->getFrontend(frontend, i, true))
+ {
+ int frontendType=0;
+ frontend->getFrontendType(frontendType);
+ eDVBRegisteredFrontend *new_fe = new eDVBRegisteredFrontend(frontend, adapter);
+// CONNECT(new_fe->stateChanged, eDVBResourceManager::feStateChanged);
+ m_simulate_frontend.push_back(new_fe);
+ frontend->setSEC(m_sec);
+ // we must link all dvb-t frontends ( for active antenna voltage )
+ if (frontendType == iDVBFrontend::feTerrestrial)
+ {
+ if (prev_dvbt_frontend)
+ {
+ prev_dvbt_frontend->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)new_fe);
+ frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)&(*prev_dvbt_frontend));
+ }
+ prev_dvbt_frontend = new_fe;
+ }
+ }
+ }
+
}
PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
if (!i->m_frontend->setSlotInfo(obj))
return NULL;
}
+ pos=0;
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_simulate_frontend.begin()); i != m_simulate_frontend.end(); ++i)
+ {
+ ePyObject obj = PyList_GET_ITEM(list, pos++);
+ if (!i->m_frontend->setSlotInfo(obj))
+ return NULL;
+ }
Py_RETURN_NONE;
}
-RESULT eDVBResourceManager::allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm)
+RESULT eDVBResourceManager::allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm, bool simulate)
{
+ eSmartPtrList<eDVBRegisteredFrontend> &frontends = simulate ? m_simulate_frontend : m_frontend;
ePtr<eDVBRegisteredFrontend> best;
int bestval = 0;
int foundone = 0;
- for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(frontends.begin()); i != frontends.end(); ++i)
{
int c = i->m_frontend->isCompatibleWith(feparm);
if (!i->m_inuse)
{
+// eDebug("Slot %d, score %d", i->m_frontend->getSlotID(), c);
if (c > bestval)
{
bestval = c;
best = i;
}
}
+// else
+// eDebug("Slot %d, score %d... but BUSY!!!!!!!!!!!", i->m_frontend->getSlotID(), c);
}
if (best)
return -ENOENT;
}
-RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel)
+#define eDebugNoSimulate(x...) \
+ do { \
+ if (!simulate) \
+ eDebug(x); \
+ } while(0)
+// else \
+// { \
+// eDebugNoNewLine("SIMULATE:"); \
+// eDebug(x); \
+// } \
+
+
+RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel, bool simulate)
{
/* first, check if a channel is already existing. */
+ std::list<active_channel> &active_channels = simulate ? m_active_simulate_channels : m_active_channels;
- if (m_cached_channel)
+ if (!simulate && m_cached_channel)
{
eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel);
if(channelid==cache_chan->getChannelID())
m_releaseCachedChannelTimer.stop();
}
-// eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
- for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
+ eDebugNoSimulate("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
+ for (std::list<active_channel>::iterator i(active_channels.begin()); i != active_channels.end(); ++i)
{
-// eDebug("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
+ eDebugNoSimulate("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
if (i->m_channel_id == channelid)
{
-// eDebug("found shared channel..");
+ eDebugNoSimulate("found shared channel..");
channel = i->m_channel;
return 0;
}
}
-
+
/* no currently available channel is tuned to this channelid. create a new one, if possible. */
if (!m_list)
{
- eDebug("no channel list set!");
+ eDebugNoSimulate("no channel list set!");
return errNoChannelList;
}
ePtr<iDVBFrontendParameters> feparm;
if (m_list->getChannelFrontendData(channelid, feparm))
{
- eDebug("channel not found!");
+ eDebugNoSimulate("channel not found!");
return errChannelNotInList;
}
ePtr<eDVBAllocatedFrontend> fe;
- int err = allocateFrontend(fe, feparm);
+ int err = allocateFrontend(fe, feparm, simulate);
if (err)
return err;
channel = 0;
return errChidNotFound;
}
- m_cached_channel = channel = ch;
- m_cached_channel_state_changed_conn =
- CONNECT(ch->m_stateChanged,eDVBResourceManager::DVBChannelStateChanged);
+
+ if (simulate)
+ channel = ch;
+ else
+ {
+ m_cached_channel = channel = ch;
+ m_cached_channel_state_changed_conn =
+ CONNECT(ch->m_stateChanged,eDVBResourceManager::DVBChannelStateChanged);
+ }
return 0;
}
RESULT eDVBResourceManager::addChannel(const eDVBChannelID &chid, eDVBChannel *ch)
{
- m_active_channels.push_back(active_channel(chid, ch));
- /* emit */ m_channelAdded(ch);
+ ePtr<iDVBFrontend> fe;
+ if (!ch->getFrontend(fe))
+ {
+ eDVBFrontend *frontend = (eDVBFrontend*)&(*fe);
+ if (frontend->is_simulate())
+ m_active_simulate_channels.push_back(active_channel(chid, ch));
+ else
+ {
+ m_active_channels.push_back(active_channel(chid, ch));
+ /* emit */ m_channelAdded(ch);
+ }
+ }
return 0;
}
RESULT eDVBResourceManager::removeChannel(eDVBChannel *ch)
{
- int cnt = 0;
- for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end();)
+ ePtr<iDVBFrontend> fe;
+ if (!ch->getFrontend(fe))
{
- if (i->m_channel == ch)
+ eDVBFrontend *frontend = (eDVBFrontend*)&(*fe);
+ std::list<active_channel> &active_channels = frontend->is_simulate() ? m_active_simulate_channels : m_active_channels;
+ int cnt = 0;
+ for (std::list<active_channel>::iterator i(active_channels.begin()); i != active_channels.end();)
{
- i = m_active_channels.erase(i);
- ++cnt;
- } else
- ++i;
+ if (i->m_channel == ch)
+ {
+ i = active_channels.erase(i);
+ ++cnt;
+ } else
+ ++i;
+ }
+ ASSERT(cnt == 1);
+ if (cnt == 1)
+ return 0;
}
- ASSERT(cnt == 1);
- if (cnt == 1)
- return 0;
return -ENOENT;
}
virtual RESULT getDemux(ePtr<eDVBDemux> &demux, int nr) = 0;
virtual int getNumFrontends() = 0;
- virtual RESULT getFrontend(ePtr<eDVBFrontend> &fe, int nr) = 0;
+ virtual RESULT getFrontend(ePtr<eDVBFrontend> &fe, int nr, bool simulate=false) = 0;
};
class eDVBAdapterLinux: public iDVBAdapter
RESULT getDemux(ePtr<eDVBDemux> &demux, int nr);
int getNumFrontends();
- RESULT getFrontend(ePtr<eDVBFrontend> &fe, int nr);
+ RESULT getFrontend(ePtr<eDVBFrontend> &fe, int nr, bool simulate=false);
static int exist(int nr);
private:
int m_nr;
- eSmartPtrList<eDVBFrontend> m_frontend;
+ eSmartPtrList<eDVBFrontend> m_frontend, m_simulate_frontend;
eSmartPtrList<eDVBDemux> m_demux;
};
#endif // SWIG
eSmartPtrList<iDVBAdapter> m_adapter;
eSmartPtrList<eDVBRegisteredDemux> m_demux;
- eSmartPtrList<eDVBRegisteredFrontend> m_frontend;
+ eSmartPtrList<eDVBRegisteredFrontend> m_frontend, m_simulate_frontend;
void addAdapter(iDVBAdapter *adapter);
struct active_channel
active_channel(const eDVBChannelID &chid, eDVBChannel *ch) : m_channel_id(chid), m_channel(ch) { }
};
- std::list<active_channel> m_active_channels;
+ std::list<active_channel> m_active_channels, m_active_simulate_channels;
ePtr<iDVBChannelList> m_list;
ePtr<iDVBSatelliteEquipmentControl> m_sec;
int canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID &ignore);
/* allocate channel... */
- RESULT allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel);
+ RESULT allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel, bool simulate=false);
RESULT allocatePVRChannel(eUsePtr<iDVBPVRChannel> &channel);
static RESULT getInstance(ePtr<eDVBResourceManager> &);
there might be a priority given to certain frontend/chid
combinations. this will be evaluated here. */
- RESULT allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm);
+ RESULT allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm, bool simulate=false);
RESULT allocateFrontendByIndex(ePtr<eDVBAllocatedFrontend> &fe, int slot_index);
/* allocate a demux able to filter on the selected frontend. */
#include <dvbsi++/cable_delivery_system_descriptor.h>
#include <dvbsi++/terrestrial_delivery_system_descriptor.h>
+#define eDebugNoSimulate(x...) \
+ do { \
+ if (!m_simulate) \
+ eDebug(x); \
+ } while(0)
+// else \
+// { \
+// eDebugNoNewLine("SIMULATE:"); \
+// eDebug(x); \
+// } \
+
+#define eDebugNoSimulateNoNewLine(x...) \
+ do { \
+ if (!m_simulate) \
+ eDebugNoNewLine(x); \
+ } while(0)
+// else \
+// { \
+// eDebugNoNewLine("SIMULATE:"); \
+// eDebugNoNewLine(x); \
+// } \
+
void eDVBDiseqcCommand::setCommandString(const char *str)
{
if (!str)
if (parm->getDVBT(oterrestrial))
return -2;
-
if (exact && oterrestrial.bandwidth != terrestrial.bandwidth &&
oterrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto &&
terrestrial.bandwidth != eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto)
int eDVBFrontend::PriorityOrder=0;
-eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok)
- :m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
+eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate)
+ :m_simulate(simulate), m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe)
,m_fd(-1), m_need_rotor_workaround(false), m_can_handle_dvbs2(false)
,m_sn(0), m_timeout(0), m_tuneTimer(0)
#if HAVE_DVB_API_VERSION < 3
#else
sprintf(m_filename, "/dev/dvb/adapter%d/frontend%d", adap, fe);
#endif
+
m_timeout = new eTimer(eApp);
CONNECT(m_timeout->timeout, eDVBFrontend::timeout);
#else
dvb_frontend_info fe_info;
#endif
- eDebug("opening frontend %d", m_dvbid);
+ eDebugNoSimulate("opening frontend %d", m_dvbid);
if (m_fd < 0)
{
- m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
- if (m_fd < 0)
+ if (!m_simulate || m_type == -1)
{
- eWarning("failed! (%s) %m", m_filename);
- return -1;
+ m_fd = ::open(m_filename, O_RDWR|O_NONBLOCK);
+ if (m_fd < 0)
+ {
+ eWarning("failed! (%s) %m", m_filename);
+ return -1;
+ }
}
}
else
m_fd = -1;
return -1;
}
- eDebug("detected %s frontend", "satellite\0cable\0 terrestrial"+fe_info.type*10);
+ eDebugNoSimulate("detected %s frontend", "satellite\0cable\0 terrestrial"+fe_info.type*10);
}
#if HAVE_DVB_API_VERSION < 3
{
if (m_secfd < 0)
{
- m_secfd = ::open(m_sec_filename, O_RDWR);
- if (m_secfd < 0)
+ if (!m_simulate)
{
- eWarning("failed! (%s) %m", m_sec_filename);
- ::close(m_fd);
- m_fd=-1;
- return -1;
+ m_secfd = ::open(m_sec_filename, O_RDWR);
+ if (m_secfd < 0)
+ {
+ eWarning("failed! (%s) %m", m_sec_filename);
+ ::close(m_fd);
+ m_fd=-1;
+ return -1;
+ }
}
}
else
setTone(iDVBFrontend::toneOff);
setVoltage(iDVBFrontend::voltageOff);
- m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read, false);
- CONNECT(m_sn->activated, eDVBFrontend::feEvent);
+ if (!m_simulate)
+ {
+ m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read, false);
+ CONNECT(m_sn->activated, eDVBFrontend::feEvent);
+ }
return 0;
}
eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp;
if (linked_fe->m_inuse)
{
- eDebug("dont close frontend %d until the linked frontend %d in slot %d is still in use",
+ eDebugNoSimulate("dont close frontend %d until the linked frontend %d in slot %d is still in use",
m_dvbid, linked_fe->m_frontend->getDVBID(), linked_fe->m_frontend->getSlotID());
return -1;
}
linked_fe->m_frontend->getData(LINKED_NEXT_PTR, tmp);
}
}
+
if (m_fd >= 0)
{
- eDebug("close frontend %d", m_dvbid);
- m_tuneTimer->stop();
+ eDebugNoSimulate("close frontend %d", m_dvbid);
setTone(iDVBFrontend::toneOff);
setVoltage(iDVBFrontend::voltageOff);
- if (m_sec)
+ m_tuneTimer->stop();
+ if (m_sec && !m_simulate)
m_sec->setRotorMoving(false);
if (!::close(m_fd))
m_fd=-1;
else
eWarning("couldnt close frontend %d", m_dvbid);
}
+ else if (m_simulate)
+ {
+ setTone(iDVBFrontend::toneOff);
+ setVoltage(iDVBFrontend::voltageOff);
+ }
#if HAVE_DVB_API_VERSION < 3
if (m_secfd >= 0)
{
case bitErrorRate:
{
uint32_t ber=0;
- if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
- eDebug("FE_READ_BER failed (%m)");
+ if (!m_simulate)
+ {
+ if (ioctl(m_fd, FE_READ_BER, &ber) < 0 && errno != ERANGE)
+ eDebug("FE_READ_BER failed (%m)");
+ }
return ber;
}
case signalQuality:
{
uint16_t snr=0;
- if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
- eDebug("FE_READ_SNR failed (%m)");
+ if (!m_simulate)
+ {
+ if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
+ eDebug("FE_READ_SNR failed (%m)");
+ }
return snr;
}
case signalQualitydB: /* this will move into the driver */
{
uint16_t snr=0;
+ if (m_simulate)
+ return 0;
if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
eDebug("FE_READ_SNR failed (%m)");
if (!strcmp(m_description, "BCM4501 (internal)"))
20377212.0 / 4194304.0,
-37791203.0 / 4194304.0,
};
-
+
float fval1, fval2, snr_in_db;
int i;
fval1 = 12.44714 - (2.0 * log10(SDS_SNRE / 256.0));
fval2 = pow(10.0, fval1)-1;
fval1 = 10.0 * log10(fval2);
-
+
if (fval1 < 10.0)
{
fval2 = SNR_COEFF[0];
fval1 = fval2;
}
snr_in_db = fval1;
-
+
return (int)(snr_in_db * 100.0);
}
else if (strstr(m_description, "Alps BSBE1 C01A") ||
case signalPower:
{
uint16_t strength=0;
- if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
- eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
+ if (!m_simulate)
+ {
+ if (ioctl(m_fd, FE_READ_SIGNAL_STRENGTH, &strength) < 0 && errno != ERANGE)
+ eDebug("FE_READ_SIGNAL_STRENGTH failed (%m)");
+ }
return strength;
}
case locked:
#else
fe_status_t status;
#endif
- if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
- eDebug("FE_READ_STATUS failed (%m)");
- return !!(status&FE_HAS_LOCK);
+ if (!m_simulate)
+ {
+ if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
+ eDebug("FE_READ_STATUS failed (%m)");
+ return !!(status&FE_HAS_LOCK);
+ }
+ return 1;
}
case synced:
{
#else
fe_status_t status;
#endif
- if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
- eDebug("FE_READ_STATUS failed (%m)");
- return !!(status&FE_HAS_SYNC);
+ if (!m_simulate)
+ {
+ if ( ioctl(m_fd, FE_READ_STATUS, &status) < 0 && errno != ERANGE )
+ eDebug("FE_READ_STATUS failed (%m)");
+ return !!(status&FE_HAS_SYNC);
+ }
+ return 1;
}
case frontendNumber:
return m_slotid;
void eDVBFrontend::getTransponderData(ePyObject dest, bool original)
{
- if (m_fd != -1 && dest && PyDict_Check(dest))
+ if (dest && PyDict_Check(dest))
{
switch(m_type)
{
case feTerrestrial:
{
FRONTENDPARAMETERS front;
- if (!original && ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
- eDebug("FE_GET_FRONTEND (%m)");
+ if (!original)
+ {
+ if (!m_simulate && m_fd != -1 && ioctl(m_fd, FE_GET_FRONTEND, &front)<0)
+ eDebug("FE_GET_FRONTEND (%m)");
+ }
else
{
const FRONTENDPARAMETERS &parm = original ? this->parm : front;
#endif
int eDVBFrontend::readInputpower()
{
+ if (m_simulate)
+ return 0;
int power=m_slotid; // this is needed for read inputpower from the correct tuner !
char proc_name[64];
sprintf(proc_name, "/proc/stb/fp/lnb_sense%d", m_slotid);
bool eDVBFrontend::setSecSequencePos(int steps)
{
- eDebug("set sequence pos %d", steps);
+ eDebugNoSimulate("set sequence pos %d", steps);
if (!steps)
return false;
while( steps > 0 )
if ( m_sec_sequence && m_sec_sequence.current() != m_sec_sequence.end() )
{
long *sec_fe_data = sec_fe->m_data;
-// eDebug("tuneLoop %d\n", m_sec_sequence.current()->cmd);
+// eDebugNoSimulate("tuneLoop %d\n", m_sec_sequence.current()->cmd);
switch (m_sec_sequence.current()->cmd)
{
case eSecCommand::SLEEP:
delay = m_sec_sequence.current()++->msec;
- eDebug("[SEC] sleep %dms", delay);
+ eDebugNoSimulate("[SEC] sleep %dms", delay);
break;
case eSecCommand::GOTO:
if ( !setSecSequencePos(m_sec_sequence.current()->steps) )
case eSecCommand::SET_VOLTAGE:
{
int voltage = m_sec_sequence.current()++->voltage;
- eDebug("[SEC] setVoltage %d", voltage);
+ eDebugNoSimulate("[SEC] setVoltage %d", voltage);
sec_fe->setVoltage(voltage);
break;
}
break;
}
case eSecCommand::SET_TONE:
- eDebug("[SEC] setTone %d", m_sec_sequence.current()->tone);
+ eDebugNoSimulate("[SEC] setTone %d", m_sec_sequence.current()->tone);
sec_fe->setTone(m_sec_sequence.current()++->tone);
break;
case eSecCommand::SEND_DISEQC:
sec_fe->sendDiseqc(m_sec_sequence.current()->diseqc);
- eDebugNoNewLine("[SEC] sendDiseqc: ");
+ eDebugNoSimulateNoNewLine("[SEC] sendDiseqc: ");
for (int i=0; i < m_sec_sequence.current()->diseqc.len; ++i)
- eDebugNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]);
- eDebug("");
+ eDebugNoSimulateNoNewLine("%02x", m_sec_sequence.current()->diseqc.data[i]);
+ eDebugNoSimulate("");
++m_sec_sequence.current();
break;
case eSecCommand::SEND_TONEBURST:
- eDebug("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
+ eDebugNoSimulate("[SEC] sendToneburst: %d", m_sec_sequence.current()->toneburst);
sec_fe->sendToneburst(m_sec_sequence.current()++->toneburst);
break;
case eSecCommand::SET_FRONTEND:
- eDebug("[SEC] setFrontend");
+ eDebugNoSimulate("[SEC] setFrontend");
setFrontend();
++m_sec_sequence.current();
break;
case eSecCommand::START_TUNE_TIMEOUT:
{
- m_timeout->start(m_sec_sequence.current()->timeout, 1);
+ if (!m_simulate)
+ m_timeout->start(m_sec_sequence.current()->timeout, 1);
++m_sec_sequence.current();
break;
}
case eSecCommand::SET_TIMEOUT:
m_timeoutCount = m_sec_sequence.current()++->val;
- eDebug("[SEC] set timeout %d", m_timeoutCount);
+ eDebugNoSimulate("[SEC] set timeout %d", m_timeoutCount);
break;
case eSecCommand::IF_TIMEOUT_GOTO:
if (!m_timeoutCount)
{
- eDebug("[SEC] rotor timout");
+ eDebugNoSimulate("[SEC] rotor timout");
setSecSequencePos(m_sec_sequence.current()->steps);
}
else
if ( idx == 0 || idx == 1 )
{
m_idleInputpower[idx] = sec_fe->readInputpower();
- eDebug("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
+ eDebugNoSimulate("[SEC] idleInputpower[%d] is %d", idx, m_idleInputpower[idx]);
}
else
- eDebug("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
+ eDebugNoSimulate("[SEC] idleInputpower measure index(%d) out of bound !!!", idx);
break;
}
case eSecCommand::IF_MEASURE_IDLE_WAS_NOT_OK_GOTO:
{
eSecCommand::pair &compare = m_sec_sequence.current()->compare;
int idx = compare.val;
- if ( idx == 0 || idx == 1 )
+ if ( !m_simulate && (idx == 0 || idx == 1) )
{
int idle = sec_fe->readInputpower();
int diff = abs(idle-m_idleInputpower[idx]);
if ( diff > 0)
{
- eDebug("measure idle(%d) was not okay.. (%d - %d = %d) retry", idx, m_idleInputpower[idx], idle, diff);
+ eDebugNoSimulate("measure idle(%d) was not okay.. (%d - %d = %d) retry", idx, m_idleInputpower[idx], idle, diff);
setSecSequencePos(compare.steps);
break;
}
}
case eSecCommand::IF_TUNER_LOCKED_GOTO:
{
+ eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
+ if (m_simulate)
+ {
+ setSecSequencePos(cmd.steps);
+ break;
+ }
int signal = 0;
int isLocked = readFrontendData(locked);
m_idleInputpower[0] = m_idleInputpower[1] = 0;
- eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
if (isLocked && ((abs((signal = readFrontendData(signalQualitydB)) - cmd.lastSignal) < 50) || !cmd.lastSignal))
{
if (cmd.lastSignal)
- eDebug("[SEC] locked step %d ok (%d %d)", cmd.okcount, signal, cmd.lastSignal);
+ eDebugNoSimulate("[SEC] locked step %d ok (%d %d)", cmd.okcount, signal, cmd.lastSignal);
else
{
- eDebug("[SEC] locked step %d ok", cmd.okcount);
+ eDebugNoSimulate("[SEC] locked step %d ok", cmd.okcount);
cmd.lastSignal = signal;
}
++cmd.okcount;
if (cmd.okcount > 4)
{
- eDebug("ok > 4 .. goto %d\n",cmd.steps);
+ eDebugNoSimulate("ok > 4 .. goto %d\n",cmd.steps);
setSecSequencePos(cmd.steps);
m_state = stateLock;
m_stateChanged(this);
else
{
if (isLocked)
- eDebug("[SEC] rotor locked step %d failed (oldSignal %d, curSignal %d)", cmd.okcount, signal, cmd.lastSignal);
+ eDebugNoSimulate("[SEC] rotor locked step %d failed (oldSignal %d, curSignal %d)", cmd.okcount, signal, cmd.lastSignal);
else
- eDebug("[SEC] rotor locked step %d failed (not locked)", cmd.okcount);
+ eDebugNoSimulate("[SEC] rotor locked step %d failed (not locked)", cmd.okcount);
--m_timeoutCount;
if (!m_timeoutCount && m_retryCount > 0)
--m_retryCount;
}
case eSecCommand::MEASURE_RUNNING_INPUTPOWER:
m_runningInputpower = sec_fe->readInputpower();
- eDebug("[SEC] runningInputpower is %d", m_runningInputpower);
+ eDebugNoSimulate("[SEC] runningInputpower is %d", m_runningInputpower);
++m_sec_sequence.current();
break;
case eSecCommand::SET_ROTOR_MOVING:
- m_sec->setRotorMoving(true);
+ if (!m_simulate)
+ m_sec->setRotorMoving(true);
++m_sec_sequence.current();
break;
case eSecCommand::SET_ROTOR_STOPPED:
- m_sec->setRotorMoving(false);
+ if (!m_simulate)
+ m_sec->setRotorMoving(false);
++m_sec_sequence.current();
break;
case eSecCommand::IF_INPUTPOWER_DELTA_GOTO:
{
- int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1];
eSecCommand::rotor &cmd = m_sec_sequence.current()->measure;
+ if (m_simulate)
+ {
+ setSecSequencePos(cmd.steps);
+ break;
+ }
+ int idleInputpower = m_idleInputpower[ (sec_fe_data[CUR_VOLTAGE]&1) ? 0 : 1];
const char *txt = cmd.direction ? "running" : "stopped";
- eDebug("[SEC] waiting for rotor %s %d, idle %d, delta %d",
+ eDebugNoSimulate("[SEC] waiting for rotor %s %d, idle %d, delta %d",
txt,
m_runningInputpower,
idleInputpower,
|| (!cmd.direction && abs(m_runningInputpower - idleInputpower) <= cmd.deltaA) )
{
++cmd.okcount;
- eDebug("[SEC] rotor %s step %d ok", txt, cmd.okcount);
+ eDebugNoSimulate("[SEC] rotor %s step %d ok", txt, cmd.okcount);
if ( cmd.okcount > 6 )
{
- eDebug("[SEC] rotor is %s", txt);
+ eDebugNoSimulate("[SEC] rotor is %s", txt);
if (setSecSequencePos(cmd.steps))
break;
}
}
else
{
- eDebug("[SEC] rotor not %s... reset counter.. increase timeout", txt);
+ eDebugNoSimulate("[SEC] rotor not %s... reset counter.. increase timeout", txt);
--m_timeoutCount;
if (!m_timeoutCount && m_retryCount > 0)
--m_retryCount;
++m_sec_sequence.current();
break;
case eSecCommand::INVALIDATE_CURRENT_SWITCHPARMS:
- eDebug("[SEC] invalidate current switch params");
+ eDebugNoSimulate("[SEC] invalidate current switch params");
sec_fe_data[CSW] = -1;
sec_fe_data[UCSW] = -1;
sec_fe_data[TONEBURST] = -1;
sec_fe_data[CSW] = sec_fe_data[NEW_CSW];
sec_fe_data[UCSW] = sec_fe_data[NEW_UCSW];
sec_fe_data[TONEBURST] = sec_fe_data[NEW_TONEBURST];
- eDebug("[SEC] update current switch params");
+ eDebugNoSimulate("[SEC] update current switch params");
++m_sec_sequence.current();
break;
case eSecCommand::INVALIDATE_CURRENT_ROTORPARMS:
- eDebug("[SEC] invalidate current rotorparams");
+ eDebugNoSimulate("[SEC] invalidate current rotorparams");
sec_fe_data[ROTOR_CMD] = -1;
sec_fe_data[ROTOR_POS] = -1;
++m_sec_sequence.current();
case eSecCommand::UPDATE_CURRENT_ROTORPARAMS:
sec_fe_data[ROTOR_CMD] = sec_fe_data[NEW_ROTOR_CMD];
sec_fe_data[ROTOR_POS] = sec_fe_data[NEW_ROTOR_POS];
- eDebug("[SEC] update current rotorparams %d %04lx %ld", m_timeoutCount, sec_fe_data[ROTOR_CMD], sec_fe_data[ROTOR_POS]);
+ eDebugNoSimulate("[SEC] update current rotorparams %d %04lx %ld", m_timeoutCount, sec_fe_data[ROTOR_CMD], sec_fe_data[ROTOR_POS]);
++m_sec_sequence.current();
break;
case eSecCommand::SET_ROTOR_DISEQC_RETRYS:
m_retryCount = m_sec_sequence.current()++->val;
- eDebug("[SEC] set rotor retries %d", m_retryCount);
+ eDebugNoSimulate("[SEC] set rotor retries %d", m_retryCount);
break;
case eSecCommand::IF_NO_MORE_ROTOR_DISEQC_RETRYS_GOTO:
if (!m_retryCount)
{
- eDebug("[SEC] no more rotor retrys");
+ eDebugNoSimulate("[SEC] no more rotor retrys");
setSecSequencePos(m_sec_sequence.current()->steps);
}
else
break;
case eSecCommand::SET_POWER_LIMITING_MODE:
{
- char proc_name[64];
- sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", sec_fe->m_dvbid);
- FILE *f=fopen(proc_name, "w");
- if (f) // new interface exist?
+ if (!m_simulate)
{
- bool slimiting = m_sec_sequence.current()->mode == eSecCommand::modeStatic;
- if (fprintf(f, "%s", slimiting ? "on" : "off") <= 0)
- eDebug("write %s failed!! (%m)", proc_name);
- else
- eDebug("[SEC] set %s current limiting", slimiting ? "static" : "dynamic");
- fclose(f);
- }
- else if (sec_fe->m_need_rotor_workaround)
- {
- char dev[16];
- int slotid = sec_fe->m_slotid;
- // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
- if (slotid < 2)
- sprintf(dev, "/dev/i2c/%d", slotid);
- else if (slotid == 2)
- sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2
- else if (slotid == 3)
- sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4
- int fd = ::open(dev, O_RDWR);
-
- unsigned char data[2];
- ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
- if(::read(fd, data, 1) != 1)
- eDebug("[SEC] error read lnbp (%m)");
- if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
+ char proc_name[64];
+ sprintf(proc_name, "/proc/stb/frontend/%d/static_current_limiting", sec_fe->m_dvbid);
+ FILE *f=fopen(proc_name, "w");
+ if (f) // new interface exist?
{
- data[0] |= 0x80; // enable static current limiting
- eDebug("[SEC] set static current limiting");
+ bool slimiting = m_sec_sequence.current()->mode == eSecCommand::modeStatic;
+ if (fprintf(f, "%s", slimiting ? "on" : "off") <= 0)
+ eDebugNoSimulate("write %s failed!! (%m)", proc_name);
+ else
+ eDebugNoSimulate("[SEC] set %s current limiting", slimiting ? "static" : "dynamic");
+ fclose(f);
}
- else
+ else if (sec_fe->m_need_rotor_workaround)
{
- data[0] &= ~0x80; // enable dynamic current limiting
- eDebug("[SEC] set dynamic current limiting");
+ char dev[16];
+ int slotid = sec_fe->m_slotid;
+ // FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
+ if (slotid < 2)
+ sprintf(dev, "/dev/i2c/%d", slotid);
+ else if (slotid == 2)
+ sprintf(dev, "/dev/i2c/2"); // first nim socket on DM8000 use /dev/i2c/2
+ else if (slotid == 3)
+ sprintf(dev, "/dev/i2c/4"); // second nim socket on DM8000 use /dev/i2c/4
+ int fd = ::open(dev, O_RDWR);
+
+ unsigned char data[2];
+ ::ioctl(fd, I2C_SLAVE_FORCE, 0x10 >> 1);
+ if(::read(fd, data, 1) != 1)
+ eDebugNoSimulate("[SEC] error read lnbp (%m)");
+ if ( m_sec_sequence.current()->mode == eSecCommand::modeStatic )
+ {
+ data[0] |= 0x80; // enable static current limiting
+ eDebugNoSimulate("[SEC] set static current limiting");
+ }
+ else
+ {
+ data[0] &= ~0x80; // enable dynamic current limiting
+ eDebugNoSimulate("[SEC] set dynamic current limiting");
+ }
+ if(::write(fd, data, 1) != 1)
+ eDebugNoSimulate("[SEC] error write lnbp (%m)");
+ ::close(fd);
}
- if(::write(fd, data, 1) != 1)
- eDebug("[SEC] error write lnbp (%m)");
- ::close(fd);
}
++m_sec_sequence.current();
break;
}
default:
- eDebug("[SEC] unhandled sec command %d",
+ eDebugNoSimulate("[SEC] unhandled sec command %d",
++m_sec_sequence.current()->cmd);
++m_sec_sequence.current();
}
- m_tuneTimer->start(delay,true);
+ if (!m_simulate)
+ m_tuneTimer->start(delay,true);
}
if (regFE)
regFE->dec_use();
+ if (m_simulate && m_sec_sequence.current() != m_sec_sequence.end())
+ tuneLoop();
}
void eDVBFrontend::setFrontend()
{
- eDebug("setting frontend %d", m_dvbid);
- m_sn->start();
- feEvent(-1);
- if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
+ if (!m_simulate)
{
- perror("FE_SET_FRONTEND failed");
- return;
+ eDebug("setting frontend %d", m_dvbid);
+ m_sn->start();
+ feEvent(-1);
+ if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
+ {
+ perror("FE_SET_FRONTEND failed");
+ return;
+ }
}
}
res = m_sec->prepare(*this, parm, feparm, 1 << m_slotid, tunetimeout);
if (!res)
{
- eDebug("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d",
+ eDebugNoSimulate("prepare_sat System %d Freq %d Pol %d SR %d INV %d FEC %d orbpos %d",
feparm.system,
feparm.frequency,
feparm.polarisation,
parm_u_qpsk_fec_inner = FEC_7_8;
break;
default:
- eDebug("no valid fec for DVB-S set.. assume auto");
+ eDebugNoSimulate("no valid fec for DVB-S set.. assume auto");
case eDVBFrontendParametersSatellite::FEC::fAuto:
parm_u_qpsk_fec_inner = FEC_AUTO;
break;
parm_u_qpsk_fec_inner = FEC_S2_QPSK_9_10;
break;
default:
- eDebug("no valid fec for DVB-S2 set.. abort !!");
+ eDebugNoSimulate("no valid fec for DVB-S2 set.. abort !!");
return -EINVAL;
}
parm_inversion |= (feparm.rolloff << 2); // Hack.. we use bit 2..3 of inversion param for rolloff
// FIXME !!! get frequency range from tuner
if ( parm_frequency < 900000 || parm_frequency > 2200000 )
{
- eDebug("%d mhz out of tuner range.. dont tune", parm_frequency/1000);
+ eDebugNoSimulate("%d mhz out of tuner range.. dont tune", parm_frequency/1000);
return -EINVAL;
}
- eDebug("tuning to %d mhz", parm_frequency/1000);
+ eDebugNoSimulate("tuning to %d mhz", parm_frequency/1000);
}
return res;
}
parm_u_qam_fec_inner = FEC_AUTO;
break;
}
- eDebug("tuning to %d khz, sr %d, fec %d, modulation %d, inversion %d",
+ eDebugNoSimulate("tuning to %d khz, sr %d, fec %d, modulation %d, inversion %d",
parm_frequency/1000,
parm_u_qam_symbol_rate,
parm_u_qam_fec_inner,
RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
{
unsigned int timeout = 5000;
- eDebug("(%d)tune", m_dvbid);
+ eDebugNoSimulate("(%d)tune", m_dvbid);
m_timeout->stop();
int res=0;
- if (!m_sn)
+ if (!m_sn && !m_simulate)
{
eDebug("no frontend device opened... do not try to tune !!!");
res = -ENODEV;
goto tune_error;
}
- m_sn->stop();
+ if (!m_simulate)
+ m_sn->stop();
+
m_sec_sequence.clear();
where.calcLockTimeout(timeout);
res = -EINVAL;
goto tune_error;
}
- m_sec->setRotorMoving(false);
+ if (!m_simulate)
+ m_sec->setRotorMoving(false);
res=prepare_sat(feparm, timeout);
if (res)
goto tune_error;
}
}
- m_tuneTimer->start(0,true);
m_sec_sequence.current() = m_sec_sequence.begin();
- if (m_state != stateTuning)
+ if (!m_simulate)
{
- m_tuning = 1;
- m_state = stateTuning;
- m_stateChanged(this);
+ m_tuneTimer->start(0,true);
+ if (m_state != stateTuning)
+ {
+ m_tuning = 1;
+ m_state = stateTuning;
+ m_stateChanged(this);
+ }
}
+ else
+ tuneLoop();
return res;
default:
return -ENODEV;
}
+ if (m_simulate)
+ return 0;
#if HAVE_DVB_API_VERSION < 3
return ::ioctl(m_secfd, SEC_SET_VOLTAGE, vlt);
#else
default:
return -ENODEV;
}
+ if (m_simulate)
+ return 0;
#if HAVE_DVB_API_VERSION < 3
return ::ioctl(m_secfd, SEC_SET_TONE, tone);
#else
RESULT eDVBFrontend::sendDiseqc(const eDVBDiseqcCommand &diseqc)
{
+ if (m_simulate)
+ return 0;
#if HAVE_DVB_API_VERSION < 3
struct secCommand cmd;
cmd.type = SEC_CMDTYPE_DISEQC_RAW;
#endif
RESULT eDVBFrontend::sendToneburst(int burst)
{
+ if (m_simulate)
+ return 0;
#if HAVE_DVB_API_VERSION < 3
secMiniCmd cmd = SEC_MINI_NONE;
#else
!!strstr(m_description, "Alps -S") ||
!!strstr(m_description, "BCM4501");
m_can_handle_dvbs2 = IsDVBS2 == Py_True;
- eDebug("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s, DVB-S2 %s",
+ eDebugNoSimulate("setSlotInfo for dvb frontend %d to slotid %d, descr %s, need rotorworkaround %s, enabled %s, DVB-S2 %s",
m_dvbid, m_slotid, m_description, m_need_rotor_workaround ? "Yes" : "No", m_enabled ? "Yes" : "No", m_can_handle_dvbs2 ? "Yes" : "No" );
return true;
arg_error:
Signal1<void,iDVBFrontend*> m_stateChanged;
private:
DECLARE_REF(eDVBFrontend);
+ bool m_simulate;
bool m_enabled;
int m_type;
int m_dvbid;
bool setSecSequencePos(int steps);
static int PriorityOrder;
public:
- eDVBFrontend(int adap, int fe, int &ok);
+ eDVBFrontend(int adap, int fe, int &ok, bool simulate=false);
virtual ~eDVBFrontend();
int readInputpower();
int openFrontend();
int closeFrontend(bool force=false);
const char *getDescription() const { return m_description; }
+ bool is_simulate() const { return m_simulate; }
};
#endif // SWIG
}
}
-int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue)
+int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue, bool simulate)
{
- RESULT res;
+ RESULT res=0;
m_reference = ref;
m_use_decode_demux = use_decode_demux;
{
eDVBChannelID chid;
ref.getChannelID(chid);
- res = m_resourceManager->allocateChannel(chid, m_channel);
- eDebug("allocate Channel: res %d", res);
+ res = m_resourceManager->allocateChannel(chid, m_channel, simulate);
+ if (!simulate)
+ eDebug("allocate Channel: res %d", res);
ePtr<iDVBChannelList> db;
if (!m_resourceManager->getChannelList(db))
- db->getService((eServiceReferenceDVB&)m_reference, m_service);
+ db->getService((eServiceReferenceDVB&)m_reference, m_service);
- if (!res)
+ if (!res && !simulate)
eDVBCIInterfaces::getInstance()->addPMTHandler(this);
- } else
+ } else if (!simulate) // no simulation of playback services
{
eDVBMetaParser parser;
m_channel = m_pvr_channel;
}
- if (m_channel)
+ if (!simulate)
{
- m_channel->connectStateChange(
- slot(*this, &eDVBServicePMTHandler::channelStateChanged),
- m_channelStateChanged_connection);
- m_last_channel_state = -1;
- channelStateChanged(m_channel);
-
- m_channel->connectEvent(
- slot(*this, &eDVBServicePMTHandler::channelEvent),
- m_channelEvent_connection);
+ if (m_channel)
+ {
+ m_channel->connectStateChange(
+ slot(*this, &eDVBServicePMTHandler::channelStateChanged),
+ m_channelStateChanged_connection);
+ m_last_channel_state = -1;
+ channelStateChanged(m_channel);
+
+ m_channel->connectEvent(
+ slot(*this, &eDVBServicePMTHandler::channelEvent),
+ m_channelEvent_connection);
- if (ref.path.empty())
+ if (ref.path.empty())
+ {
+ delete m_dvb_scan;
+ m_dvb_scan = new eDVBScan(m_channel, true, false);
+ m_dvb_scan->connectEvent(slot(*this, &eDVBServicePMTHandler::SDTScanEvent), m_scan_event_connection);
+ }
+ } else
{
- delete m_dvb_scan;
- m_dvb_scan = new eDVBScan(m_channel, true, false);
- m_dvb_scan->connectEvent(slot(*this, &eDVBServicePMTHandler::SDTScanEvent), m_scan_event_connection);
+ if (res == eDVBResourceManager::errAllSourcesBusy)
+ serviceEvent(eventNoResources);
+ else /* errChidNotFound, errNoChannelList, errChannelNotInList, errNoSourceFound */
+ serviceEvent(eventMisconfiguration);
+ return res;
}
- } else
- {
- if (res == eDVBResourceManager::errAllSourcesBusy)
- serviceEvent(eventNoResources);
- else /* errChidNotFound, errNoChannelList, errChannelNotInList, errNoSourceFound */
- serviceEvent(eventMisconfiguration);
- return res;
- }
- if (m_pvr_channel)
- {
- m_pvr_channel->setCueSheet(cue);
- m_pvr_channel->playFile(ref.path.c_str());
+ if (m_pvr_channel)
+ {
+ m_pvr_channel->setCueSheet(cue);
+ m_pvr_channel->playFile(ref.path.c_str());
+ }
}
return res;
m_pvr_channel->stopFile();
m_pvr_channel->setCueSheet(0);
}
+
m_PMT.stop();
m_PAT.stop();
m_service = 0;
int getChannel(eUsePtr<iDVBChannel> &channel);
void resetCachedProgram() { m_have_cached_program = false; }
- int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0);
+ int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false);
void free();
private:
bool m_have_cached_program;
m_params[param]=value;
}
-eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends)
- :m_lnbidx(-1), m_curSat(m_lnbs[0].m_satellites.end()), m_avail_frontends(avail_frontends), m_rotorMoving(false)
+eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends)
+ :m_lnbidx(-1), m_curSat(m_lnbs[0].m_satellites.end()), m_avail_frontends(avail_frontends), m_avail_simulate_frontends(avail_simulate_frontends), m_rotorMoving(false)
{
if (!instance)
instance = this;
setRotorPosNum(1); // stored pos 1
}
+#define eSecDebugNoSimulate(x...) \
+ do { \
+ if (!simulate) \
+ eSecDebug(x); \
+ } while(0)
+// else \
+// { \
+// eDebugNoNewLine("SIMULATE:"); \
+// eDebug(x); \
+// } \
+
int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int slot_id, int *highest_score_lnb)
{
+ bool simulate = ((eDVBFrontend*)fe)->is_simulate();
int score=0, satcount=0;
if (highest_score_lnb)
*highest_score_lnb = -1;
+ eSecDebugNoSimulate("canTune %d", slot_id);
+
for (int idx=0; idx <= m_lnbidx; ++idx )
{
bool rotor=false;
int ret = 0;
eDVBSatelliteDiseqcParameters &di_param = lnb_param.m_diseqc_parameters;
+ eSecDebugNoSimulate("lnb %d found", idx);
+
satcount += lnb_param.m_satellites.size();
std::map<int, eDVBSatelliteSwitchParameters>::iterator sit =
toneburst = di_param.m_toneburst_param,
curRotorPos;
+ eSecDebugNoSimulate("sat %d found", sat.orbital_position);
fe->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
fe->getData(eDVBFrontend::SATPOS_DEPENDS_PTR, satpos_depends_ptr);
ret = 15000;
}
+ eSecDebugNoSimulate("ret1 %d", ret);
+
if (direct_connected) // frontend with direct connection?
{
long ocsw = -1,
oucsw = -1,
oToneburst = -1;
+ eSecDebugNoSimulate("direct");
fe->getData(eDVBFrontend::ROTOR_POS, curRotorPos);
fe->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
fe->getData(eDVBFrontend::CSW, ocsw);
}
linked_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
}
+ eSecDebugNoSimulate("ret2 %d", ret);
while (ret && linked_next_ptr != -1) // check for linked tuners..
{
eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*) linked_next_ptr;
}
linked_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, (long&)linked_next_ptr);
}
+ eSecDebugNoSimulate("ret3 %d", ret);
}
else // linked frontend..
{
sec_fe->getData(eDVBFrontend::CSW, ocsw);
sec_fe->getData(eDVBFrontend::UCSW, oucsw);
sec_fe->getData(eDVBFrontend::TONEBURST, oToneburst);
+ eSecDebug("(%ld != %ld) || \n(%d && (%ld != %ld || %ld != %ld) ) ||\n( %d && %ld != %d ) )",
+ csw, ocsw, diseqc, ucsw, oucsw, toneburst, oToneburst, rotor, curRotorPos, sat.orbital_position);
if ( (csw != ocsw) ||
( diseqc && (ucsw != oucsw || toneburst != oToneburst) ) ||
( rotor && curRotorPos != sat.orbital_position ) )
}
}
}
+ eSecDebugNoSimulate("ret4 %d", ret);
}
if (ret && rotor && curRotorPos != -1 && direct_connected) {
ret -= abs(curRotorPos-sat.orbital_position);
}
+ eSecDebugNoSimulate("ret5 %d", ret);
+
if (ret)
if (satpos_depends_ptr != -1)
{
+ eSecDebugNoSimulate("satpos depends");
eDVBRegisteredFrontend *satpos_depends_to_fe = (eDVBRegisteredFrontend*) satpos_depends_ptr;
if ( satpos_depends_to_fe->m_inuse )
{
if (!rotor || curRotorPos != sat.orbital_position)
ret=0;
}
+ eSecDebugNoSimulate("ret6 %d", ret);
}
if (ret)
ret=0;
}
+ eSecDebugNoSimulate("ret %d, score old %d", ret, score);
if (ret > score)
{
score = ret;
if (highest_score_lnb)
*highest_score_lnb = idx;
}
+ eSecDebugNoSimulate("score new %d", score);
}
}
}
score -= (satcount-1);
if (score && m_not_linked_slot_mask & slot_id)
score += 5; // increase score for tuners with direct sat connection
+ eSecDebugNoSimulate("final score %d", score);
return score;
}
#define VOLTAGE(x) (lnb_param.m_increased_voltage ? iDVBFrontend::voltage##x##_5 : iDVBFrontend::voltage##x)
+#define eDebugNoSimulate(x...) \
+ do { \
+ if (!simulate) \
+ eDebug(x); \
+ } while(0)
+// else \
+// { \
+// eDebugNoNewLine("SIMULATE:"); \
+// eDebug(x); \
+// } \
+
RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int slot_id, unsigned int tunetimeout)
{
+ bool simulate = ((eDVBFrontend*)&frontend)->is_simulate();
int lnb_idx = -1;
if (canTune(sat, &frontend, slot_id, &lnb_idx))
{
&& di_param.m_committed_cmd < eDVBSatelliteDiseqcParameters::SENDNO
&& (lastcsw & 0xF0)
&& ((csw / 4) == (lastcsw / 4)) )
- eDebug("dont send committed cmd (fast diseqc)");
+ eDebugNoSimulate("dont send committed cmd (fast diseqc)");
else
{
send_mask |= 1;
RotorCmd=sw_param.m_rotorPosNum;
else // we must calc gotoxx cmd
{
- eDebug("Entry for %d,%d? not in Rotor Table found... i try gotoXX?", sat.orbital_position / 10, sat.orbital_position % 10 );
+ eDebugNoSimulate("Entry for %d,%d? not in Rotor Table found... i try gotoXX?", sat.orbital_position / 10, sat.orbital_position % 10 );
useGotoXX = true;
double SatLon = abs(sat.orbital_position)/10.00,
if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST )
SiteLon = 360 - SiteLon;
- eDebug("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
+ eDebugNoSimulate("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon );
double satHourAngle =
calcSatHourangle( SatLon, SiteLat, SiteLon );
- eDebug("PolarmountHourAngle=%lf", satHourAngle );
+ eDebugNoSimulate("PolarmountHourAngle=%lf", satHourAngle );
static int gotoXTable[10] =
{ 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
RotorCmd |= 0xE000;
}
}
- eDebug("RotorCmd = %04x", RotorCmd);
+ eDebugNoSimulate("RotorCmd = %04x", RotorCmd);
}
}
sendDiSEqC = true;
}
- eDebug("RotorCmd %02x, lastRotorCmd %02lx", RotorCmd, lastRotorCmd);
+ eDebugNoSimulate("RotorCmd %02x, lastRotorCmd %02lx", RotorCmd, lastRotorCmd);
if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
{
eSecCommand::pair compare;
return 0;
}
}
- eDebug("found no useable satellite configuration for %s freq %d%s %s on orbital position (%d)",
+ eDebugNoSimulate("found no useable satellite configuration for %s freq %d%s %s on orbital position (%d)",
sat.system ? "DVB-S2" : "DVB-S",
sat.frequency,
sat.polarisation == eDVBFrontendParametersSatellite::Polarisation::Horizontal ? "H" :
it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
}
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ it->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_POS, -1);
+ it->m_frontend->setData(eDVBFrontend::ROTOR_CMD, -1);
+ }
+
return 0;
}
fclose(f);
}
}
+ }
+
+ p1=p2=NULL;
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)p1);
return 0;
}
}
p2 = *it;
}
if (p1 && p2)
+ {
+ p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
+ p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
+ }
+
+ p1=p2=NULL;
+ for (eSmartPtrList<eDVBRegisteredFrontend>::iterator it(m_avail_simulate_frontends.begin()); it != m_avail_simulate_frontends.end(); ++it)
+ {
+ if (it->m_frontend->getSlotID() == tu1)
+ p1 = *it;
+ else if (it->m_frontend->getSlotID() == tu2)
+ p2 = *it;
+ }
+ if (p1 && p2)
{
p1->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p2);
p2->m_frontend->setData(eDVBFrontend::SATPOS_DEPENDS_PTR, (long)p1);
return 0;
}
+
return -1;
}
eDVBSatelliteLNBParameters m_lnbs[144]; // i think its enough
int m_lnbidx; // current index for set parameters
std::map<int, eDVBSatelliteSwitchParameters>::iterator m_curSat;
- eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends;
+ eSmartPtrList<eDVBRegisteredFrontend> &m_avail_frontends, &m_avail_simulate_frontends;
bool m_rotorMoving;
int m_not_linked_slot_mask;
bool m_canMeasureInputPower;
static int m_params[MAX_PARAMS];
public:
#ifndef SWIG
- eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends);
+ eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBRegisteredFrontend> &avail_frontends, eSmartPtrList<eDVBRegisteredFrontend> &avail_simulate_frontends);
RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id, unsigned int tunetimeout);
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)); }
// eDebug("use_count is now %d", slot->use_count);
slot = next;
}
+ // check if another service is waiting for the CI
+ recheckPMTHandlers();
}
- // check if another service is waiting for the CI
- recheckPMTHandlers();
}
void eDVBCIInterfaces::gotPMT(eDVBServicePMTHandler *pmthandler)
virtual SWIG_VOID(RESULT) getError(int &SWIG_OUTPUT)=0;
virtual RESULT prepare(const char *filename, time_t begTime=-1, time_t endTime=-1, int eit_event_id=-1)=0;
virtual RESULT prepareStreaming()=0;
- virtual RESULT start()=0;
+ virtual RESULT start(bool simulate=false)=0;
virtual RESULT stop()=0;
virtual SWIG_VOID(RESULT) frontendInfo(ePtr<iFrontendInformation> &SWIG_OUTPUT)=0;
virtual SWIG_VOID(RESULT) stream(ePtr<iStreamableService> &SWIG_OUTPUT)=0;
case iTSMPEGDecoder::videoEvent::eventProgressiveChanged:
m_event((iPlayableService*)this, evVideoProgressiveChanged);
break;
+ default:
+ break;
}
}
m_target_fd = -1;
m_error = 0;
m_streaming = 0;
+ m_simulate = false;
}
void eDVBServiceRecord::serviceEvent(int event)
return -1;
}
-RESULT eDVBServiceRecord::start()
+RESULT eDVBServiceRecord::start(bool simulate)
{
+ m_simulate = simulate;
m_want_record = 1;
/* when tune wasn't yet successfully, doRecord stays in "prepared"-state which is fine. */
m_event((iRecordableService*)this, evStart);
return doRecord();
}
-
RESULT eDVBServiceRecord::stop()
{
- eDebug("stop recording!");
+ if (!m_simulate)
+ eDebug("stop recording!");
if (m_state == stateRecording)
{
if (m_record)
m_target_fd = -1;
}
m_state = statePrepared;
- } else
+ } else if (!m_simulate)
eDebug("(was not recording)");
if (m_state == statePrepared)
{
return 0;
}
-
int eDVBServiceRecord::doPrepare()
{
/* allocate a ts recorder if we don't already have one. */
{
m_pids_active.clear();
m_state = statePrepared;
- return m_service_handler.tune(m_ref, 0);
+ return m_service_handler.tune(m_ref, 0, 0, m_simulate);
}
return 0;
}
if (!m_tuned)
return 0; /* try it again when we are tuned in */
- if (!m_record && m_tuned && !m_streaming)
+ if (!m_record && m_tuned && !m_streaming && !m_simulate)
{
eDebug("Recording to %s...", m_filename.c_str());
::remove(m_filename.c_str());
RESULT connectEvent(const Slot2<void,iRecordableService*,int> &event, ePtr<eConnection> &connection);
RESULT prepare(const char *filename, time_t begTime, time_t endTime, int eit_event_id);
RESULT prepareStreaming();
- RESULT start();
+ RESULT start(bool simulate=false);
RESULT stop();
RESULT stream(ePtr<iStreamableService> &ptr);
RESULT getError(int &error) { error = m_error; return 0; }
private:
enum { stateIdle, statePrepared, stateRecording };
+ bool m_simulate;
int m_state, m_want_record;
friend class eServiceFactoryDVB;
eDVBServiceRecord(const eServiceReferenceDVB &ref);
from enigma import eTimer
import datetime
+import NavigationInstance
+
class TimerEntry:
StateWaiting = 0
StatePrepared = 1
insort(self.timer_list, entry)
if not noRecalc:
self.calcNextActivation()
+
+# small piece of example code to understand how to use record simulation
+# if NavigationInstance.instance:
+# lst = [ ]
+# cnt = 0
+# for timer in self.timer_list:
+# print "timer", cnt
+# cnt += 1
+# if timer.state == 0: #waiting
+# lst.append(NavigationInstance.instance.recordService(timer.service_ref))
+# else:
+# print "STATE: ", timer.state
+#
+# for rec in lst:
+# if rec.start(True): #simulate
+# print "FAILED!!!!!!!!!!!!"
+# else:
+# print "OK!!!!!!!!!!!!!!"
+# NavigationInstance.instance.stopRecordService(rec)
+# else:
+# print "no NAV"
def setNextActivation(self, when):
delay = int((when - time()) * 1000)