bit sendHTTP(int cmd,unsigned char *str) { int i=0,len=0; len = strlen(str); datelen = len; while(!setWifi(CIPSTART,"Linked")) { U1SendString("好像出了一点问题,连接不上了\r\n"); delay(10000); //暂时连接不上,待会再连接 } LED2 = 0; // LED2 = 0; //表示连接上tcp了。 LED3 = 1; setWifi(CIPSEND,">"); delay(1000); switch(cmd) { case 1: // sendByte(strlen(GetCmd)); delay(1000); sendDate(1,NULL); break; case 2: // sendByte(strlen(PostCmd)); delay(1000); sendDate(2,str); break; default : sendDate(0,NULL); //重启wifi 一般不用 break; } LED3 = 0; //表示退出TCP连接 delay(2000); U1SendString(Rec_Buf); delay(5000); return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { thread = new QThread(); reader = new Reader(); reader->moveToThread(thread); connect(reader, SIGNAL(sendPoint(int,int,double)), this, SLOT(setPointProb(int,int,double))); connect(reader, SIGNAL(workRequested()), thread, SLOT(start())); connect(thread, SIGNAL(started()), reader, SLOT(doWork())); connect(reader, SIGNAL(finished()), thread, SLOT(quit()) , Qt::DirectConnection); connect(reader, SIGNAL(finished()), this, SLOT(fileFinished())); connect(reader, SIGNAL(sendReset()), this, SLOT(resetPositions())); setFixedSize(800,600); p_scene = new QGraphicsScene(this); p_view = new QGraphicsView(p_scene, this); QPixmap background(QCoreApplication::applicationDirPath() + "/img/sol.png"); if (background.isNull()) { std::cout << "Ouverture de sol.png échouée, ouverture de sol.jpg" << std::endl; background = QPixmap(QCoreApplication::applicationDirPath() + "/img/sol.jpg"); } p_scene->setBackgroundBrush(QBrush(background)); p_view->setGeometry(10,10,505,505); p_addPosition = new QPushButton("Ajouter position", this); p_addPosition->setGeometry(590,90, 120, 30); p_deletePos = new QPushButton("Réinitialiser positions", this); p_deletePos->setGeometry(590,130, 120, 30); p_openFile = new QPushButton("Ouvrir fichier", this); p_openFile->setGeometry(590, 170, 120, 30); p_changeTableSize = new QPushButton("Changer taille table", this); p_changeTableSize->setGeometry(50, 560, 120, 30); pauseButton = new QPushButton("", this); QIcon pauseIcon(QCoreApplication::applicationDirPath() + "/img/pause.png"); if (pauseIcon.isNull()) { std::cout << "Ouverture de pause.png échouée, ouverture de pause.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/pause.jpg")); } pauseButton->setIcon(pauseIcon); pauseButton->setGeometry(590, 250, 30, 30); pauseButton->setDisabled(true); stopButton = new QPushButton("", this); QIcon stopIcon(QCoreApplication::applicationDirPath() + "/img/stop.png"); if (stopIcon.isNull()) { std::cout << "Ouverture de stop.png échouée, ouverture de stop.jpg" << std::endl; pauseIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/stop.jpg")); } stopButton->setIcon(stopIcon); stopButton->setGeometry(630, 250, 30, 30); stopButton->setDisabled(true); stepButton = new QPushButton("", this); QIcon stepIcon(QCoreApplication::applicationDirPath() + "/img/step.png"); if (stepIcon.isNull()) { std::cout << "Ouverture de step.png échouée, ouverture de step.jpg" << std::endl; stepIcon = QIcon((QCoreApplication::applicationDirPath() + "/img/step.jpg")); } stepButton->setIcon(stepIcon); stepButton->setGeometry(670, 250, 30, 30); stepButton->setDisabled(true); p_quit = new QPushButton("Quitter", this); p_quit->setGeometry(600, 560, 100, 30); p_addPosX = new QLineEdit(this); p_addPosY = new QLineEdit(this); p_addPosP = new QLineEdit(this); p_addPosX->setGeometry(580, 50, 40, 30); p_addPosY->setGeometry(630, 50, 40, 30); p_addPosP->setGeometry(680, 50, 40, 30); p_addPosX->setPlaceholderText("Abscisse"); p_addPosY->setPlaceholderText("Ordonnée"); p_addPosP->setPlaceholderText("Proba"); currentDate = new QLabel("Pas de fichier en cours", this); currentDate->setGeometry(580, 300, 140, 30); QObject::connect(p_addPosition, SIGNAL(clicked()), this, SLOT(sendPointProbValues())); QObject::connect(this, SIGNAL(pointProbValues(int,int,double)), this, SLOT(setPointProb(int,int,double))); QObject::connect(p_deletePos, SIGNAL(clicked()), this, SLOT(resetPositions())); QObject::connect(p_quit, SIGNAL(clicked()), qApp, SLOT(quit())); QObject::connect(p_openFile, SIGNAL(clicked()), this, SLOT(readMatrixFromFile())); QObject::connect(p_changeTableSize, SIGNAL(clicked()), this, SLOT(changeTableSize())); QObject::connect(pauseButton, SIGNAL(clicked()), this, SLOT(pauseRead())); QObject::connect(stopButton, SIGNAL(clicked()), this, SLOT(stopRead())); QObject::connect(reader, SIGNAL(sendDate(QString)), this, SLOT(setDate(QString))); QObject::connect(stepButton, SIGNAL(clicked()), this, SLOT(clickNextDate())); }