refine codes.
This commit is contained in:
parent
dedc7d3bfa
commit
e1541a5da5
77
keyphase.cpp
77
keyphase.cpp
@ -6,12 +6,12 @@
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_,QWidget *parent)
|
||||
KeyPhase::KeyPhase(int slot_no_, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::KeyPhase)
|
||||
{
|
||||
, ui(new Ui::KeyPhase) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
slot_no = slot_no_;
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
@ -20,12 +20,15 @@ KeyPhase::KeyPhase(int slot_no_,QWidget *parent)
|
||||
Init();
|
||||
}
|
||||
|
||||
KeyPhase::~KeyPhase()
|
||||
{
|
||||
KeyPhase::~KeyPhase() {
|
||||
delete ui;
|
||||
}
|
||||
void KeyPhase::readJsonFile(const QString &filePath)
|
||||
{
|
||||
|
||||
void KeyPhase::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void KeyPhase::readJsonFile(const QString &filePath) {
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
@ -45,7 +48,7 @@ void KeyPhase::readJsonFile(const QString &filePath)
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
for (int i = 0; i < chan_array.size(); i++) {
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
keyphase_variables[i].id = temp_obj["id"].toInt();
|
||||
keyphase_variables[i].active = temp_obj["active"].toBool();
|
||||
@ -62,67 +65,65 @@ void KeyPhase::readJsonFile(const QString &filePath)
|
||||
keyphase_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
}
|
||||
}
|
||||
void KeyPhase::Init()
|
||||
{
|
||||
void KeyPhase::Init() {
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(keyphase_variables[i].id == 1){
|
||||
if (keyphase_variables[i].id == 1) {
|
||||
ui->checkBox_enable_1->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
if (keyphase_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
if(keyphase_variables[i].id == 2)
|
||||
{
|
||||
if (keyphase_variables[i].id == 2) {
|
||||
ui->checkBox_enable_2->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
if (keyphase_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
if(keyphase_variables[i].id == 3){
|
||||
if (keyphase_variables[i].id == 3) {
|
||||
ui->checkBox_enable_3->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
if (keyphase_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(keyphase_variables[i].events_per_revolution);
|
||||
}
|
||||
if(keyphase_variables[i].id == 4){
|
||||
if (keyphase_variables[i].id == 4) {
|
||||
ui->checkBox_enable_4->setChecked(keyphase_variables[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(keyphase_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(keyphase_variables[i].normal_voltage_low);
|
||||
if(keyphase_variables[i].automatic_threshold)
|
||||
if (keyphase_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(keyphase_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_variables[i].events_per_revolution);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyPhase::on_pushButton_confirm_clicked()
|
||||
{
|
||||
void KeyPhase::on_pushButton_confirm_clicked() {
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(keyphase_variables[i].id == 1){
|
||||
if (keyphase_variables[i].id == 1) {
|
||||
keyphase_variables[i].active = ui->checkBox_enable_1->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
@ -131,7 +132,7 @@ void KeyPhase::on_pushButton_confirm_clicked()
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 2){
|
||||
if (keyphase_variables[i].id == 2) {
|
||||
keyphase_variables[i].active = ui->checkBox_enable_2->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
@ -140,7 +141,7 @@ void KeyPhase::on_pushButton_confirm_clicked()
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 3){
|
||||
if (keyphase_variables[i].id == 3) {
|
||||
keyphase_variables[i].active = ui->checkBox_enable_3->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
@ -149,7 +150,7 @@ void KeyPhase::on_pushButton_confirm_clicked()
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
}
|
||||
if(keyphase_variables[i].id == 4){
|
||||
if (keyphase_variables[i].id == 4) {
|
||||
keyphase_variables[i].active = ui->checkBox_enable_4->isChecked();
|
||||
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
@ -162,8 +163,7 @@ void KeyPhase::on_pushButton_confirm_clicked()
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
QFile file(filePath_keyphase);
|
||||
if(!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Could not open file for writing";
|
||||
return;
|
||||
}
|
||||
@ -180,18 +180,17 @@ void KeyPhase::on_pushButton_confirm_clicked()
|
||||
temp_obj.insert("threshold", keyphase_variables[i].threshold);
|
||||
temp_obj.insert("hysteresis", keyphase_variables[i].hysteresis);
|
||||
temp_obj.insert("events_per_revolution", keyphase_variables[i].events_per_revolution);
|
||||
temp_obj.insert("automatic_threshold",keyphase_variables[i].automatic_threshold);
|
||||
temp_obj.insert("automatic_threshold", keyphase_variables[i].automatic_threshold);
|
||||
chan_array.append(temp_obj);
|
||||
}
|
||||
json_obj.insert("chan", chan_array);
|
||||
json_obj.insert("version",1);
|
||||
json_obj.insert("slot",slot_no);
|
||||
json_obj.insert("card_type",2);
|
||||
json_obj.insert("version", 1);
|
||||
json_obj.insert("slot", slot_no);
|
||||
json_obj.insert("card_type", 2);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
file.write(byte_array);
|
||||
file.close();
|
||||
|
||||
}
|
||||
|
||||
|
12
keyphase.h
12
keyphase.h
@ -7,19 +7,19 @@ namespace Ui {
|
||||
class KeyPhase;
|
||||
}
|
||||
|
||||
class KeyPhase : public QDialog
|
||||
{
|
||||
class KeyPhase : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KeyPhase(int slot_no_,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit KeyPhase(int slot_no_, QWidget *parent = nullptr);
|
||||
~KeyPhase();
|
||||
int slot_no;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::KeyPhase *ui;
|
||||
Tachometer_Variables keyphase_variables[4];
|
||||
void readJsonFile(const QString &filePath);
|
||||
|
121
keyphase.ui
121
keyphase.ui
@ -31,7 +31,7 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_body" native="true">
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
@ -45,9 +45,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<x>480</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -83,19 +86,6 @@
|
||||
<string> ===</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -197,6 +187,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_1">
|
||||
<property name="geometry">
|
||||
@ -219,6 +221,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_50">
|
||||
<property name="geometry">
|
||||
@ -552,6 +566,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_2">
|
||||
<property name="geometry">
|
||||
@ -574,6 +600,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_94">
|
||||
<property name="geometry">
|
||||
@ -846,9 +884,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<x>390</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -946,6 +987,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_3">
|
||||
<property name="geometry">
|
||||
@ -968,6 +1021,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_78">
|
||||
<property name="geometry">
|
||||
@ -1301,6 +1366,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_4">
|
||||
<property name="geometry">
|
||||
@ -1323,6 +1400,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_86">
|
||||
<property name="geometry">
|
||||
|
111
relaysetting.cpp
111
relaysetting.cpp
@ -10,14 +10,13 @@
|
||||
|
||||
RelaySetting::RelaySetting(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::RelaySetting)
|
||||
{
|
||||
, ui(new Ui::RelaySetting) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
readJsonFile(QCoreApplication::applicationDirPath() + "\\config\\main.json");
|
||||
|
||||
for (int var = 0; var < map_slot_config.size(); ++var) {
|
||||
if(map_slot_config[var].slot_type == 30){
|
||||
if (map_slot_config[var].slot_type == 30) {
|
||||
ui->comboBox_slot->addItem(QString::number(map_slot_config[var].slot));
|
||||
}
|
||||
}
|
||||
@ -61,15 +60,12 @@ RelaySetting::RelaySetting(QWidget *parent)
|
||||
this, &RelaySetting::onRadioButtonClicked);
|
||||
connect(ui->buttonGroup_STATUS, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &RelaySetting::onRadioButtonClicked);
|
||||
|
||||
}
|
||||
|
||||
RelaySetting::~RelaySetting()
|
||||
{
|
||||
RelaySetting::~RelaySetting() {
|
||||
delete ui;
|
||||
}
|
||||
void RelaySetting::readJsonFile(const QString &filePath)
|
||||
{
|
||||
void RelaySetting::readJsonFile(const QString &filePath) {
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
@ -78,9 +74,7 @@ void RelaySetting::readJsonFile(const QString &filePath)
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
@ -100,17 +94,17 @@ void RelaySetting::readJsonFile(const QString &filePath)
|
||||
slot_config.slot_type = obj["slot_type"].toInt();
|
||||
slot_config.chan_display = obj["chan_display"].toString();
|
||||
slot_config.rack_type = obj["rack_type"].toString();
|
||||
map_slot_config.insert(slot_id,slot_config);
|
||||
map_slot_config.insert(slot_id, slot_config);
|
||||
slot_id ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
{
|
||||
void RelaySetting::onRadioButtonClicked(QAbstractButton *button) {
|
||||
QButtonGroup *group = qobject_cast<QButtonGroup *>(sender());
|
||||
if (!group || !button) return;
|
||||
|
||||
if (!group || !button) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "Group:" << group << ", Selected button text:" << button->text();
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
@ -119,52 +113,53 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
}
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelaySetting, sizeof(RelaySettingReq),0,{} };
|
||||
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelaySetting, sizeof(RelaySettingReq), 0, {} };
|
||||
int slot = ui->comboBox_slot->currentText().toInt();
|
||||
qDebug() << "slot" << slot <<endl;
|
||||
qDebug() << "slot" << slot << endl;
|
||||
RelaySettingReq relay_setting_req;
|
||||
if(slot == 0)
|
||||
if (slot == 0) {
|
||||
relay_setting_req.card_id = 0xFF;
|
||||
else
|
||||
} else {
|
||||
relay_setting_req.card_id = slot & 0xFF;
|
||||
}
|
||||
QString led_id = group->objectName().mid(12);
|
||||
qDebug() << "led_id" << led_id <<endl;
|
||||
if(led_id == "OK")
|
||||
qDebug() << "led_id" << led_id << endl;
|
||||
if (led_id == "OK") {
|
||||
relay_setting_req.led_id = 0xff;
|
||||
else if(led_id == "TX_RX")
|
||||
} else if (led_id == "TX_RX") {
|
||||
relay_setting_req.led_id = 0xf1;
|
||||
else if(led_id == "TEST")
|
||||
} else if (led_id == "TEST") {
|
||||
relay_setting_req.led_id = 0xee;
|
||||
else if(led_id == "STATUS")
|
||||
} else if (led_id == "STATUS") {
|
||||
relay_setting_req.led_id = 0xe1;
|
||||
else
|
||||
} else {
|
||||
relay_setting_req.led_id = led_id.toInt() & 0xFF;
|
||||
|
||||
if(button->text() == "OFF")
|
||||
}
|
||||
if (button->text() == "OFF") {
|
||||
relay_setting_req.led_operate = 0;
|
||||
else if(button->text() == "ON")
|
||||
} else if (button->text() == "ON") {
|
||||
relay_setting_req.led_operate = 1;
|
||||
else if(button->text() == "红色")
|
||||
} else if (button->text() == "红色") {
|
||||
relay_setting_req.led_operate = 2;
|
||||
else if(button->text() == "绿色")
|
||||
} else if (button->text() == "绿色") {
|
||||
relay_setting_req.led_operate = 3;
|
||||
else if(button->text() == "红色1Hz闪烁" || button->text() == "红色闪烁")
|
||||
} else if (button->text() == "红色1Hz闪烁" || button->text() == "红色闪烁") {
|
||||
relay_setting_req.led_operate = 4;
|
||||
else if(button->text() == "红色2Hz闪烁")
|
||||
} else if (button->text() == "红色2Hz闪烁") {
|
||||
relay_setting_req.led_operate = 5;
|
||||
else if(button->text() == "绿色闪烁")
|
||||
} else if (button->text() == "绿色闪烁") {
|
||||
relay_setting_req.led_operate = 6;
|
||||
else if(button->text() == "测试")
|
||||
} else if (button->text() == "测试") {
|
||||
relay_setting_req.led_operate = 7;
|
||||
else if(button->text() == "手动")
|
||||
} else if (button->text() == "手动") {
|
||||
relay_setting_req.led_operate = 8;
|
||||
else if(button->text() == "工作")
|
||||
} else if (button->text() == "工作") {
|
||||
relay_setting_req.led_operate = 9;
|
||||
}
|
||||
qDebug() << "relay_setting_req.led_operate " << relay_setting_req.led_operate;
|
||||
char send_buf[20] ={0};
|
||||
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char*)&relay_setting_req, sizeof(RelaySettingReq));
|
||||
char send_buf[20] = {0};
|
||||
memcpy(send_buf, (char *)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char *)&relay_setting_req, sizeof(RelaySettingReq));
|
||||
int length = sizeof(PackageHead) + sizeof(RelaySettingReq);
|
||||
qint64 bytesWritten = socket.write(send_buf, length);
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
@ -172,15 +167,14 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelaySettingRsp relay_setting_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
memcpy(&header, response.data(), sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
memcpy(&relay_setting_rsp,response.data() + sizeof(PackageHead),sizeof(RelaySettingRsp));
|
||||
memcpy(&relay_setting_rsp, response.data() + sizeof(PackageHead), sizeof(RelaySettingRsp));
|
||||
qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void RelaySetting::on_pushButton_status_clicked()
|
||||
{
|
||||
void RelaySetting::on_pushButton_status_clicked() {
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
socket.connectToHost(g_strServerIp, 10000);
|
||||
@ -188,18 +182,18 @@ void RelaySetting::on_pushButton_status_clicked()
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
}
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelayStatus, sizeof(RelaySettingReq),0,{} };
|
||||
|
||||
PackageHead header = { {0xAA, 0x55, 0xAA}, kRelayStatus, sizeof(RelaySettingReq), 0, {} };
|
||||
int slot = ui->comboBox_slot->currentText().toInt();
|
||||
qDebug() << "slot" << slot <<endl;
|
||||
qDebug() << "slot" << slot << endl;
|
||||
RelayStatusReq relay_status_req;
|
||||
if(slot == 0)
|
||||
if (slot == 0) {
|
||||
relay_status_req.card_id = 0xFF;
|
||||
else
|
||||
} else {
|
||||
relay_status_req.card_id = slot & 0xFF;
|
||||
char send_buf[20] ={0};
|
||||
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char*)&relay_status_req, sizeof(RelayStatusReq));
|
||||
}
|
||||
char send_buf[20] = {0};
|
||||
memcpy(send_buf, (char *)&header, sizeof(PackageHead));
|
||||
memcpy(send_buf + sizeof(PackageHead), (char *)&relay_status_req, sizeof(RelayStatusReq));
|
||||
int length = sizeof(PackageHead) + sizeof(RelayStatusReq);
|
||||
qint64 bytesWritten = socket.write(send_buf, length);
|
||||
qDebug() << "Server response: " << bytesWritten;
|
||||
@ -207,16 +201,17 @@ void RelaySetting::on_pushButton_status_clicked()
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelayStatusRsp relay_status_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
memcpy(&header, response.data(), sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
memcpy(&relay_status_rsp,response.data() + sizeof(PackageHead),sizeof(RelayStatusRsp));
|
||||
memcpy(&relay_status_rsp, response.data() + sizeof(PackageHead), sizeof(RelayStatusRsp));
|
||||
qDebug() << "relay_setting_rsp status" << relay_status_rsp.status << endl;
|
||||
if(relay_status_rsp.status == 7)
|
||||
if (relay_status_rsp.status == 7) {
|
||||
ui->label_status->setText("测试");
|
||||
else if(relay_status_rsp.status == 8)
|
||||
} else if (relay_status_rsp.status == 8) {
|
||||
ui->label_status->setText("手动");
|
||||
else if(relay_status_rsp.status == 9)
|
||||
} else if (relay_status_rsp.status == 9) {
|
||||
ui->label_status->setText("工作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,6 +435,9 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -593,9 +596,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -639,9 +648,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -936,9 +951,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -988,9 +1009,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1467,9 +1494,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1513,9 +1546,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1804,9 +1843,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1850,9 +1895,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -3,12 +3,15 @@
|
||||
|
||||
SingleRelay::SingleRelay(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::SingleRelay)
|
||||
{
|
||||
, ui(new Ui::SingleRelay) {
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
SingleRelay::~SingleRelay()
|
||||
{
|
||||
SingleRelay::~SingleRelay() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SingleRelay::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
@ -7,15 +7,17 @@ namespace Ui {
|
||||
class SingleRelay;
|
||||
}
|
||||
|
||||
class SingleRelay : public QDialog
|
||||
{
|
||||
class SingleRelay : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit SingleRelay(QWidget *parent = nullptr);
|
||||
~SingleRelay();
|
||||
|
||||
private:
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::SingleRelay *ui;
|
||||
};
|
||||
|
||||
|
@ -76,12 +76,9 @@
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!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" /><meta charset="utf-8" /><style type="text/css">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
</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></string>
|
||||
</property>
|
||||
</widget>
|
||||
@ -99,6 +96,9 @@ li.checked::marker { content: "\2612"; }
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
@ -349,6 +349,9 @@ li.checked::marker { content: "\2612"; }
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_12">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
@ -387,23 +390,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<string><---</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<x>410</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
|
114
tachometer.cpp
114
tachometer.cpp
@ -7,12 +7,12 @@
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonArray>
|
||||
|
||||
Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
||||
Tachometer::Tachometer(int slot_no_, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::Tachometer)
|
||||
{
|
||||
, ui(new Ui::Tachometer) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
slot_no = slot_no_;
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
@ -21,13 +21,10 @@ Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
||||
Init();
|
||||
}
|
||||
|
||||
Tachometer::~Tachometer()
|
||||
{
|
||||
|
||||
Tachometer::~Tachometer() {
|
||||
delete ui;
|
||||
}
|
||||
void Tachometer::readJsonFile(const QString &filePath)
|
||||
{
|
||||
void Tachometer::readJsonFile(const QString &filePath) {
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
@ -47,7 +44,7 @@ void Tachometer::readJsonFile(const QString &filePath)
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
for (int i = 0; i < chan_array.size(); i++) {
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
tachometer_variables[i].id = temp_obj["id"].toInt();
|
||||
tachometer_variables[i].active = temp_obj["active"].toBool();
|
||||
@ -65,109 +62,115 @@ void Tachometer::readJsonFile(const QString &filePath)
|
||||
tachometer_variables[i].alert_response_time = temp_obj["alert_response_time"].toInt();
|
||||
tachometer_variables[i].danger_response_time = temp_obj["danger_response_time"].toInt();
|
||||
}
|
||||
|
||||
}
|
||||
void Tachometer::Init()
|
||||
{
|
||||
void Tachometer::Init() {
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(tachometer_variables[i].id == 1){
|
||||
if (tachometer_variables[i].id == 1) {
|
||||
ui->checkBox_chan_1->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
if (tachometer_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_1->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_1->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
if (tachometer_variables[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_1->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_1->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (tachometer_variables[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_1->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_1->setCheckable(false);
|
||||
}
|
||||
}
|
||||
if(tachometer_variables[i].id == 2){
|
||||
if (tachometer_variables[i].id == 2) {
|
||||
ui->checkBox_chan_2->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
if (tachometer_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_2->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_2->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
if (tachometer_variables[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_2->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_2->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (tachometer_variables[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(false);
|
||||
|
||||
}
|
||||
}
|
||||
if(tachometer_variables[i].id == 3){
|
||||
if (tachometer_variables[i].id == 3) {
|
||||
ui->checkBox_chan_3->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
if (tachometer_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_3->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_3->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
if (tachometer_variables[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_3->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_3->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (tachometer_variables[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(false);
|
||||
|
||||
}
|
||||
}
|
||||
if(tachometer_variables[i].id == 4){
|
||||
if (tachometer_variables[i].id == 4) {
|
||||
ui->checkBox_chan_4->setChecked(tachometer_variables[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(tachometer_variables[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(tachometer_variables[i].normal_voltage_low);
|
||||
if(tachometer_variables[i].automatic_threshold)
|
||||
if (tachometer_variables[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(tachometer_variables[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(tachometer_variables[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(tachometer_variables[i].events_per_revolution);
|
||||
ui->comboBox_record_output_4->setCurrentText(tachometer_variables[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_4->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||
if(tachometer_variables[i].alert_latching)
|
||||
if (tachometer_variables[i].alert_latching) {
|
||||
ui->radioButton_alert_latching_4->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_alert_latching_4->setCheckable(false);
|
||||
if(tachometer_variables[i].overspeed_latching)
|
||||
}
|
||||
if (tachometer_variables[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_confirm_clicked()
|
||||
{
|
||||
void Tachometer::on_pushButton_confirm_clicked() {
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(tachometer_variables[i].id == 1){
|
||||
if (tachometer_variables[i].id == 1) {
|
||||
tachometer_variables[i].active = ui->checkBox_chan_1->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
@ -180,7 +183,7 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 2){
|
||||
if (tachometer_variables[i].id == 2) {
|
||||
tachometer_variables[i].active = ui->checkBox_chan_2->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
@ -193,7 +196,7 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 3){
|
||||
if (tachometer_variables[i].id == 3) {
|
||||
tachometer_variables[i].active = ui->checkBox_chan_3->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
@ -206,7 +209,7 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||
}
|
||||
if(tachometer_variables[i].id == 4){
|
||||
if (tachometer_variables[i].id == 4) {
|
||||
tachometer_variables[i].active = ui->checkBox_chan_4->isChecked();
|
||||
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
@ -223,8 +226,7 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||
QFile file(filePath_tachometer);
|
||||
if(!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Could not open file for writing";
|
||||
return;
|
||||
}
|
||||
@ -251,9 +253,9 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
chan_array.append(temp_obj);
|
||||
}
|
||||
json_obj.insert("chan", chan_array);
|
||||
json_obj.insert("version",1);
|
||||
json_obj.insert("slot",slot_no);
|
||||
json_obj.insert("card_type",2);
|
||||
json_obj.insert("version", 1);
|
||||
json_obj.insert("slot", slot_no);
|
||||
json_obj.insert("card_type", 2);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
@ -261,3 +263,7 @@ void Tachometer::on_pushButton_confirm_clicked()
|
||||
file.close();
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
12
tachometer.h
12
tachometer.h
@ -7,18 +7,18 @@ namespace Ui {
|
||||
class Tachometer;
|
||||
}
|
||||
|
||||
class Tachometer : public QDialog
|
||||
{
|
||||
class Tachometer : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Tachometer(int slot_no_,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Tachometer(int slot_no_, QWidget *parent = nullptr);
|
||||
~Tachometer();
|
||||
int slot_no;
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::Tachometer *ui;
|
||||
|
||||
Tachometer_Variables tachometer_variables[4];
|
||||
|
138
tachometer.ui
138
tachometer.ui
@ -23,9 +23,12 @@
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<x>420</x>
|
||||
<y>550</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -51,10 +54,10 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<x>260</x>
|
||||
<y>550</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -80,7 +83,7 @@
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>630</x>
|
||||
<x>610</x>
|
||||
<y>550</y>
|
||||
<width>91</width>
|
||||
<height>32</height>
|
||||
@ -107,9 +110,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>530</x>
|
||||
<x>510</x>
|
||||
<y>550</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -122,7 +128,7 @@
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<x>130</x>
|
||||
<y>550</y>
|
||||
<width>101</width>
|
||||
<height>32</height>
|
||||
@ -197,6 +203,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_1">
|
||||
<property name="geometry">
|
||||
@ -219,6 +237,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_50">
|
||||
<property name="geometry">
|
||||
@ -675,6 +705,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_1">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -691,6 +724,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_1">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -745,6 +781,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_2">
|
||||
<property name="geometry">
|
||||
@ -767,6 +815,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_52">
|
||||
<property name="geometry">
|
||||
@ -1275,6 +1335,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_3">
|
||||
<property name="geometry">
|
||||
@ -1297,6 +1369,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_54">
|
||||
<property name="geometry">
|
||||
@ -1805,6 +1889,18 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>-25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_high_4">
|
||||
<property name="geometry">
|
||||
@ -1827,6 +1923,21 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-50.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>25.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_56">
|
||||
<property name="geometry">
|
||||
@ -2315,19 +2426,6 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>550</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -2372,8 +2470,8 @@
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
@ -592,20 +592,10 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>540</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
@ -632,6 +622,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_12">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>610</x>
|
||||
@ -644,10 +637,10 @@
|
||||
<string>帮 助</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_13">
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<x>410</x>
|
||||
<y>540</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
|
Loading…
x
Reference in New Issue
Block a user