void DVBSignalMonitor::GetRotorStatus(bool &was_moving, bool &is_moving) { DVBChannel *dvbchannel = GetDVBChannel(); if (!dvbchannel) return; const DiSEqCDevRotor *rotor = dvbchannel->GetRotor(); if (!rotor) return; QMutexLocker locker(&statusLock); was_moving = rotorPosition.GetValue() < 100; int pos = (int)truncf(rotor->GetProgress() * 100); rotorPosition.SetValue(pos); is_moving = rotorPosition.GetValue() < 100; }
/** \fn DVBSignalMonitor::UpdateValues() * \brief Fills in frontend stats and emits status Qt signals. * * This is automatically called by MonitorLoop(), after Start() * has been used to start the signal monitoring thread. */ void DVBSignalMonitor::UpdateValues(void) { if (!running || exit) return; if (streamHandlerStarted) { if (!streamHandler->IsRunning()) { error = QObject::tr("Error: stream handler died"); update_done = true; return; } EmitStatus(); if (IsAllGood()) SendMessageAllGood(); // TODO dtv signals... update_done = true; return; } AddFlags(kSigMon_WaitForSig); DVBChannel *dvbchannel = GetDVBChannel(); if (!dvbchannel) return; // Handle retuning after rotor has turned if (HasFlags(SignalMonitor::kDVBSigMon_WaitForPos)) { if (dvbchannel->GetRotor()) { if (!streamHandler->IsRetuneAllowed()) streamHandler->SetRetuneAllowed(true, this, dvbchannel); streamHandler->RetuneMonitor(); } else RemoveFlags(SignalMonitor::kDVBSigMon_WaitForPos); } bool wasLocked = false, isLocked = false; uint sig = 0, snr = 0, ber = 0, ublocks = 0; // Get info from card bool has_lock = dvbchannel->HasLock(); if (HasFlags(kSigMon_WaitForSig)) sig = (uint) (dvbchannel->GetSignalStrength() * 65535); if (HasFlags(kDVBSigMon_WaitForSNR)) snr = (uint) (dvbchannel->GetSNR() * 65535); if (HasFlags(kDVBSigMon_WaitForBER)) ber = (uint) dvbchannel->GetBitErrorRate(); if (HasFlags(kDVBSigMon_WaitForUB)) ublocks = (uint) dvbchannel->GetUncorrectedBlockCount(); has_lock |= streamHandler->IsRunning(); // Set SignalMonitorValues from info from card. { QMutexLocker locker(&statusLock); // BER and UB are actually uint32 values, but we // clamp them at 64K. This is because these values // are acutally cumulative, but we don't try to // normalize these to a time period. wasLocked = signalLock.IsGood(); signalLock.SetValue((has_lock) ? 1 : 0); isLocked = signalLock.IsGood(); if (HasFlags(kSigMon_WaitForSig)) signalStrength.SetValue(sig); if (HasFlags(kDVBSigMon_WaitForSNR)) signalToNoise.SetValue(snr); if (HasFlags(kDVBSigMon_WaitForBER)) bitErrorRate.SetValue(ber); if (HasFlags(kDVBSigMon_WaitForUB)) uncorrectedBlocks.SetValue(ublocks); } // Debug output if (wasLocked != isLocked) { VERBOSE(VB_CHANNEL, LOC + "UpdateValues -- Signal " <<(isLocked ? "Locked" : "Lost")); } EmitStatus(); if (IsAllGood()) SendMessageAllGood(); // Start table monitoring if we are waiting on any table // and we have a lock. if (isLocked && GetStreamData() && (!HasFlags(kDVBSigMon_WaitForPos) || rotorPosition.IsGood()) && HasAnyFlag(kDTVSigMon_WaitForPAT | kDTVSigMon_WaitForPMT | kDTVSigMon_WaitForMGT | kDTVSigMon_WaitForVCT | kDTVSigMon_WaitForNIT | kDTVSigMon_WaitForSDT)) { GetStreamData()->AddListeningPID(MPEG_PAT_PID); streamHandler->AddListener(GetStreamData(), true, false); streamHandlerStarted = true; } update_done = true; }