diff --git a/product/src/gui/plugin/PointRealDataWidget/CDbInterface.cpp b/product/src/gui/plugin/PointRealDataWidget/CDbInterface.cpp index 47e0a353..b72ae60c 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CDbInterface.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/CDbInterface.cpp @@ -1,4 +1,4 @@ -#include "CDbInterface.h" +#include "CDbInterface.h" #include "public/pub_logger_api/logger.h" using namespace iot_dbms; diff --git a/product/src/gui/plugin/PointRealDataWidget/CDbInterface.h b/product/src/gui/plugin/PointRealDataWidget/CDbInterface.h index 433003d9..96ab1527 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CDbInterface.h +++ b/product/src/gui/plugin/PointRealDataWidget/CDbInterface.h @@ -1,4 +1,4 @@ -#ifndef CDBINTERFACE_H +#ifndef CDBINTERFACE_H #define CDBINTERFACE_H #include diff --git a/product/src/gui/plugin/PointRealDataWidget/CPointPublic.h b/product/src/gui/plugin/PointRealDataWidget/CPointPublic.h index 5a0e7265..d47c21ed 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CPointPublic.h +++ b/product/src/gui/plugin/PointRealDataWidget/CPointPublic.h @@ -1,4 +1,4 @@ -#ifndef CPOINTPUBLIC_H +#ifndef CPOINTPUBLIC_H #define CPOINTPUBLIC_H #include diff --git a/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.cpp b/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.cpp index 97f466d9..44012e81 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.cpp @@ -1,10 +1,11 @@ -#include "CPointRealDataWidget.h" +#include "CPointRealDataWidget.h" #include "CDbInterface.h" #include "CRealTableModel.h" #include "CRealDataCollect.h" #include #include #include +#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 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(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 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(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(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(view->model()); + QList data; + model->updateRealData(data); + + m_tagMap[groupNo] = QVariantList(); + m_groupMap[groupNo] = data; + } +} + void CPointRealDataWidget::updatePointValue(const QSet &groupSet) { foreach (const int &groupNo, groupSet) diff --git a/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.h b/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.h index 6eacdbd9..4d24f270 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.h +++ b/product/src/gui/plugin/PointRealDataWidget/CPointRealDataWidget.h @@ -1,4 +1,4 @@ -#ifndef CPOINTREALDATAWIDGET_H +#ifndef CPOINTREALDATAWIDGET_H #define CPOINTREALDATAWIDGET_H #include @@ -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 &groupSet); void updatePointValue(int groupNo, QList data); diff --git a/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.cpp b/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.cpp index 84d8c39c..d98acc83 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.cpp @@ -1,4 +1,4 @@ -#include "CPointRealPluginWidget.h" +#include "CPointRealPluginWidget.h" #include "CPointRealDataWidget.h" #include diff --git a/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.h b/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.h index 64233d8e..874b07f4 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.h +++ b/product/src/gui/plugin/PointRealDataWidget/CPointRealPluginWidget.h @@ -1,4 +1,4 @@ -#ifndef CPOINTREALPLUGINWIDGET_H +#ifndef CPOINTREALPLUGINWIDGET_H #define CPOINTREALPLUGINWIDGET_H #include @@ -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: diff --git a/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.cpp b/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.cpp index cb3e6e10..e74798c9 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.cpp @@ -1,4 +1,4 @@ -#include "CRealDataCollect.h" +#include "CRealDataCollect.h" #include CRealDataCollect* CRealDataCollect::m_pInstance = NULL; diff --git a/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.h b/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.h index 5e60a89a..666b4d4b 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.h +++ b/product/src/gui/plugin/PointRealDataWidget/CRealDataCollect.h @@ -1,4 +1,4 @@ -#ifndef CREALDATACOLLECT_H +#ifndef CREALDATACOLLECT_H #define CREALDATACOLLECT_H #include diff --git a/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.cpp b/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.cpp index e0798046..b9620e2f 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.cpp @@ -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; } diff --git a/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.h b/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.h index b4de9c0e..2ed4349e 100644 --- a/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.h +++ b/product/src/gui/plugin/PointRealDataWidget/CRealTableModel.h @@ -1,4 +1,4 @@ -#ifndef CREALTABLEMODEL_H +#ifndef CREALTABLEMODEL_H #define CREALTABLEMODEL_H #include @@ -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 m_listRealData; QStringList m_channelTxList; QFont m_valueFont; + bool m_showCommunicationsDetail; }; #endif // CREALTABLEMODEL_H diff --git a/product/src/gui/plugin/PointRealDataWidget/PointRealDataWidget.pro b/product/src/gui/plugin/PointRealDataWidget/PointRealDataWidget.pro index 848d20d4..fd4ee292 100644 --- a/product/src/gui/plugin/PointRealDataWidget/PointRealDataWidget.pro +++ b/product/src/gui/plugin/PointRealDataWidget/PointRealDataWidget.pro @@ -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) diff --git a/product/src/gui/plugin/PointRealDataWidget/main.cpp b/product/src/gui/plugin/PointRealDataWidget/main.cpp index a3d62529..0594e7a8 100644 --- a/product/src/gui/plugin/PointRealDataWidget/main.cpp +++ b/product/src/gui/plugin/PointRealDataWidget/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include "CPointRealDataWidget.h" #include "net/net_msg_bus_api/MsgBusApi.h"