yuchuli 3 роки тому
батько
коміт
afdf75a3ae

+ 31 - 3
src/tool/view_message/dialogviewmessage.cpp

@@ -9,14 +9,20 @@ DialogViewMessage::DialogViewMessage(std::string strmsgname,QWidget *parent) :
 {
     ui->setupUi(this);
 
+    InitMsgType();
     mstrmsgname = strmsgname;
 
-    mpa = new iv::modulecommext::modulecommmsg<iv::testmodulecommext>();
+//    mpa = new iv::modulecommext::modulecommmsg<iv::testmodulecommext>();
 
-    ModuleExtFun funext = std::bind(&DialogViewMessage::UpdateMsg,this,std::placeholders::_1);
-    mpa->RegisterRecvPlus(strmsgname.data(),funext);
+//    ModuleExtFun funext = std::bind(&DialogViewMessage::UpdateMsg,this,std::placeholders::_1);
+//    mpa->RegisterRecvPlus(strmsgname.data(),funext);
     iv::testmodulecommext x;
 
+    ModuleFun funraw = std::bind(&DialogViewMessage::UpdateRawMsg,this,std::placeholders::_1,
+                                    std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,
+                                    std::placeholders::_5);
+    mparaw = iv::modulecomm::RegisterRecvPlus(strmsgname.data(),funraw);
+
     ::google::protobuf::Message * px = &x;
     px->GetTypeName();
 
@@ -53,3 +59,25 @@ void DialogViewMessage::UpdateMsg(google::protobuf::Message &xmsg)
     qDebug("update");
     emit msgupdate();
 }
+
+void DialogViewMessage::UpdateRawMsg(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+{
+    char * strxdata = new char[nSize];
+    memcpy(strxdata,strdata,nSize);
+    if(mvectorprob.size() == 0)
+    {
+        mvectorprob = GetProbProtoIndex(strxdata,nSize,mvectorprobname);
+    }
+
+    qDebug("prob size is %d ",mvectorprob.size());
+    if(mvectorprob.size() > 0)
+    {
+
+        std::shared_ptr<google::protobuf::Message> msg_ptr = GetProtoMessage(strxdata,nSize,mvectorprob[0]);
+        if(msg_ptr != NULL)
+        {
+            qDebug("parse ok.");
+        }
+    }
+    delete strxdata;
+}

+ 6 - 0
src/tool/view_message/dialogviewmessage.h

@@ -39,11 +39,17 @@ private:
 
     std::string mstrmsgname;
 
+    void * mparaw;
+
     iv::modulecommext::modulecommmsg<iv::testmodulecommext> * mpa;
 
     QMutex mMutexMsg;
 
+    std::vector<unsigned int> mvectorprob;
+    std::vector<std::string> mvectorprobname;
+
     void UpdateMsg(::google::protobuf::Message & xmsg);
+    void UpdateRawMsg(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname);
 
 };