|
@@ -18,7 +18,7 @@ UserinfoCommThread::UserinfoCommThread(QObject *parent, QTcpSocket *socket) :
|
|
|
OnLine = false;
|
|
|
getdata = false;
|
|
|
chkTime = true;
|
|
|
- chkTimeDate = QDate::currentDate();
|
|
|
+ chkTimeDate = QDateTime::currentDateTime();
|
|
|
uptime = QDateTime::currentDateTime().toTime_t();
|
|
|
SerivalNum = 0;
|
|
|
so = socket;
|
|
@@ -198,11 +198,11 @@ void UserinfoCommThread::check_protocol(QByteArray data)
|
|
|
CenterId = dest_addr;
|
|
|
quint16 frame_len = static_cast<quint16>((data.at(24)&0x00ff)|((data.at(25)&0x00ff)<<8));
|
|
|
quint8 Cmd = (data.at(26)&0xff);
|
|
|
+ QDateTime sendTime = QDateTime(QDate(year,month,day),QTime(hour,minutes,seconds));
|
|
|
if((frame_len>0)&&(frame_len<=1024)&&(len>=(frame_len+30))){
|
|
|
if(sn!=0x0000)
|
|
|
SerivalNum = sn;
|
|
|
frame_data = data.mid(27,static_cast<int>(frame_len));
|
|
|
- QDateTime sendTime = QDateTime(QDate(year,month,day),QTime(hour,minutes,seconds));
|
|
|
// QDateTime sendTime = curTime;
|
|
|
if((year<=curTime.date().year())&&(month>0)&&(month<13)&&(day>0)&&(day<32)&&(hour<24)&&(minutes<60)&&(seconds<60))
|
|
|
{
|
|
@@ -299,13 +299,16 @@ void UserinfoCommThread::check_protocol(QByteArray data)
|
|
|
emit CommData(QString("%1").arg(DeviceId),2,o);
|
|
|
#endif
|
|
|
}
|
|
|
- if((curTime.date().day()!=chkTimeDate.day())
|
|
|
- &&(curTime.time().hour()>2)
|
|
|
- &&(curTime.time().minute()>2))
|
|
|
+
|
|
|
+// if((sendTime.date().day()!=chkTimeDate.day())
|
|
|
+// &&(curTime.time().hour()>2)
|
|
|
+// &&(curTime.time().minute()>2))
|
|
|
+ int sendtimeInt = sendTime.toTime_t();
|
|
|
+ int systimeInt = QDateTime::currentDateTime().toTime_t();
|
|
|
+ if(abs(sendtimeInt-systimeInt)>180)
|
|
|
chkTime = true;
|
|
|
if(chkTime){
|
|
|
- setBuildingFireUserinfoTime(88888,DeviceId,curTime);
|
|
|
- chkTimeDate = QDate::currentDate();
|
|
|
+ setBuildingFireUserinfoTime(21,DeviceId,curTime);
|
|
|
chkTime = false;
|
|
|
}
|
|
|
}
|
|
@@ -498,7 +501,13 @@ void UserinfoCommThread::chkBuildingFireUserinfoPosts(quint64 srcAddr, quint64 d
|
|
|
|
|
|
void UserinfoCommThread::setBuildingFireUserinfoTime(quint64 srcAddr, quint64 destAddr, QDateTime dt)
|
|
|
{
|
|
|
- QDateTime curTime = QDateTime::currentDateTime();
|
|
|
+ QDateTime t = QDateTime::currentDateTime();
|
|
|
+ int sec = t.time().second();
|
|
|
+ int min = t.time().minute();
|
|
|
+ int hour = t.time().hour();
|
|
|
+ int day = t.date().day();
|
|
|
+ int mon = t.date().month();
|
|
|
+ int year = t.date().year();
|
|
|
QByteArray cmd = QByteArray(38,0x00);
|
|
|
quint16 frame_len = 0x0008;
|
|
|
SerivalNum++;
|
|
@@ -508,12 +517,12 @@ void UserinfoCommThread::setBuildingFireUserinfoTime(quint64 srcAddr, quint64 de
|
|
|
cmd[3] = static_cast<char>((SerivalNum>>8)&0xff);
|
|
|
cmd[4] = static_cast<char>(0x01);
|
|
|
cmd[5] = static_cast<char>(0x01);
|
|
|
- cmd[6] = static_cast<char>(curTime.time().second()&0xff);
|
|
|
- cmd[7] = static_cast<char>(curTime.time().minute()&0xff);
|
|
|
- cmd[8] = static_cast<char>(curTime.time().hour()&0xff);
|
|
|
- cmd[9] = static_cast<char>(curTime.date().day()&0xff);
|
|
|
- cmd[10] = static_cast<char>(curTime.date().month()&0xff);
|
|
|
- cmd[11] = static_cast<char>((curTime.date().year()-2000)&0xff);
|
|
|
+ cmd[6] = static_cast<char>(sec&0xff);
|
|
|
+ cmd[7] = static_cast<char>(min&0xff);
|
|
|
+ cmd[8] = static_cast<char>(hour&0xff);
|
|
|
+ cmd[9] = static_cast<char>(day&0xff);
|
|
|
+ cmd[10] = static_cast<char>(mon&0xff);
|
|
|
+ cmd[11] = static_cast<char>((year-2000)&0xff);
|
|
|
cmd[12] = static_cast<char>(srcAddr&0xff);
|
|
|
cmd[13] = static_cast<char>((srcAddr>>8)&0xff);
|
|
|
cmd[14] = static_cast<char>((srcAddr>>16)&0xff);
|
|
@@ -531,12 +540,12 @@ void UserinfoCommThread::setBuildingFireUserinfoTime(quint64 srcAddr, quint64 de
|
|
|
cmd[26] = static_cast<char>(0x01);
|
|
|
cmd[27] = static_cast<char>(0x5a);
|
|
|
cmd[28] = static_cast<char>(0x01);
|
|
|
- cmd[29] = static_cast<char>(dt.time().second()&0xff);
|
|
|
- cmd[30] = static_cast<char>(dt.time().minute()&0xff);
|
|
|
- cmd[31] = static_cast<char>(dt.time().hour()&0xff);
|
|
|
- cmd[32] = static_cast<char>(dt.date().day()&0xff);
|
|
|
- cmd[33] = static_cast<char>(dt.date().month()&0xff);
|
|
|
- cmd[34] = static_cast<char>((dt.date().year()-2000)&0xff);
|
|
|
+ cmd[29] = static_cast<char>(sec&0xff);;
|
|
|
+ cmd[30] = static_cast<char>(min&0xff);
|
|
|
+ cmd[31] = static_cast<char>(hour&0xff);
|
|
|
+ cmd[32] = static_cast<char>(day&0xff);
|
|
|
+ cmd[33] = static_cast<char>(mon&0xff);
|
|
|
+ cmd[34] = static_cast<char>((year-2000)&0xff);
|
|
|
cmd[35] = static_cast<char>(0x00);
|
|
|
cmd[36] = static_cast<char>(0x23);
|
|
|
cmd[37] = static_cast<char>(0x23);
|
|
@@ -546,10 +555,10 @@ void UserinfoCommThread::setBuildingFireUserinfoTime(quint64 srcAddr, quint64 de
|
|
|
cmd[35] = static_cast<char>(crc&0xff);
|
|
|
if(so->write(cmd)==38){
|
|
|
#ifdef CommDbg
|
|
|
- QString o = QString("[ %1 %2(%3) >>> ]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz ")).arg(so->peerAddress().toString()).arg(DeviceId);
|
|
|
+ QString o = QString("[zyj1 %1 %2(%3) >>> ]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz ")).arg(so->peerAddress().toString()).arg(DeviceId);
|
|
|
for(int i=0;i<38;i++)
|
|
|
o.append(QString(" %1").arg(cmd[i]&0xff,2,16,QChar('0')));
|
|
|
-// emit getCommData(o);
|
|
|
+ emit getCommData(o);
|
|
|
emit CommData(QString("%1").arg(DeviceId),2,o);
|
|
|
#endif
|
|
|
}
|