|
@@ -9,8 +9,8 @@ ZCCore::ZCCore(QObject *parent) : QObject(parent)
|
|
|
connect(timer,&QTimer::timeout,this,&ZCCore::time_out);
|
|
|
|
|
|
hour = 255;
|
|
|
-// netAccessManager = new QNetworkAccessManager(this);
|
|
|
-// connect(netAccessManager,&QNetworkAccessManager::finished,this,&ZCCore::finishedSlot);
|
|
|
+ netAccessManager = new QNetworkAccessManager(this);
|
|
|
+ connect(netAccessManager,&QNetworkAccessManager::finished,this,&ZCCore::finishedSlot);
|
|
|
|
|
|
netAccessManager1 = new QNetworkAccessManager(this);
|
|
|
connect(netAccessManager1,&QNetworkAccessManager::finished,this,&ZCCore::finishedSlot1);
|
|
@@ -50,31 +50,31 @@ void ZCCore::time_out()
|
|
|
sendData();
|
|
|
}
|
|
|
|
|
|
-// if(hour != QDateTime::currentDateTime().time().hour()){
|
|
|
-// hour = QDateTime::currentDateTime().time().hour();
|
|
|
+ if(hour != QDateTime::currentDateTime().time().hour()){
|
|
|
+ hour = QDateTime::currentDateTime().time().hour();
|
|
|
|
|
|
-// QByteArray post_data;
|
|
|
-// uint t = QDateTime::currentDateTime().toTime_t();
|
|
|
+ QByteArray post_data;
|
|
|
+ uint t = QDateTime::currentDateTime().toTime_t();
|
|
|
|
|
|
-// QString tmp="";
|
|
|
-// QString number= QString("%1%2%3").arg("usky").arg(t).arg("056ac8fae059c9c9e700b734922edfc8");
|
|
|
-// QByteArray str;
|
|
|
-// str = QCryptographicHash::hash(number.toLatin1(),QCryptographicHash::Md5);
|
|
|
-// tmp.append(str.toHex());
|
|
|
+ QString tmp="";
|
|
|
+ QString number= QString("%1%2%3").arg("usky").arg(t).arg("056ac8fae059c9c9e700b734922edfc8");
|
|
|
+ QByteArray str;
|
|
|
+ str = QCryptographicHash::hash(number.toLatin1(),QCryptographicHash::Md5);
|
|
|
+ tmp.append(str.toHex());
|
|
|
|
|
|
|
|
|
-// post_data.append(QString("requestType=%1&").arg(3));
|
|
|
-// post_data.append(QString("publicKey=%1&").arg(tmp));
|
|
|
-// post_data.append(QString("timeStamp=%1").arg(t));
|
|
|
+ post_data.append(QString("requestType=%1&").arg(3));
|
|
|
+ post_data.append(QString("publicKey=%1&").arg(tmp));
|
|
|
+ post_data.append(QString("timeStamp=%1").arg(t));
|
|
|
|
|
|
-// QNetworkRequest *req = new QNetworkRequest();
|
|
|
-// req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/wooGiApi"));
|
|
|
-// req->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
|
|
|
-// req->setHeader(QNetworkRequest::ContentLengthHeader,post_data.length());
|
|
|
-// QNetworkReply* reply = netAccessManager->post(*req,post_data);
|
|
|
+ QNetworkRequest *req = new QNetworkRequest();
|
|
|
+ req->setUrl(QUrl("https://iot.usky.cn/ytapi/admin/Manage/wooGiApi"));
|
|
|
+ req->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
|
|
|
+ req->setHeader(QNetworkRequest::ContentLengthHeader,post_data.length());
|
|
|
+ QNetworkReply* reply = netAccessManager->post(*req,post_data);
|
|
|
|
|
|
|
|
|
-// }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ZCCore::comLog(QString comData)
|
|
@@ -111,7 +111,7 @@ void ZCCore::AlarmReport(QString DeviceCode,QString lastid,QString SETime,QStrin
|
|
|
}
|
|
|
}
|
|
|
for(int j=0;j<33;j++){
|
|
|
- if(MeasName.compare(zcdev->devs[i].alarm[j].measName)==0){
|
|
|
+ if((MeasName.compare(zcdev->devs[i].alarm[j].measName)==0)&&((QString("PhaseLoss")).compare(MeasName)==0 || (QString("OverV")).compare(MeasName)==0 || (QString("UnderV")).compare(MeasName)==0 || (QString("BusOutage")).compare(MeasName)==0 || (QString("OverEvT")).compare(MeasName)==0 || (QString("DevAbnormal")).compare(MeasName)==0)){
|
|
|
if(DigitalValue.compare("0")==0){
|
|
|
if((soeTime-zcdev->devs[i].alarm[j].soeTime0)>60){
|
|
|
if((soeTime-busTime0)>60){
|
|
@@ -181,55 +181,55 @@ void ZCCore::sendData()
|
|
|
|
|
|
}
|
|
|
|
|
|
-//void ZCCore::finishedSlot(QNetworkReply *reply)
|
|
|
-//{
|
|
|
-// printf("enter finishedSlot ++++++++++++++\n");
|
|
|
-// QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
|
|
-// if(status_code == 200){
|
|
|
-// if(reply->error() == QNetworkReply::NoError){
|
|
|
-// QString message = QString::fromUtf8(reply->readAll());
|
|
|
-// QByteArray data = message.toLatin1();
|
|
|
-// QJsonParseError json_err;
|
|
|
-// QJsonDocument jsondoc(QJsonDocument::fromJson(data,&json_err));
|
|
|
-// //printf("json_err.error = %d\n ",json_err.error);
|
|
|
-// if(json_err.error==QJsonParseError::NoError){
|
|
|
-// QJsonObject root = jsondoc.object();
|
|
|
-// QJsonObject obj = root.value("data").toObject();
|
|
|
-// QString num = "";
|
|
|
-// int t = 0;
|
|
|
-// if((!obj.value("publicKey").isUndefined())&&(!obj.value("publicKey").isNull())){
|
|
|
-// num = obj.value("publicKey").toString();
|
|
|
-// }
|
|
|
-// if((!obj.value("timeStamp").isUndefined())&&(!obj.value("timeStamp").isNull())){
|
|
|
-// t = obj.value("timeStamp").toInt();
|
|
|
-// }
|
|
|
-
|
|
|
-// QString temp="";
|
|
|
-// QString number = QString("%1%2%3").arg("usky").arg(t).arg("056ac8fae059c9c9e700b734922edfc8");
|
|
|
-// QByteArray str = QCryptographicHash::hash(number.toLatin1(),QCryptographicHash::Md5);
|
|
|
-// temp.append(str.toHex());
|
|
|
-// if(QString::compare(num,temp)!=0){
|
|
|
-// exit(1);
|
|
|
-// }
|
|
|
+void ZCCore::finishedSlot(QNetworkReply *reply)
|
|
|
+{
|
|
|
+ printf("enter finishedSlot ++++++++++++++\n");
|
|
|
+ QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
|
|
+ if(status_code == 200){
|
|
|
+ if(reply->error() == QNetworkReply::NoError){
|
|
|
+ QString message = QString::fromUtf8(reply->readAll());
|
|
|
+ QByteArray data = message.toLatin1();
|
|
|
+ QJsonParseError json_err;
|
|
|
+ QJsonDocument jsondoc(QJsonDocument::fromJson(data,&json_err));
|
|
|
+ //printf("json_err.error = %d\n ",json_err.error);
|
|
|
+ if(json_err.error==QJsonParseError::NoError){
|
|
|
+ QJsonObject root = jsondoc.object();
|
|
|
+ QJsonObject obj = root.value("data").toObject();
|
|
|
+ QString num = "";
|
|
|
+ int t = 0;
|
|
|
+ if((!obj.value("publicKey").isUndefined())&&(!obj.value("publicKey").isNull())){
|
|
|
+ num = obj.value("publicKey").toString();
|
|
|
+ }
|
|
|
+ if((!obj.value("timeStamp").isUndefined())&&(!obj.value("timeStamp").isNull())){
|
|
|
+ t = obj.value("timeStamp").toInt();
|
|
|
+ }
|
|
|
|
|
|
+ QString temp="";
|
|
|
+ QString number = QString("%1%2%3").arg("usky").arg(t).arg("056ac8fae059c9c9e700b734922edfc8");
|
|
|
+ QByteArray str = QCryptographicHash::hash(number.toLatin1(),QCryptographicHash::Md5);
|
|
|
+ temp.append(str.toHex());
|
|
|
+ if(QString::compare(num,temp)!=0){
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
|
|
|
-// }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
-// }else{
|
|
|
|
|
|
-// }
|
|
|
+ }else{
|
|
|
|
|
|
-// }else{
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
|
|
|
-// }
|
|
|
+ }
|
|
|
|
|
|
-// reply->abort();
|
|
|
-// reply->close();
|
|
|
-// reply->deleteLater();
|
|
|
+ reply->abort();
|
|
|
+ reply->close();
|
|
|
+ reply->deleteLater();
|
|
|
|
|
|
|
|
|
-//}
|
|
|
+}
|
|
|
|
|
|
void ZCCore::finishedSlot1(QNetworkReply *reply)
|
|
|
{
|