bool EpisodeConverterWorker::initJob(QString path, bool recursive, int targetFormat, int fmtVer) { m_filesToConvert.clear(); m_errorString.clear(); m_episode.setPath(path); m_targetFormat = targetFormat; m_targetFormatVer = fmtVer; if(!m_episode.setCurrent(path)) { m_errorString = tr("Can't resolve path \"%1\"").arg(path); return false; } m_episodeBox.openEpisode(path, recursive); if(m_episodeBox.totalElements()==0) { m_errorString = tr("No files to convert"); return false; } emit totalElements(m_episodeBox.totalElements()); return true; }
void deactivate(void) { //print a short summary of the production auto outputPort = this->output(0); if (_enableBuffers) std::cout << this->getName() << " total bytes " << outputPort->totalElements() << std::endl; if (_enableBuffers) std::cout << this->getName() << " total buffers " << outputPort->totalBuffers() << std::endl; if (_enableLabels) std::cout << this->getName() << " total labels " << outputPort->totalLabels() << std::endl; if (_enableMessages) std::cout << this->getName() << " total messages " << outputPort->totalMessages() << std::endl; }
int main(){ char query[20]; listaCurso *LC=NULL; Pessoa *p=NULL; Query *Q=NULL; int elements; LC=abreFicheiro(LC); printf("Introduza a query: "); scanf("%s",query); Q=splitQuery(query); p=procuraQuery(LC,Q); p=ordena(p); elements=totalElements(p); printf("%d\n",elements); show(p); return (0); }
void NetworkSource::work(void) { const auto timeout = Poco::Timespan(this->workInfo().maxTimeoutNs/1000); auto outputPort = this->output(0); //recv the header, use output buffer when possible for zero-copy Poco::UInt16 type; Poco::UInt64 index; auto buffer = outputPort->buffer(); _ep.recv(type, index, buffer, timeout); //handle the output if (type == PothosPacketTypeBuffer) { _nextExpectedIndex = index + buffer.length; outputPort->popBuffer(buffer.length); outputPort->postBuffer(buffer); } else if (type == PothosPacketTypeMessage) { std::istringstream iss(std::string(buffer.as<char *>(), buffer.length)); Pothos::Object msg; msg.deserialize(iss); outputPort->postMessage(msg); } else if (type == PothosPacketTypeLabel) { std::istringstream iss(std::string(buffer.as<char *>(), buffer.length)); Pothos::Label label; label.index = index + outputPort->totalElements() - _nextExpectedIndex; label.data.deserialize(iss); outputPort->postLabel(label); } else this->yield(); }
void DemoController::work(void) { auto inputPort = this->input(0); auto outputPort = this->output(0); //this block's work routine only reacts to input data if (inputPort->elements() == 0) return; bool sawRxEnd = false; //Handle the input labels, check for time, and end of burst. for (const auto &label : inputPort->labels()) { if (label.id == "rxTime") { //updating the time-stamped hardware time this->handleHardwareTime(label.data.convert<long long>()); //time tracking using the absolute element count _lastRxHardwareTimeNs = label.data.convert<long long>(); _rxTimeLabelIndex = inputPort->totalElements()+label.index; } else if (label.id == "rxRate") { _lastKnownRxRate = label.data.convert<double>(); poco_notice_f1(Poco::Logger::get("DemoController"), "RX rate is %s Msps", std::to_string(_lastKnownRxRate/1e6)); } else if (label.id == "rxEnd") { sawRxEnd = true; } } poco_notice_f2(Poco::Logger::get("DemoController"), "Got %s RX elements @ %s seconds", std::to_string(inputPort->elements()), std::to_string(this->getStreamElementTime(inputPort->totalElements())/1e9)); //The user should do something meaningful with the rx buffer... //const auto &rxBuff = inputPort->buffer(); //consume the entire receive buffer inputPort->consume(inputPort->elements()); //Use the rx end of burst event to trigger new actions: if (sawRxEnd) { //perform a timed tune 0.5 seconds from the end of this burst const auto commandIndex = inputPort->totalElements() + inputPort->elements() + size_t(_lastKnownRxRate/2); const auto commandTimeNs = this->getStreamElementTime(commandIndex); this->callVoid("setCommandTime", commandTimeNs); this->callVoid("setFrequency", 1e9); this->callVoid("setCommandTime", 0); //clear //request a timed burst 1.0 seconds from the end of this burst const auto streamIndex = inputPort->totalElements() + inputPort->elements() + size_t(_lastKnownRxRate); const auto burstTimeNs = this->getStreamElementTime(streamIndex); this->callVoid("streamControl", "ACTIVATE_BURST_AT", burstTimeNs, 100); /*************************************************************** * Transmit an output burst at the same time as the input burst: * The following code shows how to get access to the tx buffer, * and post labels for both transmit time and end of burst. **************************************************************/ //the user should fill tx buffer with something meaningful... const auto numElems = std::min<size_t>(outputPort->elements(), 100); auto &txBuff = outputPort->buffer(); std::memset(txBuff.as<void *>(), 0, numElems*outputPort->dtype().size()); //create a time label at the first index of the buffer outputPort->postLabel(Pothos::Label("txTime", burstTimeNs, 0)); //create an end label at the last index of the buffer outputPort->postLabel(Pothos::Label("txEnd", true, numElems-1)); //produce num elements of the transmit buffer outputPort->produce(numElems); //Alternative custom transmit buffer option: //allocate a buffer: Pothos::BufferChunk txBuff(outputPort->dtype, numElems); //fill the buffer and create labels as usual... //post the buffer: outputPort->postBuffer(txBuff); } }