void MT500::testConnection() { for(int i = 0; i < 6; i++) { if(!ipArray[i].ip.isEmpty()){ QString msg = "[" + QDateTime::currentDateTime().toString("MM/dd/yyyy hh:mm:ss") + "] "; QTcpSocket * test = new QTcpSocket; test->connectToHost(QHostAddress(ipArray[i].ip), ipArray[i].port); if(test->waitForConnected(2000)) { msg += ipArray[i].ip + ": Test Message Sent"; ui->testBrowser->append("<font color=green>" + msg + "</font>"); test->abort(); } else { msg += ipArray[i].ip + ": Failed to Connect"; ui->testBrowser->append("<font color=red>" + msg + "</font>"); } } } if(!initial) { QString fips = fipsNo.trimmed().remove("VAZ"); QString msgToSend = "A 100 " + QDateTime::currentDateTime().toString("MM/dd/yyyy hh:mm:ss") + " " + QString::number(boxGID); sendBase(msgToSend, true); sendRaw(msgToSend); sendRawStrtoIflows(QString(encode(msgToSend))); } else initial = false; }
void MT500::getData() { QString line; int count = 0; QFile file("/home/administrator/Desktop/data.log"); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while (!in.atEnd()) { line = in.readLine(); count++; if(count > initialCount) { recordCnt++; if(recordCnt > 500){ ui->DataBrowser->clear(); recordCnt =0; } initialCount = count; if(line.length() > 0) { sendRaw(line.trimmed()); sendBase(line.trimmed(), true); QByteArray msgToSend; msgToSend = encode(line.trimmed()); sendIFLOWS(msgToSend); } } } } pollTimer->start(500); }
void MT500::readData() { validMsgTimer->start(1000); QString line; ba = inPort->readAll(); msg[byteCount] = ba[0]; byteCount++; if(byteCount == 4) { validMsgTimer->stop(); line = decode(msg); if(line == "NA") { validMsgTimer->start(1000); byteCount--; QByteArray temp; temp[0] = msg[1]; temp[1] = msg[2]; temp[2] = msg[3]; msg = temp; } else { byteCount = 0; recordCnt++; if(recordCnt > 500){ ui->DataBrowser->clear(); recordCnt =0; } QStringList fields = line.trimmed().split(" "); int gid = fields.at(1).trimmed().toInt(); if(inFilter(boxGID, gid)) { sendRaw(line.trimmed()); sendIFLOWS(msg); sendBase(line.trimmed(), true); } else { ui->DataBrowser->append("<font color=blue>"+line.trimmed()+"</font>"); sendBase(line.trimmed(), false); } } } }
void GsmTrack::slReadSerial() { QByteArray data = gsmSerial->readAll().trimmed(); //qDebug() << "the date:: " << data << endl; emit sendData(data); if(data.contains("+CSQ: ")){ int csq; int csq_tail; std::sscanf(data.data(), "+CSQ: %d,%d", &csq, &csq_tail); qDebug("the csq is:: %d\n", csq); if(csq <= 10 || csq > 31){ emit sendCsq(0); return; } emit sendCsq(csq); } // 读取网络类型与网路配置 if(data.contains("^SYSCFG: ")){ int type; std::sscanf(data.data(), "^SYSCFG: %d", &type); if(type == 13){ emit sendText("2G network it is!!"); }else if(type == 2){ emit sendText("3G network it is!!"); } } // 基站信息 // BASE:: "AT+CREG=2;+CREG?" // OUT :: +CREG: 2,1,"A5D3","19E420F",2 if(data.contains("+CREG: ")){ qDebug() << data << endl; QByteArrayList cregList = data.split(','); emit sendBase(QLatin1String( cregList.at(2) + "," + cregList.at(3) )); } }