diff --git a/ethconfig.cpp b/ethconfig.cpp new file mode 100644 index 0000000..de517fd --- /dev/null +++ b/ethconfig.cpp @@ -0,0 +1,49 @@ +#include "ethconfig.h" +#include "ui_ethconfig.h" +#include +#include + + +EthConfig::EthConfig(QWidget *parent) : + QWidget(parent), + ui(new Ui::EthConfig) +{ + ui->setupUi(this); + QRegularExpression ipRegex(R"(^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$)"); + QRegularExpressionValidator *ipValidator = new QRegularExpressionValidator(ipRegex, this); + + ui->lineEdit_IP->setValidator(ipValidator); + ui->lineEdit_netmask->setValidator(ipValidator); + ui->lineEdit_gw->setValidator(ipValidator); +} + +EthConfig::~EthConfig() +{ + delete ui; +} + +void EthConfig::on_pushButton_confirm_clicked() +{ + PackageHead header = { {0xAA, 0x55, 0xAA}, kRebootCard, sizeof(ConfigIPv4Req),0,{} }; + ConfigIPv4Req config_ip; + config_ip.ethn = ui->comboBox_eth->currentIndex(); + memcpy(config_ip.ip,ui->lineEdit_IP->text().toStdString().c_str(),sizeof(config_ip.ip)); + memcpy(config_ip.netmask,ui->lineEdit_netmask->text().toStdString().c_str(),sizeof(config_ip.netmask)); + memcpy(config_ip.gw,ui->lineEdit_gw->text().toStdString().c_str(),sizeof(config_ip.gw)); + char send_buf[100] ={0}; + memcpy(send_buf, (char*)&header, sizeof(PackageHead)); + memcpy(send_buf + sizeof(PackageHead), (char*)&config_ip, sizeof(ConfigIPv4Req)); + + int length = sizeof(PackageHead) + sizeof(ConfigIPv4Req); + qint64 bytesWritten = m_tcpClient->sendData(send_buf, length); + m_tcpClient->waitForRead(); + qDebug() << "bytesWritten: " << bytesWritten; + this->close(); +} + + +void EthConfig::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/ethconfig.h b/ethconfig.h new file mode 100644 index 0000000..f53781c --- /dev/null +++ b/ethconfig.h @@ -0,0 +1,30 @@ +#ifndef ETHCONFIG_H +#define ETHCONFIG_H + +#include +#include "MyTcpClient.h" + +namespace Ui { +class EthConfig; +} + +class EthConfig : public QWidget +{ + Q_OBJECT + +public: + explicit EthConfig(QWidget *parent = nullptr); + ~EthConfig(); + +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::EthConfig *ui; + + MyTcpClient* m_tcpClient; +}; + +#endif // ETHCONFIG_H diff --git a/ethconfig.ui b/ethconfig.ui new file mode 100644 index 0000000..e8f7b54 --- /dev/null +++ b/ethconfig.ui @@ -0,0 +1,165 @@ + + + EthConfig + + + + 0 + 0 + 361 + 300 + + + + 以太网配置 + + + + + + + + 60 + 40 + 54 + 21 + + + + 以太网: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 40 + 111 + 22 + + + + + eth1 + + + + + eth2 + + + + + + + 60 + 90 + 54 + 21 + + + + IP: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 33 + 120 + 81 + 21 + + + + 子网掩码: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 60 + 150 + 54 + 21 + + + + 网关: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 90 + 113 + 20 + + + + + + + 130 + 120 + 113 + 20 + + + + + + + 130 + 150 + 113 + 20 + + + + + + + 60 + 222 + 71 + 31 + + + + 确定 + + + + + + 170 + 222 + 81 + 31 + + + + 取消 + + + + + + + + + diff --git a/macconfig.cpp b/macconfig.cpp new file mode 100644 index 0000000..39a1e87 --- /dev/null +++ b/macconfig.cpp @@ -0,0 +1,42 @@ +#include "macconfig.h" +#include "ui_macconfig.h" +#include +#include + +MacConfig::MacConfig(QWidget *parent) : + QWidget(parent), + ui(new Ui::MacConfig) +{ + ui->setupUi(this); + QRegularExpression macRegex("^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$"); + QRegularExpressionValidator *macValidator = new QRegularExpressionValidator(macRegex, this); + ui->lineEdit_mac->setValidator(macValidator); +} + +MacConfig::~MacConfig() +{ + delete ui; +} + +void MacConfig::on_pushButton_confirm_clicked() +{ + PackageHead header = { {0xAA, 0x55, 0xAA}, kConfigMac, sizeof(ConfigMacReq),0,{} }; + ConfigMacReq config_mac; + memcpy(config_mac.mac,ui->lineEdit_mac->text().toStdString().c_str(),sizeof(config_mac.mac)); + char send_buf[20] ={0}; + memcpy(send_buf, (char*)&header, sizeof(PackageHead)); + memcpy(send_buf + sizeof(PackageHead), (char*)&config_mac, sizeof(ConfigMacReq)); + + int length = sizeof(PackageHead) + sizeof(ConfigMacReq); + qint64 bytesWritten = m_tcpClient->sendData(send_buf, length); + m_tcpClient->waitForRead(); + qDebug() << "bytesWritten: " << bytesWritten; + this->close(); +} + + +void MacConfig::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/macconfig.h b/macconfig.h new file mode 100644 index 0000000..e0abe8a --- /dev/null +++ b/macconfig.h @@ -0,0 +1,29 @@ +#ifndef MACCONFIG_H +#define MACCONFIG_H + +#include +#include "MyTcpClient.h" + +namespace Ui { +class MacConfig; +} + +class MacConfig : public QWidget +{ + Q_OBJECT + +public: + explicit MacConfig(QWidget *parent = nullptr); + ~MacConfig(); + +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::MacConfig *ui; + MyTcpClient* m_tcpClient; +}; + +#endif // MACCONFIG_H diff --git a/macconfig.ui b/macconfig.ui new file mode 100644 index 0000000..17c50de --- /dev/null +++ b/macconfig.ui @@ -0,0 +1,74 @@ + + + MacConfig + + + + 0 + 0 + 400 + 300 + + + + mac配置 + + + + + + + + 50 + 80 + 54 + 21 + + + + MAC: + + + + + + 120 + 80 + 113 + 20 + + + + + + + 50 + 212 + 91 + 31 + + + + 确定 + + + + + + 160 + 212 + 91 + 31 + + + + 取消 + + + + + + + + + diff --git a/pointname.cpp b/pointname.cpp new file mode 100644 index 0000000..aa5cd2a --- /dev/null +++ b/pointname.cpp @@ -0,0 +1,56 @@ +#include "pointname.h" +#include "ui_pointname.h" +#include "config_mgr.h" +#include "vibrationdata.h" + +PointName::PointName(int slot_no_,int cardtype,QWidget *parent) : + QWidget(parent), + ui(new Ui::PointName) +{ + ui->setupUi(this); + slot_no = slot_no_; + car_type = static_cast(cardtype); + ui->label_slot->setText(QString::number(slot_no)); + Init(); +} + +PointName::~PointName() +{ + delete ui; +} + +void PointName::Init() +{ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + return; + } + std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); + + ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name); + ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name); + ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name); + ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name); +} + +void PointName::on_pushButton_cancel_clicked() +{ + this->close(); +} + + +void PointName::on_pushButton_confirm_clicked() +{ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + return; + } + std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); + + vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text(); + vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text(); + vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text(); + vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text(); + this->close(); +} + diff --git a/pointname.h b/pointname.h new file mode 100644 index 0000000..38c9d79 --- /dev/null +++ b/pointname.h @@ -0,0 +1,31 @@ +#ifndef POINTNAME_H +#define POINTNAME_H + +#include +#include "data_config.h" + +namespace Ui { +class PointName; +} + +class PointName : public QWidget +{ + Q_OBJECT + +public: + explicit PointName(int slot_no_,int cardtype,QWidget *parent = nullptr); + ~PointName(); + int slot_no; + CardType car_type; +private slots: + void on_pushButton_cancel_clicked(); + + void on_pushButton_confirm_clicked(); + +private: + Ui::PointName *ui; + + void Init(); +}; + +#endif // POINTNAME_H diff --git a/pointname.ui b/pointname.ui new file mode 100644 index 0000000..b471d40 --- /dev/null +++ b/pointname.ui @@ -0,0 +1,211 @@ + + + PointName + + + + 0 + 0 + 416 + 291 + + + + 测点名称 + + + + + 30 + 30 + 54 + 12 + + + + 槽位号: + + + + + + 100 + 30 + 54 + 12 + + + + slot + + + + + + 80 + 232 + 81 + 31 + + + + 确定 + + + + + + 220 + 232 + 71 + 31 + + + + 取消 + + + + + + 40 + 70 + 281 + 22 + + + + + + + 通道1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 40 + 110 + 281 + 22 + + + + + + + 通道2 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 40 + 150 + 281 + 22 + + + + + + + 通道3 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 40 + 190 + 281 + 22 + + + + + + + 通道4 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + diff --git a/setpoint_tachometer.cpp b/setpoint_tachometer.cpp new file mode 100644 index 0000000..29dec8e --- /dev/null +++ b/setpoint_tachometer.cpp @@ -0,0 +1,125 @@ +#include "setpoint_tachometer.h" +#include "ui_setpoint_tachometer.h" +#include "config_mgr.h" + +Setpoint_Tachometer::Setpoint_Tachometer(int slot_no_,int cardtype,QWidget *parent) : + QWidget(parent), + ui(new Ui::Setpoint_Tachometer) +{ + ui->setupUi(this); + slot_no = slot_no_; + car_type = static_cast(cardtype); + ui->label_slot->setText(QString::number(slot_no)); + Init(); + connect(ui->comboBox_chan, QOverload::of(&QComboBox::currentIndexChanged), + this, &Setpoint_Tachometer::onComboBoxIndexChanged); + current_index = ui->comboBox_chan->currentIndex(); +} + +Setpoint_Tachometer::~Setpoint_Tachometer() +{ + if(slider_alert != nullptr) + delete slider_alert; + if(slider_danger != nullptr) + delete slider_danger; + delete ui; +} +void Setpoint_Tachometer::Init(){ + + QVBoxLayout *layout_alert = new QVBoxLayout(ui->widget_alert); + slider_alert = new RangeSlider; + layout_alert->addWidget(slider_alert); + + QVBoxLayout *layout_danger = new QVBoxLayout(ui->widget_danger); + slider_danger = new RangeSlider(1); + layout_danger->addWidget(slider_danger); + + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + speed_alert_ptr = std::dynamic_pointer_cast(base_ptr); + + switch (car_type) { + case kCardSpeedSingle:{ + slider_alert->m_upper = 3500; + slider_alert->m_lower = 1500; + slider_alert->setRange(0,5000); + slider_danger->m_upper = 4250; + slider_danger->m_lower = 750; + slider_danger->setRange(0,5000); + + int chan = ui->comboBox_chan->currentIndex(); + std::shared_ptr setpoint_data = std::dynamic_pointer_cast(base_ptr); + ui->lineEdit_alert_upper->setText(QString::number(setpoint_data->alert_danger[chan].speed_upper)); + ui->lineEdit_alert_lower->setText(QString::number(setpoint_data->alert_danger[chan].speed_lower)); + ui->checkBox_alert_upper->setChecked(setpoint_data->alert_danger[chan].speed_upper_enable); + ui->checkBox_alert_lower->setChecked(setpoint_data->alert_danger[chan].speed_lower_enable); + if(setpoint_data->alert_danger[chan].speed_upper > 0 && setpoint_data->alert_danger[chan].speed_lower){ + slider_alert->m_upper = setpoint_data->alert_danger[chan].speed_upper; + slider_alert->m_lower = setpoint_data->alert_danger[chan].speed_lower; + } + ui->lineEdit_danger_upper->setText(QString::number(setpoint_data->alert_danger[chan].danger_speed_upper)); + if(setpoint_data->alert_danger[chan].danger_speed_upper > 0 ){ + slider_danger->m_upper = setpoint_data->alert_danger[chan].danger_speed_upper; + } + }break; + } + QObject::connect(ui->lineEdit_alert_upper, &QLineEdit::editingFinished, [&]() { + slider_alert->setUpperValue(ui->lineEdit_alert_upper->text().toFloat()); + }); + QObject::connect(ui->lineEdit_alert_lower, &QLineEdit::editingFinished, [&]() { + slider_alert->setLowerValue(ui->lineEdit_alert_lower->text().toFloat()); + }); + QObject::connect(slider_alert, &RangeSlider::rangeChanged, [&](float low,float high) { + ui->lineEdit_alert_upper->setText(QString::number((int)high)); + ui->lineEdit_alert_lower->setText(QString::number((int)low)); + }); + + QObject::connect(ui->lineEdit_danger_upper, &QLineEdit::editingFinished, [&]() { + slider_danger->setUpperValue(ui->lineEdit_danger_upper->text().toFloat()); + }); + QObject::connect(slider_danger, &RangeSlider::rangeChanged, [&](float low,float high) { + ui->lineEdit_danger_upper->setText(QString::number((int)high)); + }); +} +void Setpoint_Tachometer::onComboBoxIndexChanged(int index){ + + speed_alert_ptr->alert_danger[current_index].speed_upper = ui->lineEdit_alert_upper->text().toFloat(); + speed_alert_ptr->alert_danger[current_index].speed_lower = ui->lineEdit_alert_lower->text().toFloat(); + speed_alert_ptr->alert_danger[current_index].speed_upper_enable = ui->checkBox_alert_upper->checkState(); + speed_alert_ptr->alert_danger[current_index].speed_lower_enable = ui->checkBox_alert_lower->checkState(); + speed_alert_ptr->alert_danger[current_index].danger_speed_upper = ui->lineEdit_danger_upper->text().toFloat(); + + current_index = index; + ui->lineEdit_alert_upper->setText(QString::number(speed_alert_ptr->alert_danger[index].speed_upper)); + ui->lineEdit_alert_lower->setText(QString::number(speed_alert_ptr->alert_danger[index].speed_lower)); + ui->checkBox_alert_upper->setChecked(speed_alert_ptr->alert_danger[index].speed_upper_enable); + ui->checkBox_alert_lower->setChecked(speed_alert_ptr->alert_danger[index].speed_lower_enable); + if(speed_alert_ptr->alert_danger[index].speed_upper > 0 && speed_alert_ptr->alert_danger[index].speed_lower){ + slider_alert->m_upper = speed_alert_ptr->alert_danger[index].speed_upper; + slider_alert->m_lower = speed_alert_ptr->alert_danger[index].speed_lower; + } + ui->lineEdit_danger_upper->setText(QString::number(speed_alert_ptr->alert_danger[index].danger_speed_upper)); + if(speed_alert_ptr->alert_danger[index].danger_speed_upper > 0){ + slider_danger->m_upper = speed_alert_ptr->alert_danger[index].danger_speed_upper; + } +} + +void Setpoint_Tachometer::on_pushButton_confirm_clicked() +{ + if (speed_alert_ptr == nullptr) { + qCritical() << "[Setpoint_Tachometer::confirm] should not be here"; + return; + } + speed_alert_ptr->alert_danger[current_index].speed_upper = ui->lineEdit_alert_upper->text().toFloat(); + speed_alert_ptr->alert_danger[current_index].speed_lower = ui->lineEdit_alert_lower->text().toFloat(); + speed_alert_ptr->alert_danger[current_index].speed_upper_enable = ui->checkBox_alert_upper->checkState(); + speed_alert_ptr->alert_danger[current_index].speed_lower_enable = ui->checkBox_alert_lower->checkState(); + speed_alert_ptr->alert_danger[current_index].danger_speed_upper = ui->lineEdit_danger_upper->text().toFloat(); + this->close(); +} + + +void Setpoint_Tachometer::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/setpoint_tachometer.h b/setpoint_tachometer.h new file mode 100644 index 0000000..9f5c978 --- /dev/null +++ b/setpoint_tachometer.h @@ -0,0 +1,37 @@ +#ifndef SETPOINT_TACHOMETER_H +#define SETPOINT_TACHOMETER_H + +#include +#include "data_config.h" +#include "rangeslider.h" +#include "tachometer_data.h" + +namespace Ui { +class Setpoint_Tachometer; +} + +class Setpoint_Tachometer : public QWidget +{ + Q_OBJECT + +public: + explicit Setpoint_Tachometer(int slot_no_,int cardtype,QWidget *parent = nullptr); + ~Setpoint_Tachometer(); + int slot_no; + CardType car_type; +private slots: + void onComboBoxIndexChanged(int index); + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::Setpoint_Tachometer *ui; + RangeSlider *slider_alert; + RangeSlider *slider_danger; + std::shared_ptr speed_alert_ptr = nullptr; + int current_index; + void Init(); +}; + +#endif // SETPOINT_TACHOMETER_H diff --git a/setpoint_tachometer.ui b/setpoint_tachometer.ui new file mode 100644 index 0000000..97ee384 --- /dev/null +++ b/setpoint_tachometer.ui @@ -0,0 +1,375 @@ + + + Setpoint_Tachometer + + + + 0 + 0 + 710 + 522 + + + + Form + + + + + 20 + 480 + 666 + 37 + + + + + + + 槽位号 + + + + + + + slot + + + + + + + + 通道 1 + + + + + 通道 2 + + + + + 通道 3 + + + + + 通道 4 + + + + + + + + + 100 + 35 + + + + 确定 + + + + + + + + 100 + 35 + + + + 设置为默认值 + + + + + + + + 100 + 35 + + + + 取消 + + + + + + + false + + + + 100 + 35 + + + + 打印 + + + + + + + false + + + + 100 + 35 + + + + 帮助 + + + + + + + + + 540 + 10 + 161 + 451 + + + + 危险 / 警报 2 + + + + + 40 + 40 + 36 + 16 + + + + rpm + + + Qt::AlignCenter + + + + + + 40 + 20 + 36 + 16 + + + + 转速 + + + Qt::AlignCenter + + + + + + 30 + 80 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Qt::AlignCenter + + + + + + 0 + 107 + 120 + 260 + + + + + 120 + 260 + + + + + 120 + 260 + + + + + + + + 10 + 10 + 521 + 451 + + + + 告警 / 警报 1 + + + + + 30 + 80 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Qt::AlignCenter + + + + + + 0 + 107 + 120 + 260 + + + + + 120 + 260 + + + + + 120 + 260 + + + + + + + 40 + 20 + 36 + 16 + + + + 转速 + + + Qt::AlignCenter + + + + + + 40 + 40 + 36 + 16 + + + + rpm + + + Qt::AlignCenter + + + + + + 30 + 420 + 65 + 16 + + + + 启用 + + + + + + 30 + 60 + 65 + 16 + + + + 启用 + + + + + + 30 + 380 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Qt::AlignCenter + + + + + + + diff --git a/singlerelay_data.cpp b/singlerelay_data.cpp new file mode 100644 index 0000000..61d1c7b --- /dev/null +++ b/singlerelay_data.cpp @@ -0,0 +1,4 @@ +#include "singlerelay_data.h" +SingleRelayDataNOK::SingleRelayDataNOK(){ + +} diff --git a/singlerelay_data.h b/singlerelay_data.h new file mode 100644 index 0000000..e509c02 --- /dev/null +++ b/singlerelay_data.h @@ -0,0 +1,11 @@ +#ifndef SINGLERELAY_DATA_H +#define SINGLERELAY_DATA_H + +#include "cardbase.h" +class SingleRelayDataNOK : public CardBase { + public: + SingleRelayDataNOK(); + SingleRelayNOK single_relay_nok[RELAY_COUNT]; +}; + +#endif // SINGLERELAY_DATA_H diff --git a/tmrrelayassociation_data.cpp b/tmrrelayassociation_data.cpp new file mode 100644 index 0000000..469243f --- /dev/null +++ b/tmrrelayassociation_data.cpp @@ -0,0 +1,6 @@ +#include "tmrrelayassociation_data.h" + +TmrrelayassociationData::TmrrelayassociationData() +{ + +} diff --git a/tmrrelayassociation_data.h b/tmrrelayassociation_data.h new file mode 100644 index 0000000..c642e32 --- /dev/null +++ b/tmrrelayassociation_data.h @@ -0,0 +1,14 @@ +#ifndef TMRRELAYASSOCIATIONDATA_H +#define TMRRELAYASSOCIATIONDATA_H + +#include "cardbase.h" + +class TmrrelayassociationData: public CardBase +{ +public: + TmrrelayassociationData(); + TMRRelay tmr_relay[RELAY_COUNT]; + bool sgcc_enable = false; +}; + +#endif // TMRRELAYASSOCIATIONDATA_H