Просмотр исходного кода

更新qt与pdu同步的内存数据

chenyj 1 год назад
Родитель
Сommit
80ce8290a4

BIN
Qt/Qt_Test/Qt_Test


+ 14 - 5
Qt/Qt_Test/dataupdatethread.cpp

@@ -18,7 +18,7 @@ DataUpdateThread::DataUpdateThread(QObject *parent)
     nMaxCh=0;
     nReadType=0;
     m_shmData=0;
-    bTacStatus=false;
+    bTacStatus=0;
 }
 
 DataUpdateThread::~DataUpdateThread()
@@ -174,7 +174,9 @@ int DataUpdateThread::initShm()
     }
 
     /* 设置共享内存对象的大小 */
-
+    qDebug()<<"=======================================";
+    qDebug()<<"SHM_SizeOf="<<sizeof(smartPDU_shm_data);
+    qDebug()<<"=======================================";
     if (ftruncate(shm_fd, sizeof(smartPDU_shm_data)) == -1) {
         perror("ftruncate");
         return 2;
@@ -210,12 +212,19 @@ void DataUpdateThread::setShmChRead(int nCh,int nPhID)
     {
         if(m_shmData->nSelectPowerCH!=nCh)
         {
+
             m_shmData->nSelectPowerCH=nCh;
+            qDebug()<<"ShmData_____bT_ACType:"<<bTacStatus<<"nSelectPowerCH:"<<m_shmData->nSelectPowerCH;
             bTacStatus=m_shmData->bT_ACType;
             pdu_Ctrl::instance()->isT_ACType=bTacStatus;
-            if(bTacStatus)
+            if(bTacStatus==1)
             {
-                m_shmData->nSelectPh=nPhID;
+                if(m_shmData->nSelectPh!=nPhID)
+                {
+                   m_shmData->nSelectPh=nPhID;
+                   qDebug()<<"ShmData_____nSelectPowerCH:"<<m_shmData->nSelectPowerCH<<"nSelectPh:"<<m_shmData->nSelectPh;
+                }
+
             }else
             {
                 m_shmData->nSelectPh=0;
@@ -283,7 +292,7 @@ void DataUpdateThread::ReadShmMaxch()
     }
 }
 
-bool DataUpdateThread::isT_ACType()
+int DataUpdateThread::isT_ACType()
 {
     return bTacStatus;
 }

+ 3 - 3
Qt/Qt_Test/dataupdatethread.h

@@ -26,7 +26,7 @@ struct smartPDU_shm_data
     float fT;//温度
     float fH;//湿度
     //三项数据
-    bool bT_ACType;//三相类型
+    int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
 };
 class DataUpdateThread : public QThread
@@ -48,7 +48,7 @@ public:
     void setShmChRead(int nCh,int nPhID);
     void ReadShmData();
     void ReadShmMaxch();
-    bool isT_ACType();//三相标志
+    int isT_ACType();//三相标志
 public:
     //窗口
     Widget* pwidget;
@@ -73,7 +73,7 @@ public:
     int nReadType;
     int shm_fd;
 
-    bool bTacStatus;
+    int bTacStatus;
     smartPDU_shm_data* m_shmData;
 };
 

+ 2 - 2
Qt/Qt_Test/pdu_ctrl.cpp

@@ -24,7 +24,7 @@ pdu_Ctrl::pdu_Ctrl(QObject *parent) : QObject(parent)
     nChidIndex=0;
     nChidPHIndex=0;
     m_nAngle=0;
-    isT_ACType=false;
+    isT_ACType=0;
     memset(nButtonStatus,0,sizeof(nButtonStatus));
     //
 }
@@ -203,7 +203,7 @@ void pdu_Ctrl::Main_FunBtnSet(BtnDownType nbtnType)
             case 1:
             case 2://CH通道界面如果是三项则切换至三项子通道界面
                 {
-                    if(isT_ACType)
+                    if(isT_ACType==1)
                     {
                         lastACIndex=nNowIndex;
                         m_pWidget->setShowPHIndex(1);

+ 1 - 1
Qt/Qt_Test/pdu_ctrl.h

@@ -141,7 +141,7 @@ public:
     int m_nSaveData;
     QString strSqliteAddress;
 
-    bool isT_ACType;
+    int isT_ACType;
     int lastACIndex;
 };
 

+ 2 - 0
Qt/Qt_Test/widget.cpp

@@ -188,6 +188,7 @@ void Widget::setPH(int nIndex,int nPHType)
         strPHShow=QString("Output CH%1%2").arg(nIndex).arg(strShow);
     }
     SetData(ui->label_18,strPHShow);
+    qDebug()<<"CH_Select:"<<nIndex<<"PH_Select:"<<nPHType;
 }
 /*
 void Widget::BtnDown(int nButtonID, int nDownType)
@@ -229,6 +230,7 @@ void Widget::pageUp()
         if(nMAXChildIndex>0)
         {
             nChidIndex=1;
+            nChidPHIndex=0;
             setCH(nChidIndex);
             ui->stackedWidget_Main->setCurrentIndex(2);
         }else

+ 1 - 1
pro/src/common.h

@@ -333,7 +333,7 @@ typedef struct
     float fT;//温度
     float fH;//湿度
     //三项数据
-    bool bT_ACType;//三相类型
+    int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
 } smartPDU_shm_data;