//-------------------------------------------------------------------------------------------------- void Nextion::recvAnswer() { if(!stream) return; // получаем ответ от Nextion char ch; while(stream->available()) { if(gotCommand()) // если уже есть команда processCommand(); // обрабатываем её ch = stream->read(); recvBuff += ch; } if(gotCommand()) // если уже есть команда processCommand(); // обрабатываем её }
//Runs a thread void FuseTracker::run() { QPair<FuseCppInterface::NotableAction, QString> item; QStringList list; int fails = 0; //My main thread loopto handle data Thread_Running = true; Thread_Idle = true; while ( Thread_Running ) { //Run these commands while there is data while ( Data_Read.count() > 0 ) { //Set that the thread isn't idel right now Thread_Idle = false; //Reset my failed read count fails = 0; //Pull a line from the data list if ( (item = Data_Read.takeFirst()).second.isEmpty() ) continue; //Remove any existances of this guy from the hash Data_Hash.remove( item.second ); //Handle the command gotCommand( item.first, item.second ); } //Set that the thread isn't doing anything Thread_Idle = true; //Remove any status stuff that might exists removeStatus( SYNC_PUSH ); removeStatus( SYNC_PULL ); removeStatus( ADDING_ITEMS ); //Sleep for a little while waiting for more data usleep( THREAD_SLEEP ); //Check if we've failed too many times if ( ++fails >= THREAD_FAILED ) Thread_Running = false; } //Ensure that the thread is idle, this is over kill and probably not needed Thread_Idle = true; }
void OpCounters::gotOp( int op , bool isCommand ) { switch ( op ) { case dbInsert: /*gotInsert();*/ break; // need to handle multi-insert case dbQuery: if ( isCommand ) gotCommand(); else gotQuery(); break; case dbUpdate: gotUpdate(); break; case dbDelete: gotDelete(); break; case dbGetMore: gotGetMore(); break; case dbKillCursors: case opReply: case dbMsg: break; default: log() << "OpCounters::gotOp unknown op: " << op << endl; } }
LRESULT CALLBACK DebugGui::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //TCHAR szHello[MAX_LOADSTRING]; //LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) { //case WM_CREATE: break; case WM_DESTROY: clear(); break; case WM_COMMAND: gotCommand(LOWORD(wParam), HIWORD(wParam) ); break; case WM_PAINT: PAINTSTRUCT ps; HDC hdc; RECT rt; //std::string myStr; // myStr = "Hello World"; // LPSTR s = const_cast<char *>(myStr.c_str()); std::wstring wstr; //wstr = L"Hello World"; wstr = debugStr; LPCWSTR s = wstr.c_str(); hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... GetClientRect(hWnd, &rt); //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); DrawText(hdc, s, wstr.size(), &rt, DT_LEFT|DT_WORDBREAK); EndPaint(hWnd, &ps); break; };//swend return DefWindowProc(hWnd, message, wParam, lParam); }//wndproc
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); console = new Console; console->setEnabled(false); tabs = new QTabWidget(); setCentralWidget(tabs); serial = new QSerialPort(this); settings = new SettingsDialog; ui->actionConnect->setEnabled(true); ui->actionDisconnect->setEnabled(false); ui->actionQuit->setEnabled(true); ui->actionConfigure->setEnabled(true); ui->actionAscii->setEnabled(true); ui->actionBinary->setEnabled(true); nodeNames = new NodeNames(); logFile = new LogFile(); decoder = new Decoder(); connect(decoder, SIGNAL(logMessage(QString)), logFile, SLOT(add(QString))); tempDistModel = new TempModel(this); tempDistModel->setNodeNameHelper(nodeNames); zoneSetpointModel = new SetpointModel(this); zoneSetpointModel->setNodeNameHelper(nodeNames); demandModel = new DemandModel(this); demandModel->setNodeNameHelper(nodeNames); commandModel = new CommandModel(this); commandModel->setNodeNameHelper(nodeNames); nowNextModel = new ProgNowNextModel(this); nowNextModel->setNodeNameHelper(nodeNames); unknown1060Model = new Unknown18Model(this); unknown1060Model->setNodeNameHelper(nodeNames); unknown1100Model = new Unknown16Model(this); unknown1100Model->setNodeNameHelper(nodeNames); unknown0008Model = new Unknown16Model(this); unknown0008Model->setNodeNameHelper(nodeNames); unknown0009Model = new Unknown16Model(this); unknown0009Model->setNodeNameHelper(nodeNames); unknown1F09Model = new Unknown16Model(this); unknown1F09Model->setNodeNameHelper(nodeNames); unknown3B00Model = new Unknown16Model(this); unknown3B00Model->setNodeNameHelper(nodeNames); messageModel = new MessageModel(this); MessageTab *messageTab = new MessageTab(); messageTab->setMessageCountersModel(commandModel); messageTab->setMessageLogModel(messageModel); tabs->addTab(messageTab, "Messages"); TemperaturesTab *temperaturesTab = new TemperaturesTab(); temperaturesTab->setMeasuredTempsModel(tempDistModel); temperaturesTab->setSetpointsModel(zoneSetpointModel); temperaturesTab->setDemandsModel(demandModel); temperaturesTab->setProgNowNextModel(nowNextModel); tabs->addTab(temperaturesTab, "Temperatures"); UnknownTab *unknownTab = new UnknownTab(); unknownTab->set0008Model(unknown0008Model); unknownTab->set0009Model(unknown0009Model); unknownTab->set1060Model(unknown1060Model); unknownTab->set1100Model(unknown1100Model); unknownTab->set1F09Model(unknown1F09Model); unknownTab->set3B00Model(unknown3B00Model); tabs->addTab(unknownTab, "Unknown messages"); DecoderTab *decoderTab = new DecoderTab(); tabs->addTab(decoderTab, "Decoder"); tabs->addTab(console, "Console"); initActionsConnections(); parser=NULL; setBinaryParser(); connect(serial, SIGNAL(readyRead()), this, SLOT(readData())); connect(decoder, SIGNAL(consoleMessage(QString)), this, SLOT(message(QString))); connect(decoder, SIGNAL(gotMessage(QByteArray)), messageModel, SLOT(newData(QByteArray))); //connect decoded messages to tables connect(decoder, SIGNAL(zoneTempDistribution(quint32,quint32,quint32,float)), tempDistModel, SLOT(newData(quint32,quint32,quint32,float))); connect(decoder, SIGNAL(zoneSetpointSetting(quint32,quint32,quint32,float)), zoneSetpointModel, SLOT(newData(quint32,quint32,quint32,float))); connect(decoder, SIGNAL(heatDemand(quint32,quint32,quint32,quint32)), demandModel, SLOT(newData(quint32, quint32, quint32, quint32))); connect(decoder, SIGNAL(gotCommand(quint32,quint32,quint32)), commandModel, SLOT(newData(quint32,quint32,quint32))); connect(decoder, SIGNAL(programmerNowNext(quint32,quint32,float,float,quint32)), nowNextModel, SLOT(newData(quint32, quint32, float, float, quint32))); //connect unknown messages to tables connect(decoder, SIGNAL(unknown1060(quint32,quint32,QByteArray)), unknown1060Model, SLOT(newData(quint32,quint32,QByteArray))); connect(decoder, SIGNAL(unknown1100(quint32,QByteArray)), unknown1100Model, SLOT(newData(quint32,QByteArray))); connect(decoder, SIGNAL(unknown0008(quint32,QByteArray)), unknown0008Model, SLOT(newData(quint32,QByteArray))); connect(decoder, SIGNAL(unknown0009(quint32,QByteArray)), unknown0009Model, SLOT(newData(quint32,QByteArray))); connect(decoder, SIGNAL(unknown1F09(quint32,QByteArray)), unknown1F09Model, SLOT(newData(quint32,QByteArray))); connect(decoder, SIGNAL(unknown3B00(quint32,QByteArray)), unknown3B00Model, SLOT(newData(quint32,QByteArray))); //connect decoder stats to decoder tab connect(decoder, SIGNAL(inputByteCount(quint32)), decoderTab, SLOT(inputByteCount(quint32))); connect(decoder, SIGNAL(candidatePayloadCount(quint32)), decoderTab, SLOT(candidatePayloadCount(quint32))); connect(decoder, SIGNAL(overLengthMessageCount(quint32)), decoderTab, SLOT(overLengthMessageCount(quint32))); connect(decoder, SIGNAL(lengthOddCount(quint32)), decoderTab, SLOT(lengthOddCount(quint32))); connect(decoder, SIGNAL(manchesterInvalidCount(quint32)), decoderTab, SLOT(manchesterInvalidCount(quint32))); connect(decoder, SIGNAL(validMessageCount(quint32)), decoderTab, SLOT(validMessageCount(quint32))); //connect decoded messages to influxdb connect(decoder, SIGNAL(influxData(QString)), this, SLOT(writeInflux(QString))); //receive broadcast traffic from RF receiver udpSocket = new QUdpSocket(this); udpSocket->bind(8888, QUdpSocket::ShareAddress); connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams())); //send influx format data influxSocket = new QUdpSocket(this); }