2025-05-23 10:30:52 +08:00
|
|
|
|
#include "ptExtraInfoDlg.h"
|
|
|
|
|
|
#include "ui_ptExtraInfoDlg.h"
|
|
|
|
|
|
#include "baseProperty.h"
|
|
|
|
|
|
#include "basePropertyManager.h"
|
|
|
|
|
|
#include <QButtonGroup>
|
|
|
|
|
|
#include <QJsonArray>
|
2025-11-05 18:14:31 +08:00
|
|
|
|
#include <QJsonDocument>
|
2025-05-23 10:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
PtExtraInfoDlg::PtExtraInfoDlg(QWidget *parent)
|
|
|
|
|
|
: BaseContentDlg(parent)
|
|
|
|
|
|
, ui(new Ui::ptExtraInfoDlg)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
_stateGroup_pt = new QButtonGroup(this);
|
|
|
|
|
|
_stateGroup_pt->addButton(ui->rb_tpt_pt,1);
|
|
|
|
|
|
_stateGroup_pt->addButton(ui->rb_spt_pt,0);
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->btn_add_pt,&QPushButton::clicked,this,&PtExtraInfoDlg::onAddClicked);
|
|
|
|
|
|
_count = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PtExtraInfoDlg::~PtExtraInfoDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PtExtraInfoDlg::createGroupView(groupStateInfo infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& info:infos.info) {
|
|
|
|
|
|
propertyContentInfo inf;
|
|
|
|
|
|
inf.proName = info.name;
|
|
|
|
|
|
inf.proType = info.type;
|
|
|
|
|
|
_mapPro.insert(info.name,inf);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMap<QString,propertyStateInfo> PtExtraInfoDlg::getPropertyValue(BaseProperty* pPro)
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,propertyStateInfo> map;
|
|
|
|
|
|
|
|
|
|
|
|
for(auto &pro:_mapPro)
|
|
|
|
|
|
{
|
|
|
|
|
|
propertyStateInfo info;
|
|
|
|
|
|
info.type = pro.proType;
|
|
|
|
|
|
info.name = pro.proName;
|
2025-10-11 18:51:33 +08:00
|
|
|
|
if(info.name == "额定电压(V)" || info.name == "un_v") //此处应为类型名
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_ratedVol->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_pfwv_pt->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_iwv_pt->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "额定电压因数" || info.name == "rvf")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_ratedVolFactor->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "一次绕组接线接地方式" || info.name == "pwcc")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_pwwgm->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
info.defaultValue = ui->le_rf_pt->text();
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "相数" || info.name == "phase_num")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(ui->rb_tpt_pt->isChecked())
|
|
|
|
|
|
info.defaultValue = 1;
|
|
|
|
|
|
else
|
|
|
|
|
|
info.defaultValue = 0;
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.name == "PT二次绕组" || info.name == "pt_sec_winding")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
QJsonObject object;
|
|
|
|
|
|
QJsonArray arr;
|
|
|
|
|
|
for(auto info:_mapPT)
|
|
|
|
|
|
{
|
|
|
|
|
|
QJsonObject obj;
|
|
|
|
|
|
obj["id"] = info.id;
|
|
|
|
|
|
obj["transformationRatio"] = info.transRatio;
|
2025-11-05 18:14:31 +08:00
|
|
|
|
obj["minTransformationRatio"] = info.minTransRatio;
|
|
|
|
|
|
obj["maxTransformationRatio"] = info.maxTransRatio;
|
2025-05-23 10:30:52 +08:00
|
|
|
|
obj["accuracyClass"] = info.accuracyClass;
|
|
|
|
|
|
obj["secondaryLoadCapacity"] = info.secondaryLoadCapacity;
|
|
|
|
|
|
obj["windingConnectionMethod"] = info.windingConnectionMethod;
|
|
|
|
|
|
arr.push_back(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
object["winding"] = arr;
|
|
|
|
|
|
info.defaultValue = object;
|
|
|
|
|
|
}
|
|
|
|
|
|
map.insert(pro.proName,info);
|
|
|
|
|
|
}
|
2025-07-22 20:00:46 +08:00
|
|
|
|
pPro->setDataChanged(true);
|
2025-05-23 10:30:52 +08:00
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PtExtraInfoDlg::setPropertyValue(QVariant var)
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<QString,propertyStateInfo> map = var.value<QMap<QString,propertyStateInfo>>();
|
|
|
|
|
|
for(auto &info:map)
|
|
|
|
|
|
{
|
2025-11-05 18:14:31 +08:00
|
|
|
|
if(info.name == "额定电压(V)" || info.name == "un_v") //此处应为类型名
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_ratedVol->setText(QString::number(info.defaultValue.toDouble()));
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_pfwv_pt->setText(QString::number(info.defaultValue.toDouble()));
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_iwv_pt->setText(QString::number(info.defaultValue.toDouble()));
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "额定电压因数" || info.name == "rvf")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_ratedVolFactor->setText(QString::number(info.defaultValue.toDouble()));
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "一次绕组接线接地方式" || info.name == "pwcc")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_pwwgm->setText(info.defaultValue.toString());
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->le_rf_pt->setText(QString::number(info.defaultValue.toDouble()));
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "相数" || info.name == "phase_num")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(info.defaultValue.toInt() == 1)
|
|
|
|
|
|
ui->rb_tpt_pt->setChecked(true);
|
|
|
|
|
|
else
|
|
|
|
|
|
ui->rb_spt_pt->setChecked(true);
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
else if(info.name == "PT二次绕组" || info.name == "pt_sec_winding")
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QString jsonString = info.defaultValue.toString();
|
|
|
|
|
|
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
|
|
|
|
|
|
QJsonObject jsonObject = jsonDocument.object();
|
|
|
|
|
|
|
|
|
|
|
|
QJsonObject object = jsonObject;
|
|
|
|
|
|
|
2025-05-23 10:30:52 +08:00
|
|
|
|
QJsonArray arr = object["winding"].toArray();
|
|
|
|
|
|
for (QJsonValueRef jsonObj : arr)
|
|
|
|
|
|
{
|
|
|
|
|
|
QJsonObject node = jsonObj.toObject();
|
|
|
|
|
|
int id = node["id"].toInt();
|
|
|
|
|
|
QString sTr = node["transformationRatio"].toString();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QString sMinTr = node["minTransformationRatio"].toString();
|
|
|
|
|
|
QString sMaxTr = node["maxTransformationRatio"].toString();
|
2025-05-23 10:30:52 +08:00
|
|
|
|
QString sAr = node["accuracyClass"].toString();
|
|
|
|
|
|
QString sSlc = node["secondaryLoadCapacity"].toString();
|
|
|
|
|
|
QString sWin = node["windingConnectionMethod"].toString();
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc,sWin,id);
|
2025-05-23 10:30:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PtExtraInfoDlg::onAddClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
QString sTr = ui->le_tr_pt->text();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QString sMinTr = ui->le_trMin_pt->text();
|
|
|
|
|
|
QString sMaxTr = ui->le_trMax_pt->text();
|
2025-05-23 10:30:52 +08:00
|
|
|
|
QString sAr = ui->le_ac_pt->text();
|
|
|
|
|
|
QString sSlc = ui->le_slc_pt->text();
|
|
|
|
|
|
QString sWinding = ui->cb_wcm->currentText();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
addTableRow(sTr,sMinTr,sMaxTr,sAr,sSlc,sWinding);
|
2025-05-23 10:30:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PtExtraInfoDlg::onDeleteClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
QPushButton *btn = qobject_cast<QPushButton*>(sender());
|
|
|
|
|
|
if (btn) {
|
|
|
|
|
|
// 获取按钮在表格中的位置
|
|
|
|
|
|
QModelIndex index = ui->tb_pt->indexAt(btn->pos());
|
|
|
|
|
|
if (index.isValid()) {
|
|
|
|
|
|
QTableWidgetItem* pFirstItem = ui->tb_pt->item(index.row(),0);
|
|
|
|
|
|
int id = pFirstItem->data(Qt::UserRole).toInt();
|
|
|
|
|
|
_mapPT.remove(QString::number(id));
|
|
|
|
|
|
ui->tb_pt->removeRow(index.row());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
void PtExtraInfoDlg::addTableRow(QString sTr,QString sTrMin,QString sTrMax,QString sAr,QString sSlc,QString sWinding,int id)
|
2025-05-23 10:30:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(_mapPT.contains(QString::number(id)))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PtExtraInfo info;
|
|
|
|
|
|
if(id == -1){ //缺省id时新建,否则加载
|
|
|
|
|
|
info.id = _count;
|
|
|
|
|
|
_count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
info.id = id;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int row = ui->tb_pt->rowCount();
|
|
|
|
|
|
ui->tb_pt->insertRow(row);
|
|
|
|
|
|
|
|
|
|
|
|
// 变比(输入框)
|
|
|
|
|
|
QTableWidgetItem *item = new QTableWidgetItem(sTr);
|
|
|
|
|
|
item->setData(Qt::UserRole,info.id);
|
|
|
|
|
|
ui->tb_pt->setItem(row, 0, item);
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
//最小变比
|
|
|
|
|
|
ui->tb_pt->setItem(row, 1, new QTableWidgetItem(sTrMin));
|
|
|
|
|
|
|
|
|
|
|
|
//最大变比
|
|
|
|
|
|
ui->tb_pt->setItem(row, 2, new QTableWidgetItem(sTrMax));
|
|
|
|
|
|
|
2025-05-23 10:30:52 +08:00
|
|
|
|
// 精度等级(下拉框)
|
2025-11-05 18:14:31 +08:00
|
|
|
|
ui->tb_pt->setItem(row, 3, new QTableWidgetItem(sAr));
|
2025-05-23 10:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 二次负载容量(输入框)
|
2025-11-05 18:14:31 +08:00
|
|
|
|
ui->tb_pt->setItem(row, 4, new QTableWidgetItem(sSlc));
|
2025-05-23 10:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 绕组接法(下拉框)
|
2025-11-05 18:14:31 +08:00
|
|
|
|
ui->tb_pt->setItem(row, 5, new QTableWidgetItem(sWinding));
|
2025-05-23 10:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 删除按钮
|
|
|
|
|
|
QPushButton *deleteBtn = new QPushButton("删除");
|
|
|
|
|
|
connect(deleteBtn, &QPushButton::clicked, this, &PtExtraInfoDlg::onDeleteClicked);
|
2025-11-05 18:14:31 +08:00
|
|
|
|
ui->tb_pt->setCellWidget(row, 6, deleteBtn);
|
2025-05-23 10:30:52 +08:00
|
|
|
|
|
|
|
|
|
|
info.transRatio = sTr;
|
2025-11-05 18:14:31 +08:00
|
|
|
|
info.minTransRatio = sTrMin;
|
|
|
|
|
|
info.maxTransRatio = sTrMax;
|
2025-05-23 10:30:52 +08:00
|
|
|
|
info.accuracyClass = sAr;
|
|
|
|
|
|
info.secondaryLoadCapacity = sSlc;
|
|
|
|
|
|
info.windingConnectionMethod = sWinding;
|
|
|
|
|
|
_mapPT.insert(QString::number(info.id),info);
|
|
|
|
|
|
}
|