mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
11111111
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
ZZ_HttpTransfer::ZZ_HttpTransfer(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pNetworkManager = nullptr;
|
||||
m_pNetworkManagerThread = nullptr;
|
||||
//connect(this, &ZZ_HttpTransfer::SignalInit_Self, this, &ZZ_HttpTransfer::SlotInit_Self);
|
||||
}
|
||||
|
||||
ZZ_HttpTransfer::~ZZ_HttpTransfer()
|
||||
@ -10,14 +12,24 @@ ZZ_HttpTransfer::~ZZ_HttpTransfer()
|
||||
{
|
||||
delete m_pNetworkManager;
|
||||
}
|
||||
if (m_pNetworkManagerThread != nullptr)
|
||||
{
|
||||
delete m_pNetworkManagerThread;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// void ZZ_HttpTransfer::Init_Self()
|
||||
// {
|
||||
// emit SignalInit_Self();
|
||||
// }
|
||||
|
||||
int ZZ_HttpTransfer::SendData()
|
||||
{
|
||||
if (m_pNetworkManager == nullptr)
|
||||
if (m_pNetworkManagerThread == nullptr)
|
||||
{
|
||||
m_pNetworkManager = new QNetworkAccessManager();
|
||||
connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||
m_pNetworkManagerThread = new QNetworkAccessManager();
|
||||
connect(m_pNetworkManagerThread, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinishedThread(QNetworkReply*)));
|
||||
}
|
||||
|
||||
QNetworkRequest qnRequest;
|
||||
@ -44,7 +56,7 @@ int ZZ_HttpTransfer::SendData()
|
||||
qbSend.append(qstrSend.toLatin1());
|
||||
qbSend.append((char*)m_vecCalcedData[i][j].fData, sizeof(float)*m_vecCalcedData[i][j].iPixels);
|
||||
|
||||
m_pNetworkManager->post(qnRequest, qbSend);
|
||||
m_pNetworkManagerThread->post(qnRequest, qbSend);
|
||||
iFlagIsReplied = 0;
|
||||
int iCount = 0;
|
||||
while (!iFlagIsReplied)
|
||||
@ -120,7 +132,7 @@ int ZZ_HttpTransfer::SendInfo()
|
||||
{
|
||||
iCount++;
|
||||
Delay_MSec(500);
|
||||
if (iCount>20)
|
||||
if (iCount>2)
|
||||
{
|
||||
iFlagIsReplied = 1;
|
||||
qDebug() << "Reply Timeout:Upload Info ";
|
||||
@ -135,16 +147,73 @@ int ZZ_HttpTransfer::SendInfo()
|
||||
|
||||
int ZZ_HttpTransfer::SendErr()
|
||||
{
|
||||
if (m_pNetworkManager == nullptr)
|
||||
{
|
||||
m_pNetworkManager = new QNetworkAccessManager();
|
||||
connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
QNetworkRequest qnRequest;
|
||||
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
|
||||
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Warning.php"));
|
||||
|
||||
QByteArray abTest;
|
||||
QByteArray qbSend;
|
||||
QString qstrSend;
|
||||
qbSend.clear();
|
||||
qstrSend.clear();
|
||||
|
||||
m_pNetworkManager->post(qnRequest, abTest);
|
||||
if (m_struErrInfo.fChassisTempErr==-1000)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
qstrSend += "Case_Temp:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||
}
|
||||
if (m_struErrInfo.fTecTempErr == -1000)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
qstrSend += "##TEC_Temp:" + QString("%1").arg(m_struErrInfo.fTecTempErr);
|
||||
}
|
||||
if (m_struErrInfo.iDataTransferErr == -1000)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
qstrSend += "##No_Data:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||
}
|
||||
if (m_struErrInfo.iShutterErr == -1000)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
qstrSend += "##Shutter_Pos:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||
}
|
||||
|
||||
qbSend = qstrSend.toLatin1();
|
||||
m_pNetworkManager->post(qnRequest, qbSend);
|
||||
iFlagIsReplied = 0;
|
||||
int iCount = 0;
|
||||
while (!iFlagIsReplied)
|
||||
{
|
||||
iCount++;
|
||||
Delay_MSec(500);
|
||||
if (iCount > 2)
|
||||
{
|
||||
iFlagIsReplied = 1;
|
||||
qDebug() << "Reply Timeout:Upload Info ";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZZ_HttpTransfer::SetErrInfo(ErrInfo struErrInfo)
|
||||
{
|
||||
m_struErrInfo = struErrInfo;
|
||||
}
|
||||
|
||||
void ZZ_HttpTransfer::SetContext(EContext struEC, MEContext struMEC)
|
||||
{
|
||||
m_struEC = struEC;
|
||||
@ -172,8 +241,8 @@ void ZZ_HttpTransfer::Delay_MSec(ZZ_U16 usMS)
|
||||
int ZZ_HttpTransfer::SlotReplyFinished(QNetworkReply* qnReply)
|
||||
{
|
||||
|
||||
//QString qstrURL = qnReply->url().toString();
|
||||
//QByteArray qbData = qnReply->readAll();
|
||||
QString qstrURL = qnReply->url().toString();
|
||||
QByteArray qbData = qnReply->readAll();
|
||||
if (qnReply->error()== QNetworkReply::NoError)
|
||||
{
|
||||
iFlagIsReplied = 1;
|
||||
@ -185,3 +254,36 @@ int ZZ_HttpTransfer::SlotReplyFinished(QNetworkReply* qnReply)
|
||||
//delete qnReply;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_HttpTransfer::SlotReplyFinishedThread(QNetworkReply* qnReply)
|
||||
{
|
||||
|
||||
QString qstrURL = qnReply->url().toString();
|
||||
QByteArray qbData = qnReply->readAll();
|
||||
if (qnReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
iFlagIsReplied = 1;
|
||||
}
|
||||
qnReply->abort();
|
||||
qnReply->close();
|
||||
qnReply->deleteLater();
|
||||
qnReply = NULL;
|
||||
//delete qnReply;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int ZZ_HttpTransfer::SlotInit_Self()
|
||||
// {
|
||||
// if (m_pNetworkManager == nullptr)
|
||||
// {
|
||||
// m_pNetworkManager = new QNetworkAccessManager();
|
||||
// connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// delete m_pNetworkManager;
|
||||
// m_pNetworkManager = new QNetworkAccessManager();
|
||||
// connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
Reference in New Issue
Block a user