add measurement outside device

This commit is contained in:
baiYue 2026-01-23 17:39:46 +08:00
parent cccac84f10
commit cf2b5278f3
15 changed files with 1572 additions and 78 deletions

View File

@ -76,6 +76,8 @@ public:
virtual QList<QUuid>& getLstInstruct() {return lstInstruct;}
virtual void setLstEtc(QList<QUuid> lst) {lstEtc = lst;}
virtual QList<QUuid>& getLstEtc() {return lstEtc;}
void setMeasurement(QMap<QString,MeasurementInfo> map) {mMeasurement = map;}
auto getMeasurement() {return mMeasurement;}
protected:
QString sType;
QList<QUuid> lstComponent; //包含的设备
@ -92,6 +94,7 @@ protected:
QList<QUuid> lstStatus; //状态检测
QList<QUuid> lstInstruct; //监控
QList<QUuid> lstEtc; //其他设备
QMap<QString,MeasurementInfo> mMeasurement; //量测 <name,info>
};
class ModelProperty:public AbstractProperty //模型基类

View File

@ -50,6 +50,7 @@ set(DIAGRAMCAVAS_HEADER_FILES
include/structDataPropertyDelegate.h
include/structDataCauseEditDlg.h
include/structDataActionParaDlg.h
include/bayMeasureDlg.h
include/diagramEditor/editPanel.h
include/diagramEditor/editView.h
include/diagramEditor/editScene.h
@ -182,6 +183,7 @@ set(DIAGRAMCAVAS_SOURCE_FILES
source/structDataPropertyDelegate.cpp
source/structDataCauseEditDlg.cpp
source/structDataActionParaDlg.cpp
source/bayMeasureDlg.cpp
source/diagramEditor/editPanel.cpp
source/diagramEditor/editView.cpp
source/diagramEditor/editScene.cpp
@ -289,6 +291,7 @@ set(UI_FILES
ui/loadMonitorPageDlg.ui
ui/diagramConnectSetting.ui
ui/structDataPreviewDlg.ui
ui/bayMeasureDlg.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)

View File

@ -0,0 +1,47 @@
#ifndef BAYMEASUREDLG_H
#define BAYMEASUREDLG_H
#include <QDialog>
#include "global.h"
/*******************************************************
********************************************************/
QT_BEGIN_NAMESPACE
namespace Ui { class bayMeasureDlg; }
QT_END_NAMESPACE
class MeasureSettingDlg;
class BayProperty;
class BayMeasureDlg : public QDialog
{
Q_OBJECT
public:
BayMeasureDlg(QWidget *parent = nullptr);
~BayMeasureDlg();
void getPropertyValue(BayProperty* pBay);
void setPropertyValue(BayProperty* pBay);
auto& getValidType() {return _validType;} //获取可用的量测属性
void setUi();
void addMeasure(MeasurementInfo,int mode = 0); //mode:0新建1修改
void addOtherMeasure(QStringList); //本间隔的其他量测
BayProperty* getBayProperty(){return _bayProperty;}
void showDlg(BayProperty* pBay);
public slots:
void onAddClicked();
void onDeleteClicked();
void onModifyClicked();
void onIndexRbtnClicked(const QPoint &pos); //索引列表右键菜单
void onOkClicked();
void onCancelClicked();
private:
void initial();
private:
Ui::bayMeasureDlg *ui;
BayProperty* _bayProperty; //当前间隔属性
MeasureSettingDlg* _measureDlg;
QList<measureAttributeType> _validType; //可用的属性列表
QMap<QString,MeasurementInfo> _mapMeasure; //量测列表
};
#endif

View File

@ -33,6 +33,7 @@ struct itemPageInfo;
class EditBaseItem;
class MonitorPanel;
class ItemPropertyDlg;
class BayMeasureDlg;
class FixedPortsModel : public BaseModel, public Serializable
{
@ -96,6 +97,8 @@ public:
QRectF calculateItemsBoundingRect(QList<GraphicsBaseItem*> items); //返回包含所有item的rect
void addBayByData(BayProperty*,ModelFunctionType = ModelFunctionType::ProjectModel); //data生成bay
void showBayMeasureDlg(BayProperty*); //显示间隔量测
void addTestData(); //生成测试基模
QJsonObject turnListToJson(QList<QUuid> lst,QString sInerTag,QString sOutTag); //将list转换为QJsonObject,<lst,内部标签,外部标签>
QList<QUuid> turnJsonArrToList(QJsonObject obj,QString sInner,QString sOut);
@ -186,6 +189,7 @@ private:
QTimer* m_dataTimer; //获取数据的定时器
QStringList _curRequestLst; //当前请求对象列表
QMap<QString,QMap<quint64,double>> _curData; //当前数据
BayMeasureDlg* m_bayMeasureDlg; //间隔量测
public:
static bool _dataInitialised;
};

View File

@ -208,9 +208,10 @@ public:
int collidesWithHandle(const QPointF& point)
{
foreach (int key, m_vecHanle.keys())
if(m_vecHanle.isEmpty())
return HandleTag::H_none;
for (auto& pHandle: m_vecHanle)
{
ItemControlHandle* pHandle = m_vecHanle.value(key);
if (pHandle)
{
QPointF pt = pHandle->mapFromScene(point);

View File

@ -12,6 +12,7 @@ namespace Ui { class measureSettingDlg; }
QT_END_NAMESPACE
class BayInfoDlg;
class BayMeasureDlg;
class MeasureSettingDlg : public QDialog
{
@ -21,7 +22,9 @@ public:
~MeasureSettingDlg();
void initial();
void setBay(BayInfoDlg* p) {_pBay = p;}
void setParentType(int n) {_nParentType = n;}
void setBayComponent(BayInfoDlg* p) {_pBayComponent = p;}
void setBayMeasure(BayMeasureDlg* p) {_pBayMeasure = p;}
void showDlg(int type,propertyStateInfo,bool isDouble = false);
void showDlg(MeasurementInfo,propertyStateInfo,bool isDouble = false,MeasurementInfo symmetryInfo = MeasurementInfo()); //修改
public slots:
@ -45,7 +48,8 @@ private:
QJsonObject safeToJsonObject(const QVariant& var); //var转json
private:
Ui::measureSettingDlg *ui;
BayInfoDlg* _pBay;
BayInfoDlg* _pBayComponent; //component中的bay元件父
BayMeasureDlg* _pBayMeasure; //间隔父
QButtonGroup* _pEventStrategy; //事件策略组
QButtonGroup* _pEventYXGroup; //遥信事件组
@ -55,6 +59,7 @@ private:
QMap<int,PtExtraInfo> _tempPtMap;
int _curComponentType;
bool _isDouble = false;
int _nParentType = 0; //所属父类型 0元件 1间隔
};
#endif

View File

@ -397,7 +397,7 @@ void BayInfoDlg::onAddClicked()
{
if(_measureDlg == nullptr){
_measureDlg = new MeasureSettingDlg(this);
_measureDlg->setBay(this);
_measureDlg->setBayComponent(this);
}
int curType = 0; //当前对象类型
if(_itemProperty)
@ -497,7 +497,7 @@ void BayInfoDlg::onModifyClicked()
auto info = _mapMeasure.value(sName);
if(_measureDlg == nullptr){
_measureDlg = new MeasureSettingDlg(this);
_measureDlg->setBay(this);
_measureDlg->setBayComponent(this);
}
bool isDouble = false;
if(_bayProperty){ //判断double

View File

@ -0,0 +1,448 @@
#include <QButtonGroup>
#include <QJsonArray>
#include <QMutableListIterator>
#include <QMenu>
#include "bayMeasureDlg.h"
#include "ui_bayMeasureDlg.h"
#include "baseProperty.h"
#include "basePropertyManager.h"
#include "measureSettingDlg.h"
#include "graphicsDataModel/fixedPortsModel.h"
#include "dataBase.h"
BayMeasureDlg::BayMeasureDlg(QWidget *parent)
: QDialog(parent)
, ui(new Ui::bayMeasureDlg)
,_measureDlg(nullptr)
,_bayProperty(nullptr)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
initial();
}
BayMeasureDlg::~BayMeasureDlg()
{
delete ui;
}
void BayMeasureDlg::initial()
{
setUi();
connect(ui->btn_add,&QPushButton::clicked,this,&BayMeasureDlg::onAddClicked);
connect(ui->tableWidget_local, &QTableWidget::customContextMenuRequested, this, &BayMeasureDlg::onIndexRbtnClicked);
connect(ui->btn_ok,&QPushButton::clicked,this,&BayMeasureDlg::onOkClicked);
connect(ui->btn_cancel,&QPushButton::clicked,this,&BayMeasureDlg::onCancelClicked);
}
void BayMeasureDlg::getPropertyValue(BayProperty* pBay)
{
pBay->setMeasurement(_mapMeasure);
}
void BayMeasureDlg::setPropertyValue(BayProperty* pBay)
{
_mapMeasure.clear();
ui->tableWidget_other->setRowCount(0);
ui->tableWidget_local->setRowCount(0); //清空列表
ui->le_zhbh->clear();
ui->le_jk->clear();
ui->le_dtgz->clear();
ui->le_gzlb->clear();
ui->le_ztjc->clear();
ui->le_qt->clear();
if(pBay)
{
QList<measureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
_validType = lstType;
//间隔处理
_bayProperty = pBay;
auto map = pBay->getMeasurement();
for(auto& info:map){
addMeasure(info);
}
if(_bayProperty){
auto lstFrom = _bayProperty->getLstFrom();
auto lstTo = _bayProperty->getLstTo();
auto lstProtect = _bayProperty->getLstProtect();
auto lstFaultRecord = _bayProperty->getLstFaultRecord();
auto lstDynSense = _bayProperty->getLstDynSense();
auto lstStatus = _bayProperty->getLstStatus();
auto lstInstruct = _bayProperty->getLstInstruct();
auto lstEtc = _bayProperty->getLstEtc();
QStringList sLstFrom;
for(auto& fromId:lstFrom){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(fromId);
if(pPro){
sLstFrom.append(pPro->tag());
}
}
QStringList sLstTo;
for(auto& toId:lstTo){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(toId);
if(pPro){
sLstTo.append(pPro->tag());
}
}
QStringList sLstProtect;
for(auto& protectId:lstProtect){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(protectId);
if(pPro){
sLstProtect.append(pPro->tag());
}
}
QStringList sLstFaultRecord;
for(auto& faultRecordId:lstFaultRecord){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(faultRecordId);
if(pPro){
sLstFaultRecord.append(pPro->tag());
}
}
QStringList sLstDynSense;
for(auto& dynSenseId:lstDynSense){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(dynSenseId);
if(pPro){
sLstDynSense.append(pPro->tag());
}
}
QStringList sLstStatus;
for(auto& statusId:lstStatus){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(statusId);
if(pPro){
sLstStatus.append(pPro->tag());
}
}
QStringList sLstInstruct;
for(auto& instructId:lstInstruct){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(instructId);
if(pPro){
sLstInstruct.append(pPro->tag());
}
}
QStringList sLstEtc;
for(auto& etcId:lstEtc){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(etcId);
if(pPro){
sLstEtc.append(pPro->tag());
}
}
QList<BaseProperty*> lstOther;
QList<QUuid> lstCompo = _bayProperty->getLstComponent();
for(auto& compoId:lstCompo){
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(compoId);
if(pPro){
lstOther.append(pPro);
}
}
QStringList lstOtherMeasure;
for(auto& compo:lstOther){
auto map = compo->getMeasurement();
for(auto& measure:map){
lstOtherMeasure.append(compo->tag()+"-"+measure.tag);
}
}
ui->le_zhbh->setText(sLstProtect.join(""));
ui->le_jk->setText(sLstInstruct.join(""));
ui->le_dtgz->setText(sLstDynSense.join(""));
ui->le_gzlb->setText(sLstFaultRecord.join(""));
ui->le_ztjc->setText(sLstStatus.join(""));
ui->le_qt->setText(sLstEtc.join(""));
ui->le_bayName->setText(_bayProperty->name());
addOtherMeasure(lstOtherMeasure);
}
}
}
void BayMeasureDlg::setUi()
{
QStringList headerText;
headerText<<"TAG"<<"名称"<<"设备"<<"端子"<<"类型"<<"SIZE"<<"事件";
ui->tableWidget_local->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tableWidget_local->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget_local->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget_local->setColumnCount(headerText.count());
ui->tableWidget_local->setHorizontalHeaderLabels(headerText);
ui->tableWidget_local->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget_local->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget_local->setStyleSheet(
"QTableWidget::item {"
" padding: 5px;" // 可选:增加内边距
" white-space: pre-wrap;" // 关键:保留空白符并允许自动换行
"}"
);
headerText.clear();
headerText<<"TAG";
ui->tableWidget_other->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tableWidget_other->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget_other->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget_other->setColumnCount(headerText.count());
ui->tableWidget_other->setHorizontalHeaderLabels(headerText);
ui->tableWidget_other->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget_other->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget_other->setStyleSheet(
"QTableWidget::item {"
" padding: 5px;" // 可选:增加内边距
" white-space: pre-wrap;" // 关键:保留空白符并允许自动换行
"}"
);
}
void BayMeasureDlg::addMeasure(MeasurementInfo info,int mode)
{
if(mode == 0){ //新建
if(_mapMeasure.contains(info.name))
return;
int row = ui->tableWidget_local->rowCount();
ui->tableWidget_local->insertRow(row);
QTableWidgetItem* tagItem = new QTableWidgetItem(info.tag);
ui->tableWidget_local->setItem(row, 0, tagItem);
QTableWidgetItem* nameItem = new QTableWidgetItem(info.name);
ui->tableWidget_local->setItem(row, 1, nameItem);
QTableWidgetItem* deviceItem = new QTableWidgetItem(info.sDevice);
ui->tableWidget_local->setItem(row, 2, deviceItem);
QTableWidgetItem* channelItem = new QTableWidgetItem(info.sChannel);
ui->tableWidget_local->setItem(row, 3, channelItem);
QString sType;
if(info.type == 0){
sType = "遥测";
}
else if(info.type == 1){
sType = "遥信";
}
else if(info.type == 2){
sType = "遥控";
}
else if(info.type == 3){
sType = "遥调";
}
else if(info.type == 4){
sType = "整定值";
}
QTableWidgetItem* typeItem = new QTableWidgetItem(sType);
ui->tableWidget_local->setItem(row, 4, typeItem);
QTableWidgetItem* sizeItem = new QTableWidgetItem(QString::number(info.size));
ui->tableWidget_local->setItem(row, 5, sizeItem);
QTableWidgetItem* enableItem = new QTableWidgetItem(info.bEnable?"启用":"关闭");
ui->tableWidget_local->setItem(row, 6, enableItem);
if(_bayProperty){
QUuid bayId = _bayProperty->uuid();
QUuid itemId = QUuid("11111111-1111-1111-1111-111111111111");
info.bayUuid = bayId;
info.componentUuid = itemId;
_mapMeasure.insert(info.name,info);
}
}
else if(mode == 1){ //修改
QAbstractItemModel* model = ui->tableWidget_local->model();
int rowCount = model->rowCount();
QModelIndex index;
for (int row = 0; row < rowCount; ++row) {
QModelIndex col1Index = model->index(row, 1);
QVariant data = model->data(col1Index, Qt::DisplayRole);
if (data.toString() == info.name) {
// 返回本行第0列的QModelIndex
index = model->index(row, 1);
}
}
QString sName = index.data().toString();
if(_mapMeasure.contains(sName)){
auto itemDevice = ui->tableWidget_local->item(index.row(),2);
if(itemDevice){
itemDevice->setText(info.sDevice);
}
auto itemChannel = ui->tableWidget_local->item(index.row(),3);
if(itemChannel){
itemChannel->setText(info.sChannel);
}
auto itemType = ui->tableWidget_local->item(index.row(),4);
if(itemType){
QString sType;
if(info.type == 0){
sType = "遥测";
}
else if(info.type == 1){
sType = "遥信";
}
else if(info.type == 2){
sType = "遥控";
}
else if(info.type == 3){
sType = "遥调";
}
else if(info.type == 4){
sType = "整定值";
}
itemType->setText(sType);
}
auto itemSize = ui->tableWidget_local->item(index.row(),5);
if(itemSize){
itemSize->setText(QString::number(info.size));
}
auto itemEnable = ui->tableWidget_local->item(index.row(),6);
if(itemEnable){
itemEnable->setText(info.bEnable?"启用":"关闭");
}
if(_bayProperty){
QUuid bayId = _bayProperty->uuid();
info.bayUuid = bayId;
_mapMeasure[info.name] = info;
}
}
}
}
void BayMeasureDlg::addOtherMeasure(QStringList lst)
{
for(auto& str:lst){
int row = ui->tableWidget_other->rowCount();
ui->tableWidget_other->insertRow(row);
QTableWidgetItem* tagItem = new QTableWidgetItem(str);
ui->tableWidget_local->setItem(row, 0, tagItem);
}
}
void BayMeasureDlg::showDlg(BayProperty* pBay)
{
show();
setPropertyValue(pBay);
}
void BayMeasureDlg::onAddClicked()
{
if(_measureDlg == nullptr){
_measureDlg = new MeasureSettingDlg(this);
_measureDlg->setParentType(1);
_measureDlg->setBayMeasure(this);
}
int curType = 0; //当前对象类型
_measureDlg->showDlg(curType,propertyStateInfo());
}
void BayMeasureDlg::onDeleteClicked()
{
// 获取当前选中的索引
QModelIndexList selectedIndexes = ui->tableWidget_local->selectionModel()->selectedRows();
if (selectedIndexes.isEmpty()) {
return; // 没有选中任何行
}
// 获取当前选中的第一项索引
QModelIndex index = selectedIndexes.first();
if (!index.isValid()) {
return;
}
QModelIndex indexName = index.sibling(index.row(),1);
QString sName = indexName.data().toString();
if(_mapMeasure.contains(sName)){
MeasurementInfo info = _mapMeasure.take(sName);
}
int currentRow = ui->tableWidget_local->currentRow();
if (currentRow == -1) {
return; // 没有选中行
}
ui->tableWidget_local->removeRow(currentRow);
}
void BayMeasureDlg::onModifyClicked()
{
// 获取当前选中的索引
QModelIndexList selectedIndexes = ui->tableWidget_local->selectionModel()->selectedRows();
if (selectedIndexes.isEmpty()) {
return; // 没有选中任何行
}
// 获取当前选中的第一项索引
QModelIndex index = selectedIndexes.first();
if (!index.isValid()) {
return;
}
QModelIndex indexName = index.sibling(index.row(),1);
QString sName = indexName.data().toString();
if(_mapMeasure.contains(sName)){
auto info = _mapMeasure.value(sName);
if(_measureDlg == nullptr){
_measureDlg = new MeasureSettingDlg(this);
_measureDlg->setParentType(1);
_measureDlg->setBayMeasure(this);
}
_measureDlg->showDlg(info,propertyStateInfo());
}
}
void BayMeasureDlg::onIndexRbtnClicked(const QPoint &pos)
{
// 获取当前点击的位置对应的索引
QModelIndex index = ui->tableWidget_local->indexAt(pos);
if (!index.isValid()) {
return; // 如果点击的是空白区域,直接返回
}
QMenu menu;
QAction *modifyAction = new QAction("修改量测", this);
QAction *deleteAction = new QAction("移除量测", this);
menu.addAction(modifyAction);
menu.addAction(deleteAction);
// 连接删除菜单项的触发信号与槽函数
connect(modifyAction, &QAction::triggered, this, &BayMeasureDlg::onModifyClicked);
connect(deleteAction, &QAction::triggered, this, &BayMeasureDlg::onDeleteClicked);
// 在点击位置显示菜单
menu.exec(ui->tableWidget_local->mapToGlobal(pos));
}
void BayMeasureDlg::onOkClicked()
{
getPropertyValue(_bayProperty);
hide();
}
void BayMeasureDlg::onCancelClicked()
{
hide();
}

View File

@ -50,6 +50,7 @@
#include "uiCommunicationBus.h"
#include "instance/dataAccessor.h"
#include "graphicsItem/handleText.h"
#include "bayMeasureDlg.h"
#include "global.h"
bool FixedPortsModel::_dataInitialised = false;
@ -64,6 +65,7 @@ FixedPortsModel::FixedPortsModel(PowerEntity* pEntity)
,m_pBayManager(nullptr)
,m_curPropertyDlg(nullptr)
,m_dataTimer(nullptr)
,m_bayMeasureDlg(nullptr)
{
_cavas = nullptr;
loadNodeDataFromDataBase();
@ -774,6 +776,14 @@ void FixedPortsModel::loadNodeDataFromDataBase()
pBay->setLstInstruct(insLst);
auto etcLst = turnJsonArrToList(bay.etc,"id","ids");
pBay->setLstEtc(etcLst);
QMap<QString,MeasurementInfo> mapMeasure;
QList<MeasurementInfo> tempLst = DataBase::GetInstance()->getBayMeasurement(bay.uuid);
for(auto& info:tempLst){
if(info.componentUuid == QUuid("11111111-1111-1111-1111-111111111111")) //只处理间隔外量测
mapMeasure.insert(info.name,info);
}
pBay->setMeasurement(mapMeasure);
}
_dataInitialised = true;
}
@ -894,6 +904,8 @@ void FixedPortsModel::saveNode(int nPageId)
QList<zoneInfo> lstZone = DataBase::GetInstance()->getAllZone();
QList<stationInfo> lstStation = DataBase::GetInstance()->getAllStation();
QMap<int,attributeGroup> groupMap = DataBase::GetInstance()->AttributeGroup(); //属性组名
bool bExist = DataBase::GetInstance()->componentExist(QUuid("11111111-1111-1111-1111-111111111111").toString());
bool bSaveFlag = false;
for(auto& bay:_bayItem)
{
@ -926,6 +938,198 @@ void FixedPortsModel::saveNode(int nPageId)
DataBase::GetInstance()->updateBay(pBay->uuid(),pBay->name(),tempTag,pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"",pBay->getInService(),0,QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent(),QJsonObject());
}
QString sGridTag;
QString sGridName;
QString sZoneTag;
QString sZoneName;
QString sStationTag;
QString sStationName;
QList<QUuid> lstId = pBay->getLstComponent(); //获取间隔下的所有item取一个item所属的层级关系
if(!lstId.isEmpty()){
auto pItemData = BasePropertyManager::instance().findEntityData(lstId.first());
if(pItemData){
for(auto& gridInfo:lstGrid){
if(pItemData->grid() == gridInfo.tagname){
sGridTag= gridInfo.tagname;
sGridName= gridInfo.name;
break;
}
}
for(auto& zoneInfo:lstZone){
if(pItemData->zone() == zoneInfo.tagname){
sZoneTag = zoneInfo.tagname;
sZoneName = zoneInfo.name;
break;
}
}
for(auto& stationInfo:lstStation){
if(pItemData->station() == stationInfo.tagname){
sStationTag = stationInfo.tagname;
sStationName = stationInfo.name;
break;
}
}
}
}
if(!bExist){
if(!bSaveFlag){
DataBase::GetInstance()->insertComponent(QUuid("11111111-1111-1111-1111-111111111111"),"","","","","","","",sStationTag,-1,false,-1,-1,QJsonObject(),QJsonObject(),QJsonObject(),1);
bSaveFlag = true;
}
}
QMap<QString,MeasurementInfo> mapMeasure = pBay->getMeasurement(); //量测
QList<ExtraProperty> lstTemp= DataBase::GetInstance()->getBayExtraProperty(tempTag); //component中的层级关系
QList<ExtraProperty> lstExtra;
for(auto& info:lstTemp){
if(info.component_uuid != QUuid("11111111-1111-1111-1111-111111111111")) //只判断设备外量测
continue;
lstExtra.append(info);
}
QList<MeasurementInfo> lstDataBase;
QList<MeasurementInfo> lstTempBase = DataBase::GetInstance()->getBayMeasurement(pBay->uuid()); //数据库中现有量测
for(auto& info:lstTempBase){
if(info.componentUuid != QUuid("11111111-1111-1111-1111-111111111111")) //只判断设备外量测
continue;
lstDataBase.append(info);
}
for(auto& info:mapMeasure)
{
int tpe = info.type; //todo:建立类型映射表
QJsonObject objDataSource;
QJsonObject objIoAddress;
if(info.nSource == 1){ //3611
objDataSource["type"] = 1;
objIoAddress["station"] = info.sStation;
objIoAddress["device"] = info.sDevice;
objIoAddress["channel"] = info.sChannel;
}
else if(info.nSource == 2){ //104
objDataSource["type"] = 2;
objIoAddress["station"] = info.sStation;
objIoAddress["packet"] = info.nPacket;
objIoAddress["offset"] = info.nOffset;
}
objDataSource["io_address"] = objIoAddress;
QJsonObject objEventPlan;
QJsonObject objCause;
QJsonObject objAction;
QJsonArray arrPara;
objEventPlan["enable"] = info.bEnable;
if(tpe == 0){ //遥测
for(auto iter = info.mapTE.begin();iter != info.mapTE.end();++iter){
objCause[iter.key()] = iter.value();
}
}
else if(tpe == 1){ //遥信
objCause["edge"] = info.sEdge;
}
objEventPlan["cause"] = objCause;
objAction["command"] = info.sCommand;
for(auto &para:info.lstParameter){
arrPara.append(para);
}
objAction["parameters"] = arrPara;
objEventPlan["action"] = objAction;
QJsonObject objBinding;
if(!info.sWindType.isEmpty()){
QJsonObject objWind;
objWind["ratio"] = info.nRatio;
objWind["polarity"] = info.nPolarity;
objWind["index"] = info.nIndex;
objBinding[info.sWindType] = objWind;
}
QString tempMeasure = info.tag+"_"+_pageName; //tag后加工程名保持全局唯一
bool val = DataBase::GetInstance()->ifBayMeasureExist(info.name,pBay->uuid());
if(val){
DataBase::GetInstance()->updateMeasurement(info.name,tpe,objDataSource,objEventPlan,objBinding,info.size,QUuid("11111111-1111-1111-1111-111111111111"));
}
else{
DataBase::GetInstance()->insertMeasurement(info.name,tempMeasure,tpe,objDataSource,objEventPlan,objBinding,info.size,info.bayUuid,QUuid("11111111-1111-1111-1111-111111111111"));
}
for(int i = 0;i < lstDataBase.size();++i) //从数据库记录中移除操作过的对象
{
if(lstDataBase[i].name == info.name){
lstDataBase.removeAt(i);
break;
}
}
for(int i = 0;i < lstExtra.size();++i){ //同步层级信息计数
if(lstExtra[i].name == info.name){
lstExtra.removeAt(i);
break;
}
}
ExtraProperty extraPro; //层级信息
extraPro.name = info.name;
extraPro.tag = tempMeasure;
extraPro.grid_tag = sGridTag;
extraPro.grid_name = sGridName;
extraPro.zone_tag = sZoneTag;
extraPro.zone_name = sZoneName;
extraPro.station_tag = sStationTag;
extraPro.station_name = sStationName;
extraPro.currentLevel = QString::number(pBay->getVoltage())+"kv";
extraPro.page_tag = _widget->pageName(); //暂时相同
extraPro.bay_name = pBay->name();
extraPro.bay_tag = pBay->tag();
extraPro.component_uuid = QUuid("11111111-1111-1111-1111-111111111111");
for(auto& groupInfo:groupMap){
if("bay" == groupInfo.groupType){
extraPro.group_name = groupInfo.groupName;
break;
}
}
if(tpe == 0){
extraPro.type_name = "遥测";
extraPro.type_tag = "telemetry";
}
else if(tpe == 1){
extraPro.type_name = "遥信";
extraPro.type_tag = "telesignal";
}
else if(tpe == 2){
extraPro.type_name = "遥控";
extraPro.type_tag = "telecontrol";
}
extraPro.code = extraPro.getFullName();
extraPro.sourceType = "measurement";
extraPro.connect_para = sGridTag+"."+sZoneTag+"."+sStationTag+"."+extraPro.bay_tag+"."+extraPro.tag;
//取data 量测tag
bool exist = DataBase::GetInstance()->ifExtraPropertyExist(extraPro.code);
if(exist)
DataBase::GetInstance()->updateExtraProperty(extraPro);
else
DataBase::GetInstance()->insertExtraProperty(extraPro);
}
for(auto& info:lstDataBase) //操作的记录小于数据库中的记录,删除库中多出的记录
{
DataBase::GetInstance()->delteMeasurement(info.name,info.componentUuid);
}
for(auto& info:lstExtra){ //删除库中多出的层级信息
DataBase::GetInstance()->deleteExtraProperty(info.code);
}
}
}
@ -2887,6 +3091,15 @@ void FixedPortsModel::addBayByData(BayProperty* pData,ModelFunctionType typ)
}
}
void FixedPortsModel::showBayMeasureDlg(BayProperty* pPro)
{
if(m_bayMeasureDlg == nullptr)
{
m_bayMeasureDlg = new BayMeasureDlg(_widget);
}
m_bayMeasureDlg->showDlg(pPro);
}
void FixedPortsModel::addTestData()
{
QUuid breakerId = QUuid::createUuid();

View File

@ -11,6 +11,7 @@ ElectricBayItem::ElectricBayItem(const QRectF &rect,QGraphicsItem *parent)
m_dWidth = rect.width();
m_dHeight = rect.height();
m_font.setPointSize(12);
setFlag(QGraphicsItem::ItemIgnoresTransformations, false);
}
ElectricBayItem::~ElectricBayItem()
@ -50,6 +51,7 @@ void ElectricBayItem::updateTextShape()
QRectF recText = metrics.boundingRect(m_text);
//_recLabel = recText.translated(g_offsetX,g_offsetY);
recText.moveTo(m_showRect.topLeft()-QPointF(recText.width(),recText.height()));
recText.adjust(-3,-3,3,3);
_recLabel = recText;
shape();
}

View File

@ -3,14 +3,16 @@
#include "measureSettingDlg.h"
#include "bayInfoDlg.h"
#include "graphicsDataModel/fixedPortsModel.h"
#include "graphicsItem/graphicsBaseItem.h"
#include "bayMeasureDlg.h"
#include "baseProperty.h"
#include "basePropertyManager.h"
#include "ui_measureSettingDlg.h"
MeasureSettingDlg::MeasureSettingDlg(QWidget *parent)
: QDialog(parent)
, ui(new Ui::measureSettingDlg)
,_pBay(nullptr)
,_pBayComponent(nullptr)
,_pBayMeasure(nullptr)
,_pEventStrategy(nullptr)
,_pEventYXGroup(nullptr)
,_curMode(0)
@ -140,26 +142,57 @@ void MeasureSettingDlg::showDlg(int type,propertyStateInfo proInfo,bool isDouble
QStringList lstTag;
QStringList lstName;
show();
if(_pBay){
QString curItemName; //当前元件名称
if(_pBay){
auto pItemData = _pBay->getProperty();
if(_nParentType == 0){
if(_pBayComponent){
QString curItemName; //当前元件名称
auto pItemData = _pBayComponent->getProperty();
curItemName = pItemData->name();
}
auto lst = _pBay->getValidType();
for(auto& item:lst){
item.tag = item.tag+"_"+curItemName;
item.name = item.name+"_"+curItemName;
lstTag.append(item.tag);
lstName.append(item.name);
}
ui->cb_tag->addItems(lstTag);
ui->cb_name->addItems(lstName);
auto lst = _pBayComponent->getValidType();
for(auto& item:lst){
item.tag = item.tag+"_"+curItemName;
item.name = item.name+"_"+curItemName;
lstTag.append(item.tag);
lstName.append(item.name);
}
ui->cb_tag->addItems(lstTag);
ui->cb_name->addItems(lstName);
BaseProperty* pro = _pBay->getProperty();
if(pro){
ui->le_s1->setText(pro->station());
ui->le_s2->setText(pro->station());
BaseProperty* pro = _pBayComponent->getProperty();
if(pro){
ui->le_s1->setText(pro->station());
ui->le_s2->setText(pro->station());
}
}
}
else if(_nParentType == 1){
QString curBayName;
if(_pBayMeasure){
auto pItemBay = _pBayMeasure->getBayProperty();
curBayName = pItemBay->name();
auto lst = _pBayMeasure->getValidType();
for(auto& item:lst){
item.tag = item.tag+"_"+curBayName;
item.name = item.name+"_"+curBayName;
lstTag.append(item.tag);
lstName.append(item.name);
}
ui->cb_tag->addItems(lstTag);
ui->cb_name->addItems(lstName);
BayProperty* pro = _pBayMeasure->getBayProperty(); //间隔不直接包含站,找到间隔所属设备的站
if(pro){
QList<QUuid> lst = pro->getLstComponent();
QString sStation;
if(!lst.isEmpty()){
auto pPro = BasePropertyManager::instance().findEntityData(lst.first());
if(pPro){
sStation = pPro->station();
}
}
ui->le_s1->setText(sStation);
ui->le_s2->setText(sStation);
}
}
}
}
@ -184,9 +217,6 @@ void MeasureSettingDlg::showDlg(MeasurementInfo info,propertyStateInfo proInfo,b
ui->cb_windIndex->clear();
QMap<int,CtExtraInfo> map;
/*QString jsonString = proInfo.defaultValue.toString();
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
QJsonObject obj = jsonDocument.object();*/
QJsonObject obj = safeToJsonObject(proInfo.defaultValue);
if(obj.contains("winding")){
@ -216,9 +246,6 @@ void MeasureSettingDlg::showDlg(MeasurementInfo info,propertyStateInfo proInfo,b
ui->cb_windIndex->clear();
QMap<int,PtExtraInfo> map;
/*QString jsonString = proInfo.defaultValue.toString();
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
QJsonObject obj = jsonDocument.object();*/
QJsonObject obj = safeToJsonObject(proInfo.defaultValue);
if(obj.contains("winding")){
@ -483,22 +510,29 @@ void MeasureSettingDlg::onOkClicked()
}
}
}
if(_pBay){
if(_isDouble)
info.sSymmetry = ui->le_dbName->text(); //与double互相记录
_pBay->addMeasure(info,_curMode);
if(_nParentType == 0){
if(_pBayComponent){
if(_isDouble)
info.sSymmetry = ui->le_dbName->text(); //与double互相记录
_pBayComponent->addMeasure(info,_curMode);
}
if(_isDouble){
MeasurementInfo dbInfo;
dbInfo = info;
dbInfo.tag = ui->le_dbTag->text();
dbInfo.name = ui->le_dbName->text();
dbInfo.nPolarity = -info.nPolarity;
dbInfo.sSymmetry = info.name; //与source互相记录
if(_pBayComponent)
_pBayComponent->addMeasure(dbInfo,_curMode);
}
}
if(_isDouble){
MeasurementInfo dbInfo;
dbInfo = info;
dbInfo.tag = ui->le_dbTag->text();
dbInfo.name = ui->le_dbName->text();
dbInfo.nPolarity = -info.nPolarity;
dbInfo.sSymmetry = info.name; //与source互相记录
if(_pBay)
_pBay->addMeasure(dbInfo,_curMode);
else if(_nParentType == 1){
if(_pBayMeasure){
_pBayMeasure->addMeasure(info,_curMode);
}
}
ui->cb_tag->blockSignals(false);
@ -517,16 +551,27 @@ void MeasureSettingDlg::onCancelClicked()
void MeasureSettingDlg::onTagChanged(const QString& str)
{
auto lst = _pBay->getValidType();
QString curItemName;
if(_pBay){
auto pItemData = _pBay->getProperty();
curItemName = "_"+pItemData->name();
QList<measureAttributeType> lst;
QString curName;
if(_nParentType == 0){
if(_pBayComponent){
lst = _pBayComponent->getValidType();
auto pItemData = _pBayComponent->getProperty();
curName = "_"+pItemData->name();
}
}
else if(_nParentType == 1){
if(_pBayMeasure){
lst = _pBayMeasure->getValidType();
auto pItemBay = _pBayMeasure->getBayProperty();
curName = "_"+pItemBay->name();
}
}
QString name;
for(auto& item:lst){
if(item.tag+curItemName == str){
name = item.name+curItemName;
if(item.tag+curName == str){
name = item.name+curName;
ui->cb_name->setCurrentText(name);
break;
}
@ -540,16 +585,27 @@ void MeasureSettingDlg::onTagChanged(const QString& str)
void MeasureSettingDlg::onNameChanged(const QString& str)
{
auto lst = _pBay->getValidType();
QString curItemName;
if(_pBay){
auto pItemData = _pBay->getProperty();
curItemName = "_"+pItemData->name();
QList<measureAttributeType> lst;
QString curName;
if(_nParentType == 0){
if(_pBayComponent){
lst = _pBayComponent->getValidType();
auto pItemData = _pBayComponent->getProperty();
curName = "_"+pItemData->name();
}
}
else if(_nParentType == 1){
if(_pBayMeasure){
lst = _pBayMeasure->getValidType();
auto pItemBay = _pBayMeasure->getBayProperty();
curName = "_"+pItemBay->name();
}
}
QString tag;
for(auto& item:lst){
if(item.name+curItemName == str){
tag = item.tag+curItemName;
if(item.name+curName == str){
tag = item.tag+curName;
ui->cb_tag->setCurrentText(tag);
break;
}

View File

@ -567,13 +567,22 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
GraphicsProjectModelItem* item = qgraphicsitem_cast<GraphicsProjectModelItem*>(items.first());
if(item)
{
if(item->getItemType() == GIT_bay) //间隔暂时返回
return;
ModelProperty* pro = item->getProperty();
if(pro){
QString modelName = pro->modelName();
QUuid uuid = item->itemId();
_model->showModelDlg(modelName,uuid,item);
if(item->getItemType() == GIT_bay){ //间隔
ElectricBayItem* pBay = dynamic_cast<ElectricBayItem*>(items.first());
if (pBay) {
auto pPro = dynamic_cast<BayProperty*>(pBay->getProperty());
if(pPro){
_model->showBayMeasureDlg(pPro);
}
}
}
else{
ModelProperty* pro = item->getProperty();
if(pro){
QString modelName = pro->modelName();
QUuid uuid = item->itemId();
_model->showModelDlg(modelName,uuid,item);
}
}
}
}

View File

@ -0,0 +1,534 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>bayMeasureDlg</class>
<widget class="QDialog" name="bayMeasureDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>819</width>
<height>648</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_2" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>21</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
background: #2c5282;
color: white;
border: none;
}
QWidget QLabel {
color: white;
font-size: 12px;
background: transparent;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>间隔量测</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>762</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>8</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_title_bay">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border:4px double dark;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>继保/综保设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_zhbh">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>监控设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="le_jk">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>动态感知设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="le_dtgz">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>安全自动装置</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="le_gzlb">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>状态监测设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="le_ztjc">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>其他设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="le_qt">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>间隔名称</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_bayName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>序号</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_index_1"/>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>--</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_index_2"/>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>本间隔的一次设备外量测</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="label_12">
<property name="text">
<string>名称</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="label_14">
<property name="text">
<string>SIZE</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="btn_add">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
background-color: #5a79a1; /* 中性灰蓝,不刺眼 */
color: white;
border: none; /* 无边框,扁平化 */
border-radius: 4px; /* 小圆角,扁平感 */
font-size: 13px; /* 适中字号 */
font-weight: 500; /* 中等字重 */
}
QPushButton:hover {
background-color: #4a5d7e; /* 稍深的灰蓝 */
}
QPushButton:pressed {
background-color: #3d4e6b; /* 更深的灰蓝 */
}
QPushButton:disabled {
background-color: #a0b3d1; /* 灰调的浅蓝 */
color: #d1dce9; /* 浅灰色文字 */
}
</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>设备</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>TAG</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_17">
<property name="text">
<string>类型</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_13">
<property name="text">
<string>端子</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="label_18">
<property name="text">
<string>事件</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="label_19">
<property name="text">
<string>对称</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_local">
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>本间隔的其他量测</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_other">
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<property name="styleSheet">
<string notr="true">QPushButton {
background-color: #5a79a1; /* 中性灰蓝,不刺眼 */
color: white;
border: none; /* 无边框,扁平化 */
border-radius: 4px; /* 小圆角,扁平感 */
font-size: 13px; /* 适中字号 */
font-weight: 500; /* 中等字重 */
}
QPushButton:hover {
background-color: #4a5d7e; /* 稍深的灰蓝 */
}
QPushButton:pressed {
background-color: #3d4e6b; /* 更深的灰蓝 */
}
QPushButton:disabled {
background-color: #a0b3d1; /* 灰调的浅蓝 */
color: #d1dce9; /* 浅灰色文字 */
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>646</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_ok">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_cancel">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -72,7 +72,9 @@ public:
bool updateMeasurement(QString name,int type,QJsonObject dataSource,QJsonObject eventPlan,QJsonObject binding,int size,QUuid componentId);
bool delteMeasurement(QString name,QUuid componentId);
bool ifMeasureExist(QString name,QUuid componentId);
bool ifBayMeasureExist(QString name,QUuid bayId);
QList<MeasurementInfo> getMeasurement(QUuid componentId);
QList<MeasurementInfo> getBayMeasurement(QUuid bayUuid); //返回间隔下的所有量测
QMap<QString,MeasurementInfo> getAllMeasurements();
/*********************************************************************************/
bool insertExtraProperty(ExtraProperty); //属性层级与连接信息
@ -80,6 +82,7 @@ public:
bool deleteExtraProperty(QString code);
bool ifExtraPropertyExist(QString code);
QList<ExtraProperty> getCompoExtraProperty(QUuid uid); //获取component中的层级信息
QList<ExtraProperty> getBayExtraProperty(QString bayTag); //获取间隔的层级信息
QList<ExtraProperty> getAllExtraProperty();
/*********************************************************************************/
bool deleteComponentById(int id);

View File

@ -236,18 +236,22 @@ bool DataBase::insertComponent(QUuid uuid,QString modelName,QString nspath,QStri
QJsonDocument contextDoc(context);
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
qry.prepare("INSERT INTO component(global_uuid, model_name,tag, name, grid, zone, station, type, context, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
qry.prepare("INSERT INTO component(global_uuid, model_name, nspath, tag, name, grid, zone, station, type, in_service, state, status, context, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
qry.bindValue(0,uuid);
qry.bindValue(1,modelName);
qry.bindValue(2,tag);
qry.bindValue(3,name);
qry.bindValue(4,grid);
qry.bindValue(5,zone);
qry.bindValue(6,station);
qry.bindValue(7,type);
qry.bindValue(8,strCon);
qry.bindValue(9,op);
qry.bindValue(10,QDateTime::currentDateTime());
qry.bindValue(2,nspath);
qry.bindValue(3,tag);
qry.bindValue(4,name);
qry.bindValue(5,grid);
qry.bindValue(6,zone);
qry.bindValue(7,station);
qry.bindValue(8,type);
qry.bindValue(9,inService);
qry.bindValue(10,state);
qry.bindValue(11,status);
qry.bindValue(12,strCon);
qry.bindValue(13,op);
qry.bindValue(14,QDateTime::currentDateTime());
bool res = qry.exec();
QString str = qry.lastQuery();
const QVariantList list = qry.boundValues();
@ -1497,6 +1501,28 @@ bool DataBase::ifMeasureExist(QString name,QUuid componentId)
return false;
}
bool DataBase::ifBayMeasureExist(QString name,QUuid bayId)
{
QString strSQL = "SELECT id FROM measurement WHERE name = ? AND bay_uuid = ?";
QVariantList params;
params.append(name);
params.append(bayId);
try
{
QSqlQuery query = executeSQL(strSQL,false,params);
while (query.next())
{
return true;
}
}
catch (const std::exception& e)
{
return false;
}
return false;
}
QList<MeasurementInfo> DataBase::getMeasurement(QUuid componentId)
{
QList<MeasurementInfo> lst;
@ -1585,6 +1611,94 @@ QList<MeasurementInfo> DataBase::getMeasurement(QUuid componentId)
}
}
QList<MeasurementInfo> DataBase::getBayMeasurement(QUuid bayUuid)
{
QList<MeasurementInfo> lst;
QString strSQL = "SELECT tag, name, type, data_source, event_plan, binding, size, bay_uuid, component_uuid FROM measurement WHERE bay_uuid = ?";
QVariantList params;
params.append(bayUuid);
try
{
QSqlQuery query = executeSQL(strSQL,false,params);
while (query.next())
{
MeasurementInfo info;
info.tag = query.value(0).toString();
info.name = query.value(1).toString();
info.type = query.value(2).toInt();
QString conData = query.value(3).toString();
QJsonObject objData = QstringToJson(conData);
QString sEvent = query.value(4).toString();
QJsonObject objEvent = QstringToJson(sEvent);
QString sBinding = query.value(5).toString();
QJsonObject objBinding = QstringToJson(sBinding);
info.size = query.value(6).toInt();
info.bayUuid = QUuid(query.value(7).toString());
info.componentUuid = QUuid(query.value(8).toString());
info.nSource = objData["type"].toInt();
QJsonObject objIoAddress = objData["io_address"].toObject();
info.sStation = objIoAddress["station"].toString();
info.sDevice = objIoAddress["device"].toString();
info.sChannel = objIoAddress["channel"].toString();
info.nPacket = objIoAddress["packet"].toInt();
info.nOffset = objIoAddress["offset"].toInt();
info.bEnable = objEvent["enable"].toBool();
QJsonObject objCause = objEvent["cause"].toObject();
if(objCause.contains("upup")){
info.mapTE.insert("upup",objCause["upup"].toDouble());
}
if(objCause.contains("up")){
info.mapTE.insert("up",objCause["up"].toDouble());
}
if(objCause.contains("down")){
info.mapTE.insert("down",objCause["down"].toDouble());
}
if(objCause.contains("downdown")){
info.mapTE.insert("downdown",objCause["downdown"].toDouble());
}
info.sEdge = objCause["edge"].toString();
QJsonObject objAction = objEvent["action"].toObject();
info.sCommand = objAction["command"].toString();
QJsonArray arrPara = objAction["parameters"].toArray();
for(const QJsonValue &paraValue:arrPara){
info.lstParameter.append(paraValue.toString());
}
if(objBinding.contains("ct") || objBinding.contains("pt") ){
if(objBinding.contains("ct")){
QJsonObject objWind = objBinding["ct"].toObject();
info.nRatio = objWind["ratio"].toInt();
info.nPolarity = objWind["polarity"].toInt();
info.nIndex = objWind["index"].toInt();
info.sWindType = "ct";
}
else{
QJsonObject objWind = objBinding["pt"].toObject();
info.nRatio = objWind["ratio"].toInt();
info.nPolarity = objWind["polarity"].toInt();
info.nIndex = objWind["index"].toInt();
info.sWindType = "pt";
}
}
lst.append(info);
}
query.clear();
return lst;
}
catch (const std::exception& e)
{
return lst;
}
}
QMap<QString,MeasurementInfo> DataBase::getAllMeasurements()
{
QMap<QString,MeasurementInfo> lst;
@ -1827,6 +1941,58 @@ QList<ExtraProperty> DataBase::getCompoExtraProperty(QUuid uid)
}
}
QList<ExtraProperty> DataBase::getBayExtraProperty(QString bayTag)
{
QList<ExtraProperty> lst;
QString strSQL = "SELECT code, tag, name, grid_name, zone_name, station_name, current_level, bay_name, component_name, group_name, type_name, grid_tag, zone_tag, station_tag, page_tag, bay_tag, component_uuid, component_tag, group_tag, type_tag, source_type, source_config, connect_para FROM properties_setting WHERE bay_tag = ?";
QVariantList params;
params.append(bayTag);
try
{
QSqlQuery query = executeSQL(strSQL,false,params);
while (query.next())
{
ExtraProperty info;
info.code = query.value(0).toString();
info.tag = query.value(1).toString();
info.name = query.value(2).toString();
info.grid_name = query.value(3).toString();
info.zone_name = query.value(4).toString();
info.station_name = query.value(5).toString();
info.currentLevel = query.value(6).toString();
info.bay_name = query.value(7).toString();
info.component_name = query.value(8).toString();
info.group_name = query.value(9).toString();
info.type_name = query.value(10).toString();
info.grid_tag = query.value(11).toString();
info.zone_tag = query.value(12).toString();
info.station_tag = query.value(13).toString();
info.page_tag = query.value(14).toString();
info.bay_tag = query.value(15).toString();
info.component_uuid = QUuid(query.value(16).toString());
info.component_tag = query.value(17).toString();
info.group_tag = query.value(18).toString();
info.type_tag = query.value(19).toString();
info.sourceType = query.value(20).toString();
QString sConfig = query.value(21).toString();
QJsonObject objConfig = QstringToJson(sConfig);
info.sourceConfig = objConfig.toVariantMap();
info.connect_para = query.value(22).toString();
lst.append(info);
}
query.clear();
return lst;
}
catch (const std::exception& e)
{
return lst;
}
}
QList<ExtraProperty> DataBase::getAllExtraProperty()
{
QList<ExtraProperty> lst;