5 次代码提交 b0102777ea ... ccbe4d0777

作者 SHA1 备注 提交日期
  chenyuanjie ccbe4d0777 上传QT和app两方提示信息同步的功能 1 年之前
  chenyuanjie 6a673d5657 Merge branch 'master' of https://gowone.dy.takin.cc/liyuezong/SmartPDCode 1 年之前
  chenyuanjie 6d51ab16b1 Merge branch 'master' of https://gowone.dy.takin.cc/liyuezong/SmartPDCode 1 年之前
  chenyuanjie 77502ea4bb Merge branch 'master' of https://gowone.dy.takin.cc/liyuezong/SmartPDCode 1 年之前
  chenyuanjie d732968434 增加了高配与中配低配的兼容 1 年之前

+ 6 - 3
Qt/Qt_Test/Qt_Test.pro

@@ -30,7 +30,8 @@ SOURCES += \
     volviewform.cpp \
     udphelper.cpp \
     dataupdatethread.cpp \
-    buttonclickthread.cpp
+    buttonclickthread.cpp \
+    msgwidget.cpp
 
 HEADERS += \
     pdu_ctrl.h \
@@ -38,11 +39,13 @@ HEADERS += \
     volviewform.h \
     udphelper.h \
     dataupdatethread.h \
-    buttonclickthread.h
+    buttonclickthread.h \
+    msgwidget.h
 
 FORMS += \
     volviewform.ui \
-    widget.ui
+    widget.ui \
+    msgwidget.ui
 
 target.path = /root/web_temp
 INSTALLS += target

+ 1 - 1
Qt/Qt_Test/Qt_Test.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.5.2, 2025-06-22T00:53:08. -->
+<!-- Written by QtCreator 4.5.2, 2025-07-19T14:10:39. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 1 - 2
Qt/Qt_Test/buttonclickthread.h

@@ -1,7 +1,6 @@
 #ifndef BUTTONCLICKTHREAD_H
 #define BUTTONCLICKTHREAD_H
-//#define hightSmartPDU
-#define rs485KEY
+
 #include <QObject>
 #include <QThread>
 #include <QDebug>

+ 103 - 0
Qt/Qt_Test/dataupdatethread.cpp

@@ -19,6 +19,7 @@ DataUpdateThread::DataUpdateThread(QObject *parent)
     nReadType=0;
     m_shmData=0;
     bTacStatus=0;
+    nIndexMSG=0;
 }
 
 DataUpdateThread::~DataUpdateThread()
@@ -80,12 +81,14 @@ void DataUpdateThread::run()
                     pwidget->UpdateDate();
                     pwidget->update();
                 }
+                ReadMSG();
             }else
             {
                 int nMode=pwidget->getShowModeIndex();
                 int nPage=pwidget->getShowPagIndex();
                 //qDebug() <<"ReadType=1 nMode:"<<nMode<<";nPage"<<nPage;
                 ReadShmMaxch();
+                ReadMSG();
                 if(nMode==0&&nPage!=0)
                 {
                     int nSubPag=pwidget->getShowSubIndex();
@@ -118,6 +121,12 @@ void DataUpdateThread::run()
     }
 }
 
+void DataUpdateThread::SetShowWidget(Widget *pShowWidget)
+{
+    pwidget=pShowWidget;
+    connect(pwidget,SIGNAL(signal_ClickMSG()),this,SLOT(slot_ClickMSG()));
+}
+
 void DataUpdateThread::ReadSqlData(int nCHID)
 {
     if(!isDBOpen)
@@ -319,4 +328,98 @@ int DataUpdateThread::isT_ACType()
     return bTacStatus;
 }
 
+void DataUpdateThread::ReadMSG()
+{
+    if(nReadType!=1&&!m_shmData)
+    {
+        return;
+    }
+    if(0<=nIndexMSG&&nIndexMSG<10)
+    {
+        switch(m_shmData->nTypeCtrlType[nIndexMSG])
+        {
+            case MSGCtrl_Null:
+            case MSGCtrl_Click:
+            {
+                bool isHaveMSG=false;
+                //未检测到更新从当前位置循环遍历一遍
+                qDebug()<<"MSG_Find"<<nIndexMSG<<"=Null";
+                for(int nIndex=0;nIndex<10;nIndex++)//监测其他的点是否有被更新依次刷新过去
+                {
+                    nIndexMSG=NextIndex();
+                    if(m_shmData->nTypeCtrlType[nIndexMSG]==MSGCtrl_Write)//检测到新的点。
+                    {
+                        qDebug()<<nIndexMSG<<"=MSGCtrl_Write";
+                        isHaveMSG=true;
+                        QString strShow=QString::fromLocal8Bit(m_shmData->strMSG[nIndexMSG]);
+                        qDebug()<<"MSG_Update char*MSG="<<m_shmData->strMSG[nIndexMSG];
+                        qDebug()<<"MSG_Update strMSG="<<strShow;
+                        ShowMSGWidget(strShow);
+                        break;
+                    }else
+                    {
+                        //qDebug()<<nIndexMSG<<"="<<m_shmData->nTypeCtrlType[nIndexMSG];
+                    }
+                }
+                if(isHaveMSG)
+                {
+                    nIndexMSG=0;//如果全没有就重新设置到0从0开始
+                }
+            }
+            break;
+            case MSGCtrl_Write://存在已写入的数据
+            {
+                QString strShow=QString::fromLocal8Bit(m_shmData->strMSG[nIndexMSG]);
+                qDebug()<<"MSG_Update char*MSG="<<m_shmData->strMSG[nIndexMSG];
+                qDebug()<<"MSG_Update strMSG="<<strShow;
+                ShowMSGWidget(strShow);
+            }
+            break;
+            default:
+                break;
+        }
+        qDebug()<<"MSG_Switch_end nIndexMSG ="<<nIndexMSG;
+    }
+}
+
+int DataUpdateThread::NextIndex()
+{
+    if(0<=nIndexMSG&&nIndexMSG<9)
+    {
+        return nIndexMSG+1;
+    }else
+    {
+        return 0;
+    }
+}
+
+void DataUpdateThread::ShowMSGWidget(QString strShowData)
+{
+    if(strShowData.isEmpty())return;
+    if(pwidget&&pwidget->isHiddenMSGWidget())
+    {
+        if(strShowData!=strNowMSG)
+        {
+            strNowMSG=strShowData;
+            pwidget->ShowMSGWidget(strShowData);
+        }
+    }
+}
+
+void DataUpdateThread::slot_ClickMSG()
+{
+    strNowMSG="";
+    if(nReadType!=1&&!m_shmData)
+    {
+        return;
+    }
+    if(0<=nIndexMSG&&nIndexMSG<10)
+    {
+        m_shmData->nTypeCtrlType[nIndexMSG]=MSGCtrl_Click;
+    }
+    nIndexMSG=NextIndex();
+
+    //ReadMSG();
+}
+
 

+ 21 - 1
Qt/Qt_Test/dataupdatethread.h

@@ -30,6 +30,16 @@ struct smartPDU_shm_data
     //三项数据
     int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
+    //报警列表 0表示空,1表示写入,2表示已确认可清空。
+    int nTypeCtrlType[10];
+    char strMSG[10][50];
+};
+enum MSGCtrlType
+{
+    MSGCtrl_Null=0,
+    MSGCtrl_Write=1,
+    MSGCtrl_Click=2,
+    MSGCtrl_ReWrite=3,
 };
 class DataUpdateThread : public QThread
 {
@@ -41,6 +51,7 @@ public:
 
     void run();
 
+    void SetShowWidget(Widget* pShowWidget);
     void ReadSqlData(int nCHID=0);
     void ReadMaxCh();
 
@@ -52,6 +63,12 @@ public:
     void ReadShmMaxch();
     void ReadShmVer();
     int isT_ACType();//三相标志
+
+    void ReadMSG();//获取报警提示
+    int NextIndex();
+    void ShowMSGWidget(QString strShowData);
+public slots:
+    void slot_ClickMSG();//确认msg
 public:
     //窗口
     Widget* pwidget;
@@ -74,12 +91,15 @@ public:
     QString strStatus;
     QString strVer;
     int nMaxCh;
-
+    //读取状态:-1空删除,0
     int nReadType;
     int shm_fd;
 
     int bTacStatus;
     smartPDU_shm_data* m_shmData;
+    //显示msg位置
+    int nIndexMSG;
+    QString strNowMSG;//当前显示的名字
 };
 
 #endif // DATAUPDATETHREAD_H

+ 8 - 2
Qt/Qt_Test/main.cpp

@@ -23,9 +23,14 @@ int main(int argc, char *argv[])
     g_proxy_widget = scene->addWidget((QWidget*)&w);
     g_proxy_widget->setRotation(0);
     // Set window size
+#ifdef RS485Type
+    w.resize(screen_info.width()+2, screen_info.height()+2);
+    qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
+    qDebug()<<"WRect:x="<<w.width()<<"y="<<w.height();
+#else
     w.resize(screen_info.width(), screen_info.height());
     qDebug()<<"Rect:x="<<screen_info.width()<<"y="<<screen_info.height();
-
+#endif
     pdu_Ctrl::instance()->InitData(&w,g_proxy_widget,gview,screen_info.width(), screen_info.height());
     gview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     gview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -41,7 +46,8 @@ int main(int argc, char *argv[])
     //============================线程开启====================================
     //数据更新线程
     DataUpdateThread thread_Update(nullptr);
-    thread_Update.pwidget=&w;
+    thread_Update.SetShowWidget(&w);
+
     //QString appDirPath = QCoreApplication::applicationDirPath();
     //thread_Update.strSqliteAddress=appDirPath+"/pdu_dat.db";
     thread_Update.initShm();

+ 22 - 0
Qt/Qt_Test/msgwidget.cpp

@@ -0,0 +1,22 @@
+#include "msgwidget.h"
+#include "ui_msgwidget.h"
+
+MSGWidget::MSGWidget(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::MSGWidget)
+{
+    ui->setupUi(this);
+    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+    setAttribute(Qt::WA_TranslucentBackground);
+    ui->label->setWordWrap(true);
+}
+
+MSGWidget::~MSGWidget()
+{
+    delete ui;
+}
+
+void MSGWidget::SetText(QString strShow)
+{
+    ui->label->setText(strShow);
+}

+ 22 - 0
Qt/Qt_Test/msgwidget.h

@@ -0,0 +1,22 @@
+#ifndef MSGWIDGET_H
+#define MSGWIDGET_H
+
+#include <QDialog>
+
+namespace Ui {
+class MSGWidget;
+}
+
+class MSGWidget : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit MSGWidget(QWidget *parent = 0);
+    ~MSGWidget();
+    void SetText(QString strShow);
+private:
+    Ui::MSGWidget *ui;
+};
+
+#endif // MSGWIDGET_H

+ 74 - 0
Qt/Qt_Test/msgwidget.ui

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MSGWidget</class>
+ <widget class="QWidget" name="MSGWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>144</width>
+    <height>71</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QWidget
+{
+	background-color: rgb(125, 125, 125);
+}
+QLabel
+{
+	color: rgb(255, 255, 255);
+}</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>2</number>
+   </property>
+   <property name="topMargin">
+    <number>2</number>
+   </property>
+   <property name="rightMargin">
+    <number>2</number>
+   </property>
+   <property name="bottomMargin">
+    <number>2</number>
+   </property>
+   <item>
+    <widget class="QLabel" name="label_2">
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <property name="text">
+      <string>WARNING</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="font">
+      <font>
+       <pointsize>9</pointsize>
+      </font>
+     </property>
+     <property name="text">
+      <string>xxxxxxxxxxxxxxxxxxxxxxx</string>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 40 - 0
Qt/Qt_Test/pdu_ctrl.cpp

@@ -45,6 +45,33 @@ void pdu_Ctrl::slot_setAngel(int nAngle)
             m_nSaveAngle=m_nAngle;
             SetPDUInit();
         }
+#ifdef RS485Type
+        if(nAngle==0||nAngle==180)
+        {
+            m_pWidget->resize(m_nWidth+2, m_nHeight+2);
+            if(nAngle==0)
+            {
+                m_pAngleCtrl->setPos(0,0);
+            }else
+            {
+                m_pAngleCtrl->setPos(m_pWidget->size().width()-2,m_pWidget->size().height()-2);
+            }
+            //QRect pRect=size();
+            qDebug()<<"x:"<<m_pWidget->geometry().x()<<"y:"<<m_pWidget->geometry().y()<<"Width:"<<m_pWidget->size().width()<<"Height:"<<m_pWidget->size().height();
+        }else
+        {
+            m_pWidget->resize(m_nHeight+2,m_nWidth+2);
+            if(nAngle==90)
+            {
+                m_pAngleCtrl->setPos(m_nWidth-2,0);
+
+            }else
+            {
+                m_pAngleCtrl->setPos(0,m_nHeight-2);
+            }
+            qDebug()<<"x:"<<m_pWidget->geometry().x()<<"y:"<<m_pWidget->geometry().y()<<"Width:"<<m_pWidget->size().width()<<"Height:"<<m_pWidget->size().height();
+        }
+#else
         if(nAngle==0||nAngle==180)
         {
             m_pWidget->resize(m_nWidth, m_nHeight);
@@ -70,6 +97,8 @@ void pdu_Ctrl::slot_setAngel(int nAngle)
             }
             qDebug()<<"x:"<<m_pWidget->geometry().x()<<"y:"<<m_pWidget->geometry().y()<<"Width:"<<m_pWidget->size().width()<<"Height:"<<m_pWidget->size().height();
         }
+
+#endif
         m_pView->update();
     }
 }
@@ -279,6 +308,8 @@ void pdu_Ctrl::Main_FunBtnSet(BtnDownType nbtnType)
             int nNowIndex=m_pWidget->getShowPagIndex();
             qDebug()<<"NowIndex="<<nNowIndex;
             switch (nNowIndex) {
+#ifdef RS485Type
+#else
             case 1:
             case 2://CH通道界面如果是三项则切换至三项子通道界面
                 {
@@ -296,6 +327,7 @@ void pdu_Ctrl::Main_FunBtnSet(BtnDownType nbtnType)
                     ChangeView(widgetType_Main,lastACIndex);
                 }
                 break;
+#endif
             default://其他界面
                 //在显示主界面时是旋转窗口
                 m_nAngle+=90;
@@ -547,6 +579,14 @@ void pdu_Ctrl::ButtonDown(int nButtonID, BtnDownType nDownType)
         return;
     }
 
+    if(m_pWidget&&!m_pWidget->isHiddenMSGWidget())
+    {
+        if(nDownType==BtnDown_C||nDownType==BtnDown_D)
+        {
+            m_pWidget->ClickMSGBtn();
+            return;
+        }
+    }
     if(nViewShowType==widgetType_Main)
     {
         qDebug()<<"widgetType="<<widgetType_Main;

+ 5 - 1
Qt/Qt_Test/pdu_ctrl.h

@@ -6,6 +6,8 @@
 #include <QGraphicsProxyWidget>
 #include <QGraphicsView>
 #include "widget.h"
+
+
 #define hightSmartPDU
 //#define RS485Type
 //#define RS485IpType
@@ -116,6 +118,8 @@ public slots:
     void slot_DClickBtn(int nButton);
     void slot_LClickBtn(int nButton);
     void slot_BtnClear(int nButton);
+
+
 private:
     //单例数据
     explicit pdu_Ctrl(QObject *parent = nullptr);
@@ -134,7 +138,7 @@ private:
     //其他界面指针
     QGraphicsProxyWidget* m_pAngleCtrl;
     QGraphicsView* m_pView;
-    Widget* m_pWidget;
+    Widget* m_pWidget;//主界面
     int m_nWidth;
     int m_nHeight;
 

文件差异内容过多而无法显示
+ 1214 - 0
Qt/Qt_Test/widget - 485.ui


+ 36 - 9
Qt/Qt_Test/widget.cpp

@@ -21,12 +21,7 @@ Widget::Widget(QWidget *parent) :
     m_nHeight = 128;
     m_pAngleCtrl=NULL;
 #ifdef RS485Type
-    ui->label_MSName->hide();
-    ui->label_MSData->hide();
-    ui->label_3->hide();
-    ui->label_4->hide();
-    ui->label_5->hide();
-#else
+#ifdef RS485IpType
     //ui->label_MSName->hide();
     //ui->label_MSData->hide();
     //ui->label_3->hide();
@@ -34,13 +29,23 @@ Widget::Widget(QWidget *parent) :
     //ui->label_5->hide();
     ui->label_modbus_type->hide();
     ui->label_modbus_Addr->hide();
+#else
+    ui->label_MSName->hide();
+    ui->label_MSData->hide();
+    ui->label_3->hide();
+    ui->label_4->hide();
+    ui->label_5->hide();
 #endif
-#ifdef hightSmartPDU
+#else
+//#ifdef hightSmartPDU
     ui->label_modbus_type->hide();
     ui->label_modbus_Addr->hide();
+//#endif
 #endif
     ui->stackedWidget_Main->setCurrentIndex(0);
     //ui->stackedWidget_Main->setCurrentWidget(ui->page_7);
+    m_pMSGWidget=new MSGWidget(this);
+    m_pMSGWidget->hide();
 }
 
 Widget::~Widget()
@@ -273,7 +278,7 @@ void Widget::pageUp()
             {
                 nChidPHIndex+=1;
                 setPH(nChidIndex,nChidPHIndex);
-            }else if(nChidPHIndex=3||nChidPHIndex==0)
+            }else if(nChidPHIndex==3||nChidPHIndex==0)
             {
                 nChidPHIndex=1;
                 setPH(nChidIndex,nChidPHIndex);
@@ -327,7 +332,7 @@ void Widget::pageDown()
         {
             nChidPHIndex-=1;
             setPH(nChidIndex,nChidPHIndex);
-        }else if(nChidPHIndex=1||nChidPHIndex==0)
+        }else if(nChidPHIndex==1||nChidPHIndex==0)
         {
             nChidPHIndex=3;
             setPH(nChidIndex,nChidPHIndex);
@@ -430,3 +435,25 @@ void Widget::CtrlBtnSet(int nIndex, int nData)
     }break;
     }
 }
+
+void Widget::ShowMSGWidget(QString strShowData)
+{
+    if(strShowData.isEmpty())
+        return;
+    if(m_pMSGWidget&&m_pMSGWidget->isHidden())
+    {
+        m_pMSGWidget->SetText(strShowData);
+        QRect parentRect = this->geometry();
+        m_pMSGWidget->move(parentRect.center() - m_pMSGWidget->rect().center());
+        m_pMSGWidget->show();
+    }
+}
+
+void Widget::ClickMSGBtn()
+{
+    if(m_pMSGWidget&&!m_pMSGWidget->isHidden())
+    {
+        m_pMSGWidget->hide();
+        emit signal_ClickMSG();
+    }
+}

+ 20 - 3
Qt/Qt_Test/widget.h

@@ -4,11 +4,11 @@
 #include <QWidget>
 #include "udphelper.h"
 #include "volviewform.h"
-#include <QList>
+//#include <QList>
 #include <QLabel>
 #include <QGraphicsProxyWidget>
 #include <QGraphicsView>
-
+#include "msgwidget.h"
 namespace Ui {
 class Widget;
 }
@@ -77,6 +77,19 @@ public:
     void setSelectStatus(int nIndex);
     void CtrlBtnSet(int nIndex,int nData);
     int nMAXChildIndex;
+
+    //显示msg窗口
+    void ShowMSGWidget(QString strShowData);
+    //是否显示MSG
+    bool isHiddenMSGWidget(){
+        if(m_pMSGWidget)
+            return m_pMSGWidget->isHidden();
+        return false;
+    }
+    //点击任意按钮确认
+    void ClickMSGBtn();
+signals:
+    void signal_ClickMSG();//报警确认
 public:
     Ui::Widget *ui;
 private:
@@ -84,7 +97,7 @@ private:
     UdpHelper* udpHelper;
     int device_type ;
     int device_chn ;
-    QList<VolViewForm*> volView;
+    //QList<VolViewForm*> volView;
     //当前显示页面ID
     int nChidIndex;
     int nChidPHIndex;
@@ -93,6 +106,10 @@ private:
     QGraphicsView* m_pView;
     int m_nWidth;
     int m_nHeight;
+
+
+    MSGWidget* m_pMSGWidget;//提示界面
+    int nIndexShow;
 };
 
 #endif // WIDGET_H

+ 1 - 1
Qt/Qt_Test/widget.ui

@@ -95,7 +95,7 @@ QLabel
           <item>
            <widget class="QStackedWidget" name="stackedWidget_Main">
             <property name="currentIndex">
-             <number>3</number>
+             <number>0</number>
             </property>
             <widget class="QWidget" name="page_4">
              <layout class="QVBoxLayout" name="verticalLayout_6">

二进制
cust_data/qt/IP/Qt_Test


二进制
cust_data/qt/Qt_Test


二进制
cust_data/qt/rgb_lcd/Qt_Test


+ 1 - 0
pro/src/app.c

@@ -2572,6 +2572,7 @@ static void* shm_thread(void *arg)
                     }
 
                     _globalDeviceManager->g_shm_Data->bPDUSet = 1;
+                    _globalDeviceManager->g_lastAlarmIndex=0;
                 }
                 else
                 { // 小于0 则主程序已析构退出重新等待加载

+ 4 - 0
pro/src/common.h

@@ -509,6 +509,9 @@ typedef struct
     //三项数据
     int bT_ACType;//三相类型
     int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
+        //报警列表 0表示空,1表示写入,2表示已确认可清空。
+    int nTypeCtrlType[10];
+    char strMSG[10][50];    
 } smartPDU_shm_data;
 
 //消息队列头结构体定义
@@ -1346,6 +1349,7 @@ typedef struct
     struct modbus_slave_read_reg g_modebus_read;
     struct modbus_slave_write_reg g_modebus_write;
     smartPDU_shm_data* g_shm_Data;
+    int                 g_lastAlarmIndex; //最后一次报警索引位置
     pthread_mutex_t     _power_ds;        //定时器锁 
     pthread_mutex_t     _power_update;        //数据刷新锁
     pthread_mutex_t     _sensor_update;        //传感器刷新锁

+ 53 - 1
pro/src/sqlite_handle.c

@@ -2855,6 +2855,53 @@ int dev_update_sensor_over_manage(sqlite3 *db,int product_id,int sensor_id,Globa
     sqlite3_free_table(pResult);
     return 0 ;
 }
+/// @brief 报警信息同步到(小屏幕)
+/// @param arg 
+/// @return 
+static void AlarmToShm(char* strData)
+{
+    GlobalPowerManger* _globalPowerMangerTemp = NULL ;
+    GlobalDeviceManager *_globalDeviceManager = (GlobalDeviceManager *)&__globalDeviceManage;
+    int nSize=strlen(strData);
+    if (nSize>50||nSize<=0)
+    {
+        /* code */
+        return;
+    }
+    
+    if (_globalDeviceManager->g_shm_Data)
+    { // 初始化成功
+        if(_globalDeviceManager->g_shm_Data->bPDUSet)
+        {
+            int isLastIndex=-1;//判断最后一个空闲的索引位置
+            for (size_t i = 0; i < 10; i++)
+            {
+                if (_globalDeviceManager->g_shm_Data->nTypeCtrlType[i] == 0||_globalDeviceManager->g_shm_Data->nTypeCtrlType[i] == 2)
+                {
+                    isLastIndex = i;
+                }
+            }    
+            if (isLastIndex != -1)//全部被占满则使用全局记录的位置进行添加
+            {
+                _globalDeviceManager->g_shm_Data->nTypeCtrlType[_globalDeviceManager->g_lastAlarmIndex]=1;//设置更新了一个报警
+                strcpy(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex], strData);
+                if (_globalDeviceManager->g_lastAlarmIndex < 10 && _globalDeviceManager->g_lastAlarmIndex >= 0)
+                {
+                    _globalDeviceManager->g_lastAlarmIndex++;
+                }
+                else
+                {
+                    _globalDeviceManager->g_lastAlarmIndex = 0;
+                }
+            }else//未被全部占满则使用空闲位置添加
+            {
+                _globalDeviceManager->g_shm_Data->nTypeCtrlType[isLastIndex]=1;//设置更新了一个报警
+                strcpy(_globalDeviceManager->g_shm_Data->strMSG[isLastIndex], strData);
+                _globalDeviceManager->g_lastAlarmIndex=isLastIndex;
+            }            
+        }
+    }
+}
 
 /// @brief 插入一条告警信息
 /// @param db 
@@ -2909,7 +2956,12 @@ int dev_insert_alarm_info(sqlite3* db,int product_id,int alarm_type,time_data_t
     sqlite3_free_table(pResult);
 
     //mail_send();
-
+    //只有是电源 传感器以及网络告警才同步到小屏幕上显示报警信息
+    if (alarm_type==ALARM_TYPE_POWER||alarm_type==ALARM_TYPE_SENSOR||alarm_type==ALARM_TYPE_NETWORK)
+    {
+        AlarmToShm(alarm_content);
+    }
+    
     return alarmNumber;
 }