std::vector<zmq_player::Packet> DataReader::readData() const { if (!connection_) { std::cout << "ERROR: No database loaded..." << std::endl; return std::vector<zmq_player::Packet>(); } //This is the list of data which will be filled and returned to the user std::vector<zmq_player::Packet> data; //Let's read the data from the DB try { sqlite::query dataQuery(*connection_, "SELECT Data, Timestamp FROM Packets;"); sqlite::query::iterator queryIter = dataQuery.begin(); for (; queryIter != dataQuery.end(); ++queryIter) { zmq_player::Packet newPacket; newPacket.Data = queryIter->column< std::string >(0); newPacket.Timestamp = queryIter->column< boost::int64_t >(1); data.push_back(newPacket); } } catch (sqlite::sqlite_error& error) { std::cout << __FUNCTION__ << ": " << error.what() << std::endl; } return data; }
HttpControl::HttpControl(QObject *parent):QObject(parent), m_airMode(1), m_airPower(false), m_airTemp(25), m_tvChangle(0), m_tvVoice(0), m_tvPower(false) { sock = new QTcpSocket; sock->bind(4589); sock->connectToHost("localhost",4589); // sock->write("hello,I am Qt"); timer = new QTimer; timer->setInterval(300); timer->start(); connect(sock,SIGNAL(readyRead()),this,SLOT(dataCome())); connect(timer,SIGNAL(timeout()),this,SLOT(dataQuery())); // connect(timer,SIGNAL(timeout()),this,SLOT(dataQueryTv())); // connect(timer,SIGNAL(timeout()),this,SLOT(dataQueryLight())); }