void chat_message_list_to_clipboard(int first, int last) { std::ostringstream s; stream_log(s, first, last, true); copy_to_clipboard(s.str(), false); }
float sensor::GetDistance() { #if SENSOR QByteArray Bresponse; QString response; if (serial.isOpen() && serial.isWritable()) { //Préparation de la trame QByteArray ba = QString("DIST").toLocal8Bit(); //conversion QString -> QByteArray ba.append("\r"); //serial.clear(); serial.write(ba); //serial.flush(); serial.waitForBytesWritten(-1); //while(serial.flush()); qDebug() << "Demande de distance" << endl; //Attente datas disponibles //while(!serial.waitForReadyRead(10)); //Récupération de la distance (valeur = 0 to 1023) while(serial.waitForReadyRead(500)) { //serial.flush(); //serial.waitForReadyRead(10); Bresponse = serial.readAll(); response += QString(Bresponse); qDebug() << "response : " << response << endl; if(response.contains('\n')) break; } //Calcul de la distance en mm float dist = COEFA * response.toFloat() + COEFB; if(response.toFloat() < 10)//Si obstacle trop proche du capteur return 0; else if(response.toFloat() > 1020)//Si obstacle trop loin du capteur return 1000; else return dist; } else { qDebug() << "ERREUR de Port COM" << endl; QFile errFile(QCoreApplication::applicationDirPath() + ERROR); QTextStream stream_log(&errFile); errFile.open(QIODevice::WriteOnly | QIODevice::Text); stream_log << "Erreur de port COM (Arduino SENSOR)." << endl; errFile.close(); exit(EXIT_PRB_PORT_COM_GRBL); } return 0; #else return 45.45; #endif }
void populate_chat_message_list(int first, int last) { std::ostringstream s; stream_log(s, first, last); msg_label->set_label(s.str()); }