add copy and move sub card config
This commit is contained in:
parent
3bcd3c9c9b
commit
a4a8007913
@ -32,18 +32,18 @@ MyTcpClient* MyTcpClient::instance()
|
|||||||
}
|
}
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
void MyTcpClient::connectToServer(const QString &host, quint16 port) {
|
int MyTcpClient::connectToServer(const QString &host, quint16 port) {
|
||||||
serverHost = host;
|
serverHost = host;
|
||||||
serverPort = port;
|
serverPort = port;
|
||||||
if (socket->state() == QAbstractSocket::ConnectedState) {
|
if (socket->state() == QAbstractSocket::ConnectedState) {
|
||||||
qDebug() << "Already connected!";
|
qDebug() << "Already connected!";
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
qDebug() << "Connecting to" << host << ":" << port;
|
qDebug() << "Connecting to" << host << ":" << port;
|
||||||
socket->connectToHost(host, port);
|
socket->connectToHost(host, port);
|
||||||
if (!socket->waitForConnected()) {
|
if (!socket->waitForConnected()) {
|
||||||
qDebug() << "Connection failed!";
|
qDebug() << "Connection failed!";
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public:
|
|||||||
explicit MyTcpClient(QObject *parent = nullptr);
|
explicit MyTcpClient(QObject *parent = nullptr);
|
||||||
~MyTcpClient();
|
~MyTcpClient();
|
||||||
|
|
||||||
void connectToServer(const QString &host, quint16 port);
|
int connectToServer(const QString &host, quint16 port);
|
||||||
int sendData(char* data,qint64 len);
|
int sendData(char* data,qint64 len);
|
||||||
void waitForRead();
|
void waitForRead();
|
||||||
void disconnectFromServer();
|
void disconnectFromServer();
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QRegularExpressionValidator>
|
#include <QRegularExpressionValidator>
|
||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
Connect::Connect(QWidget *parent) :
|
Connect::Connect(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -30,7 +31,6 @@ void Connect::on_pushButton_connect_clicked()
|
|||||||
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
||||||
QSettings *settings = new QSettings(QCoreApplication::applicationDirPath() + "/config/config.ini", QSettings::IniFormat);
|
QSettings *settings = new QSettings(QCoreApplication::applicationDirPath() + "/config/config.ini", QSettings::IniFormat);
|
||||||
settings->setValue("Server/IP", ui->lineEdit_IP->text());
|
settings->setValue("Server/IP", ui->lineEdit_IP->text());
|
||||||
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
103
mainwindow.cpp
103
mainwindow.cpp
@ -116,7 +116,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
//qInstallMessageHandler(messageHandler);
|
//qInstallMessageHandler(messageHandler);
|
||||||
#endif
|
#endif
|
||||||
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||||
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_24f3";
|
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_3bcd";
|
||||||
ui->label_version->setText(Version);
|
ui->label_version->setText(Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,9 +438,9 @@ void MainWindow::onMenuActionTriggered() {
|
|||||||
}else if(action->text() == "获取进程号"){
|
}else if(action->text() == "获取进程号"){
|
||||||
GetCardProcessID(button_id);
|
GetCardProcessID(button_id);
|
||||||
}else if(action->text() == "复制板卡配置"){
|
}else if(action->text() == "复制板卡配置"){
|
||||||
GetCardProcessID(button_id);
|
CopySubCard(button_id);
|
||||||
}else if(action->text() == "移动板卡配置"){
|
}else if(action->text() == "移动板卡配置"){
|
||||||
GetCardProcessID(button_id);
|
MoveSubCard(button_id);
|
||||||
}
|
}
|
||||||
break; // 找到按钮后,跳出循环
|
break; // 找到按钮后,跳出循环
|
||||||
}
|
}
|
||||||
@ -922,6 +922,13 @@ void MainWindow::CopySubCard(int slot){
|
|||||||
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的板卡号!"));
|
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的板卡号!"));
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
QMessageBox *box = new QMessageBox(QMessageBox::Question, "提示", "是否进行板卡配置复制?", QMessageBox::Yes | QMessageBox::No, this);
|
||||||
|
box->button(QMessageBox::Yes)->setText("确认");
|
||||||
|
box->button(QMessageBox::No)->setText("取消");
|
||||||
|
int res = box->exec();
|
||||||
|
if(QMessageBox::No == res){
|
||||||
|
return;
|
||||||
|
}
|
||||||
int card_type_old = -1, card_type_new = -1;
|
int card_type_old = -1, card_type_new = -1;
|
||||||
std::shared_ptr<CardBase> base_ptr_old = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
std::shared_ptr<CardBase> base_ptr_old = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
if(base_ptr_old != nullptr){
|
if(base_ptr_old != nullptr){
|
||||||
@ -934,17 +941,99 @@ void MainWindow::CopySubCard(int slot){
|
|||||||
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("请选择相同的板卡类型!"));
|
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("请选择相同的板卡类型!"));
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("目标板卡无配置,请使用“移动板卡配置”!"));
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr_old);
|
||||||
vib_data->slot_ = value;
|
vib_data->slot_ = value;
|
||||||
vib_data->relative_number = value;
|
vib_data->relative_number = value;
|
||||||
ConfigMgr::Instance()->AddCard(vib_data);
|
ConfigMgr::Instance()->AddCard(vib_data);
|
||||||
|
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||||
|
for (int i = 1; i < buttonList.count(); i++) {
|
||||||
|
if(i == value){
|
||||||
|
switch (base_ptr_old->card_type_) {
|
||||||
|
case kCardVibSingle :{
|
||||||
|
buttonList[i]->setText("振动");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardKeyphaseSingle:{
|
||||||
|
buttonList[i]->setText("键相");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardSpeedSingle:{
|
||||||
|
buttonList[i]->setText("转速");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardRelaySingle:
|
||||||
|
case kCardRelaySingleNOK:
|
||||||
|
case kCardRelayTMRBackup:
|
||||||
|
case kCardRelayTMRPrimary:{
|
||||||
|
buttonList[i]->setText("继电器");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void MainWindow::MoveSubCard(int slot){
|
void MainWindow::MoveSubCard(int slot){
|
||||||
|
slot_no = slot;
|
||||||
|
QString strTips = QString("请输入1到15之间的数值");
|
||||||
|
bool ok = false;
|
||||||
|
int value = QInputDialog::getInt(this, tr("输入整数对话框"), strTips, 0, 1, 15, 1, &ok);
|
||||||
|
if(!ok) return;
|
||||||
|
if(value < 1){
|
||||||
|
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的板卡号!"));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
QMessageBox *box = new QMessageBox(QMessageBox::Question, "提示", "是否进行板卡配置移动?", QMessageBox::Yes | QMessageBox::No, this);
|
||||||
|
box->button(QMessageBox::Yes)->setText("确认");
|
||||||
|
box->button(QMessageBox::No)->setText("取消");
|
||||||
|
int res = box->exec();
|
||||||
|
if(QMessageBox::No == res){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<CardBase> base_ptr_old = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
|
std::shared_ptr<CardBase> base_ptr_new = ConfigMgr::Instance()->GetSlotPtr(value);
|
||||||
|
if(base_ptr_new != nullptr){
|
||||||
|
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("目标板卡非空!"));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr_old);
|
||||||
|
vib_data->slot_ = value;
|
||||||
|
ConfigMgr::Instance()->AddCard(vib_data);
|
||||||
|
ConfigMgr::Instance()->RemoveCard(base_ptr_old);
|
||||||
|
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||||
|
for (int i = 1; i < buttonList.count(); i++) {
|
||||||
|
if(i == value){
|
||||||
|
switch (base_ptr_old->card_type_) {
|
||||||
|
case kCardVibSingle :{
|
||||||
|
buttonList[i]->setText("振动");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardKeyphaseSingle:{
|
||||||
|
buttonList[i]->setText("键相");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardSpeedSingle:{
|
||||||
|
buttonList[i]->setText("转速");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kCardRelaySingle:
|
||||||
|
case kCardRelaySingleNOK:
|
||||||
|
case kCardRelayTMRBackup:
|
||||||
|
case kCardRelayTMRPrimary:{
|
||||||
|
buttonList[i]->setText("继电器");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}else if(i == slot){
|
||||||
|
buttonList[i]->setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void MainWindow::readData(const QByteArray &data) {
|
void MainWindow::readData(const QByteArray &data) {
|
||||||
qDebug() << "Received from server:" << data;
|
qDebug() << "Received from server:" << data;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user