[ref]同步711 实时列表插件,有差异,711更新

This commit is contained in:
shi_jq 2025-03-17 15:05:26 +08:00
parent 7470b86880
commit 46de2e029d
13 changed files with 279 additions and 15 deletions

View File

@ -1,4 +1,4 @@
#include "CDbInterface.h"
#include "CDbInterface.h"
#include "public/pub_logger_api/logger.h"
using namespace iot_dbms;

View File

@ -1,4 +1,4 @@
#ifndef CDBINTERFACE_H
#ifndef CDBINTERFACE_H
#define CDBINTERFACE_H
#include <QMap>

View File

@ -1,4 +1,4 @@
#ifndef CPOINTPUBLIC_H
#ifndef CPOINTPUBLIC_H
#define CPOINTPUBLIC_H
#include <QString>

View File

@ -1,10 +1,11 @@
#include "CPointRealDataWidget.h"
#include "CPointRealDataWidget.h"
#include "CDbInterface.h"
#include "CRealTableModel.h"
#include "CRealDataCollect.h"
#include <QGridLayout>
#include <QTableView>
#include <QHeaderView>
#include "pub_utility_api/FileStyle.h"
CPointRealDataWidget::CPointRealDataWidget(bool editMode, QWidget *parent)
: QWidget(parent),
@ -72,6 +73,34 @@ void CPointRealDataWidget::initialize()
m_pTimer->start(1000);
}
void CPointRealDataWidget::initStyle()
{
QString qss = QString();
std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss") ;
QFile qssfile1(QString::fromStdString(strFullPath));
qssfile1.open(QFile::ReadOnly);
if (qssfile1.isOpen())
{
qss += QLatin1String(qssfile1.readAll());
//setStyleSheet(qss);
qssfile1.close();
}
strFullPath = iot_public::CFileStyle::getPathOfStyleFile("PointRealDataWidget.qss") ;
QFile qssfile2(QString::fromStdString(strFullPath));
qssfile2.open(QFile::ReadOnly);
if (qssfile2.isOpen())
{
qss += QLatin1String(qssfile2.readAll());
//setStyleSheet(qss);
qssfile2.close();
}
if(!qss.isEmpty())
{
setStyleSheet(qss);
}
}
void CPointRealDataWidget::switchAppcontext(int appContext)
{
if(m_objAppContext == appContext)
@ -272,6 +301,167 @@ QString CPointRealDataWidget::addPoint(int GroupNo, const QStringList &RealTagLi
return "";
}
QString CPointRealDataWidget::addRealPoint(int GroupNo, const QString &strRealTagList)
{
if(m_groupMap.find(GroupNo) == m_groupMap.constEnd())
{
return tr("未找到组号%1!").arg(QString::number(GroupNo));
}
QStringList RealTagList = strRealTagList.split(";");
if (RealTagList.count() == 0)
{
return "";
}
//< 得到所有可能的点标签
QMap<QString, QStringList> tagMap;
QString devGroup;
foreach (QString RealTag, RealTagList) {
if(RealTag.isEmpty() || RealTag.split(".").length() != 7)
{
continue;
}
if (devGroup.isEmpty())
{
devGroup = truncTag(RealTag, "g");
}
tagMap[devGroup].append(RealTag);
QString tagName = RealTag;
SRealData realData;
QString temp;
QString table = truncTag(tagName, "t");
QString vlast = truncTag(tagName, "v");
if (vlast == "channel")
{
temp = CDbInterface::instance()->readChannelTag(truncTag(tagName, "d"), table);
}
else
{
temp = CDbInterface::instance()->readPointInfo(truncTag(tagName, "p"), table);
}
if (temp.isEmpty())
{
continue;
}
if (vlast == "channel")
{
realData.tag_name = temp;
realData.description = m_channelTxList[0];
realData.table_name = "fes_channel_para";
realData.column = "status";
realData.type = TYPE_CHANNEL;
}
else
{
m_tagMap[GroupNo].append(QVariant::fromValue(tagName));
realData.tag_name = truncTag(tagName, "p");
realData.description = temp.section(",", 0, 0);
realData.table_name = table;
if (realData.table_name == "analog" || realData.table_name == "accuml")
{
realData.unit = temp.section(",", 1, 1);
}
else if (realData.table_name == "digital" || realData.table_name == "mix")
{
realData.stateTextName = temp.section(",", 1, 1);
}
}
realData.nDomainId = CDbInterface::instance()->readDomainId(truncTag(tagName, "l"));
realData.nAppId = CDbInterface::instance()->readAppId(truncTag(tagName, "a"));
m_groupMap[GroupNo].append(realData);
if (realData.type == TYPE_POINT)
{
m_pDpcdaForApp->subscribe(realData.table_name.toStdString(), realData.tag_name.toStdString(), realData.column.toStdString());
}
}
QTableView *view = m_tableMap.value(GroupNo);
if(view)
{
CRealTableModel *model = dynamic_cast<CRealTableModel*>(view->model());
model->updateRealData(m_groupMap[GroupNo]);
}
return "";
}
QString CPointRealDataWidget::addCommPoint(int GroupNo, const QString &strRealTagList)
{
if(m_groupMap.find(GroupNo) == m_groupMap.constEnd())
{
return tr("未找到组号%1!").arg(QString::number(GroupNo));
}
QStringList RealTagList = strRealTagList.split(";");
if (RealTagList.count() == 0)
{
return "";
}
//< 得到所有可能的点标签
QMap<QString, QStringList> tagMap;
QString devGroup;
foreach (QString RealTag, RealTagList) {
if(RealTag.isEmpty() || RealTag.split(".").length() != 7)
{
continue;
}
if (devGroup.isEmpty())
{
devGroup = truncTag(RealTag, "g");
}
tagMap[devGroup].append(RealTag);
QString tagName = RealTag;
SRealData realData;
QString temp;
QString table = truncTag(tagName, "t");
temp = CDbInterface::instance()->readPointInfo(truncTag(tagName, "p"), table);
if (temp.isEmpty())
{
continue;
}
m_tagMap[GroupNo].append(QVariant::fromValue(tagName));
realData.tag_name = truncTag(tagName, "p");
realData.description = temp.section(",", 0, 0);
realData.table_name = table;
if (realData.table_name == "digital")
{
realData.stateTextName = temp.section(",", 1, 1);
}
else
{
continue;
}
realData.nDomainId = CDbInterface::instance()->readDomainId(truncTag(tagName, "l"));
realData.nAppId = CDbInterface::instance()->readAppId(truncTag(tagName, "a"));
m_groupMap[GroupNo].append(realData);
if (realData.type == TYPE_POINT)
{
m_pDpcdaForApp->subscribe(realData.table_name.toStdString(), realData.tag_name.toStdString(), realData.column.toStdString());
}
}
QTableView *view = m_tableMap.value(GroupNo);
if(view)
{
CRealTableModel *model = dynamic_cast<CRealTableModel*>(view->model());
model->setColumnCount(4);
model->setShowCommunicationsDetail(true);
model->updateRealData(m_groupMap[GroupNo]);
}
return "";
}
QVariantList CPointRealDataWidget::getPointList(int GroupNo)
{
return m_tagMap.value(GroupNo);
@ -341,6 +531,19 @@ void CPointRealDataWidget::setHeaderVisible(int GroupNo, int header, bool visibl
}
}
void CPointRealDataWidget::setHeaderDesc(int GroupNo, const QString& headerDescs)
{
QTableView *view = m_tableMap.value(GroupNo);
if(!view)
{
return;
}
CRealTableModel *model = dynamic_cast<CRealTableModel*>(view->model());
QStringList headerDescList = headerDescs.split(",");
model->setHeaderLabels(headerDescList);
}
void CPointRealDataWidget::setShowGrid(int GroupNo, bool isShow)
{
QTableView *view = m_tableMap.value(GroupNo);
@ -394,6 +597,20 @@ void CPointRealDataWidget::setChannelText(const QString &text, const QString &no
}
}
void CPointRealDataWidget::clear(int groupNo)
{
QTableView *view = m_tableMap.value(groupNo);
if(view)
{
CRealTableModel *model = dynamic_cast<CRealTableModel*>(view->model());
QList<SRealData> data;
model->updateRealData(data);
m_tagMap[groupNo] = QVariantList();
m_groupMap[groupNo] = data;
}
}
void CPointRealDataWidget::updatePointValue(const QSet<int> &groupSet)
{
foreach (const int &groupNo, groupSet)

View File

@ -1,4 +1,4 @@
#ifndef CPOINTREALDATAWIDGET_H
#ifndef CPOINTREALDATAWIDGET_H
#define CPOINTREALDATAWIDGET_H
#include <QWidget>
@ -20,7 +20,12 @@ public:
void initialize();
public slots:
void initStyle();
/**
* @brief switchAppcontext
* @param appContext 1: 2:
@ -37,7 +42,7 @@ public slots:
int addGroup(const QStringList &name, int row, int column);
/**
* @brief addPoint
* @brief addPoint
* @param GroupNo
* @param RealTagList "station1.PSCADA.digital.station1.NQ-G01_NRINC.OC1.value"
* @param PointList "digital.OC1.value"
@ -45,6 +50,22 @@ public slots:
*/
QString addPoint(int GroupNo, const QStringList &RealTagList, const QStringList &PointList);
/**
* @brief addRealPoint
* @param GroupNo
* @param RealTagList "station1.PSCADA.digital.station1.NQ-G01_NRINC.OC1.value;station1.PSCADA.digital.station1.NQ-G01_NRINC.OC1.value"
* @return ,
*/
QString addRealPoint(int GroupNo, const QString& strRealTagList);
/**
* @brief addRealPoint ,
* @param GroupNo
* @param RealTagList "station1.PSCADA.digital.station1.NQ-G01_NRINC.OC1.value;station1.PSCADA.digital.station1.NQ-G01_NRINC.OC1.value"
* @return ,
*/
QString addCommPoint(int GroupNo, const QString& strRealTagList);
/**
* @brief getPointList
* @param GroupNo
@ -83,6 +104,14 @@ public slots:
*/
void setHeaderVisible(int GroupNo, int header = Qt::Horizontal, bool visible = true);
/**
* @brief setHeaderVisible
* @param GroupNo
* @param header 1: 2:
* @param visible
*/
void setHeaderDesc(int GroupNo, const QString& headerDescs);
/**
* @brief setShowGrid 线
* @param GroupNo
@ -113,6 +142,8 @@ public slots:
*/
void setChannelText(const QString& text, const QString &normal, const QString &abnormal);
void clear(int groupNo);
private slots:
void updatePointValue(const QSet<int> &groupSet);
void updatePointValue(int groupNo, QList<SRealData> data);

View File

@ -1,4 +1,4 @@
#include "CPointRealPluginWidget.h"
#include "CPointRealPluginWidget.h"
#include "CPointRealDataWidget.h"
#include <QWidget>

View File

@ -1,4 +1,4 @@
#ifndef CPOINTREALPLUGINWIDGET_H
#ifndef CPOINTREALPLUGINWIDGET_H
#define CPOINTREALPLUGINWIDGET_H
#include <QObject>
@ -7,7 +7,7 @@
class CPointRealPluginWidget : public QObject, public CPluginWidgetInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "kbd.PluginWidgetInterface/1.0")
Q_PLUGIN_METADATA(IID HMI_WidgetPlugin_IID)
Q_INTERFACES(CPluginWidgetInterface)
public:

View File

@ -1,4 +1,4 @@
#include "CRealDataCollect.h"
#include "CRealDataCollect.h"
#include <QTimer>
CRealDataCollect* CRealDataCollect::m_pInstance = NULL;

View File

@ -1,4 +1,4 @@
#ifndef CREALDATACOLLECT_H
#ifndef CREALDATACOLLECT_H
#define CREALDATACOLLECT_H
#include <QMap>

View File

@ -1,4 +1,4 @@
#include "CRealTableModel.h"
#include "CRealTableModel.h"
#include "CDbInterface.h"
CRealTableModel::CRealTableModel(QObject *parent, const QStringList &header)
@ -51,6 +51,11 @@ QVariant CRealTableModel::headerData(int section, Qt::Orientation orientation, i
return QVariant();
}
void CRealTableModel::setHeaderLabels(const QStringList& headers)
{
m_header = headers;
}
int CRealTableModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
@ -145,4 +150,9 @@ QVariant CRealTableModel::data(const QModelIndex &index, int role) const
}
return QVariant();
}
void CRealTableModel::setShowCommunicationsDetail(bool showCommunicationsDetail)
{
m_showCommunicationsDetail = showCommunicationsDetail;
}

View File

@ -1,4 +1,4 @@
#ifndef CREALTABLEMODEL_H
#ifndef CREALTABLEMODEL_H
#define CREALTABLEMODEL_H
#include <QFont>
@ -24,17 +24,22 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
void setHeaderLabels(const QStringList& headers);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void setShowCommunicationsDetail(bool showCommunicationsDetail);
private:
QStringList m_header;
int nColumnCount;
QList<SRealData> m_listRealData;
QStringList m_channelTxList;
QFont m_valueFont;
bool m_showCommunicationsDetail;
};
#endif // CREALTABLEMODEL_H

View File

@ -47,7 +47,8 @@ LIBS += \
-lpub_logger_api \
-lprotobuf \
-lnet_msg_bus_api \
-ldp_chg_data_api
-ldp_chg_data_api \
-lpub_utility_api
include($$PWD/../../../idl_files/idl_files.pri)

View File

@ -1,4 +1,4 @@
#include <QApplication>
#include <QApplication>
#include "CPointRealDataWidget.h"
#include "net/net_msg_bus_api/MsgBusApi.h"