Sfoglia il codice sorgente

调试修正了qt报警功能

chenyuanjie 1 anno fa
parent
commit
ac686cf118

+ 2 - 0
Qt/Qt_Test/dataupdatethread.cpp

@@ -427,6 +427,8 @@ void DataUpdateThread::slot_ClickMSG()
     if(0<=nIndexMSG&&nIndexMSG<10)
     {
         m_shmData->nTypeCtrlType[nIndexMSG]=MSGCtrl_Click;
+        qDebug()<<"slot_ClickMSGIndex=:"<<nIndexMSG;
+        qDebug()<<"slot_ClickMSGIndexData=:"<<m_shmData->nTypeCtrlType[nIndexMSG];
     }
     nIndexMSG=NextIndex();
 

+ 6 - 1
Qt/Qt_Test/msgwidget.ui

@@ -41,6 +41,11 @@ QLabel
    </property>
    <item>
     <widget class="QLabel" name="label_2">
+     <property name="font">
+      <font>
+       <pointsize>12</pointsize>
+      </font>
+     </property>
      <property name="styleSheet">
       <string notr="true"/>
      </property>
@@ -56,7 +61,7 @@ QLabel
     <widget class="QLabel" name="label">
      <property name="font">
       <font>
-       <pointsize>9</pointsize>
+       <pointsize>10</pointsize>
       </font>
      </property>
      <property name="text">

+ 1 - 0
Qt/Qt_Test/widget.cpp

@@ -444,6 +444,7 @@ void Widget::ShowMSGWidget(QString strShowData)
     {
         m_pMSGWidget->SetText(strShowData);
         QRect parentRect = this->geometry();
+        m_pMSGWidget->setFixedWidth(parentRect.width()-4);
         m_pMSGWidget->move(parentRect.center() - m_pMSGWidget->rect().center());
         m_pMSGWidget->show();
         qDebug()<<"MSGWidget_Show geometry("<<m_pMSGWidget->geometry().x()<<","<<m_pMSGWidget->geometry().y()<<","<<m_pMSGWidget->geometry().width()<<","<<m_pMSGWidget->geometry().height()<<")";

BIN
cust_data/qt/IP/Qt_Test


BIN
cust_data/qt/Qt_Test


+ 17 - 10
pro/src/sqlite_handle.c

@@ -2889,14 +2889,12 @@ static void AlarmToShm(char* strData)
                 if (_globalDeviceManager->g_shm_Data->nTypeCtrlType[i] == 0||_globalDeviceManager->g_shm_Data->nTypeCtrlType[i] == 2)
                 {
                     isLastIndex = i;
+                    break;
                 }
             }    
-            if (isLastIndex != -1)//全部被占满则使用全局记录的位置进行添加
+            if (isLastIndex == -1)//全部被占满则使用全局记录的位置进行添加
             {
-                _globalDeviceManager->g_shm_Data->nTypeCtrlType[_globalDeviceManager->g_lastAlarmIndex]=1;//设置更新了一个报警
-                memset(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex],0,nMAXLens);
-                strcpy(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex], strSave);
-                if (_globalDeviceManager->g_lastAlarmIndex < 10 && _globalDeviceManager->g_lastAlarmIndex >= 0)
+                if (_globalDeviceManager->g_lastAlarmIndex < 9 && _globalDeviceManager->g_lastAlarmIndex >= 0)
                 {
                     _globalDeviceManager->g_lastAlarmIndex++;
                 }
@@ -2904,12 +2902,21 @@ static void AlarmToShm(char* strData)
                 {
                     _globalDeviceManager->g_lastAlarmIndex = 0;
                 }
-            }else//未被全部占满则使用空闲位置添加
+
+                _globalDeviceManager->g_shm_Data->nTypeCtrlType[_globalDeviceManager->g_lastAlarmIndex]=1;//设置更新了一个报警
+                memset(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex],0,nMAXLens);
+                strcpy(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex], strSave);
+
+            }
+            else // 未被全部占满则使用空闲位置添加
             {
-                _globalDeviceManager->g_shm_Data->nTypeCtrlType[isLastIndex]=1;//设置更新了一个报警
-                strcpy(_globalDeviceManager->g_shm_Data->strMSG[isLastIndex], strSave);
-                _globalDeviceManager->g_lastAlarmIndex=isLastIndex;
-            }            
+                if (isLastIndex >= 0 && isLastIndex < 10)
+                {
+                    _globalDeviceManager->g_shm_Data->nTypeCtrlType[isLastIndex] = 1; // 设置更新了一个报警
+                    strcpy(_globalDeviceManager->g_shm_Data->strMSG[isLastIndex], strSave);
+                    _globalDeviceManager->g_lastAlarmIndex = isLastIndex;
+                }
+            }
         }
     }
 }