2025-07-04 18:47:49 +08:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
#include "measureSettingDlg.h"
|
|
|
|
|
|
#include "bayInfoDlg.h"
|
|
|
|
|
|
#include "graphicsDataModel/fixedPortsModel.h"
|
|
|
|
|
|
#include "graphicsItem/graphicsBaseItem.h"
|
|
|
|
|
|
#include "baseProperty.h"
|
|
|
|
|
|
#include "ui_measureSettingDlg.h"
|
|
|
|
|
|
|
|
|
|
|
|
MeasureSettingDlg::MeasureSettingDlg(QWidget *parent)
|
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
|
, ui(new Ui::measureSettingDlg)
|
|
|
|
|
|
,_pBay(nullptr)
|
2025-11-05 18:14:31 +08:00
|
|
|
|
,_pEventStrategy(nullptr)
|
|
|
|
|
|
,_pEventYXGroup(nullptr)
|
|
|
|
|
|
,_curMode(0)
|
2025-07-04 18:47:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
2025-11-05 18:14:31 +08:00
|
|
|
|
setStyleSheet("background-color: white;");
|
2025-07-04 18:47:49 +08:00
|
|
|
|
initial();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MeasureSettingDlg::~MeasureSettingDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::initial()
|
|
|
|
|
|
{
|
2025-11-05 18:14:31 +08:00
|
|
|
|
_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);
|
|
|
|
|
|
|
2025-07-04 18:47:49 +08:00
|
|
|
|
connect(ui->btn_ok,&QPushButton::clicked,this,&MeasureSettingDlg::onOkClicked);
|
|
|
|
|
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&MeasureSettingDlg::onCancelClicked);
|
2025-11-05 18:14:31 +08:00
|
|
|
|
connect(ui->btn_addPara,&QPushButton::clicked,this,&MeasureSettingDlg::onAddParaClicked);
|
|
|
|
|
|
connect(ui->btn_delPara,&QPushButton::clicked,this,&MeasureSettingDlg::onDelParaClicked);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
connect(ui->cb_tag,&QComboBox::textActivated,this,&MeasureSettingDlg::onTagChanged);
|
|
|
|
|
|
connect(ui->cb_name,&QComboBox::textActivated,this,&MeasureSettingDlg::onNameChanged);
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
connect(ui->cb_rule,&QComboBox::currentIndexChanged, this,&MeasureSettingDlg::onRuleIndexChanged);
|
|
|
|
|
|
connect(ui->cb_type,&QComboBox::currentIndexChanged, this,&MeasureSettingDlg::onTypeIndexChanged);
|
|
|
|
|
|
|
2025-07-04 18:47:49 +08:00
|
|
|
|
// 设置正则验证器: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);
|
2025-11-05 18:14:31 +08:00
|
|
|
|
|
|
|
|
|
|
ui->cb_rule->setItemData(0, 1);
|
|
|
|
|
|
ui->cb_rule->setItemData(1, 2);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::showDlg()
|
|
|
|
|
|
{
|
2025-11-05 18:14:31 +08:00
|
|
|
|
_curMode = 0;
|
|
|
|
|
|
//ui->cb_tag->setEditable(true);
|
|
|
|
|
|
//ui->cb_name->setEditable(true);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
clearData();
|
|
|
|
|
|
QStringList lstTag;
|
|
|
|
|
|
QStringList lstName;
|
|
|
|
|
|
show();
|
|
|
|
|
|
if(_pBay){
|
2025-11-05 18:14:31 +08:00
|
|
|
|
QString curItemName; //当前元件名称
|
|
|
|
|
|
if(_pBay){
|
|
|
|
|
|
auto pItemData = _pBay->getProperty();
|
|
|
|
|
|
curItemName = pItemData->name();
|
|
|
|
|
|
}
|
2025-07-04 18:47:49 +08:00
|
|
|
|
auto lst = _pBay->getValidType();
|
|
|
|
|
|
for(auto& item:lst){
|
2025-11-05 18:14:31 +08:00
|
|
|
|
item.tag = item.tag+"_"+curItemName;
|
|
|
|
|
|
item.name = item.name+"_"+curItemName;
|
2025-07-04 18:47:49 +08:00
|
|
|
|
lstTag.append(item.tag);
|
|
|
|
|
|
lstName.append(item.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui->cb_tag->addItems(lstTag);
|
|
|
|
|
|
ui->cb_name->addItems(lstName);
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
/*QStringList lstDevice;
|
2025-07-04 18:47:49 +08:00
|
|
|
|
if(_pBay){
|
|
|
|
|
|
FixedPortsModel* pModel = _pBay->getModelController();
|
|
|
|
|
|
if(pModel){
|
|
|
|
|
|
auto map = pModel->allItems();
|
|
|
|
|
|
for(auto& pItem:map){
|
|
|
|
|
|
auto pPro = pItem->getProperty();
|
|
|
|
|
|
if(pPro){
|
|
|
|
|
|
lstDevice.append(pPro->tag()); //根据本图的图元获取对应设备名
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
ui->cb_equip->clear();
|
|
|
|
|
|
ui->cb_equip->addItem(curItemName);
|
2025-07-18 18:26:13 +08:00
|
|
|
|
BaseProperty* pro = _pBay->getProperty();
|
|
|
|
|
|
if(pro){
|
|
|
|
|
|
ui->cb_equip->setCurrentText(pro->tag());
|
2025-11-05 18:14:31 +08:00
|
|
|
|
ui->le_s1->setText(pro->station());
|
|
|
|
|
|
ui->le_s2->setText(pro->station());
|
2025-07-18 18:26:13 +08:00
|
|
|
|
}
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-05 18:14:31 +08:00
|
|
|
|
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 ¶:info.lstParameter){
|
|
|
|
|
|
ui->lst_parameter->addItem(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-04 18:47:49 +08:00
|
|
|
|
void MeasureSettingDlg::clearData()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->cb_tag->count())
|
|
|
|
|
|
ui->cb_tag->clear();
|
|
|
|
|
|
if(ui->cb_name->count())
|
|
|
|
|
|
ui->cb_name->clear();
|
|
|
|
|
|
ui->le_port->clear();
|
|
|
|
|
|
ui->le_size->clear();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
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();
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::onOkClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
MeasurementInfo info;
|
|
|
|
|
|
info.tag = ui->cb_tag->currentText();
|
|
|
|
|
|
info.name = ui->cb_name->currentText();
|
|
|
|
|
|
info.equipment = ui->cb_equip->currentText();
|
|
|
|
|
|
info.channel = ui->le_port->text();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
info.type = ui->cb_type->currentIndex();
|
2025-07-04 18:47:49 +08:00
|
|
|
|
info.size = ui->le_size->text().toInt();
|
2025-11-05 18:14:31 +08:00
|
|
|
|
|
|
|
|
|
|
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());
|
2025-07-04 18:47:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(_pBay)
|
2025-11-05 18:14:31 +08:00
|
|
|
|
_pBay->addMeasure(info,_curMode);
|
2025-07-04 18:47:49 +08:00
|
|
|
|
hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::onCancelClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::onTagChanged(const QString& str)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto lst = _pBay->getValidType();
|
|
|
|
|
|
for(auto& item:lst){
|
|
|
|
|
|
if(item.tag == str){
|
|
|
|
|
|
ui->cb_name->setCurrentText(item.name);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MeasureSettingDlg::onNameChanged(const QString& str)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto lst = _pBay->getValidType();
|
|
|
|
|
|
for(auto& item:lst){
|
|
|
|
|
|
if(item.name == str){
|
|
|
|
|
|
ui->cb_tag->setCurrentText(item.tag);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 18:14:31 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|