From 8f75f5672cd6c22bd41045ce004006737e05a8af Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Thu, 17 Apr 2025 20:33:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_config.h | 46 ++ setpoint.ui | 12 +- singlerelay.cpp | 4 + singlerelay.h | 38 ++ singlerelay.ui | 37 +- tmrrelayassociation.ui | 1075 +++++++++++++++++++++++++++------------- 6 files changed, 827 insertions(+), 385 deletions(-) diff --git a/data_config.h b/data_config.h index 2a0b630..f81c9e0 100644 --- a/data_config.h +++ b/data_config.h @@ -70,6 +70,11 @@ enum CMTCommand { kConfigSubCard = 16, // 请求无包体,响应有包体 kRS485BaudrateSet = 17, // RS485波特率配置 kRS485BaudrateGet = 18, // RS485波特率获取 + kConfigIPv4 = 19, // 配置IP地址 + kConfigMac = 20, // 配置Mac地址 + kRebootCard = 21, // 重启板卡 + kGetCardDcValue = 22, // 获取子板平均值 + kGetRelayStatus = 23, // 获取继电器状态 }; enum RS485Baudrate { kBaudrate2400 = 0, @@ -320,7 +325,48 @@ typedef struct { typedef struct { uint8_t code; // 0: success } BaudrateSetRsp; +// cmd: kConfigIPv4 +typedef struct { + uint8_t ethn; // 0: eth0, 1: eth1 + char ip[16]; + char netmask[16]; +} ConfigIPv4Req; +// 配置IP的响应结构为CommonRsp + +// cmd: kConfigMac +typedef struct { + uint8_t ethn; // 0: eth0, 1: eth1 + char mac[18]; +} ConfigMacReq; + +// 配置MAC的响应结构为CommonRsp + +// cmd: kRebootCard +typedef struct { + uint8_t card_id; // 0: cpu板卡, 1~15对应相应槽位 +} RebootCardReq; + +// 此命令无响应,可观察各板卡灯的变化情况 + +// cmd: kGetCardDcValue +typedef struct { + uint8_t card_id; // 1 ~ 15 +} GetCardDcValueReq; + +typedef struct { + float dc_value[4]; +} GetCardDcValueRsp; + +// cmd: kGetRelayStatus +typedef struct { + uint8_t card_id; +} GetRelayStatusReq; + +typedef struct { + uint8_t card_id; + uint16_t status; // 0: 正常 1:开出, 从低位到高位分别为继电器的通道1 ~ 16 +} GetRelayStatusRsp; #pragma pack() #endif // DATA_CONFIG_H diff --git a/setpoint.ui b/setpoint.ui index 1376538..de23c23 100644 --- a/setpoint.ui +++ b/setpoint.ui @@ -11,7 +11,7 @@ - Form + 触发配置 @@ -50,16 +50,6 @@ - - - - 80 - 30 - 69 - 22 - - - diff --git a/singlerelay.cpp b/singlerelay.cpp index 5f34285..412bd72 100644 --- a/singlerelay.cpp +++ b/singlerelay.cpp @@ -6,6 +6,10 @@ SingleRelay::SingleRelay(QWidget *parent) , ui(new Ui::SingleRelay) { ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + QVBoxLayout *layout = new QVBoxLayout(ui->widget_relay); + DropTextEdit *textEdit = new DropTextEdit; + + layout->addWidget(textEdit); } SingleRelay::~SingleRelay() { diff --git a/singlerelay.h b/singlerelay.h index a5f9a49..5fce5e5 100644 --- a/singlerelay.h +++ b/singlerelay.h @@ -2,6 +2,11 @@ #define SINGLERELAY_H #include +#include +#include +#include +#include +#include namespace Ui { class SingleRelay; @@ -20,5 +25,38 @@ class SingleRelay : public QDialog { private: Ui::SingleRelay *ui; }; +class DropTextEdit : public QTextEdit { +public: + DropTextEdit(QWidget *parent = nullptr) : QTextEdit(parent) { + setAcceptDrops(true); + setReadOnly(false); // 确保不是只读的 + } +protected: + void dragEnterEvent(QDragEnterEvent *event) override { + qDebug() << "dragEnterEvent" << event->mimeData()->formats(); + if (event->mimeData()->hasText()) { + event->acceptProposedAction(); + } else { + event->ignore(); + } + } + + void dragMoveEvent(QDragMoveEvent *event) override { + if (event->mimeData()->hasText()) { + event->acceptProposedAction(); + } else { + event->ignore(); + } + } + + void dropEvent(QDropEvent *event) override { + if (event->mimeData()->hasText()) { + insertPlainText(event->mimeData()->text()); + event->acceptProposedAction(); + } else { + event->ignore(); + } + } +}; #endif // SINGLERELAY_H diff --git a/singlerelay.ui b/singlerelay.ui index 9fd8699..da020b3 100644 --- a/singlerelay.ui +++ b/singlerelay.ui @@ -11,7 +11,7 @@ - Dialog + 继电器组态 @@ -65,23 +65,6 @@ 或(*) - - - - 240 - 380 - 551 - 131 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'.AppleSystemUIFont'; font-size:13pt;">S02C01P##NO</span></p></body></html> - - @@ -111,7 +94,7 @@ p, li { white-space: pre-wrap; } 打 印... - + 620 @@ -120,6 +103,12 @@ p, li { white-space: pre-wrap; } 161 + + true + + + QAbstractItemView::DragOnly + S02C01P##NO (Slot 2 Channel 1 Not OK) @@ -1096,6 +1085,16 @@ p, li { white-space: pre-wrap; } + + + + 240 + 380 + 561 + 131 + + + diff --git a/tmrrelayassociation.ui b/tmrrelayassociation.ui index c3c571b..6c39c67 100644 --- a/tmrrelayassociation.ui +++ b/tmrrelayassociation.ui @@ -6,8 +6,8 @@ 0 0 - 838 - 576 + 853 + 624 @@ -39,232 +39,11 @@ 13 - - - - 30 - 56 - 471 - 16 - - - - 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - - - - - - 20 - 70 - 31 - 251 - - - - PushButton - - - - - - 50 - 70 - 31 - 251 - - - - PushButton - - - - - - 110 - 70 - 31 - 251 - - - - PushButton - - - - - - 80 - 70 - 31 - 251 - - - - PushButton - - - - - - 230 - 70 - 31 - 251 - - - - PushButton - - - - - - 200 - 70 - 31 - 251 - - - - PushButton - - - - - - 170 - 70 - 31 - 251 - - - - PushButton - - - - - - 140 - 70 - 31 - 251 - - - - PushButton - - - - - - 410 - 70 - 31 - 251 - - - - PushButton - - - - - - 440 - 70 - 31 - 251 - - - - PushButton - - - - - - 350 - 70 - 31 - 251 - - - - PushButton - - - - - - 380 - 70 - 31 - 251 - - - - PushButton - - - - - - 470 - 70 - 31 - 251 - - - - PushButton - - - - - - 320 - 70 - 31 - 251 - - - - PushButton - - - - - - 290 - 70 - 31 - 251 - - - - PushButton - - - - - - 260 - 70 - 31 - 251 - - - - PushButton - - - 520 - 40 + 230 + 340 111 16 @@ -276,9 +55,9 @@ - 520 - 60 - 301 + 230 + 360 + 361 161 @@ -323,123 +102,6 @@ - - - - 520 - 240 - 61 - 31 - - - - 与(*) - - - - - - 590 - 240 - 61 - 31 - - - - 或(+) - - - - - - 520 - 280 - 61 - 31 - - - - - - - - - - 590 - 280 - 61 - 31 - - - - ) - - - - - - 660 - 240 - 61 - 71 - - - - Enter - - - - - - 750 - 240 - 61 - 31 - - - - <--- - - - - - - 750 - 280 - 61 - 31 - - - - CLR - - - - - - 510 - 320 - 271 - 61 - - - - TMR - 0 of 15 逻辑操作数/通道 - - - - - 10 - 20 - 261 - 31 - - - - 24 - - - @@ -572,8 +234,8 @@ - 250 - 370 + 60 + 550 91 16 @@ -585,10 +247,10 @@ - 250 - 390 + 230 + 540 551 - 131 + 31 @@ -599,7 +261,7 @@ 520 - 540 + 590 71 32 @@ -612,7 +274,7 @@ 230 - 540 + 590 71 32 @@ -628,7 +290,7 @@ 610 - 540 + 590 81 32 @@ -641,7 +303,7 @@ 410 - 540 + 590 71 32 @@ -654,7 +316,7 @@ 760 - 545 + 595 71 20 @@ -663,6 +325,709 @@ NCT6100T + + + + 30 + 340 + 71 + 16 + + + + 国网组态 + + + + + + 0 + 50 + 606 + 295 + + + + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 1 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 2 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 3 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 4 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 5 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 6 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 7 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 8 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 9 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 10 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 11 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 12 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 13 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 14 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 15 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 16 + + + Qt::AlignCenter + + + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + PushButton + + + + + + + + + + + + 620 + 90 + 201 + 431 + + +