Browse Source

coreobject.cpp代码增加nopic_count全局变量侦测图像预览接口故障

yaoqiang 4 years ago
parent
commit
112094f3bb
2 changed files with 37 additions and 28 deletions
  1. 32 23
      CamCore/coreobject.cpp
  2. 5 5
      YtCam.pro.user

+ 32 - 23
CamCore/coreobject.cpp

@@ -20,11 +20,14 @@ extern QString getNewId();
 uint start_time;
 bool had_reg;
 
+int nopic_count;
+
 MyEHomeShm *ytShm;
 
 CoreObject::CoreObject(QObject *parent) :
     QObject(parent)
 {
+    nopic_count = 0;
     processList.clear();
     sqlList.clear();
     reportList.clear();
@@ -449,37 +452,40 @@ BOOL InputStreamData(QString deviceid, BYTE byDataType, char* pBuffer, int iData
     int i;
     uint t = QDateTime::currentDateTime().toTime_t();
     ytShm->workingTime[0] = t;
-    for(i=0;i<DEVICES_COUNT;i++){
-        if(QString(ytShm->eHomeDevice[i].deviceID).compare(deviceid)==0){
-            if(ytShm->eHomeDevice[i].io[0]==0x01){
-                ytShm->eHomeDevice[i].time[0] = t;
-                if(ytShm->eHomeDevice[i].savetmp==0x00){
-                    if(ytShm->eHomeDevice[i].tmpfile!=NULL){
-                        fclose(ytShm->eHomeDevice[i].tmpfile);
-                        ytShm->eHomeDevice[i].tmpfile = NULL;
-                    }
-                    QString tmpfile = QString("/tmp/%1.mp4").arg(ytShm->eHomeDevice[i].deviceID).replace(" ","_");
-                    sprintf(ytShm->eHomeDevice[i].filename,"%s",tmpfile.toUtf8().data());
-                    setFullTime(&(ytShm->eHomeDevice[i].onLinetime),QDateTime::currentDateTime());
-                    ytShm->eHomeDevice[i].savetmp = 0x01;
-                    ytShm->eHomeDevice[i].tmpfile  = fopen(tmpfile.toUtf8().data(),"wb");
-                    fwrite(pBuffer,iDataLen,1,ytShm->eHomeDevice[i].tmpfile);
-                }else{
-                    if(ytShm->eHomeDevice[i].tmpfile!=NULL){
-                        fwrite(pBuffer,iDataLen,1,ytShm->eHomeDevice[i].tmpfile);
-                    }else{
+    if(iDataLen>0){
+        nopic_count = 0;
+        for(i=0;i<DEVICES_COUNT;i++){
+            if(QString(ytShm->eHomeDevice[i].deviceID).compare(deviceid)==0){
+                if(ytShm->eHomeDevice[i].io[0]==0x01){
+                    ytShm->eHomeDevice[i].time[0] = t;
+                    if(ytShm->eHomeDevice[i].savetmp==0x00){
+                        if(ytShm->eHomeDevice[i].tmpfile!=NULL){
+                            fclose(ytShm->eHomeDevice[i].tmpfile);
+                            ytShm->eHomeDevice[i].tmpfile = NULL;
+                        }
                         QString tmpfile = QString("/tmp/%1.mp4").arg(ytShm->eHomeDevice[i].deviceID).replace(" ","_");
                         sprintf(ytShm->eHomeDevice[i].filename,"%s",tmpfile.toUtf8().data());
                         setFullTime(&(ytShm->eHomeDevice[i].onLinetime),QDateTime::currentDateTime());
-//                        ytShm->eHomeDevice[i].savetmp = 0x01;
+                        ytShm->eHomeDevice[i].savetmp = 0x01;
                         ytShm->eHomeDevice[i].tmpfile  = fopen(tmpfile.toUtf8().data(),"wb");
                         fwrite(pBuffer,iDataLen,1,ytShm->eHomeDevice[i].tmpfile);
+                    }else{
+                        if(ytShm->eHomeDevice[i].tmpfile!=NULL){
+                            fwrite(pBuffer,iDataLen,1,ytShm->eHomeDevice[i].tmpfile);
+                        }else{
+                            QString tmpfile = QString("/tmp/%1.mp4").arg(ytShm->eHomeDevice[i].deviceID).replace(" ","_");
+                            sprintf(ytShm->eHomeDevice[i].filename,"%s",tmpfile.toUtf8().data());
+                            setFullTime(&(ytShm->eHomeDevice[i].onLinetime),QDateTime::currentDateTime());
+    //                        ytShm->eHomeDevice[i].savetmp = 0x01;
+                            ytShm->eHomeDevice[i].tmpfile  = fopen(tmpfile.toUtf8().data(),"wb");
+                            fwrite(pBuffer,iDataLen,1,ytShm->eHomeDevice[i].tmpfile);
+                        }
                     }
+                }else{
+                    NET_ECMS_StopGetRealStream(ytShm->eHomeDevice[i].LoginId,ytShm->eHomeDevice[i].SessionId);
                 }
-            }else{
-                NET_ECMS_StopGetRealStream(ytShm->eHomeDevice[i].LoginId,ytShm->eHomeDevice[i].SessionId);
+                return true;
             }
-            return true;
         }
     }
     return false;
@@ -924,9 +930,12 @@ void CoreObject::time_out()
         while(AlaList.hasNext()){
             AlarmEvent ae = AlaList.next();
             if((t.toTime_t()-ae.t_stamp)>120){
+                nopic_count++;
                 a_count++;
                 appendLog(QString("[ %1 out(%2:%3) ] %4 %5").arg(t.toString("yyyy-MM-dd HH:mm:ss")).arg(alarmList.length()).arg(a_count).arg(ae.Device_Code).arg(ae.Event_Time));
                 clear_devalarm(ae);
+                if(nopic_count>5)
+                    exit(1);
             }
         }
     }

+ 5 - 5
YtCam.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.7.2, 2021-05-28T16:09:21. -->
+<!-- Written by QtCreator 4.7.2, 2021-05-31T08:40:44. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
@@ -192,7 +192,7 @@
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">CamCore/CamCore.pro</value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/yt/Qt2/build-YtCam-Qt_5_9_7-Release/CamCore</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
     <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
@@ -249,7 +249,7 @@
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">CamDog/CamDog.pro</value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/yt/Qt2/build-YtCam-Qt_5_9_7-Release/CamDog</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
     <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
@@ -306,7 +306,7 @@
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">cgi/cgi.pro</value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/yt/Qt2/build-YtCam-Qt_5_9_7-Release/cgi</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
     <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
@@ -363,7 +363,7 @@
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">ytDHCamCore/ytDHCamCore.pro</value>
     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/yt/Qt2/build-YtCam-Qt_5_9_7-Release/ytDHCamCore</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
     <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>