yuchuli 2 жил өмнө
parent
commit
13ee462221

+ 32 - 1
src/tool/RemoteCtrl_Wide/grpcpc.cpp

@@ -63,6 +63,15 @@ int grpcpc::Produceh264frame(int ncampos,iv::h264rawframedata & xframe)
     return 0;
 }
 
+int64_t grpcpc::GetFrameCount(int ncampos)
+{
+    if(mbUseRTSP)
+    {
+        return mprtspdown[ncampos]->GetFrameCount();
+    }
+    return 0;
+}
+
 int grpcpc::Consumeh264frame(int ncampos,iv::h264rawframedata & xframe)
 {
     if(mbUseRTSP)
@@ -257,6 +266,9 @@ void grpcpc::run()
       timespec.tv_nsec = 0;
       timespec.clock_type = GPR_TIMESPAN;
 
+    mstrConnectState = "Connecting...";
+
+    unsigned int nnodata = 10;
 
     while(!QThread::isInterruptionRequested())
     {
@@ -351,12 +363,14 @@ void grpcpc::run()
 //                xTime1.start();
                 Status status = stub_->queryctrl(&context, request, &xreply);
                 if (status.ok()) {
+                    mstrConnectState = "Connected.";
 //                    std::cout<<" query time: "<<xTime1.elapsed()<<std::endl;
                     std::cout<<nid<<" query successfully, res is "<<xreply.nres()<<std::endl;
                     if(xreply.nres() == 1)
                     {
 
-
+                        nnodata = 0;
+                        mstrVehicleState = "Online.";
                         if(nlasttime != xmsg.xtime())
                         {
                             iv::cloud::cloudmsg xmsg;
@@ -372,6 +386,12 @@ void grpcpc::run()
                     else
                     {
                         std::this_thread::sleep_for(std::chrono::milliseconds(30));
+                        if(nnodata < 10000000) nnodata++;
+                        if(nnodata>10)
+                        {
+                            mstrVehicleState = "Offline.";
+                        }
+
                     }
                 } else {
                   std::cout << status.error_code() << ": " << status.error_message()
@@ -385,6 +405,7 @@ void grpcpc::run()
                                target_str, grpc::InsecureChannelCredentials(),cargs);
 
                       stub_ = iv::UploadThread::NewStub(channel);
+                      mstrConnectState = "Connecting.";
                   }
                   std::this_thread::sleep_for(std::chrono::milliseconds(900));
 
@@ -596,4 +617,14 @@ void grpcpc::setctrlMD5(std::string strmd5)
     gstrctrlMD5 = strmd5;
 }
 
+std::string grpcpc::GetConnectState()
+{
+    return  mstrConnectState;
+}
+
+std::string grpcpc::GetVehicleState()
+{
+    return  mstrVehicleState;
+}
+
 

+ 8 - 0
src/tool/RemoteCtrl_Wide/grpcpc.h

@@ -112,6 +112,9 @@ public:
     void setqueryMD5(std::string strmd5);
     void setctrlMD5(std::string strmd5);
 
+    std::string GetConnectState();
+    std::string GetVehicleState();
+
 public:
     int Consumeh264frame(int ncampos,iv::h264rawframedata & xframe);
     int Consumeh264frame(int ncampos,iv::h264rawframedata & xframe,int nwaitms);
@@ -119,6 +122,8 @@ public:
     int SetCtrlMsg(std::string strmsgname,char * strdata,int ndatasize);
     int GetQueryMsg(iv::cloud::cloudmsg & xcloudmsg,int nwaitms);
 
+    int64_t GetFrameCount(int ncampos);
+
 private:
 
     std::vector<iv::h264rawframedata> mvectorh264frame[NUM_CAM];
@@ -149,6 +154,9 @@ private:
     std::string mstrrtsppass = "hello";
     rtspclientdown * mprtspdown[NUM_CAM];
 
+    std::string mstrConnectState = "Init.";
+    std::string mstrVehicleState = "Offline";
+
 
 };
 

+ 8 - 0
src/tool/RemoteCtrl_Wide/mainwindowcenter.cpp

@@ -810,6 +810,14 @@ void MainWindow::onTimerUpdateView()
 
  //   unsigned int i;
 
+    ui->lineEdit_Status_Connect->setText(mgrpcpc->GetConnectState().data());
+    ui->lineEdit_Status_Vehicle->setText(mgrpcpc->GetVehicleState().data());
+
+    ui->lineEdit_Status_Front->setText(QString::number(mgrpcpc->GetFrameCount(0)));
+    ui->lineEdit_Status_Rear->setText(QString::number(mgrpcpc->GetFrameCount(1)));
+    ui->lineEdit_Status_Left->setText(QString::number(mgrpcpc->GetFrameCount(2)));
+    ui->lineEdit_Status_Right->setText(QString::number(mgrpcpc->GetFrameCount(3)));
+
    char strlatency[1000];
    char strtem[100];
    snprintf(strlatency,1000,"Latency(Up|FrameRate|Down): ");

+ 7 - 0
src/tool/RemoteCtrl_Wide/rtspclientdown.cpp

@@ -81,6 +81,8 @@ void rtspclientdown::threadrtspdown(std::string strrtspserver)
 
         mcv.notify_all();
 
+        mnFrameCount++;
+
 
          av_packet_unref(&i_pkt);
     }
@@ -134,3 +136,8 @@ int rtspclientdown::Getrtspframe(iv::h264rawframedata &xframe, int nwaitms)
 
 
 }
+
+int64_t rtspclientdown::GetFrameCount()
+{
+    return  mnFrameCount;
+}

+ 3 - 0
src/tool/RemoteCtrl_Wide/rtspclientdown.h

@@ -43,12 +43,15 @@ private:
 
     int mretrycount = 0;
 
+    int64_t mnFrameCount = 0;
+
 private:
     void threadrtspdown(std::string strrtspserver);
 
 public:
     int Getrtspframe(iv::h264rawframedata & xframe,int nwaitms);
     int Getretrycount();
+    int64_t GetFrameCount();
 };
 
 #endif // RTSPCLIENTDOWN_H