void MsgProcessor::run() { while (true) { lock_.lock(); int rawmsg_count = message_queue_.count(); lock_.unlock(); if (rawmsg_count == 0) break; Json::Reader reader; Json::Value root; QByteArray unparse_msg = message_queue_.dequeue(); int idx = unparse_msg.indexOf("\r\n\r\n"); unparse_msg = unparse_msg.mid(idx+4); if (!reader.parse(QString(unparse_msg).toStdString(), root, false)) { continue; } qDebug()<<"recive msg"<<QString::fromStdString(root.toStyledString())<<endl; if (root["retcode"].asInt() == 121) { } QVector<QQMsg *> be_sorting_msg; for (unsigned int i = 0; i < root["result"].size(); ++i) { const Json::Value result = root["result"][i]; if ( isMsgRepeat(result) ) continue; QString type = QString::fromStdString(result["poll_type"].asString()); QQMsg *msg = createMsg(type, result); if ( msg ) be_sorting_msg.append(msg); } if ( be_sorting_msg.size() > 1 ) sortByTime(be_sorting_msg); dispatchMsg(be_sorting_msg); } }
/** Reads a file containing a list of Julian days and measurements * * @param[in] fileName the name of a file to be read. The file * is assumed to be formatted as a 2xN comma-delimited table, * with the first column a floating point Julian date and the second * a floating point measurement. The file may also contain comment lines * preceded by '#'. * @param[out] timeVec a vector containing the times of each * observation * @param[out] dataVec a vector containing the measurement (typically flux * or magnitude) observed at each time * * @post @p timeVec is sorted in ascending order * @post @p timeVec.size() = @p dataVec.size() * @post for all i, @p dataVec[i] is the measurement taken at @p timeVec[i] * * @exception std::bad_alloc Thrown if there is not enough memory to store * the data. * @exception kpfutils::except::FileIo Thrown if any file operation fails. * * @exceptsafe The function arguments are unchanged in the event of an exception. */ void readCsvLightCurve(const string& fileName, DoubleVec &timeVec, DoubleVec &dataVec) { // copy-and-swap vector<double> tempTimes, tempData; boost::shared_ptr<FILE> hInput = fileCheckOpen(fileName, "r"); readTable(hInput.get(), " %lf , %lf", tempTimes, tempData); sortByTime(tempTimes, tempData); // IMPORTANT: no exceptions beyond this point swap(timeVec, tempTimes); swap(dataVec, tempData ); }
/** Reads a file containing a list of obsids, Julian days, measurements, errors, and limits * * @param[in] fileName the name of a file to be read. The file * is assumed to be formatted as a 5xN space-delimited table, with * the first column a running index, the second a floating point * Julian date, the third a floating point measurement, the fourth * a floating point error, and the fifth a detection limit in the same * units as the measurement. The file may also contain comment lines * preceded by '#'. * @param[in] errMax the maximum error to tolerate in a data point. Any * points with an error exceeding @p errMax are ignored. * @param[out] timeVec a vector containing the times of each * observation * @param[out] dataVec a vector containing the measurement (typically flux * or magnitude) observed at each time * @param[out] errVec a vector containing the error on each measurement * * @post @p timeVec is sorted in ascending order * @post @p timeVec.size() = @p dataVec.size() = @p errVec.size() * @post for all i, @p dataVec[i] ± @p errVec[i] is the * measurement taken at @p timeVec[i] * @post for all i, @p errVec[i] ≤ @p errMax * * @exception std::bad_alloc Thrown if there is not enough memory to store * the data. * @exception kpfutils::except::FileIo Thrown if any file operation fails. * * @exceptsafe The function arguments are unchanged in the event of an exception. * * @bug Current implementation ignores limits. */ void readWg2LightCurve(const string& fileName, double errMax, DoubleVec &timeVec, DoubleVec &dataVec, DoubleVec &errVec) { // copy-and-swap vector<double> tempTimes, tempData, tempErrs; boost::shared_ptr<FILE> hInput = fileCheckOpen(fileName, "r"); readTable(hInput.get(), " %*i %lf %lf %lf %*lf", tempTimes, tempData, tempErrs); errorFilter(errMax, tempTimes, tempData, tempErrs); sortByTime(tempTimes, tempData, tempErrs); // IMPORTANT: no exceptions beyond this point swap(timeVec, tempTimes); swap(dataVec, tempData ); swap( errVec, tempErrs ); }