diff --git a/TSI_Config.pro b/TSI_Config.pro index af548a8..455498f 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -20,7 +20,6 @@ SOURCES += \ setpoint.cpp \ singlerelay.cpp \ tachometer.cpp \ - tcpclient.cpp \ velocity.cpp HEADERS += \ @@ -35,7 +34,6 @@ HEADERS += \ setpoint.h \ singlerelay.h \ tachometer.h \ - tcpclient.h \ velocity.h FORMS += \ diff --git a/data_config.h b/data_config.h index 09f01a7..28ba88a 100644 --- a/data_config.h +++ b/data_config.h @@ -16,7 +16,12 @@ typedef struct { QPushButton* slot_btn; }SlotConfig; - +enum CMTCommand { + kEigenvalueCmd = 1, + kExceptionInfo = 2, + kUpgradeCard = 3, + kGetVersionInfo = 4 +}; enum SlotType{ POWER = 10, CONFIG = 20, @@ -79,10 +84,11 @@ typedef struct{ typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; // 命令 - int len; // 数据长度 + int len; // 数据长度 uint8_t crc; // 数据 CRC 校验和 char data[0]; // 文件内容 } PackageHead; + typedef struct { uint8_t card_id; // 0xff是本机,其它子卡是1~15 char data[0]; @@ -92,6 +98,15 @@ typedef struct { uint8_t code; // 0: 上传成功 } UpgradeRsp; +typedef struct { + uint8_t card_id; // 0xff是本机,其它子卡是1~15 +} GetVersionReq; + +typedef struct { + uint8_t fpga; // fpga版本号 + uint8_t sw; // 软件版本号 + char fpga_data[9]; // fpga版本日期 +} VersionRsp; #pragma pack() #endif // DATA_CONFIG_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 4fa938d..34bb30d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "keyphase.h" #include "singlerelay.h" #include "tachometer.h" @@ -15,14 +16,13 @@ #include #include #include -#include "ftpclient.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); - + slot = -1; btnGroup_slot = new QButtonGroup(this); btnGroup_slot->addButton(ui->pushButton_slot3); btnGroup_slot->addButton(ui->pushButton_slot4); @@ -39,6 +39,7 @@ MainWindow::MainWindow(QWidget *parent) btnGroup_slot->addButton(ui->pushButton_slot15); btnGroup_slot->addButton(ui->pushButton_slot16); btnGroup_slot->addButton(ui->pushButton_slot17); + btnGroup_slot->addButton(ui->pushButton_slot18); ui->pushButton_slot->setChecked(true); readJsonFile(QCoreApplication::applicationDirPath() + "\\config\\main.json"); @@ -77,7 +78,7 @@ void MainWindow::readJsonFile(const QString &filePath) qDebug() << "JSON document is not an object or an array"; return; } - int slot_id = 3; + int slot_id = 0; QJsonArray jsonArray = jsonDoc.array(); for (const QJsonValue &value : jsonArray) { SlotConfig slot_config; @@ -96,9 +97,9 @@ void MainWindow::createMenu() { QList buttonList = btnGroup_slot->buttons(); for (int i = 0; i < buttonList.count(); i++){ - buttonList[i]->setText(map_slot_config[i + 3].chan_display); - createMenu(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]); - map_slot_config[ i + 3].slot_btn = (QPushButton*)buttonList[i]; + buttonList[i]->setText(map_slot_config[i].chan_display); + createMenu(QString("%1").arg(i + 3), (QPushButton*)buttonList[i]); + map_slot_config[i].slot_btn = (QPushButton*)buttonList[i]; // else // createMenuSet(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]); } @@ -141,6 +142,7 @@ void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent ) mainMenu->addMenu(keyphasor); QAction *reset = mainMenu->addAction("重置模块"); QAction *upgrade = mainMenu->addAction("升级固件"); + QAction *version = mainMenu->addAction("查看版本"); parent->setContextMenuPolicy(Qt::CustomContextMenu); connect(parent,&QPushButton::customContextMenuRequested,[=](const QPoint &pos) { @@ -157,6 +159,7 @@ void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent ) QObject::connect(keyphasor_2, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); QObject::connect(reset, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); QObject::connect(upgrade, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); + QObject::connect(version, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); } @@ -322,13 +325,10 @@ void MainWindow::onMenuActionTriggered() map_slot_config[button_id].chan_display = ""; } }else if(action->text() == "升级固件"){ - sendUpgradePackage(button_id-3); + sendUpgradePackage(button_id - 3); + }else if(action->text() == "查看版本"){ + getVersion(button_id - 3); } -// QMenu* menu = button->menu(); -// if (!menu) { -// qWarning() << "菜单为空,无法清除属性!"; -// return; -// } clearMenuProperties(button->menu()); createMenu(); break; // 找到按钮后,跳出循环 @@ -424,10 +424,10 @@ void MainWindow::on_pushButton_save_clicked() QJsonObject itemObj; QJsonArray slotArray; for(int i = 0; i < map_slot_config.size();i++){ - itemObj["slot"] = map_slot_config[i+3].slot; - itemObj["slot_type"] = map_slot_config[i+3].slot_type; - itemObj["chan_display"] = map_slot_config[i+3].chan_display; - itemObj["rack_type"] = map_slot_config[i+3].rack_type; + itemObj["slot"] = map_slot_config[i+1].slot; + itemObj["slot_type"] = map_slot_config[i+1].slot_type; + itemObj["chan_display"] = map_slot_config[i+1].chan_display; + itemObj["rack_type"] = map_slot_config[i+1].rack_type; slotArray.append(itemObj); } QJsonDocument jsonDoc; @@ -491,9 +491,8 @@ void MainWindow::sendUpgradePackage(int slot) PackageHead header = { {0xAA, 0x55, 0xAA}, 3, fileSize,0,{} }; // 计算文件的 CRC 校验和 - qDebug() << "filheader.file_md5" << slot < - - 0 - @@ -380,29 +377,7 @@ - 1 - - - Qt::AlignCenter - - - - - - - - 50 - 0 - - - - - 16777215 - 16777215 - - - - 2 + Qt::AlignCenter @@ -424,7 +399,7 @@ - 3 + Qt::AlignCenter @@ -446,7 +421,7 @@ - 4 + 1 Qt::AlignCenter @@ -468,7 +443,7 @@ - 5 + 2 Qt::AlignCenter @@ -490,7 +465,7 @@ - 6 + 3 Qt::AlignCenter @@ -512,7 +487,7 @@ - 7 + 4 Qt::AlignCenter @@ -534,7 +509,7 @@ - 8 + 5 Qt::AlignCenter @@ -556,7 +531,7 @@ - 9 + 6 Qt::AlignCenter @@ -578,7 +553,7 @@ - 10 + 7 Qt::AlignCenter @@ -600,7 +575,7 @@ - 11 + 8 Qt::AlignCenter @@ -622,7 +597,7 @@ - 12 + 9 Qt::AlignCenter @@ -644,7 +619,7 @@ - 13 + 10 Qt::AlignCenter @@ -666,7 +641,7 @@ - 14 + 11 Qt::AlignCenter @@ -688,7 +663,7 @@ - 15 + 12 Qt::AlignCenter @@ -710,7 +685,7 @@ - 16 + 13 Qt::AlignCenter @@ -732,7 +707,29 @@ - 17 + 14 + + + Qt::AlignCenter + + + + + + + + 50 + 0 + + + + + 16777215 + 16777215 + + + + 15 Qt::AlignCenter @@ -779,28 +776,6 @@ - - - - - 50 - 0 - - - - - 16777215 - 16777215 - - - - 通信板 - - - Qt::AlignCenter - - - @@ -819,7 +794,7 @@ Qt::DefaultContextMenu - + CPU @@ -841,7 +816,7 @@ Qt::DefaultContextMenu - + 振动 @@ -860,7 +835,7 @@ - + 振动 @@ -879,7 +854,7 @@ - + 振动 @@ -898,7 +873,7 @@ - + 振动 @@ -1092,6 +1067,25 @@ + + + + + 50 + 280 + + + + + 16777215 + 280 + + + + + + + @@ -1112,7 +1106,7 @@ 0 0 1072 - 23 + 21