Ver Fonte

COM test with PIS protocol.

Qiuyang há 2 anos atrás
pai
commit
5ec2c2f7d1

+ 38 - 17
framework/request/include/PIDSClientResultMsg.h

@@ -24,35 +24,56 @@ public:
     void Serialization(uint8_t* data)
     {
         data[0] = PIDS_DATA_HEAD;
-        data[1] = PIDS_SRC_TC1;
+        data[1] = PIDS_DATA_TYPE;
         data[2] = PIDS_SRC_TYPE_MIVA;
-        // IP
-        data[3] = 172;
+        
+        //rsvd
+        data[3] = 0;
         data[4] = 0;
         data[5] = 0;
-        data[6] = 1;
+        data[6] = 0;
+
+        //length
+        data[7] = 0x00;
+        data[8] = 0x30;
 
-        int16_t length = 36;
-        data[7] = (length & 0x00FF);
-        data[8] = (length & 0xFF00) >> 8;
+        //rsvd
+        data[9] = 0;
+        data[10] = 0;
+        data[11] = 0;
+        data[12] = 0;
+        data[13] = 0;
 
         // 填充数据
         // Time
-        getBCDTime(data + 9); 
+        //getBCDTime(data + 14); 
+        getTime(data + 14);
+
+        data[21] = 0;
+        data[22] = 0;
+
+        //Data
+        // data[23] = this->data[0].Grade;
+        // data[24] = this->data[1].Grade;
+        // data[25] = this->data[2].Grade;
+        // data[26] = this->data[3].Grade;
+        // data[27] = this->data[4].Grade;
+        // data[28] = this->data[5].Grade;
 
-        data[15] = this->TrainLine;
-        data[16] = this->Train;
+        data[23] = this->data[0].Num;
+        data[24] = this->data[1].Num;
+        data[25] = this->data[2].Num;
+        data[26] = this->data[3].Num;
+        data[27] = this->data[4].Num;
+        data[28] = this->data[5].Num;
 
-        int id = 0;
-        for(int i = 0; i < 18; i+=3)
+        //rsvd
+        for(int i = 29; i < 45; i++)
         {
-            data[17+i] = this->data[id].Grade;
-            data[18+i] = (this->data[id].Num & 0x00FF);
-            data[19+i] = (this->data[id].Num & 0xFF00) >> 8;
-            id++;
+            data[i] = 0;
         }
 
-        int16_t crc = Crc16::GetCRC16(data, 9, length);
+        int16_t crc = Crc16::GetCRC16(data, 9, 36);
         data[45] = (crc & 0xFF00) >> 8;
         data[46] = (crc & 0x00FF);
          

+ 19 - 0
framework/request/include/PIDSDataDefine.h

@@ -9,6 +9,7 @@
 using namespace std;
 
 #define PIDS_DATA_HEAD  (0xFD)  // 帧头
+#define PIDS_DATA_TYPE  (0x04)  // From MIVA to PIS
 #define PIDS_DATA_END   (0xFE)  // 帧尾
 
 #define PIDS_SRC_TC1    (0x01)  // 源设备车厢编号:TC1
@@ -49,6 +50,7 @@ void getBCDTime(uint8_t *out)
 
     t = time(NULL);
     tp = localtime(&t);
+    out[i++] = HEX2BCD(tp->tm_year % 100);
     out[i++] = HEX2BCD(tp->tm_year-100);
     out[i++] = HEX2BCD(tp->tm_mon+1);
     out[i++] = HEX2BCD(tp->tm_mday);
@@ -57,6 +59,23 @@ void getBCDTime(uint8_t *out)
     out[i++] = HEX2BCD(tp->tm_sec);
 }
 
+void getTime(uint8_t *out)
+{
+    time_t t;
+    int i = 0;
+    struct tm *tp = NULL;
+
+    t = time(NULL);
+    tp = localtime(&t);
+    out[i++] = tp->tm_year / 100 + 19;
+    out[i++] = tp->tm_year % 100;
+    out[i++] = tp->tm_mon+1;
+    out[i++] = tp->tm_mday;
+    out[i++] = tp->tm_hour;
+    out[i++] = tp->tm_min;
+    out[i++] = tp->tm_sec;
+}
+
 void getDataTime(char *ctime)
 {
     time_t rawtime;

BIN
lib/libmiva_core.so


BIN
lib/libmodules.so


BIN
lib/libnvdsinfer_custom_impl_Yolo.so


+ 1 - 1
modules/deviceState/src/deviceState.cpp

@@ -76,8 +76,8 @@ namespace MIVA
      */    
     int32_t deviceState::SyncFdThreshold(int sourceNum, bool outState){
         std::lock_guard<mutex> gurad(m_mutex);
-        static int num = 0;
         static int fdMin = 3000;
+        //static int num = 0;
         // if(num != sourceNum || outState){
         //     num = sourceNum;
         //     fdMin = 3000;

+ 6 - 3
modules/inference/src/inference.cpp

@@ -149,7 +149,7 @@ namespace MIVA{
         this->nvosd = gst_element_factory_make ("nvdsosd", "nv-onscreendisplay");
 
         this->sink = gst_element_factory_make ("fakesink", "nvvideo-renderer");
-        
+
         if (!this->pgie || !this->nvvidconv || !this->nvosd || !this->sink) {
             ErrorL << "One element could not be created. Exiting.";
             return -1;
@@ -204,6 +204,7 @@ namespace MIVA{
         gst_object_unref (this->tiler_sink_pad);
 
         this->enable = true;
+        InfoL<<"Infer init OK.";
         return OK;
     }
 
@@ -220,11 +221,11 @@ namespace MIVA{
         pool.async([&](){
             if(num == 0){
                 num++;
-                if(m_recorder != nullptr && this->RestartTask() == OK) m_recorder->Start();
+                if(m_recorder != nullptr && this->RestartTask() == OK) {m_recorder->Start(); }
                 // 不能去掉, 去掉会触发Deepstream内部句柄无法释放的Bug
                 g_main_loop_run(this->loop);
             }else{
-                if(m_recorder != nullptr && this->RestartTask() == OK) m_recorder->Start();
+                if(m_recorder != nullptr && this->RestartTask() == OK) {m_recorder->Start(); }
             }
         });
         pool.start();
@@ -862,6 +863,8 @@ namespace MIVA{
         for (auto iter = this->m_InferInfo->DataSources.begin(); iter != this->m_InferInfo->DataSources.end(); iter++){
             if(iter->source_bin != NULL){
                 state_return = gst_element_set_state(iter->source_bin, GST_STATE_NULL);
+                if(!state_return)
+                    WarnL<<"Gst state change failure.";
             }
         }
     }

+ 2 - 2
modules/monitor/src/monitor.cpp

@@ -47,9 +47,9 @@ namespace MIVA
         this->file = fopen("/proc/meminfo","r");
         char keyword[20];
         char valuech[20];
-        long mem = 0;
         fscanf(file,"MemTotal: %s kB\n",keyword);
-        mem = atol(keyword)/1000;
+        //long mem = 0;
+        //mem = atol(keyword)/1000;
         fscanf(file,"MemFree: %s kB\n",valuech);
         fscanf(file,"MemAvailable: %s kB\n",valuech);
         MemoryUsage=atol(valuech)/1000;

+ 8 - 1
modules/recorder/src/recorder.cpp

@@ -71,12 +71,19 @@ namespace MIVA
         time_t rawtime;
         char ctime[80];
         struct tm *info;
+        dirp = opendir(this->Dir.c_str());
+        if(dirp == NULL){
+            mkdir((this->Dir).c_str(),S_IRWXU|S_IRWXG|S_IRWXO);
+        }
+        else{
+            closedir(dirp);
+        }
         time(&rawtime);
         info = localtime(&rawtime);
         strftime(ctime, 80, "%Y-%m-%d_%H:%M:%S", info);
         this->outDir = ctime;
         this->outDir = this->Dir + this->outDir.substr(0, 7);
-        dirp = opendir(this ->outDir.c_str());
+        dirp = opendir(this->outDir.c_str());
         if(dirp == NULL){
             mkdir((this->outDir).c_str(),S_IRWXU|S_IRWXG|S_IRWXO);
         }else{

+ 14 - 4
modules/userApp/src/user_app.cpp

@@ -155,6 +155,7 @@ namespace MIVA
                 data.AddrNum = GetAddrNum(data.Pid);
                 this->m_InferInfo->DataSources.push_back(data);
                 sourceId++;
+                InfoL << "Load source with id:"<<data.Id<<" url:"<<data.uri; 
             }
             if(m_Infer->Init() != OK){
                 ErrorL << "Inference module initialization failed";
@@ -262,7 +263,7 @@ namespace MIVA
         #endif
 
         // 定时上报数据
-        this->m_timer1 = std::make_shared<Timer>(1.0f,[&](){
+        this->m_timer1 = std::make_shared<Timer>(2.0f,[&](){
             this->ReportData(); // 上报数据
             return true;
         }, nullptr);
@@ -293,6 +294,12 @@ namespace MIVA
             return true;
         },nullptr);
 
+        /*if(this->m_manager->getStartPower() != OK) WarnL << "推理未结束或内存所剩不足或资源未释放完全" << endl;
+        this ->m_timer0 = std::make_shared<Timer>(5.0f, [&](){
+            this->ListenClosed();
+            return false;
+        }, nullptr);*/
+
         // 记录时间
         clock_gettime(CLOCK_BOOTTIME, &time1);
         InfoL << "Task started successfully!" << endl;
@@ -375,7 +382,8 @@ namespace MIVA
         if(this->m_httpClient == NULL) this->m_httpClient = HttpClient::CreateNew();
         
         DebugL << "登录Netty" << endl;
-        if(this->m_httpClient->Init(this->account,this->Netty_ip,8760) != OK){
+        //if(this->m_httpClient->Init(this->account,this->Netty_ip,8760) != OK){
+        if(this->m_httpClient->Init(this->account,this->Netty_ip,80) != OK){
             ErrorL << "HttpClient登录Netty失败" << endl;
         }else{
             DebugL << "登录Netty成功!!!!" << endl;
@@ -549,6 +557,7 @@ namespace MIVA
             // 获取到关好门的信号
             if((serverResultMag.DoorFlag))
             {   
+                InfoL<<"Door closed.";
                 if(this->m_manager->getStartPower() != OK) WarnL << "推理未结束或内存所剩不足或资源未释放完全" << endl;
                 if(CloseTimer != nullptr) CloseTimer.reset();
                 // 定时5s后启动
@@ -851,9 +860,10 @@ namespace MIVA
      */    
     uint32_t UserApp::DataCalculation(uint32_t noLoad, uint32_t dynamicLoad, int num)
     {
+        //TODO: Add acture calculation logic
         uint32_t result = 0;
-        
-        return num;
+        result = num;
+        return result;
     }
 
     int UserApp::GetAddrNum(std::string Pid){

BIN
source/config/FP16/yolov5s.engine