add measure dataSource/eventPlan setting

This commit is contained in:
baiYue 2025-11-05 18:14:31 +08:00
parent 3a369e0b97
commit 0354edfcfb
27 changed files with 2078 additions and 496 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
build/
.vscode/
.qtcreator/
# ---> CMake
CMakeLists.txt.user

View File

@ -876,6 +876,8 @@ struct DiagramContent {
struct PtExtraInfo
{
int id;
QString minTransRatio; //最小变比
QString maxTransRatio; //最大变比
QString transRatio; //变比
QString accuracyClass; //精度等级
QString secondaryLoadCapacity; //二次负载容量
@ -886,6 +888,8 @@ struct CtExtraInfo
{
int id;
QString transRatio; //变比
QString minTransRatio; //最小变比
QString maxTransRatio; //最大变比
QString accuracyClass; //精度等级
QString secondaryLoadCapacity; //二次负载容量
};
@ -896,10 +900,23 @@ struct MeasurementInfo //量测
QString name; //量测名称
QString equipment; //设备名称
QString channel; //设备端子
QString type; //量测类型
int type; //量测类型 0:遥测 1:遥信 2:遥控
int size; //量测size
QUuid bayUuid; //所属间隔
QUuid componentUuid; //所属设备
//通讯
int nSource; //数据来源 1:cl3611 2:104
QString sStation; //子站名称
QString sChannel; //通道名(cl3611) 遥测TMx(1-8); P; Q; S; PF; F; deltaF; UAB; UBC; UCA; 遥信: TSxx(01-10); 遥控: TCx;
int nPacket; //包号(104)
int nOffset; //偏移量(104)
//事件
bool bEnable = false; //"enable"开启标志
QMap<QString,double> mapTE; //遥测"cause" key:upup,up,down,downdown可选val:0-100
QString sEdge; //遥信"cause:edge" raising, falling 字符串单选
QString sCommand; //"action:command" info, warning, error, critical, exception 字符串单选
QStringList lstParameter; //"action:parameters" 字符串数组
};
//==================================================

View File

@ -25,12 +25,13 @@ public:
virtual void setPropertyValue(QVariant);
auto& getValidType() {return _validType;} //获取可用的量测属性
void setUi();
void addMeasure(MeasurementInfo);
void addMeasure(MeasurementInfo,int mode = 0); //mode:0新建1修改
void addOtherMeasure(QStringList); //本间隔的其他量测
BaseProperty* getProperty() {return _itemProperty;}
public slots:
void onAddClicked();
void onDeleteClicked();
void onModifyClicked();
void onIndexRbtnClicked(const QPoint &pos); //索引列表右键菜单
private:
void initial();

View File

@ -28,7 +28,7 @@ public slots:
void onAddClicked();
void onDeleteClicked();
protected:
void addTableRow(QString,QString,QString,int id = -1);
void addTableRow(QString,QString,QString,QString,QString,int id = -1);
private:
Ui::ctExtraInfoDlg *ui;
QMap<QString,CtExtraInfo> _mapCT;

View File

@ -112,6 +112,7 @@ public Q_SLOTS:
private:
void addPortsToItem_json(PortState,QJsonArray,GraphicsProjectModelItem*); //将json格式的port添加到item
void autoSetModelName(GraphicsBaseModelItem*); //如果此页的工程模已被设置将projectName更新到item
QString removeSuffix(const QString& str); //移除最后一个下划线后的内容 (处理各种tag后缀)
private:
QMap<QUuid,GraphicsProjectModelItem*> _nodeItem; //工程模对象

View File

@ -595,7 +595,7 @@ public:
QRectF updateBoundRect();
protected:
QList<GraphicsBaseItem*> m_childItems;
int m_direction = 0; //组内布局0横1纵
int m_direction = 1; //组内布局0横1纵
int m_spacing = 0; //间距
int _groupType = 0; //组类型0联合(子item独立连接),1聚合(子item仅作展示)
};

View File

@ -2,6 +2,7 @@
#define MEASURESETTINGDLG_H
#include <QDialog>
#include <QButtonGroup>
/*******************************************************
********************************************************/
@ -10,6 +11,7 @@ namespace Ui { class measureSettingDlg; }
QT_END_NAMESPACE
class BayInfoDlg;
struct MeasurementInfo;
class MeasureSettingDlg : public QDialog
{
@ -21,16 +23,28 @@ public:
void initial();
void setBay(BayInfoDlg* p) {_pBay = p;}
void showDlg();
void showDlg(MeasurementInfo); //修改
public slots:
void onOkClicked();
void onCancelClicked();
void onTagChanged(const QString&);
void onNameChanged(const QString&);
void onRuleIndexChanged(int); //通信方式改变时
void onTypeIndexChanged(int); //量测类型改变时
void onAddParaClicked();
void onDelParaClicked();
void onEventStrategyChange(int); //事件策略改变
private:
void clearData();
private:
Ui::measureSettingDlg *ui;
BayInfoDlg* _pBay;
QButtonGroup* _pEventStrategy; //事件策略组
QButtonGroup* _pEventYXGroup; //遥信事件组
bool _curMode; //0新增1修改
};
#endif

View File

@ -28,7 +28,7 @@ public slots:
void onAddClicked();
void onDeleteClicked();
protected:
void addTableRow(QString,QString,QString,QString,int id = -1);
void addTableRow(QString,QString,QString,QString,QString,QString,int id = -1);
private:
Ui::ptExtraInfoDlg *ui;
QMap<QString,PtExtraInfo> _mapPT;

View File

@ -72,14 +72,9 @@ void BayInfoDlg::setPropertyValue(QVariant var)
{
_itemProperty = property;
QList<measureAttributeType> lstType = DataBase::GetInstance()->getMeasureAttributeTypes();
auto map = property->getMeasurement();
_validType = lstType;
for(auto& info:map){
addMeasure(info);
}
//间隔处理
_bayProperty = nullptr;
QMap<QUuid,ElectricBayItem*> mapBay = _curModelController->allBayItem();
@ -97,6 +92,11 @@ void BayInfoDlg::setPropertyValue(QVariant var)
}
}
auto map = property->getMeasurement();
for(auto& info:map){
addMeasure(info);
}
if(_bayProperty){
auto lstFrom = _bayProperty->getLstFrom();
auto lstTo = _bayProperty->getLstTo();
@ -242,8 +242,9 @@ void BayInfoDlg::setUi()
);
}
void BayInfoDlg::addMeasure(MeasurementInfo info)
void BayInfoDlg::addMeasure(MeasurementInfo info,int mode)
{
if(mode == 0){ //新建
if(_mapMeasure.contains(info.name))
return;
int row = ui->tableWidget_local->rowCount();
@ -261,7 +262,23 @@ void BayInfoDlg::addMeasure(MeasurementInfo info)
QTableWidgetItem* channelItem = new QTableWidgetItem(info.channel);
ui->tableWidget_local->setItem(row, 3, channelItem);
QTableWidgetItem* typeItem = new QTableWidgetItem(info.type);
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));
@ -275,11 +292,55 @@ void BayInfoDlg::addMeasure(MeasurementInfo info)
_mapMeasure.insert(info.name,info);
}
for(int i = 0;i < _validType.size();++i){
/*for(int i = 0;i < _validType.size();++i){
if(_validType.at(i).name == info.name){ //可用类型中移除该类型
_validType.removeAt(i);
break;
}
}*/
}
else if(mode == 1){ //修改
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 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));
}
}
}
}
@ -320,11 +381,11 @@ void BayInfoDlg::onDeleteClicked()
QModelIndex indexName = index.sibling(index.row(),1);
QString sName = indexName.data().toString();
if(_mapMeasure.contains(sName)){
MeasurementInfo info = _mapMeasure.take(sName);
/*MeasurementInfo info = _mapMeasure.take(sName);
measureAttributeType typ;
typ.name = info.name;
typ.tag = info.tag;
_validType.append(typ);
_validType.append(typ);*/
}
int currentRow = ui->tableWidget_local->currentRow();
@ -335,6 +396,32 @@ void BayInfoDlg::onDeleteClicked()
ui->tableWidget_local->removeRow(currentRow);
}
void BayInfoDlg::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->setBay(this);
}
_measureDlg->showDlg(info);
}
}
void BayInfoDlg::onIndexRbtnClicked(const QPoint &pos)
{
// 获取当前点击的位置对应的索引
@ -344,10 +431,13 @@ void BayInfoDlg::onIndexRbtnClicked(const QPoint &pos)
}
QMenu menu;
QAction *modifyAction = new QAction("修改量测", this);
QAction *deleteAction = new QAction("移除量测", this);
menu.addAction(modifyAction);
menu.addAction(deleteAction);
// 连接删除菜单项的触发信号与槽函数
connect(modifyAction, &QAction::triggered, this, &BayInfoDlg::onModifyClicked);
connect(deleteAction, &QAction::triggered, this, &BayInfoDlg::onDeleteClicked);
// 在点击位置显示菜单

View File

@ -4,6 +4,7 @@
#include "basePropertyManager.h"
#include <QButtonGroup>
#include <QJsonArray>
#include <QJsonDocument>
CtExtraInfoDlg::CtExtraInfoDlg(QWidget *parent)
: BaseContentDlg(parent)
@ -85,6 +86,8 @@ QMap<QString,propertyStateInfo> CtExtraInfoDlg::getPropertyValue(BaseProperty* p
{
QJsonObject obj;
obj["id"] = info.id;
obj["minTransformationRatio"] = info.minTransRatio;
obj["maxTransformationRatio"] = info.maxTransRatio;
obj["transformationRatio"] = info.transRatio;
obj["accuracyClass"] = info.accuracyClass;
obj["secondaryLoadCapacity"] = info.secondaryLoadCapacity;
@ -100,62 +103,64 @@ QMap<QString,propertyStateInfo> CtExtraInfoDlg::getPropertyValue(BaseProperty* p
}
void CtExtraInfoDlg::setPropertyValue(QVariant var)
{
BaseProperty* pPro = static_cast<BaseProperty*>(var.value<void*>());
if(pPro)
{
QMap<QString,propertyStateInfo> map = var.value<QMap<QString,propertyStateInfo>>();
for(auto &info:map)
{
if(info.name == "额定电流") //此处应为类型名
if(info.name == "额定电流(A)" || info.name == "in_a") //此处应为类型名
{
ui->le_ratedCurrent->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "工频耐压")
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
{
ui->le_pfwv_ct->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "冲击耐压")
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
{
ui->le_iwv_ct->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "动稳定电流")
else if(info.name == "动稳定电流(A)" || info.name == "dsc_a")
{
ui->le_dsc_ct->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "仪表保安系数")
else if(info.name == "仪表保安系数" || info.name == "fs")
{
ui->le_isf->setText(info.defaultValue.toString());
}
else if(info.name == "短时热电流")
else if(info.name == "稳定电流(A)" || info.name == "ith_a")
{
ui->le_sttc->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "额定频率")
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
{
ui->le_rf_ct->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "相数")
else if(info.name == "相数" || info.name == "phase_num")
{
if(info.defaultValue.toInt() == 1)
ui->rb_tpt_ct->setChecked(true);
else
ui->rb_zst_ct->setChecked(true);
}
else if(info.name == "ct绕组")
else if(info.name == "CT绕组" || info.name == "ct_winding")
{
QJsonObject object = info.defaultValue.toJsonObject();
QString jsonString = info.defaultValue.toString();
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
QJsonObject jsonObject = jsonDocument.object();
QJsonObject object = jsonObject;
QJsonArray arr = object["winding"].toArray();
for (QJsonValueRef jsonObj : arr)
{
QJsonObject node = jsonObj.toObject();
int id = node["id"].toInt();
QString sTr = node["transformationRatio"].toString();
QString sMinTr = node["minTransformationRatio"].toString();
QString sMaxTr = node["maxTransformationRatio"].toString();
QString sAr = node["accuracyClass"].toString();
QString sSlc = node["secondaryLoadCapacity"].toString();
addTableRow(sTr,sAr,sSlc,id);
}
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc,id);
}
}
}
@ -164,9 +169,11 @@ void CtExtraInfoDlg::setPropertyValue(QVariant var)
void CtExtraInfoDlg::onAddClicked()
{
QString sTr = ui->le_tr_ct->text();
QString sMinTr = ui->le_trMin_ct->text();
QString sMaxTr = ui->le_trMax_ct->text();
QString sAr = ui->le_ac_ct->text();
QString sSlc = ui->le_slc_ct->text();
addTableRow(sTr,sAr,sSlc);
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc);
}
void CtExtraInfoDlg::onDeleteClicked()
@ -184,7 +191,7 @@ void CtExtraInfoDlg::onDeleteClicked()
}
}
void CtExtraInfoDlg::addTableRow(QString sTr,QString sAr,QString sSlc,int id)
void CtExtraInfoDlg::addTableRow(QString sTr,QString sMinTr,QString sMaxTr,QString sAr,QString sSlc,int id)
{
if(_mapCT.contains(QString::number(id)))
{
@ -208,19 +215,27 @@ void CtExtraInfoDlg::addTableRow(QString sTr,QString sAr,QString sSlc,int id)
item->setData(Qt::UserRole,info.id);
ui->tb_ct->setItem(row, 0, item);
//最小变比
ui->tb_ct->setItem(row, 1, new QTableWidgetItem(sMinTr));
//最大变比
ui->tb_ct->setItem(row, 2, new QTableWidgetItem(sMaxTr));
// 精度等级(下拉框)
ui->tb_ct->setItem(row, 1, new QTableWidgetItem(sAr));
ui->tb_ct->setItem(row, 3, new QTableWidgetItem(sAr));
// 二次负载容量(输入框)
ui->tb_ct->setItem(row, 2, new QTableWidgetItem(sSlc));
ui->tb_ct->setItem(row, 4, new QTableWidgetItem(sSlc));
// 删除按钮
QPushButton *deleteBtn = new QPushButton("删除");
connect(deleteBtn, &QPushButton::clicked, this, &CtExtraInfoDlg::onDeleteClicked);
ui->tb_ct->setCellWidget(row, 3, deleteBtn);
ui->tb_ct->setCellWidget(row, 5, deleteBtn);
info.transRatio = sTr;
info.minTransRatio = sMinTr;
info.maxTransRatio = sMaxTr;
info.accuracyClass = sAr;
info.secondaryLoadCapacity = sSlc;
_mapCT.insert(QString::number(info.id),info);

View File

@ -125,7 +125,7 @@ void DiagramCavas::onSignal_savePage()
QString sMeta = pData->metaModelName();
QString sModel = pData->modelName();
if(!updatedModel.contains(sModel)){
ProjectModelManager::instance().updateSetting(sMeta,sModel); //更新使用的图标数据
ProjectModelManager::instance().updateSetting(sMeta,sModel,true); //更新使用的图标数据
updatedModel.append(sModel);
}

View File

@ -39,6 +39,7 @@
#include <QJsonArray>
#include <QMessageBox>
#include <QRandomGenerator>
#include <QJsonDocument>
#include "baseProperty.h"
#include "projectModelSetting.h"
#include "bayManagerDlg.h"
@ -142,6 +143,7 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos,double width
BaseProperty* pro = nullptr;
GraphicsProjectModelItem* item = nullptr;
QMap<QUuid,BaseProperty*> mapData = BasePropertyManager::instance().getEntityData(); //加载的图形必定关联component(todo:完善判断条件,如判断拓扑节点)
if(mapData.contains(id))
{
pro = mapData.value(id);
@ -153,6 +155,13 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos,double width
QString sMeta = pro->metaModelName();
QString sProModel = pro->modelName();
modelDataInfo mapValue = DataManager::instance().modelData()[sProModel];
PropertyValueInfo valueInfo; //属性组设置的数据 (ct,pt二次绕组)
if(mapValue.groupInfo.contains("base_extend"))
{
valueInfo = mapValue.groupInfo["base_extend"].mapInfo[id];
}
double dX = 0.0;
double dY = 0.0;
if(type == GIT_itemRect)
@ -248,11 +257,91 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos,double width
}
auto pCt = new ElectricSvgGroupCT(QRect(-dX*0.5, -dY*0.5, dX, dY));
pCt->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sProModel].modelSetting.mapUsedSvg);
pCt->setItemType(GIT_ctGroup);
item = pCt;
QJsonArray portArr = pro->context()["port"].toArray();
addPortsToItem_json(P_const,portArr,item);
if(!valueInfo.isEmpty()){ //使用设置的绕组数更新自己
int nCtSize = 0; //ct设置的个数
int nCtType = 0; //ct类型 1三相0零相
if(valueInfo.contains("ct_winding")){
propertyStateInfo val = valueInfo.value("ct_winding");
QJsonDocument jsonDocument = QJsonDocument::fromJson(val.defaultValue.toString().toUtf8().data());
if(!jsonDocument.isNull()){
QJsonObject obj = jsonDocument.object();
if(obj.contains("winding")){
QJsonArray arr = obj["winding"].toArray();
nCtSize = arr.size();
}
}
}
if(valueInfo.contains("phase_num")){
propertyStateInfo val = valueInfo.value("phase_num");
nCtType = val.defaultValue.toInt();
}
QPair<int,int> pair(nCtType,nCtSize);
QVariant var = QVariant::fromValue(pair);
pCt->setupFinish(var);
}
}
else if(type == GIT_ptGroup)
{
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
QByteArray svg;
if(model.modelSetting.mapSvg.isEmpty()){
svg = DataBase::GetInstance()->ModelType()[6].icon;
}
else{
svg = model.modelSetting.mapSvg.first();
}
if(width == 0 && height == 0){
dX = 50;
dY = 50;
}
else{
dX = width;
dY = height;
}
auto pPt = new ElectricSvgGroupPT(QRect(-dX*0.5, -dY*0.5, dX, dY));
pPt->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sProModel].modelSetting.mapUsedSvg);
pPt->setItemType(GIT_ptGroup);
item = pPt;
QJsonArray portArr = pro->context()["port"].toArray();
addPortsToItem_json(P_const,portArr,item);
if(!valueInfo.isEmpty()){ //使用设置的绕组数更新自己
QList<int> lst; //二次绕组接法
if(valueInfo.contains("pt_sec_winding")){
propertyStateInfo val = valueInfo.value("pt_sec_winding");
QJsonDocument jsonDocument = QJsonDocument::fromJson(val.defaultValue.toString().toUtf8().data());
if(!jsonDocument.isNull()){
QJsonObject obj = jsonDocument.object();
QJsonArray arr = obj["winding"].toArray();
for (QJsonValueRef jsonObj : arr)
{
QJsonObject node = jsonObj.toObject();
QString sWinding = node["windingConnectionMethod"].toString();
if(sWinding == "Y"){
lst.append(1);
}
else{
lst.append(0);
}
}
}
QVariant var = QVariant::fromValue(lst);
pPt->setupFinish(var);
}
}
}
else if(type == GIT_DS)
{
@ -585,10 +674,12 @@ void FixedPortsModel::loadNodeDataFromDataBase()
QList<componentInfo> lst= DataBase::GetInstance()->getAllComponents();
for(auto &info:lst)
{
QString preTag = removeSuffix(info.tag);
QString prePath = removeSuffix(info.nspath);
BaseProperty* pData = addNodeData(info.uuid,info.type,info.name,info.modelName);
pData->setTag(info.tag);
pData->setTag(preTag);
pData->setName(info.name);
pData->setPath(info.nspath);
pData->setPath(prePath);
pData->setDescription(info.description);
pData->setInService(info.inService);
pData->setState(info.state);
@ -612,6 +703,7 @@ void FixedPortsModel::loadNodeDataFromDataBase()
QMap<QString,MeasurementInfo> mapMeasure;
for(auto& info:lstMeasure)
{
info.tag = removeSuffix(info.tag);
mapMeasure.insert(info.name,info);
}
pData->setMeasurement(mapMeasure);
@ -629,8 +721,10 @@ void FixedPortsModel::loadNodeDataFromDataBase()
QList<bayInfo> lstBay = DataBase::GetInstance()->getAllBay();
for(auto& bay:lstBay)
{
QString showTag = removeSuffix(bay.tag);
BayProperty* pBay = addBayData(bay.uuid);
pBay->setName(bay.name);
pBay->setTag(showTag);
pBay->setType(bay.type);
pBay->setLstComponent(bay.components);
pBay->setVoltage(bay.unom);
@ -768,6 +862,7 @@ void FixedPortsModel::saveNode(int nPageId)
BayProperty* pBay = dynamic_cast<BayProperty*>(pro);
if(pBay){
bool val = DataBase::GetInstance()->ifBayExist(pBay->uuid());
QString tempTag = pBay->tag()+"_"+_pageName; //tag后加工程名保持全局唯一
if(!val){
QJsonObject objFrom = turnListToJson(pBay->getLstFrom(),"id","ids");
QJsonObject objTo= turnListToJson(pBay->getLstTo(),"id","ids");
@ -778,7 +873,7 @@ void FixedPortsModel::saveNode(int nPageId)
QJsonObject objIns= turnListToJson(pBay->getLstInstruct(),"id","ids");
QJsonObject objEtc= turnListToJson(pBay->getLstEtc(),"id","ids");
DataBase::GetInstance()->insertBay(pBay->uuid(),pBay->name(),pBay->tag(),pBay->getType(),pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"1",pBay->getInService(),0,"1","1","1",QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent(),QJsonObject());
DataBase::GetInstance()->insertBay(pBay->uuid(),pBay->name(),tempTag,pBay->getType(),pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"1",pBay->getInService(),0,"1","1","1",QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent(),QJsonObject());
}
else{
QJsonObject objFrom = turnListToJson(pBay->getLstFrom(),"id","ids");
@ -790,7 +885,7 @@ void FixedPortsModel::saveNode(int nPageId)
QJsonObject objIns= turnListToJson(pBay->getLstInstruct(),"id","ids");
QJsonObject objEtc= turnListToJson(pBay->getLstEtc(),"id","ids");
DataBase::GetInstance()->updateBay(pBay->uuid(),pBay->name(),pBay->tag(),pBay->getVoltage(),pBay->getFla(),pBay->getCapacity(),"",pBay->getInService(),0,QJsonObject(),objFrom,objTo,objProtec,objFalRec,objStatus,objDynSen,objIns,objEtc,pBay->getLstComponent(),QJsonObject());
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());
}
}
}
@ -828,7 +923,8 @@ void FixedPortsModel::saveNode(int nPageId)
modelDataInfo& dataInfo = pVariable->getPropertyValue();
if(exist) //已存在更新
{
DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
QString tempTag = pData->tag()+"_"+_pageName; //tag后加工程名使得全局唯一
DataBase::GetInstance()->updateComponent(pData->uuid(),tempTag,pData->name(),pData->context());
for(auto &val:dataInfo.groupInfo)
{
if(val.groupName == "component")
@ -845,7 +941,9 @@ void FixedPortsModel::saveNode(int nPageId)
}
else
{
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->modelName(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->status(),pData->connectedBus(),pData->label(),pData->context(),1);
QString tempTag = pData->tag()+"_"+_pageName; //tag后加工程名使得全局唯一
QString tempPath = pData->path()+"_"+_pageName;
DataBase::GetInstance()->insertComponent(pData->uuid(),pData->modelName(),tempPath,tempTag,pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->status(),pData->connectedBus(),pData->label(),pData->context(),1);
for(auto &val:dataInfo.groupInfo)
{
if(val.groupName == "component")
@ -866,31 +964,54 @@ void FixedPortsModel::saveNode(int nPageId)
QList<MeasurementInfo> lstDataBase = DataBase::GetInstance()->getMeasurement(pData->uuid()); //数据库中现有量测
for(auto& info:mapMeasure)
{
int tpe = 0; //todo:建立类型映射表
if(info.type == "遥测"){
tpe = 0;
int tpe = info.type; //todo:建立类型映射表
QJsonObject objDataSource;
QJsonObject objIoAddress;
if(info.nSource == 1){ //3611
objDataSource["type"] = 1;
objIoAddress["station"] = info.sStation;
objIoAddress["device"] = info.equipment;
objIoAddress["channel"] = info.sChannel;
}
else if(info.type == "遥信"){
tpe = 1;
else if(info.nSource == 2){ //104
objDataSource["type"] = 2;
objIoAddress["station"] = info.sStation;
objIoAddress["packet"] = info.nPacket;
objIoAddress["offset"] = info.nOffset;
}
else if(info.type == "遥控"){
tpe = 2;
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(info.type == "遥调"){
tpe = 3;
}
else if(info.type == "整定值"){
tpe = 4;
else if(tpe == 1){ //遥信
objCause["edge"] = info.sEdge;
}
QJsonObject obj;
obj["type"] = info.equipment;
obj["main_pos"] = info.channel;
objEventPlan["cause"] = objCause;
objAction["command"] = info.sCommand;
for(auto &para:info.lstParameter){
arrPara.append(para);
}
objAction["parameters"] = arrPara;
objEventPlan["action"] = objAction;
QString tempTag = info.tag+"_"+_pageName; //tag后加工程名保持全局唯一
bool val = DataBase::GetInstance()->ifMeasureExist(info.name,pData->uuid());
if(val){
DataBase::GetInstance()->updateMeasurement(info.name,tpe,obj,info.size,pData->uuid());
DataBase::GetInstance()->updateMeasurement(info.name,tpe,objDataSource,objEventPlan,info.size,pData->uuid());
}
else{
DataBase::GetInstance()->insertMeasurement(info.name,info.tag,tpe,obj,info.size,info.bayUuid,info.componentUuid);
DataBase::GetInstance()->insertMeasurement(info.name,tempTag,tpe,objDataSource,objEventPlan,info.size,info.bayUuid,info.componentUuid);
}
for(int i = 0;i < lstDataBase.size();++i) //从数据库记录中移除操作过的对象
@ -1078,7 +1199,13 @@ void FixedPortsModel::addPortsToItem_json(PortState sta,QJsonArray jArr,Graphics
if(sta == P_const){
HandleType tye = HandleType(portObj["portType"].toInt());
PortPos locate = PortPos(portObj["locate"].toInt());
pItem->addPort(P_const,QPointF(x,y),portId,tye,locate);
double ratioX = 0.0;
double ratioY = 0.0;
if(portObj.contains("xRatio") || portObj.contains("yRatio")){
ratioX = portObj["xRatio"].toDouble();
ratioY = portObj["yRatio"].toDouble();
}
pItem->addPort(P_const,QPointF(x,y),portId,tye,locate,ratioX,ratioY);
}
else if(sta == p_movable){
pItem->addPort(p_movable,QPointF(x,y),portId);
@ -1101,6 +1228,14 @@ void FixedPortsModel::autoSetModelName(GraphicsBaseModelItem* pItem)
}
}
QString FixedPortsModel::removeSuffix(const QString& str)
{
int lastUnderscore = str.lastIndexOf('_');
if (lastUnderscore == -1) return str; // 没有下划线
return str.left(lastUnderscore);
}
QWidget* FixedPortsModel::getTopWidget()
{
@ -1542,6 +1677,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
GraphicsBaseModelItem* pBaseItem = _baseItem.value(pBase->uuid());
pPro->setSourceItemId(pBaseItem->itemId().toString()); //设置被哪个对象生成
pPro->setMetaModelName(pBase->metaModelName()); //传递基模名
pPro->setPath(pBase->getBay());
QString sMeta = pBase->metaModelName();
QString sModel = pBase->modelName();
@ -1622,7 +1758,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
pPtGroup->setGroupType(1);
pPtGroup->setLayout(1);
pProItem = pPtGroup;
pProItem->setItemType(GIT_ctGroup);
pProItem->setItemType(GIT_ptGroup);
}
else if(type == GIT_baseES)
{

View File

@ -511,6 +511,8 @@ void GraphicsProjectModelItem::updateConnectData()
port["y"] = ptr->pos().y();
port["locate"] = ptr->portPos();
port["portType"] = ptr->getType();
port["xRatio"] = ptr->getXPercent();
port["yRatio"] = ptr->getYPercent();
arr.push_back(port);
}
}

View File

@ -10,9 +10,13 @@ MeasureSettingDlg::MeasureSettingDlg(QWidget *parent)
: QDialog(parent)
, ui(new Ui::measureSettingDlg)
,_pBay(nullptr)
,_pEventStrategy(nullptr)
,_pEventYXGroup(nullptr)
,_curMode(0)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
setStyleSheet("background-color: white;");
initial();
}
@ -23,33 +27,61 @@ MeasureSettingDlg::~MeasureSettingDlg()
void MeasureSettingDlg::initial()
{
_pEventStrategy = new QButtonGroup(this);
_pEventStrategy->addButton(ui->rb_eventOff,0);
_pEventStrategy->addButton(ui->rb_eventOn,1);
_pEventYXGroup = new QButtonGroup(this);
_pEventYXGroup->addButton(ui->rb_yxDown,0);
_pEventYXGroup->addButton(ui->rb_yxRise,1);
connect(_pEventStrategy,&QButtonGroup::idClicked,this,&MeasureSettingDlg::onEventStrategyChange);
connect(ui->btn_ok,&QPushButton::clicked,this,&MeasureSettingDlg::onOkClicked);
connect(ui->btn_cancel,&QPushButton::clicked,this,&MeasureSettingDlg::onCancelClicked);
connect(ui->btn_addPara,&QPushButton::clicked,this,&MeasureSettingDlg::onAddParaClicked);
connect(ui->btn_delPara,&QPushButton::clicked,this,&MeasureSettingDlg::onDelParaClicked);
connect(ui->cb_tag,&QComboBox::textActivated,this,&MeasureSettingDlg::onTagChanged);
connect(ui->cb_name,&QComboBox::textActivated,this,&MeasureSettingDlg::onNameChanged);
connect(ui->cb_rule,&QComboBox::currentIndexChanged, this,&MeasureSettingDlg::onRuleIndexChanged);
connect(ui->cb_type,&QComboBox::currentIndexChanged, this,&MeasureSettingDlg::onTypeIndexChanged);
// 设置正则验证器1-5000整数
QRegularExpression regExp("^(?:[1-9]|[1-9]\\d{1,2}|[1-4]\\d{3}|5000)$");
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp,ui->le_size);
ui->le_size->setValidator(validator);
ui->cb_rule->setItemData(0, 1);
ui->cb_rule->setItemData(1, 2);
}
void MeasureSettingDlg::showDlg()
{
_curMode = 0;
//ui->cb_tag->setEditable(true);
//ui->cb_name->setEditable(true);
clearData();
QStringList lstTag;
QStringList lstName;
show();
if(_pBay){
QString curItemName; //当前元件名称
if(_pBay){
auto pItemData = _pBay->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);
QStringList lstDevice;
/*QStringList lstDevice;
if(_pBay){
FixedPortsModel* pModel = _pBay->getModelController();
if(pModel){
@ -61,16 +93,108 @@ void MeasureSettingDlg::showDlg()
}
}
}
}
ui->cb_equip->addItems(lstDevice);
}*/
ui->cb_equip->clear();
ui->cb_equip->addItem(curItemName);
BaseProperty* pro = _pBay->getProperty();
if(pro){
ui->cb_equip->setCurrentText(pro->tag());
ui->le_s1->setText(pro->station());
ui->le_s2->setText(pro->station());
}
}
}
void MeasureSettingDlg::showDlg(MeasurementInfo info)
{
show();
//ui->cb_tag->setEditable(false);
//ui->cb_name->setEditable(false);
_curMode = 1;
clearData();
ui->cb_tag->setCurrentText(info.tag);
ui->cb_name->setCurrentText(info.name);
ui->cb_equip->setCurrentText(info.equipment);
ui->le_port->setText(info.channel);
ui->cb_type->setCurrentIndex(info.type);
ui->le_size->setText(QString::number(info.size));
if(info.nSource == 1){ //3611
ui->cb_rule->setCurrentIndex(0);
ui->le_s1->setText(info.sStation);
ui->le_d1->setText(info.equipment);
if(info.type == 0){ //遥测
ui->cb_channelYC->setCurrentText(info.sChannel);
}
else if(info.type == 1){ //遥信
ui->cb_channelYX->setCurrentText(info.sChannel);
}
else if(info.type == 2){ //遥控
ui->cb_channelYK->setCurrentText(info.sChannel);
}
}
else if(info.nSource == 2){ //104
ui->cb_rule->setCurrentIndex(1);
ui->le_s2->setText(info.sStation);
ui->le_packet->setText(QString::number(info.nPacket));
ui->le_offset->setText(QString::number(info.nOffset));
}
if(info.bEnable){
ui->rb_eventOn->setChecked(true);
}
else{
ui->rb_eventOff->setChecked(true);
}
ui->le_measure->setText(ui->cb_type->currentText());
if(info.type == 0){ //遥测
if(info.mapTE.contains("upup")){
ui->checkBox_upup->setChecked(true);
ui->dbsb_upup->setValue(info.mapTE["upup"]);
}
else{
ui->checkBox_upup->setChecked(false);
}
if(info.mapTE.contains("up")){
ui->checkBox_up->setChecked(true);
ui->dbsb_up->setValue(info.mapTE["up"]);
}
else{
ui->checkBox_up->setChecked(false);
}
if(info.mapTE.contains("down")){
ui->checkBox_down->setChecked(true);
ui->dbsb_down->setValue(info.mapTE["down"]);
}
else{
ui->checkBox_down->setChecked(false);
}
if(info.mapTE.contains("downdown")){
ui->checkBox_downdown->setChecked(true);
ui->dbsb_downdown->setValue(info.mapTE["downdown"]);
}
else{
ui->checkBox_downdown->setChecked(false);
}
}
else if(info.type == 1){ //遥信
if(info.sEdge == "raising"){ //上升沿
ui->rb_yxRise->setChecked(true);
}
else if(info.sEdge == "falling"){ //上升沿
ui->rb_yxDown->setChecked(true);
}
}
ui->cb_command->setCurrentText(info.sCommand);
for(auto &para:info.lstParameter){
ui->lst_parameter->addItem(para);
}
}
void MeasureSettingDlg::clearData()
{
if(ui->cb_tag->count())
@ -79,6 +203,20 @@ void MeasureSettingDlg::clearData()
ui->cb_name->clear();
ui->le_port->clear();
ui->le_size->clear();
ui->cb_type->setCurrentIndex(0);
ui->cb_rule->setCurrentIndex(0);
ui->rb_eventOff->setChecked(true);
ui->checkBox_upup->setChecked(false);
ui->checkBox_up->setChecked(false);
ui->checkBox_down->setChecked(false);
ui->checkBox_downdown->setChecked(false);
ui->dbsb_upup->clear();
ui->dbsb_up->clear();
ui->dbsb_down->clear();
ui->dbsb_downdown->clear();
ui->cb_command->setCurrentIndex(0);
ui->le_parameter->clear();
ui->lst_parameter->clear();
}
void MeasureSettingDlg::onOkClicked()
@ -88,15 +226,55 @@ void MeasureSettingDlg::onOkClicked()
info.name = ui->cb_name->currentText();
info.equipment = ui->cb_equip->currentText();
info.channel = ui->le_port->text();
info.type = ui->cb_type->currentText();
info.type = ui->cb_type->currentIndex();
info.size = ui->le_size->text().toInt();
if(info.channel.isEmpty() || info.size == 0){
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"参数未设置完毕"));
return;
info.nSource = ui->cb_rule->currentData().toInt();
if(info.nSource == 1){ //cl3611
info.sStation = ui->le_s1->text();
}
else if(info.nSource == 2){
info.sStation = ui->le_s2->text();
}
if(info.type == 0)
info.sChannel = ui->cb_channelYC->currentText();
else if(info.type == 1)
info.sChannel = ui->cb_channelYX->currentText();
else if(info.type == 2)
info.sChannel = ui->cb_channelYK->currentText();
info.nPacket = ui->le_packet->text().toInt(); //包号
info.nOffset = ui->le_offset->text().toInt(); //偏移量
if(_pEventStrategy){ //事件策略开关
info.bEnable = _pEventStrategy->checkedId();
}
if(ui->checkBox_upup->isChecked()){
info.mapTE.insert("upup",ui->dbsb_upup->value());
}
if(ui->checkBox_up->isChecked()){
info.mapTE.insert("up",ui->dbsb_up->value());
}
if(ui->checkBox_downdown->isChecked()){
info.mapTE.insert("downdown",ui->dbsb_downdown->value());
}
if(ui->checkBox_down->isChecked()){
info.mapTE.insert("down",ui->dbsb_down->value());
}
if(_pEventYXGroup->checkedId() == 0){
info.sEdge = "falling";
}
else if(_pEventYXGroup->checkedId() == 1){
info.sEdge = "raising";
}
info.sCommand = ui->cb_command->currentText();
for(int i = 0;i < ui->lst_parameter->count();++i){
QListWidgetItem *item = ui->lst_parameter->item(i);
info.lstParameter.append(item->text());
}
if(_pBay)
_pBay->addMeasure(info);
_pBay->addMeasure(info,_curMode);
hide();
}
@ -126,3 +304,60 @@ void MeasureSettingDlg::onNameChanged(const QString& str)
}
}
}
void MeasureSettingDlg::onRuleIndexChanged(int n)
{
ui->sw_type->setCurrentIndex(n);
}
void MeasureSettingDlg::onTypeIndexChanged(int n)
{
switch (n) {
case 0: //遥测
ui->sw_channel->setCurrentIndex(0);
ui->gb_yc->setVisible(true);
ui->gb_yx->setVisible(false);
break;
case 1: //遥信
ui->sw_channel->setCurrentIndex(1);
ui->gb_yc->setVisible(false);
ui->gb_yx->setVisible(true);
break;
case 2: //遥控
ui->sw_channel->setCurrentIndex(2);
ui->gb_yc->setVisible(false);
ui->gb_yx->setVisible(false);
break;
default:
ui->gb_yc->setVisible(false);
ui->gb_yx->setVisible(false);
break;
}
ui->le_measure->setText(ui->cb_type->currentText());
}
void MeasureSettingDlg::onAddParaClicked()
{
QString str = ui->le_parameter->text();
auto lst = ui->lst_parameter->findItems(str,Qt::MatchExactly);
if(lst.isEmpty()){ //列表中不存在
ui->lst_parameter->addItem(str);
}
}
void MeasureSettingDlg::onDelParaClicked()
{
auto pItem = ui->lst_parameter->takeItem(ui->lst_parameter->currentRow());
if(pItem)
delete pItem;
}
void MeasureSettingDlg::onEventStrategyChange(int n)
{
if(n == 0){ //不启用
ui->sw_event->setCurrentIndex(0);
}
else if(n == 1){ //启用
ui->sw_event->setCurrentIndex(1);
}
}

View File

@ -7,6 +7,7 @@
#include "projectModelManager.h"
#include <QSvgRenderer>
#include <QPainter>
#include "global.h"
ProjectIconSetting::ProjectIconSetting(QWidget *parent)
: QDialog(parent)
@ -80,7 +81,7 @@ void ProjectIconSetting::addItems(QMap<QString,QByteArray> mapSvg)
// 创建目标大小的pixmap
QPixmap pixmap(_iconSize);
//pixmap.fill(Qt::transparent); // 透明背景
pixmap.fill(Qt::transparent); // 透明背景
// 创建画家并在pixmap上绘制SVG
QPainter painter(&pixmap);
@ -101,7 +102,7 @@ void ProjectIconSetting::selectImage(int row)
if (!selectedSVG.isEmpty()) {
QSvgRenderer renderer(selectedSVG);
QPixmap pixmap(32, 32);
pixmap.fill(Qt::transparent);
//pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
renderer.render(&painter);

View File

@ -72,7 +72,7 @@ void ProjectModelSetting::loadPicture()
{
QString sPath = path+files.at(i);
QPixmap pixmap(sPath);
pixmap.fill(Qt::transparent);
//pixmap.fill(Qt::transparent);
QListWidgetItem *newitem=new QListWidgetItem(QIcon(pixmap.scaled(100, 100)),files.at(i));
QFile file(sPath);
if (!file.open(QIODevice::ReadOnly)) {
@ -202,7 +202,7 @@ void ProjectModelSetting::onSelectClicked()
{
if(!_curItemData->getModelProperty().modelSetting.mapSvg.contains(item->text()))
{
QByteArray data = item->data(Qt::UserRole + 1).toByteArray();
QByteArray data = QByteArray::fromHex(item->data(Qt::UserRole + 1).toByteArray());
_curItemData->getModelProperty().modelSetting.mapSvg.insert(item->text(),data);
}
lst.append(item->text());
@ -320,7 +320,7 @@ void ProjectModelSetting::onSaveClicked()
{
PropertyModel pro = _curItemData->getModelProperty().deepCopy();
ProjectModelManager::instance().getData()[_curItemData->metaModelName()][sModelName] = pro;
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName);
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName,true);
QMap<QString,QJsonObject> mapCheckState = DataBase::GetInstance()->getCheckStateFromManager(sModelName);
QString sRes = ProjectModelManager::instance().modifyProjectModel(sMeta,sModelName,mapCheckState);
if(!sRes.isEmpty())
@ -344,7 +344,7 @@ void ProjectModelSetting::onSaveClicked()
PropertyModel pro = _curItemData->getModelProperty().deepCopy();
ProjectModelManager::instance().getData()[_curItemData->metaModelName()].insert(sModelName,pro);
ProjectModelManager::instance().generate(_curItemData->metaModelName(),sModelName);
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName);
ProjectModelManager::instance().updateSetting(_curItemData->metaModelName(),sModelName,true);
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"保存成功"));
}

View File

@ -4,6 +4,7 @@
#include "basePropertyManager.h"
#include <QButtonGroup>
#include <QJsonArray>
#include <QJsonDocument>
PtExtraInfoDlg::PtExtraInfoDlg(QWidget *parent)
: BaseContentDlg(parent)
@ -82,6 +83,8 @@ QMap<QString,propertyStateInfo> PtExtraInfoDlg::getPropertyValue(BaseProperty* p
QJsonObject obj;
obj["id"] = info.id;
obj["transformationRatio"] = info.transRatio;
obj["minTransformationRatio"] = info.minTransRatio;
obj["maxTransformationRatio"] = info.maxTransRatio;
obj["accuracyClass"] = info.accuracyClass;
obj["secondaryLoadCapacity"] = info.secondaryLoadCapacity;
obj["windingConnectionMethod"] = info.windingConnectionMethod;
@ -101,51 +104,58 @@ void PtExtraInfoDlg::setPropertyValue(QVariant var)
QMap<QString,propertyStateInfo> map = var.value<QMap<QString,propertyStateInfo>>();
for(auto &info:map)
{
if(info.name == "额定电压") //此处应为类型名
if(info.name == "额定电压(V)" || info.name == "un_v") //此处应为类型名
{
ui->le_ratedVol->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "工频耐压")
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
{
ui->le_pfwv_pt->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "冲击耐压")
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
{
ui->le_iwv_pt->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "额定电压因数")
else if(info.name == "额定电压因数" || info.name == "rvf")
{
ui->le_ratedVolFactor->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "一次绕组接线接地方式")
else if(info.name == "一次绕组接线接地方式" || info.name == "pwcc")
{
ui->le_pwwgm->setText(info.defaultValue.toString());
}
else if(info.name == "额定频率")
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
{
ui->le_rf_pt->setText(QString::number(info.defaultValue.toDouble()));
}
else if(info.name == "相数")
else if(info.name == "相数" || info.name == "phase_num")
{
if(info.defaultValue.toInt() == 1)
ui->rb_tpt_pt->setChecked(true);
else
ui->rb_spt_pt->setChecked(true);
}
else if(info.name == "pt绕组")
else if(info.name == "PT二次绕组" || info.name == "pt_sec_winding")
{
QJsonObject object = info.defaultValue.toJsonObject();
QString jsonString = info.defaultValue.toString();
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
QJsonObject jsonObject = jsonDocument.object();
QJsonObject object = jsonObject;
QJsonArray arr = object["winding"].toArray();
for (QJsonValueRef jsonObj : arr)
{
QJsonObject node = jsonObj.toObject();
int id = node["id"].toInt();
QString sTr = node["transformationRatio"].toString();
QString sMinTr = node["minTransformationRatio"].toString();
QString sMaxTr = node["maxTransformationRatio"].toString();
QString sAr = node["accuracyClass"].toString();
QString sSlc = node["secondaryLoadCapacity"].toString();
QString sWin = node["windingConnectionMethod"].toString();
addTableRow(sTr,sAr,sSlc,sWin,id);
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc,sWin,id);
}
}
}
@ -154,10 +164,12 @@ void PtExtraInfoDlg::setPropertyValue(QVariant var)
void PtExtraInfoDlg::onAddClicked()
{
QString sTr = ui->le_tr_pt->text();
QString sMinTr = ui->le_trMin_pt->text();
QString sMaxTr = ui->le_trMax_pt->text();
QString sAr = ui->le_ac_pt->text();
QString sSlc = ui->le_slc_pt->text();
QString sWinding = ui->cb_wcm->currentText();
addTableRow(sTr,sAr,sSlc,sWinding);
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc,sWinding);
}
void PtExtraInfoDlg::onDeleteClicked()
@ -175,7 +187,7 @@ void PtExtraInfoDlg::onDeleteClicked()
}
}
void PtExtraInfoDlg::addTableRow(QString sTr,QString sAr,QString sSlc,QString sWinding,int id)
void PtExtraInfoDlg::addTableRow(QString sTr,QString sTrMin,QString sTrMax,QString sAr,QString sSlc,QString sWinding,int id)
{
if(_mapPT.contains(QString::number(id)))
{
@ -199,21 +211,29 @@ void PtExtraInfoDlg::addTableRow(QString sTr,QString sAr,QString sSlc,QString sW
item->setData(Qt::UserRole,info.id);
ui->tb_pt->setItem(row, 0, item);
//最小变比
ui->tb_pt->setItem(row, 1, new QTableWidgetItem(sTrMin));
//最大变比
ui->tb_pt->setItem(row, 2, new QTableWidgetItem(sTrMax));
// 精度等级(下拉框)
ui->tb_pt->setItem(row, 1, new QTableWidgetItem(sAr));
ui->tb_pt->setItem(row, 3, new QTableWidgetItem(sAr));
// 二次负载容量(输入框)
ui->tb_pt->setItem(row, 2, new QTableWidgetItem(sSlc));
ui->tb_pt->setItem(row, 4, new QTableWidgetItem(sSlc));
// 绕组接法(下拉框)
ui->tb_pt->setItem(row, 3, new QTableWidgetItem(sWinding));
ui->tb_pt->setItem(row, 5, new QTableWidgetItem(sWinding));
// 删除按钮
QPushButton *deleteBtn = new QPushButton("删除");
connect(deleteBtn, &QPushButton::clicked, this, &PtExtraInfoDlg::onDeleteClicked);
ui->tb_pt->setCellWidget(row, 4, deleteBtn);
ui->tb_pt->setCellWidget(row, 6, deleteBtn);
info.transRatio = sTr;
info.minTransRatio = sTrMin;
info.maxTransRatio = sTrMax;
info.accuracyClass = sAr;
info.secondaryLoadCapacity = sSlc;
info.windingConnectionMethod = sWinding;

View File

@ -37,7 +37,7 @@
<property name="verticalSpacing">
<number>10</number>
</property>
<item row="0" column="0" colspan="17">
<item row="0" column="0" colspan="20">
<widget class="QLabel" name="label_title_ct">
<property name="minimumSize">
<size>
@ -69,21 +69,14 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="4">
<item row="1" column="2" colspan="3">
<widget class="QLineEdit" name="le_ratedCurrent">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="label_18">
<property name="text">
<string>A</string>
</property>
</widget>
</item>
<item row="1" column="7" colspan="2">
<item row="1" column="8" colspan="3">
<widget class="QLabel" name="label_22">
<property name="text">
<string>动稳定电流</string>
@ -93,21 +86,21 @@
</property>
</widget>
</item>
<item row="1" column="9" colspan="4">
<item row="1" column="11" colspan="4">
<widget class="QLineEdit" name="le_dsc_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="13">
<item row="1" column="15">
<widget class="QLabel" name="label_21">
<property name="text">
<string>A</string>
</property>
</widget>
</item>
<item row="1" column="14">
<item row="1" column="17">
<widget class="QLabel" name="label_27">
<property name="text">
<string>短时热电流</string>
@ -117,14 +110,14 @@
</property>
</widget>
</item>
<item row="1" column="15">
<item row="1" column="18">
<widget class="QLineEdit" name="le_sttc">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="16">
<item row="1" column="19">
<widget class="QLabel" name="label_26">
<property name="text">
<string>As</string>
@ -148,14 +141,14 @@
</property>
</widget>
</item>
<item row="2" column="4" colspan="3">
<item row="2" column="4" colspan="2">
<widget class="QLabel" name="label_19">
<property name="text">
<string>V/1min</string>
</property>
</widget>
</item>
<item row="2" column="7">
<item row="2" column="7" colspan="2">
<widget class="QLabel" name="label_24">
<property name="text">
<string>冲击耐压</string>
@ -165,21 +158,21 @@
</property>
</widget>
</item>
<item row="2" column="8" colspan="2">
<item row="2" column="9" colspan="3">
<widget class="QLineEdit" name="le_iwv_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="10">
<item row="2" column="12" colspan="2">
<widget class="QLabel" name="label_23">
<property name="text">
<string>V</string>
</property>
</widget>
</item>
<item row="2" column="11">
<item row="2" column="14" colspan="2">
<widget class="QLabel" name="label_25">
<property name="text">
<string>仪表保安系数</string>
@ -189,14 +182,14 @@
</property>
</widget>
</item>
<item row="2" column="12" colspan="2">
<item row="2" column="16">
<widget class="QLineEdit" name="le_isf">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="14">
<item row="2" column="17">
<widget class="QLabel" name="label_28">
<property name="text">
<string>额定频率</string>
@ -206,14 +199,14 @@
</property>
</widget>
</item>
<item row="2" column="15">
<item row="2" column="18">
<widget class="QLineEdit" name="le_rf_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="16">
<item row="2" column="19">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Hz</string>
@ -258,7 +251,7 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="4">
<item row="5" column="1" colspan="2">
<widget class="QLineEdit" name="le_tr_ct">
<property name="readOnly">
<bool>false</bool>
@ -266,6 +259,30 @@
</widget>
</item>
<item row="5" column="5" colspan="2">
<widget class="QLineEdit" name="le_trMin_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="7">
<widget class="QLabel" name="label_36">
<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="8" colspan="2">
<widget class="QLineEdit" name="le_trMax_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="10" colspan="3">
<widget class="QLabel" name="label_34">
<property name="text">
<string>精度等级</string>
@ -275,28 +292,28 @@
</property>
</widget>
</item>
<item row="5" column="7" colspan="4">
<item row="5" column="13" colspan="3">
<widget class="QLineEdit" name="le_ac_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="11">
<item row="5" column="16">
<widget class="QLabel" name="label_33">
<property name="text">
<string>二次负载容量</string>
</property>
</widget>
</item>
<item row="5" column="12" colspan="3">
<item row="5" column="17" colspan="2">
<widget class="QLineEdit" name="le_slc_ct">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="16">
<item row="5" column="19">
<widget class="QPushButton" name="btn_add_ct">
<property name="minimumSize">
<size>
@ -315,13 +332,13 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="17">
<item row="6" column="0" colspan="20">
<widget class="QTableWidget" name="tb_ct">
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>180</number>
<number>100</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
@ -331,6 +348,16 @@
<string>变比</string>
</property>
</column>
<column>
<property name="text">
<string>最小变比</string>
</property>
</column>
<column>
<property name="text">
<string>最大变比</string>
</property>
</column>
<column>
<property name="text">
<string>精度等级</string>
@ -348,6 +375,23 @@
</column>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="label_18">
<property name="text">
<string>A</string>
</property>
</widget>
</item>
<item row="5" column="3" colspan="2">
<widget class="QLabel" name="label_35">
<property name="text">
<string>最小变比</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

File diff suppressed because it is too large Load Diff

View File

@ -31,10 +31,13 @@
<property name="bottomMargin">
<number>10</number>
</property>
<property name="spacing">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>10</number>
</property>
<item row="0" column="0" colspan="14">
<item row="0" column="0" colspan="22">
<widget class="QLabel" name="label_title_pt">
<property name="minimumSize">
<size>
@ -66,21 +69,21 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="3">
<item row="1" column="2" colspan="5">
<widget class="QLineEdit" name="le_ratedVol">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="7">
<widget class="QLabel" name="label_2">
<property name="text">
<string>V</string>
</property>
</widget>
</item>
<item row="1" column="6">
<item row="1" column="8" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>工频耐压</string>
@ -90,21 +93,21 @@
</property>
</widget>
</item>
<item row="1" column="7" colspan="2">
<item row="1" column="12" colspan="2">
<widget class="QLineEdit" name="le_pfwv_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="9">
<item row="1" column="14" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>V/1min</string>
</property>
</widget>
</item>
<item row="1" column="10">
<item row="1" column="16" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>冲击耐压</string>
@ -114,14 +117,14 @@
</property>
</widget>
</item>
<item row="1" column="11" colspan="2">
<item row="1" column="18" colspan="3">
<widget class="QLineEdit" name="le_iwv_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="13">
<item row="1" column="21">
<widget class="QLabel" name="label_6">
<property name="text">
<string>V</string>
@ -138,14 +141,14 @@
</property>
</widget>
</item>
<item row="2" column="2" colspan="3">
<item row="2" column="2" colspan="5">
<widget class="QLineEdit" name="le_ratedVolFactor">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="6">
<item row="2" column="8" colspan="4">
<widget class="QLabel" name="label_8">
<property name="text">
<string>一次绕组接线接地方式</string>
@ -155,14 +158,14 @@
</property>
</widget>
</item>
<item row="2" column="7" colspan="3">
<item row="2" column="12" colspan="2">
<widget class="QLineEdit" name="le_pwwgm">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="10">
<item row="2" column="16" colspan="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>额定频率</string>
@ -172,14 +175,14 @@
</property>
</widget>
</item>
<item row="2" column="11" colspan="2">
<item row="2" column="18" colspan="3">
<widget class="QLineEdit" name="le_rf_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="13">
<item row="2" column="21">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Hz</string>
@ -193,21 +196,21 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<item row="3" column="1" colspan="3">
<widget class="QRadioButton" name="rb_tpt_pt">
<property name="text">
<string>三相互感器</string>
</property>
</widget>
</item>
<item row="3" column="3" colspan="2">
<item row="3" column="4" colspan="3">
<widget class="QRadioButton" name="rb_spt_pt">
<property name="text">
<string>单相互感器</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<item row="4" column="0" colspan="6">
<widget class="QLabel" name="label_12">
<property name="text">
<string>本元件内含PT二次绕组的配置:</string>
@ -221,49 +224,77 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<item row="5" column="1" colspan="2">
<widget class="QLineEdit" name="le_tr_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="4" colspan="2">
<widget class="QLabel" name="label_14">
<item row="5" column="3" colspan="2">
<widget class="QLabel" name="label_17">
<property name="text">
<string>精度等级</string>
<string>最小变比</string>
</property>
</widget>
</item>
<item row="5" column="6">
<widget class="QLineEdit" name="le_ac_pt">
<item row="5" column="5">
<widget class="QLineEdit" name="le_trMin_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="7">
<widget class="QLabel" name="label_15">
<item row="5" column="6" colspan="3">
<widget class="QLabel" name="label_18">
<property name="text">
<string>二次负载容量</string>
<string>最大变比</string>
</property>
</widget>
</item>
<item row="5" column="8" colspan="2">
<widget class="QLineEdit" name="le_slc_pt">
<item row="5" column="9">
<widget class="QLineEdit" name="le_trMax_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="10">
<widget class="QLabel" name="label_14">
<property name="text">
<string>精度等级</string>
</property>
</widget>
</item>
<item row="5" column="11" colspan="2">
<widget class="QLineEdit" name="le_ac_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="13" colspan="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>二次负载容量</string>
</property>
</widget>
</item>
<item row="5" column="15" colspan="2">
<widget class="QLineEdit" name="le_slc_pt">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="17" colspan="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>绕组接法</string>
</property>
</widget>
</item>
<item row="5" column="11">
<item row="5" column="19">
<widget class="QComboBox" name="cb_wcm">
<property name="currentText">
<string>Y</string>
@ -280,7 +311,7 @@
</item>
</widget>
</item>
<item row="5" column="12" colspan="2">
<item row="5" column="20" colspan="2">
<widget class="QPushButton" name="btn_add_pt">
<property name="minimumSize">
<size>
@ -299,7 +330,7 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="14">
<item row="6" column="0" colspan="22">
<widget class="QTableWidget" name="tb_pt">
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
@ -315,6 +346,16 @@
<string>变比</string>
</property>
</column>
<column>
<property name="text">
<string>最小变比</string>
</property>
</column>
<column>
<property name="text">
<string>最大变比</string>
</property>
</column>
<column>
<property name="text">
<string>精度等级</string>

View File

@ -68,8 +68,8 @@ public:
bool ifBayExist(QUuid uuid);
bool deleteBay(QUuid uuid);
/*********************************************************************************/
bool insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,int size,QUuid bayId,QUuid componentId);
bool updateMeasurement(QString name,int type,QJsonObject dataSource,int size,QUuid componentId);
bool insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,QJsonObject eventPlan,int size,QUuid bayId,QUuid componentId);
bool updateMeasurement(QString name,int type,QJsonObject dataSource,QJsonObject eventPlan,int size,QUuid componentId);
bool delteMeasurement(QString name,QUuid componentId);
bool ifMeasureExist(QString name,QUuid componentId);
QList<MeasurementInfo> getMeasurement(QUuid componentId);

View File

@ -23,7 +23,7 @@ public:
QList<QStandardItem*> getGroupSub(QStandardItemModel*,const QString&); //返回指定组下的属性(如果存在)
MapMeta& getData() {return m_mapTotalData;}
void deleteData(const QString& meta,const QString& proj);
void updateSetting(const QString& sMeta,const QString& sPro); //更新模型数据(图片
void updateSetting(const QString& sMeta,const QString& sPro,bool toHex = false); //更新模型数据(图片 toHex转换数据为16进制
QStringList getProjectModelLst(const QString& sMeta);
public:
QStringList getModelList() const; //获取元模型列表
@ -45,6 +45,11 @@ private:
QJsonObject getSelectedState(QList<QStandardItem*> select,QList<QStandardItem*> base); //返回json格式的选中状态
QString getItemDataType(const QStandardItem* pItem); //返回数据类型
projectModelSetting getModelSetting(const QString& sMeta,const QString& sProject); //获取指定工程模的设定
QByteArray cleanHexData(const QByteArray& hexData);
QByteArray fixHexLength(const QByteArray& hexData);
QByteArray extractHexOnly(const QByteArray& data);
QByteArray safeFromHex(const QByteArray& hexData);
private:
MapMeta m_mapTotalData;
bool _bInitialised;

View File

@ -9,6 +9,7 @@
#include <QSqlError>
#include <QSqlDriver>
#include <QJsonDocument>
#include <QJsonArray>
DataBase* DataBase::dbInstance = nullptr;
int DataBase::_id = 0;
@ -307,6 +308,13 @@ bool DataBase::insertDynamicProperty(QUuid uuid,groupStateValue groupValue)
{
strPros += QString(",")+pro.name;
strPronouns += QString(",?");
if(pro.defaultValue.userType() == qMetaTypeId<QJsonObject>()) //json特殊处理
{
QJsonDocument contextDoc(pro.defaultValue.toJsonObject());
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
params.append(strCon);
}
else
params.append(pro.defaultValue);
}
QString strSQL = QString("INSERT INTO %1(global_uuid, attribute_group%2) VALUES (?, ?%3)").arg(groupValue.tableName,strPros,strPronouns);
@ -331,6 +339,13 @@ bool DataBase::updateDynamicProperty(QUuid uuid,groupStateValue groupValue)
for(auto &pro:groupValue.mapInfo[uuid])
{
setClauses.append(QString("%1 = ?").arg(pro.name));
if(pro.defaultValue.userType() == qMetaTypeId<QJsonObject>()) //json特殊处理
{
QJsonDocument contextDoc(pro.defaultValue.toJsonObject());
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
params.append(strCon);
}
else
params.append(pro.defaultValue);
}
params.append(uuid);
@ -1369,17 +1384,21 @@ bool DataBase::deleteBay(QUuid uuid)
}
/*****************************************************************************/
bool DataBase::insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,int size,QUuid bayId,QUuid componentId)
bool DataBase::insertMeasurement(QString name,QString tag,int type,QJsonObject dataSource,QJsonObject eventPlan,int size,QUuid bayId,QUuid componentId)
{
QString strSQL = "INSERT INTO measurement(tag, name, type, data_source, size, bay_uuid, component_uuid) VALUES (?, ?, ?, ?, ?, ?, ?)";
QString strSQL = "INSERT INTO measurement(tag, name, type, data_source, event_plan, size, bay_uuid, component_uuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
QJsonDocument dataDoc(dataSource);
QString strData = dataDoc.toJson(QJsonDocument::Compact);
QJsonDocument eventDoc(eventPlan);
QString strEvent = eventDoc.toJson(QJsonDocument::Compact);
QVariantList params;
params.append(tag);
params.append(name);
params.append(type);
params.append(strData);
params.append(strEvent);
params.append(size);
params.append(bayId);
params.append(componentId);
@ -1396,15 +1415,19 @@ bool DataBase::insertMeasurement(QString name,QString tag,int type,QJsonObject d
}
}
bool DataBase::updateMeasurement(QString name,int type,QJsonObject dataSource,int size,QUuid componentId)
bool DataBase::updateMeasurement(QString name,int type,QJsonObject dataSource,QJsonObject eventPlan,int size,QUuid componentId)
{
QJsonDocument dataDoc(dataSource);
QString strData = dataDoc.toJson(QJsonDocument::Compact);
QString strSQL = "UPDATE measurement SET type = ?,data_source = ?,size = ? WHERE name = ? AND component_uuid = ?";
QJsonDocument eventDoc(eventPlan);
QString strEvent = eventDoc.toJson(QJsonDocument::Compact);
QString strSQL = "UPDATE measurement SET type = ?,data_source = ?,event_plan = ?,size = ? WHERE name = ? AND component_uuid = ?";
QVariantList params;
params.append(type);
params.append(strData);
params.append(strEvent);
params.append(size);
params.append(name);
params.append(componentId);
@ -1466,7 +1489,7 @@ bool DataBase::ifMeasureExist(QString name,QUuid componentId)
QList<MeasurementInfo> DataBase::getMeasurement(QUuid componentId)
{
QList<MeasurementInfo> lst;
QString strSQL = "SELECT tag, name, type, data_source, size, bay_uuid, component_uuid FROM measurement WHERE component_uuid = ?";
QString strSQL = "SELECT tag, name, type, data_source, event_plan, size, bay_uuid, component_uuid FROM measurement WHERE component_uuid = ?";
QVariantList params;
params.append(componentId);
@ -1478,14 +1501,49 @@ QList<MeasurementInfo> DataBase::getMeasurement(QUuid componentId)
MeasurementInfo info;
info.tag = query.value(0).toString();
info.name = query.value(1).toString();
info.type = query.value(2).toString();
QString con = query.value(3).toString();
QJsonObject obj = QstringToJson(con);
info.equipment = obj["type"].toString();
info.channel = obj["main_pos"].toString();
info.size = query.value(4).toInt();
info.bayUuid = QUuid(query.value(5).toString());
info.componentUuid = QUuid(query.value(6).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);
info.size = query.value(5).toInt();
info.bayUuid = QUuid(query.value(6).toString());
info.componentUuid = QUuid(query.value(7).toString());
info.nSource = objData["type"].toInt();
QJsonObject objIoAddress = objData["io_address"].toObject();
info.sStation = objData["station"].toString();
info.equipment = objIoAddress["device"].toString();
info.channel = objIoAddress["channel"].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());
}
lst.append(info);
}
query.clear();
@ -2352,6 +2410,10 @@ QMap<QUuid,PropertyValueInfo> DataBase::selectGroupPropertyByState(const QString
pro.name = proVal.name;
pro.type = proVal.type;
pro.isVisibe = proVal.isVisibe;
/*if(proVal.type == "JSONB"){ //json单独处理
pro.defaultValue = query.value(proVal.name).toJsonObject();
}
else*/
pro.defaultValue = query.value(proVal.name );
info.insert(proVal.name ,pro);
}
@ -2403,7 +2465,7 @@ PropertyValueInfo DataBase::selectGroupPropertyByValue(const QString& tableName,
}
}
QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QList<measureAttributeType> DataBase::getMeasureAttributeTypes() //暂时调换获取的name与tag
{
QList<measureAttributeType> lst;
QString strSQL = "SELECT attribute,attribute_name FROM basic.attribute WHERE is_visible = ?";
@ -2442,8 +2504,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tn2 = name;
QString tt2 = tag;
measureAttributeType measure;
measure.name = tn2.replace("sn",sn);
measure.tag = tt2.replace("sn",sn);
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
@ -2464,8 +2526,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tn2 = name;
QString tt2 = tag;
measureAttributeType measure;
measure.name = tn2.replace("sn",sn);
measure.tag = tt2.replace("sn",sn);
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
@ -2484,8 +2546,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tn2 = name;
QString tt2 = tag;
measureAttributeType measure;
measure.name = tn2.replace("sn",sn);
measure.tag = tt2.replace("sn",sn);
measure.tag = tn2.replace("sn",sn);
measure.name = tt2.replace("sn",sn);
lst.append(measure);
}
}
@ -2503,8 +2565,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tag = attTag;
measureAttributeType measure;
measure.name = name.replace("_$",i);
measure.tag = tag.replace("_$",i);
measure.tag = name.replace("_$",i);
measure.name = tag.replace("_$",i);
lst.append(measure);
}
}
@ -2518,8 +2580,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tag = attTag;
measureAttributeType measure;
measure.name = name.replace("_$",u);
measure.tag = tag.replace("_$",u);
measure.tag = name.replace("_$",u);
measure.name = tag.replace("_$",u);
lst.append(measure);
}
}
@ -2534,8 +2596,8 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tag = attTag;
measureAttributeType measure;
measure.name = name.replace("$",dor);
measure.tag = tag.replace("$",dor);
measure.tag = name.replace("$",dor);
measure.name = tag.replace("$",dor);
lst.append(measure);
}
}
@ -2551,15 +2613,15 @@ QList<measureAttributeType> DataBase::getMeasureAttributeTypes()
QString tag = attTag;
measureAttributeType measure;
measure.name = name.replace("sn",sn);
measure.tag = tag.replace("sn",sn);
measure.tag = name.replace("sn",sn);
measure.name = tag.replace("sn",sn);
lst.append(measure);
}
}
else{ //没有分支
measureAttributeType measure;
measure.name = attName;
measure.tag = attTag;
measure.tag = attName;
measure.name = attTag;
lst.append(measure);
}
}

View File

@ -266,7 +266,7 @@ void ProjectModelManager::deleteData(const QString& sMeta,const QString& sProjec
m_mapTotalData[sMeta].remove(sProject);
}
void ProjectModelManager::updateSetting(const QString& sMeta,const QString& sProject)
void ProjectModelManager::updateSetting(const QString& sMeta,const QString& sProject,bool toHex)
{
QJsonObject object;
QJsonArray arr;
@ -278,7 +278,14 @@ void ProjectModelManager::updateSetting(const QString& sMeta,const QString& sPro
{
QJsonObject obj;
obj["name"] = iter.key();
obj["data"] = QString::fromUtf8(iter.value());
QString sData;
if(toHex){
QByteArray svgString = QString(iter.value()).toUtf8().toHex();
sData = QString::fromUtf8(svgString);
}
else
sData = QString::fromUtf8(iter.value());
obj["data"] = sData;
arr.push_back(obj);
}
object["picture"] = arr;
@ -287,7 +294,14 @@ void ProjectModelManager::updateSetting(const QString& sMeta,const QString& sPro
{
QJsonObject obj;
obj["name"] = iter.key();
obj["data"] = QString::fromUtf8(iter.value());
QString sData;
if(toHex){
QByteArray svgString = QString(iter.value()).toUtf8().toHex();
sData = QString::fromUtf8(svgString);
}
else
sData = QString::fromUtf8(iter.value());
obj["data"] = sData;
arrUsed.push_back(obj);
}
object["usingPicture"] = arrUsed;
@ -831,7 +845,7 @@ projectModelSetting ProjectModelManager::getModelSetting(const QString& sMeta,co
{
QJsonObject node = jsonObj.toObject();
QString sName = node["name"].toString();
QByteArray bData = QByteArray::fromHex(node["data"].toString().toUtf8());
QByteArray bData = safeFromHex(node["data"].toString().toUtf8());
setting.mapSvg.insert(sName,bData);
}
@ -840,8 +854,59 @@ projectModelSetting ProjectModelManager::getModelSetting(const QString& sMeta,co
{
QJsonObject node = jsonObj.toObject();
QString sName = node["name"].toString();
QByteArray bData = QByteArray::fromHex(node["data"].toString().toUtf8());
QByteArray bData = safeFromHex(node["data"].toString().toUtf8());
setting.mapUsedSvg.insert(sName,bData);
}
return setting;
}
QByteArray ProjectModelManager::cleanHexData(const QByteArray& hexData) {
QByteArray cleaned = hexData;
// 移除空格、换行等空白字符
cleaned.replace(" ", "");
cleaned.replace("\n", "");
cleaned.replace("\t", "");
cleaned.replace("\r", "");
return cleaned;
}
// 问题2: 数据长度不是偶数
QByteArray ProjectModelManager::fixHexLength(const QByteArray& hexData) {
if (hexData.length() % 2 != 0) {
// 如果是奇数长度在末尾补0
return hexData + "0";
}
return hexData;
}
// 问题3: 包含非十六进制字符
QByteArray ProjectModelManager::extractHexOnly(const QByteArray& data) {
QByteArray result;
for (char c : data) {
if ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F')) {
result.append(c);
}
}
return result;
}
QByteArray ProjectModelManager::safeFromHex(const QByteArray& hexData) {
// 步骤1: 清理数据
QByteArray cleaned = cleanHexData(hexData);
// 步骤2: 检查并修复长度
cleaned = fixHexLength(cleaned);
// 步骤3: 提取纯十六进制字符(如果需要)
if (cleaned != extractHexOnly(cleaned)) {
cleaned = extractHexOnly(cleaned);
cleaned = fixHexLength(cleaned);
}
// 步骤4: 尝试转换
QByteArray result = QByteArray::fromHex(cleaned);
return result;
}

View File

@ -155,12 +155,12 @@ void CMainWindow::initializeAction()
QAction* actRun = ui->menuMode->addAction(QString::fromWCharArray(L"运行"));
connect(actRun,&QAction::triggered,m_pDiagramCavas,&DiagramCavas::onSignal_runPage);
QAction* actEditBay = ui->menuProject->addAction(QString::fromWCharArray(L"管理间隔"));
connect(actEditBay,&QAction::triggered,this,&CMainWindow::onAction_editBay);
QAction* actEdit = ui->menuProject->addAction(QString::fromWCharArray(L"编辑工程模"));
connect(actEdit,&QAction::triggered,this,&CMainWindow::onAction_editProject);
QAction* actEditBay = ui->menuBay->addAction(QString::fromWCharArray(L"管理间隔"));
connect(actEditBay,&QAction::triggered,this,&CMainWindow::onAction_editBay);
QAction* testAct = ui->menuTest->addAction(QString::fromWCharArray(L"生成测试基模"));
connect(testAct,&QAction::triggered,m_pDiagramCavas,&DiagramCavas::onCreateTestBaseModelDiagram);
}

View File

@ -59,9 +59,9 @@ void TopologyView::initial()
QString sZone = nZ;
QString sStation = nS;
if(info.tag.isEmpty())
if(info.name.isEmpty())
continue;
QStandardItem *pItem = new QStandardItem(info.tag);
QStandardItem *pItem = new QStandardItem(info.name);
pItem->setData(info.uuid.toString(),Qt::UserRole);
addItemToView(sGrid,sZone,sStation,rootItem,pItem);
}

View File

@ -43,11 +43,6 @@
<string>工程模</string>
</property>
</widget>
<widget class="QMenu" name="menuBay">
<property name="title">
<string>间隔管理</string>
</property>
</widget>
<widget class="QMenu" name="menuTest">
<property name="title">
<string>测试</string>
@ -57,7 +52,6 @@
<addaction name="menuView"/>
<addaction name="menuMode"/>
<addaction name="menuProject"/>
<addaction name="menuBay"/>
<addaction name="menuTest"/>
</widget>
<widget class="QToolBar" name="toolBar">