Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74784e2e40 | |||
| 020e7fb47e | |||
| ee2d142182 | |||
| 43a6bfff3c | |||
| e71d0abfe8 | |||
| ac2f1ee8ec | |||
| 166b62af1b | |||
| baf5ae0a37 | |||
| 55c9f8e435 | |||
| 46a0a87da9 | |||
| 2c42a9eaa7 | |||
| 0da25401ac | |||
| 9f3b468afc | |||
| c5a57c9678 | |||
| 16bad754f0 | |||
| 3ec608686f | |||
| 3461aa9e4a | |||
| 37cd43791e | |||
| 8f75f5672c | |||
| 4b28af5a4e | |||
| 64f60fe3af | |||
| ac94c60151 | |||
| 69eecc6824 | |||
| 0eb563da4e | |||
| c1f45d3524 | |||
| ae6c9fdd25 | |||
| fcae5b8236 | |||
| d167660911 | |||
| 64bd8799fb | |||
| b03cf0c257 | |||
| e952ec06a5 | |||
| 70d34a54a2 | |||
| 44c0daefe8 | |||
| 4c8d546c84 | |||
| 7575aa4aa9 | |||
| 4a0e1a44c5 | |||
| eaed2efaa5 | |||
| 576fe1ffd1 | |||
| 50901aefed | |||
| 653d994f9c | |||
| 6c6acfea62 | |||
| 3dd25ff15b | |||
| 385d30613c | |||
| 0c217eea58 | |||
| 306db57a47 | |||
| f7cf832d9a | |||
| e1541a5da5 | |||
| dedc7d3bfa | |||
| 28e8e6779c | |||
| 21ea1b3f8b |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"memory": "cpp"
|
||||
}
|
||||
}
|
||||
@ -70,8 +70,54 @@ void MyTcpClient::onConnected() {
|
||||
}
|
||||
|
||||
void MyTcpClient::onReadyRead() {
|
||||
QByteArray data = socket->readAll();
|
||||
emit dataReceived(data);
|
||||
while (socket->bytesAvailable() > 0) {
|
||||
if (m_waitingForHeader) {
|
||||
// 1. 先尝试读取头部(固定长度)
|
||||
if (socket->bytesAvailable() < sizeof(PackageHead)) {
|
||||
return; // 数据不够,等待下次触发
|
||||
}
|
||||
|
||||
// 读取头部
|
||||
socket->read(reinterpret_cast<char*>(&m_currentHead), sizeof(PackageHead));
|
||||
|
||||
// 验证头部标识(0xAA55AA)
|
||||
if (m_currentHead.head[0] != 0xAA ||
|
||||
m_currentHead.head[1] != 0x55 ||
|
||||
m_currentHead.head[2] != 0xAA) {
|
||||
qWarning() << "Invalid header! Disconnecting...";
|
||||
return;
|
||||
}
|
||||
|
||||
// 进入等待数据状态
|
||||
m_waitingForHeader = false;
|
||||
m_buffer.clear();
|
||||
m_buffer.append(reinterpret_cast<char*>(&m_currentHead), sizeof(PackageHead)); // 先存头部
|
||||
} else {
|
||||
// 2. 根据头部的 len 读取剩余数据
|
||||
qint64 remainingBytes = m_currentHead.len - (m_buffer.size() - sizeof(PackageHead));
|
||||
|
||||
if (remainingBytes <= 0) {
|
||||
// 数据已经完整,触发信号
|
||||
emit dataReceived(m_buffer);
|
||||
m_waitingForHeader = true; // 重置状态,准备接收下一个包
|
||||
break; // 继续处理缓冲区可能的下一个包
|
||||
}
|
||||
|
||||
// 读取剩余数据(不超过 remainingBytes)
|
||||
QByteArray newData = socket->read(remainingBytes);
|
||||
qDebug() << "Read" << newData.size() << "bytes";
|
||||
m_buffer.append(newData);
|
||||
|
||||
// 检查是否已经读完
|
||||
if (m_buffer.size() - sizeof(PackageHead) >= m_currentHead.len) {
|
||||
qDebug() << "m_buffer" << m_buffer.size() << "bytes";
|
||||
emit dataReceived(m_buffer);
|
||||
m_waitingForHeader = true; // 准备接收下一个包
|
||||
}
|
||||
}
|
||||
}
|
||||
// QByteArray data = socket->readAll();
|
||||
// emit dataReceived(data);
|
||||
}
|
||||
|
||||
void MyTcpClient::onDisconnected() {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
#include "data_config.h"
|
||||
|
||||
class MyTcpClient : public QObject {
|
||||
Q_OBJECT
|
||||
@ -39,6 +40,10 @@ private:
|
||||
quint16 serverPort;
|
||||
bool shouldReconnect; // 标记是否需要重连
|
||||
static MyTcpClient* m_instance;
|
||||
|
||||
QByteArray m_buffer; // 存储当前正在接收的数据
|
||||
bool m_waitingForHeader = true; // 是否在等待头部
|
||||
PackageHead m_currentHead; // 当前包的头部信息
|
||||
};
|
||||
|
||||
#endif // MYTCPCLIENT_H
|
||||
|
||||
@ -11,41 +11,77 @@ CONFIG += c++11
|
||||
SOURCES += \
|
||||
MyTcpClient.cpp \
|
||||
acceleration.cpp \
|
||||
cardbase.cpp \
|
||||
common.cpp \
|
||||
config_mgr.cpp \
|
||||
connect.cpp \
|
||||
ethconfig.cpp \
|
||||
keyphase.cpp \
|
||||
keyphase_data.cpp \
|
||||
macconfig.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
pointname.cpp \
|
||||
radial_vibration.cpp \
|
||||
rangeslider.cpp \
|
||||
relaysetting.cpp \
|
||||
seismic_monitor.cpp \
|
||||
setpoint.cpp \
|
||||
setpoint_tachometer.cpp \
|
||||
singlerelay.cpp \
|
||||
singlerelay_data.cpp \
|
||||
tachometer.cpp \
|
||||
velocity.cpp
|
||||
tachometer_data.cpp \
|
||||
tmrrelayassociation.cpp \
|
||||
tmrrelayassociation_data.cpp \
|
||||
velocity.cpp \
|
||||
vibrationdata.cpp
|
||||
|
||||
HEADERS += \
|
||||
MyTcpClient.h \
|
||||
acceleration.h \
|
||||
acceleration_ds.h \
|
||||
cardbase.h \
|
||||
common.h \
|
||||
config_mgr.h \
|
||||
connect.h \
|
||||
data_config.h \
|
||||
displacement_ds.h \
|
||||
ethconfig.h \
|
||||
keyphase.h \
|
||||
keyphase_data.h \
|
||||
macconfig.h \
|
||||
mainwindow.h \
|
||||
pointname.h \
|
||||
radial_vibration.h \
|
||||
rangeslider.h \
|
||||
relaysetting.h \
|
||||
seismic_monitor.h \
|
||||
setpoint.h \
|
||||
setpoint_tachometer.h \
|
||||
singlerelay.h \
|
||||
singlerelay_data.h \
|
||||
tachometer.h \
|
||||
velocity.h
|
||||
tachometer_data.h \
|
||||
tmrrelayassociation.h \
|
||||
tmrrelayassociation_data.h \
|
||||
velocity.h \
|
||||
velocity_ds.h \
|
||||
vibrationdata.h
|
||||
|
||||
FORMS += \
|
||||
acceleration.ui \
|
||||
connect.ui \
|
||||
ethconfig.ui \
|
||||
keyphase.ui \
|
||||
macconfig.ui \
|
||||
mainwindow.ui \
|
||||
pointname.ui \
|
||||
radial_vibration.ui \
|
||||
relaysetting.ui \
|
||||
seismic_monitor.ui \
|
||||
setpoint.ui \
|
||||
setpoint_tachometer.ui \
|
||||
singlerelay.ui \
|
||||
tachometer.ui \
|
||||
tmrrelayassociation.ui \
|
||||
|
||||
528
acceleration.cpp
528
acceleration.cpp
@ -6,10 +6,13 @@
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
|
||||
Acceleration::Acceleration(int slot_no_,int channel_,bool active,QWidget *parent) :
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Acceleration)
|
||||
{
|
||||
ui(new Ui::Acceleration) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
@ -17,265 +20,302 @@ Acceleration::Acceleration(int slot_no_,int channel_,bool active,QWidget *parent
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if(active)
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
else
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_filter);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_variables);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
Acceleration::~Acceleration()
|
||||
{
|
||||
Acceleration::~Acceleration() {
|
||||
delete ui;
|
||||
}
|
||||
void Acceleration::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
if(filePath.contains("filter_")){
|
||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
||||
for(int i = 0; i < filter_array.size(); i++){
|
||||
QJsonObject temp_obj = filter_array[i].toObject();
|
||||
filter[i].type = temp_obj["type"].toString();
|
||||
filter[i].low = temp_obj["low"].toInt();
|
||||
filter[i].high = temp_obj["high"].toInt();
|
||||
filter[i].checked = temp_obj["checked"].toBool();
|
||||
}
|
||||
}else if(filePath.contains("acceleration_variables_")){
|
||||
|
||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||
for(int i = 0; i < variables_array.size(); i++){
|
||||
QJsonObject temp_obj = variables_array[i].toObject();
|
||||
variables[i].type = temp_obj["type"].toString();
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].bias_voltage = temp_obj["bias_voltage"].toInt();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}
|
||||
void Acceleration::on_checkBox_rms_toggled(bool checked) {
|
||||
// TODO: 自定义的回调
|
||||
if (checked) {
|
||||
if (ui->checkBox_integrate->isChecked()) {
|
||||
QStringList items = {"0-25 mm/s rms", "0-50 mm/s rms", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
} else {
|
||||
QStringList items = {"0-20 m/s^2 rms", "0-50 m/s^2 rms", "0-100 m/s^2 rms", "0-200 m/s^2 rms", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
}
|
||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||
delay.alert = delay_obj["alert"].toInt();
|
||||
delay.danger = delay_obj["danger"].toDouble();
|
||||
delay.active_100ms = delay_obj["100ms"].toBool();
|
||||
alert_variables.rms_active = json_obj["rms_active"].toBool();
|
||||
alert_variables.integrate_active = json_obj["integrate_active"].toBool();
|
||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||
alert_variables.comparision = json_obj["comparision"].toString();
|
||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||
return;
|
||||
}
|
||||
if (ui->checkBox_integrate->isChecked()) {
|
||||
QStringList items = {"0-25 mm/s pk", "0-50 mm/s pk", "0-100 mm/s pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
} else {
|
||||
QStringList items = {"0-20 m/s^2 pk", "0-50 m/s^2 pk", "0-100 m/s^2 pk", "0-200 m/s^2 pk", "0-250 m/s^2 pk", "0-400 m/s^2 pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
void Acceleration::Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].checked){
|
||||
if(filter[i].type == "band_pass"){
|
||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage));
|
||||
ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||
}
|
||||
}
|
||||
ui->spinBox_alert->setValue(delay.alert);
|
||||
ui->doubleSpinBox_danger->setValue(delay.danger);
|
||||
ui->checkBox_100ms->setChecked(delay.active_100ms);
|
||||
ui->checkBox_rms->setChecked(alert_variables.rms_active);
|
||||
ui->checkBox_integrate->setChecked(alert_variables.integrate_active);
|
||||
ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching);
|
||||
ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching);
|
||||
ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok);
|
||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].type == "band_pass"){
|
||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||
void Acceleration::on_checkBox_integrate_toggled(bool checked) {
|
||||
// TODO: 自定义的回调
|
||||
if (checked) {
|
||||
if (ui->checkBox_rms->isChecked()) {
|
||||
QStringList items = {"0-25 mm/s rms", "0-50 mm/s rms", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
} else {
|
||||
QStringList items = {"0-25 mm/s pk", "0-50 mm/s pk", "0-100 mm/s pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
}
|
||||
}
|
||||
delay.alert = ui->spinBox_alert->value();
|
||||
delay.danger = ui->doubleSpinBox_danger->value();
|
||||
delay.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
alert_variables.rms_active = ui->checkBox_rms->isChecked();
|
||||
alert_variables.integrate_active = ui->checkBox_integrate->isChecked();
|
||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
||||
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||
|
||||
QJsonObject filter_obj,variables_obj;
|
||||
QJsonArray filter_array;
|
||||
for(int i = 0; i < 3; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",filter[i].type);
|
||||
temp_obj.insert("low",filter[i].low);
|
||||
temp_obj.insert("high",filter[i].high);
|
||||
temp_obj.insert("checked",filter[i].checked);
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 4; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",variables[i].type);
|
||||
if(variables[i].type == "direct"){
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
}
|
||||
variables_array.append(temp_obj);
|
||||
}
|
||||
variables_obj.insert("variables",variables_array);
|
||||
QJsonObject delay_obj;
|
||||
delay_obj.insert("alert",delay.alert);
|
||||
delay_obj.insert("danger",delay.danger);
|
||||
delay_obj.insert("100ms",delay.active_100ms);
|
||||
variables_obj.insert("delay",delay_obj);
|
||||
variables_obj.insert("rms_active",alert_variables.rms_active);
|
||||
variables_obj.insert("integrate_active",alert_variables.integrate_active);
|
||||
variables_obj.insert("alert_latching",alert_variables.alert_latching);
|
||||
variables_obj.insert("danger_latching",alert_variables.danger_latching);
|
||||
variables_obj.insert("timed_ok",alert_variables.timed_ok);
|
||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||
variables_obj.insert("comparision",alert_variables.comparision);
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QJsonDocument jsonDoc_filter(filter_obj);
|
||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath;
|
||||
return;
|
||||
}
|
||||
file.write(jsonDoc_filter.toJson());
|
||||
file.close();
|
||||
QJsonDocument jsonDoc_variables(variables_obj);
|
||||
filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
file.setFileName(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath;
|
||||
if (ui->checkBox_rms->isChecked()) {
|
||||
QStringList items = {"0-20 m/s^2 rms", "0-50 m/s^2 rms", "0-100 m/s^2 rms", "0-200 m/s^2 rms", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
} else {
|
||||
QStringList items = {"0-20 m/s^2 pk", "0-50 m/s^2 pk", "0-100 m/s^2 pk", "0-200 m/s^2 pk", "0-250 m/s^2 pk", "0-400 m/s^2 pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(0);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Acceleration::on_checkBox_1x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_1x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
file.write(jsonDoc_variables.toJson());
|
||||
file.close();
|
||||
ui->comboBox_1x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
void Acceleration::on_pushButton_set_default_clicked()
|
||||
{
|
||||
|
||||
void Acceleration::on_checkBox_2x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_2x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->comboBox_2x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
void Acceleration::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Acceleration::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibAcc) {
|
||||
qDebug() << "[Acceleration::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Acceleration::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(variable_ptr->direct_.full_scale_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
|
||||
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
|
||||
// ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
// ui->comboBox_bias_volt_range->setCurrentIndex();
|
||||
ui->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag);
|
||||
ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag);
|
||||
ui->spinBox_alert->setValue(variable_ptr->delay_.alert);
|
||||
ui->doubleSpinBox_danger->setValue(variable_ptr->delay_.danger);
|
||||
ui->checkBox_100ms->setChecked(variable_ptr->delay_.active_100ms);
|
||||
ui->checkBox_rms->setChecked(variable_ptr->rms_active_);
|
||||
ui->checkBox_integrate->setChecked(variable_ptr->integrate_active_);
|
||||
ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_);
|
||||
ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_);
|
||||
ui->checkBox_timed_ok->setChecked(variable_ptr->timed_ok_);
|
||||
ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage);
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Acceleration::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibAcc) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibAcc;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->rms_active_ = ui->checkBox_rms->isChecked();
|
||||
variable->integrate_active_ = ui->checkBox_integrate->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
variable->timed_ok_ = ui->checkBox_timed_ok->isChecked();
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->rms_active_ = ui->checkBox_rms->isChecked();
|
||||
variable->integrate_active_ = ui->checkBox_integrate->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
variable->timed_ok_ = ui->checkBox_timed_ok->isChecked();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
void Acceleration::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
@ -8,30 +8,29 @@ namespace Ui {
|
||||
class Acceleration;
|
||||
}
|
||||
|
||||
class Acceleration : public QWidget
|
||||
{
|
||||
class Acceleration : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Acceleration(int slot_no_,int channel_,bool active,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Acceleration(int slot_no_, int channel_, bool active, QWidget *parent = nullptr);
|
||||
~Acceleration();
|
||||
int slot_no;
|
||||
int channel;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_set_default_clicked();
|
||||
|
||||
private:
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_checkBox_1x_ampl_toggled(bool checked);
|
||||
void on_checkBox_2x_ampl_toggled(bool checked);
|
||||
void on_checkBox_rms_toggled(bool checked);
|
||||
void on_checkBox_integrate_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::Acceleration *ui;
|
||||
|
||||
Filter filter[3];
|
||||
Dealy delay;
|
||||
Variables variables[4];
|
||||
Alert_Variables alert_variables;
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
189
acceleration.ui
189
acceleration.ui
@ -485,6 +485,41 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-100 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-250 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_direct_clamp">
|
||||
<property name="geometry">
|
||||
@ -529,6 +564,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_1x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -537,8 +575,46 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-100 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-250 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -575,6 +651,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -591,6 +670,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -601,6 +683,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -614,6 +699,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_2x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -622,6 +710,41 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-100 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-250 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 m/s^2 pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_rms">
|
||||
<property name="geometry">
|
||||
@ -859,17 +982,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>偏置电压</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -877,21 +995,11 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_two_ma_clamp">
|
||||
<property name="geometry">
|
||||
@ -933,6 +1041,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_comparision_percentage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -943,6 +1054,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_comparision">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -953,17 +1067,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>偏置电压</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -971,21 +1080,11 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
@ -1032,6 +1131,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
@ -1043,19 +1145,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_point_name">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
@ -1071,6 +1160,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
@ -1084,6 +1176,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
|
||||
46
acceleration_ds.h
Normal file
46
acceleration_ds.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef ACCELERATION_DS_H
|
||||
#define ACCELERATION_DS_H
|
||||
|
||||
// 加速度峰值的量程范围
|
||||
typedef enum {
|
||||
kAccPK20 = 0, // 0-20 m/s^2 pk
|
||||
kAccPK50 = 1, // 0-50 m/s^2 pk
|
||||
kAccPK100 = 2, // 0-100 m/s^2 pk
|
||||
kAccPK200 = 3, // 0-200 m/s^2 pk
|
||||
kAccPK250 = 4, // 0-250 m/s^2 pk
|
||||
kAccPK400 = 5, // 0-400 m/s^2 pk
|
||||
kAccPKCustom = 6 // custom
|
||||
} AccPKFullScaleRange;
|
||||
|
||||
// 加速度有效值的量程范围
|
||||
typedef enum {
|
||||
kAccRMS20 = 0, // 0-20 m/s^2 rms
|
||||
kAccRMS50 = 1, // 0-50 m/s^2 rms
|
||||
kAccRMS100 = 2, // 0-100 m/s^2 rms
|
||||
kAccRMS200 = 3, // 0-200 m/s^2 rms
|
||||
kAccRMSCustom = 4 // custom
|
||||
} AccRMSFullScaleRange;
|
||||
|
||||
// 速度峰值的量程范围
|
||||
typedef enum {
|
||||
kAccVelPK25 = 0, // 0-25 mm/s pk
|
||||
kAccVelPK50 = 1, // 0-50 mm/s pk
|
||||
kAccVelPK100 = 2, // 0-100 mm/s pk
|
||||
kAccVelCustom = 3 // custom
|
||||
} AccVelPKFullScaleRange;
|
||||
|
||||
typedef enum {
|
||||
kAccVelRMS25 = 0, // 0-25 mm/s rms
|
||||
kAccVelRMS50 = 1, // 0-50 mm/s rms
|
||||
kAccVelRMSCustom = 2 // custom
|
||||
} AccVelRMSFullScaleRange;
|
||||
|
||||
// recorder out
|
||||
typedef enum {
|
||||
kAccRecorderOutNone = 0,
|
||||
kAccRecorderOutDirectAmpl = 1,
|
||||
kAccRecorderOut1XAmpl = 2,
|
||||
kAccRecorderOut2XAmpl = 3,
|
||||
} AccRecorderOut;
|
||||
|
||||
#endif // ACCELERATION_DS_H
|
||||
6
cardbase.cpp
Normal file
6
cardbase.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "cardbase.h"
|
||||
|
||||
//CardBase::CardBase()
|
||||
//{
|
||||
|
||||
//}
|
||||
53
cardbase.h
Normal file
53
cardbase.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef CARDBASE_H
|
||||
#define CARDBASE_H
|
||||
|
||||
#include "data_config.h"
|
||||
//#ifdef NAME
|
||||
// #undef NAME
|
||||
//#endif
|
||||
//#define NAME(x) (x, #x)
|
||||
|
||||
class CardBase {
|
||||
public:
|
||||
CardBase() {}
|
||||
virtual ~CardBase() {}
|
||||
int version_;
|
||||
int slot_; // 从1~15
|
||||
CardType card_type_;
|
||||
};
|
||||
|
||||
class VariableBase {
|
||||
public:
|
||||
VariableBase() {}
|
||||
virtual ~VariableBase() {}
|
||||
|
||||
int id_;
|
||||
VibChannelType type_;
|
||||
Filter filter_[3];
|
||||
DirectImpl direct_;
|
||||
XImpl x1_;
|
||||
XImpl x2_;
|
||||
RecorderOut recorder_out_;
|
||||
Delay delay_;
|
||||
};
|
||||
|
||||
// 位移
|
||||
class RadialVariable : public VariableBase {
|
||||
public:
|
||||
bool alert_latching_;
|
||||
bool danger_latching_;
|
||||
RadialImpl not1x_;
|
||||
RadialImpl smax_;
|
||||
};
|
||||
|
||||
// 加速度与速度
|
||||
class AccVelVariable : public VariableBase {
|
||||
public:
|
||||
bool alert_latching_;
|
||||
bool danger_latching_;
|
||||
bool timed_ok_;
|
||||
bool rms_active_;
|
||||
bool integrate_active_;
|
||||
};
|
||||
|
||||
#endif // CARDBASE_H
|
||||
598
config_mgr.cpp
Normal file
598
config_mgr.cpp
Normal file
@ -0,0 +1,598 @@
|
||||
#include "config_mgr.h"
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "tachometer_data.h"
|
||||
#include "keyphase_data.h"
|
||||
#include "singlerelay_data.h"
|
||||
#include "tmrrelayassociation_data.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
ConfigMgr *ConfigMgr::instance = nullptr;
|
||||
|
||||
ConfigMgr::~ConfigMgr() {
|
||||
}
|
||||
|
||||
void ConfigMgr::Save(QString & file_path) {
|
||||
QJsonObject doc_obj;
|
||||
int slot = 0;
|
||||
QJsonArray card_type;
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
if (card_type_[i] == kCardNone) {
|
||||
continue;
|
||||
}
|
||||
QJsonObject card_item;
|
||||
slot = i + 1;
|
||||
card_item["type"] = card_type_[i];
|
||||
card_item["slot"] = slot;
|
||||
card_type.append(card_item);
|
||||
if (card_type_[i] != kCardVibSingle &&
|
||||
card_type_[i] != kCardVibTMRPrimary &&
|
||||
card_type_[i] != kCardSpeedSingle &&
|
||||
card_type_[i] != kCardSpeedTMRPrimary &&
|
||||
card_type_[i] != kCardKeyphaseSingle &&
|
||||
card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary &&
|
||||
card_type_[i] != kCardRelaySingleNOK) {
|
||||
continue;
|
||||
}
|
||||
// process slot
|
||||
QJsonObject slot_item;
|
||||
if (card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary &&
|
||||
card_type_[i] != kCardRelaySingleNOK &&
|
||||
card_type_[i] != kCardRelayTMRBackup) {
|
||||
for (int cid = 0; cid < CHANNEL_COUNT; ++cid) {
|
||||
QJsonObject channel_item;
|
||||
if (card_type_[i] == kCardVibSingle ||
|
||||
card_type_[i] == kCardVibTMRPrimary) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
channel_item["standby"] = ptr->base_config_[cid].standby;
|
||||
channel_item["active"] = ptr->base_config_[cid].active;
|
||||
channel_item["rack_type"] = 0; // TODO:
|
||||
channel_item["channel_type"] = ptr->base_config_[cid].channel_type;
|
||||
channel_item["transducer_id"] = ptr->base_config_[cid].transducer_id;
|
||||
channel_item["scale_factor"] = ptr->base_config_[cid].scale_factor;
|
||||
channel_item["sampling_rate"] = ptr->base_config_[cid].sampling_rate;
|
||||
channel_item["power"] = ptr->base_config_[cid].power;
|
||||
channel_item["point_name"] = ptr->base_config_[cid].point_name;
|
||||
channel_item["chan_id"] = ptr->base_config_[cid].chan_id;
|
||||
QJsonArray voltage_range;
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_low);
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_high);
|
||||
channel_item["normal_voltage_range"] = voltage_range;
|
||||
QJsonObject setpoint_data;
|
||||
setpoint_data["direct_upper"] = qRound(ptr->alert_danger[cid].direct_upper * 10)/10.0;
|
||||
setpoint_data["direct_enable"] = ptr->alert_danger[cid].direct_enable;
|
||||
setpoint_data["1x_ampl_upper"] = qRound(ptr->alert_danger[cid].x1_ampl_upper * 10)/10.0;
|
||||
setpoint_data["1x_ampl_lower"] = qRound(ptr->alert_danger[cid].x1_ampl_lower * 10)/10.0;
|
||||
setpoint_data["1x_ampl_enable"] = ptr->alert_danger[cid].x1_ampl_enable;
|
||||
setpoint_data["2x_ampl_upper"] = qRound(ptr->alert_danger[cid].x2_ampl_upper * 10)/10.0;
|
||||
setpoint_data["2x_ampl_lower"] = qRound(ptr->alert_danger[cid].x2_ampl_lower * 10)/10.0;
|
||||
setpoint_data["2x_ampl_enable"] = ptr->alert_danger[cid].x2_ampl_enable;
|
||||
setpoint_data["danger_param"] = ptr->alert_danger[cid].danger_param;
|
||||
setpoint_data["danger_upper"] = qRound(ptr->alert_danger[cid].danger_upper * 10)/10.0;
|
||||
setpoint_data["danger_enable"] = ptr->alert_danger[cid].danger_enable;
|
||||
channel_item["setpoint"] = setpoint_data;
|
||||
// variables
|
||||
QJsonObject variables;
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
|
||||
if (base_channel_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (ptr->base_config_[cid].channel_type == kVibRadial) {
|
||||
std::shared_ptr<RadialVariable> radial_ptr = std::dynamic_pointer_cast<RadialVariable>(base_channel_ptr);
|
||||
if(radial_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = radial_ptr->filter_[0].low;
|
||||
low_pass["high"] = radial_ptr->filter_[0].high;
|
||||
low_pass["checked"] = radial_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = radial_ptr->filter_[1].low;
|
||||
high_pass["high"] = radial_ptr->filter_[1].high;
|
||||
high_pass["checked"] = radial_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = radial_ptr->filter_[2].low;
|
||||
band_pass["high"] = radial_ptr->filter_[2].high;
|
||||
band_pass["checked"] = radial_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
QJsonObject direct;
|
||||
QJsonObject x1;
|
||||
QJsonObject x2;
|
||||
QJsonObject recorder_out;
|
||||
QJsonObject delay;
|
||||
QJsonArray latching;
|
||||
direct["full_scale_range"] = radial_ptr->direct_.full_scale_range;
|
||||
direct["clamp_value"] = radial_ptr->direct_.clamp_value;
|
||||
direct["custom"] = radial_ptr->direct_.custom;
|
||||
variables["direct"] = direct;
|
||||
x1["checked"] = radial_ptr->x1_.checked;
|
||||
x1["full_scale_range"] = radial_ptr->x1_.full_scale_range;
|
||||
x1["clamp_value"] = radial_ptr->x1_.clamp_value;
|
||||
x1["custom"] = radial_ptr->x1_.custom;
|
||||
x1["phase_lag"] = radial_ptr->x1_.phase_lag;
|
||||
variables["x1"] = x1;
|
||||
x2["checked"] = radial_ptr->x2_.checked;
|
||||
x2["full_scale_range"] = radial_ptr->x2_.full_scale_range;
|
||||
x2["clamp_value"] = radial_ptr->x2_.clamp_value;
|
||||
x2["custom"] = radial_ptr->x2_.custom;
|
||||
x2["phase_lag"] = radial_ptr->x2_.phase_lag;
|
||||
variables["x2"] = x2;
|
||||
recorder_out["recorder_output"] = radial_ptr->recorder_out_.recorder_output;
|
||||
recorder_out["two_ma_clamp"] = radial_ptr->recorder_out_.two_ma_clamp;
|
||||
recorder_out["trip_multiply"] = radial_ptr->recorder_out_.trip_multiply;
|
||||
recorder_out["comparision"] = radial_ptr->recorder_out_.comparision;
|
||||
recorder_out["percentage"] = radial_ptr->recorder_out_.percentage;
|
||||
variables["recorder_out"] = recorder_out;
|
||||
delay["alert"] = radial_ptr->delay_.alert;
|
||||
delay["danger"] = radial_ptr->delay_.danger;
|
||||
delay["active_100ms"] = radial_ptr->delay_.active_100ms;
|
||||
variables["delay"] = delay;
|
||||
latching.append(radial_ptr->alert_latching_);
|
||||
latching.append(radial_ptr->danger_latching_);
|
||||
variables["latching"] = latching;
|
||||
} else {
|
||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||
if(av_ptr == nullptr){
|
||||
continue;
|
||||
}
|
||||
// filter
|
||||
QJsonArray filter;
|
||||
QJsonObject low_pass;
|
||||
low_pass["low"] = av_ptr->filter_[0].low;
|
||||
low_pass["high"] = av_ptr->filter_[0].high;
|
||||
low_pass["checked"] = av_ptr->filter_[0].checked;
|
||||
filter.append(low_pass);
|
||||
QJsonObject high_pass;
|
||||
high_pass["low"] = av_ptr->filter_[1].low;
|
||||
high_pass["high"] = av_ptr->filter_[1].high;
|
||||
high_pass["checked"] = av_ptr->filter_[1].checked;
|
||||
filter.append(high_pass);
|
||||
QJsonObject band_pass;
|
||||
band_pass["low"] = av_ptr->filter_[2].low;
|
||||
band_pass["high"] = av_ptr->filter_[2].high;
|
||||
band_pass["checked"] = av_ptr->filter_[2].checked;
|
||||
filter.append(band_pass);
|
||||
variables["filter"] = filter;
|
||||
QJsonObject direct;
|
||||
QJsonObject x1;
|
||||
QJsonObject x2;
|
||||
QJsonObject recorder_out;
|
||||
QJsonObject delay;
|
||||
QJsonArray latching;
|
||||
direct["full_scale_range"] = av_ptr->direct_.full_scale_range;
|
||||
direct["clamp_value"] = av_ptr->direct_.clamp_value;
|
||||
direct["custom"] = av_ptr->direct_.custom;
|
||||
variables["direct"] = direct;
|
||||
x1["checked"] = av_ptr->x1_.checked;
|
||||
x1["full_scale_range"] = av_ptr->x1_.full_scale_range;
|
||||
x1["clamp_value"] = av_ptr->x1_.clamp_value;
|
||||
x1["custom"] = av_ptr->x1_.custom;
|
||||
x1["phase_lag"] = av_ptr->x1_.phase_lag;
|
||||
variables["x1"] = x1;
|
||||
x2["checked"] = av_ptr->x2_.checked;
|
||||
x2["full_scale_range"] = av_ptr->x2_.full_scale_range;
|
||||
x2["clamp_value"] = av_ptr->x2_.clamp_value;
|
||||
x2["custom"] = av_ptr->x2_.custom;
|
||||
x2["phase_lag"] = av_ptr->x2_.phase_lag;
|
||||
variables["x2"] = x2;
|
||||
QJsonObject rms_integrate;
|
||||
rms_integrate["rms_active"] = av_ptr->rms_active_;
|
||||
rms_integrate["integrate_active"] = av_ptr->integrate_active_;
|
||||
variables["rms_integrate"] = rms_integrate;
|
||||
recorder_out["recorder_output"] = av_ptr->recorder_out_.recorder_output;
|
||||
recorder_out["two_ma_clamp"] = av_ptr->recorder_out_.two_ma_clamp;
|
||||
recorder_out["trip_multiply"] = av_ptr->recorder_out_.trip_multiply;
|
||||
recorder_out["comparision"] = av_ptr->recorder_out_.comparision;
|
||||
recorder_out["percentage"] = av_ptr->recorder_out_.percentage;
|
||||
variables["recorder_out"] = recorder_out;
|
||||
delay["alert"] = av_ptr->delay_.alert;
|
||||
delay["danger"] = av_ptr->delay_.danger;
|
||||
delay["active_100ms"] = av_ptr->delay_.active_100ms;
|
||||
variables["delay"] = delay;
|
||||
latching.append(av_ptr->alert_latching_);
|
||||
latching.append(av_ptr->danger_latching_);
|
||||
latching.append(av_ptr->timed_ok_);
|
||||
variables["latching"] = latching;
|
||||
}
|
||||
channel_item["variable"] = variables;
|
||||
} else if (card_type_[i] == kCardSpeedSingle || card_type_[i] == kCardSpeedTMRPrimary) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<TachometerData> ptr = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
||||
QJsonObject setpoint_data;
|
||||
setpoint_data["speed_upper"] = ptr->alert_danger[cid].speed_upper;
|
||||
setpoint_data["speed_lower"] = ptr->alert_danger[cid].speed_lower;
|
||||
setpoint_data["speed_upper_enable"] = ptr->alert_danger[cid].speed_upper_enable;
|
||||
setpoint_data["speed_lower_enable"] = ptr->alert_danger[cid].speed_lower_enable;
|
||||
setpoint_data["danger_speed_upper"] = ptr->alert_danger[cid].danger_speed_upper;
|
||||
channel_item["setpoint"] = setpoint_data;
|
||||
channel_item.insert("active", ptr->variables_[cid].active);
|
||||
channel_item.insert("normal_voltage_range", voltage_range_array);
|
||||
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
||||
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
||||
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
||||
channel_item.insert("record_output", ptr->variables_[cid].record_output);
|
||||
channel_item.insert("two_ma_clamp", ptr->variables_[cid].two_ma_clamp);
|
||||
channel_item.insert("alert_latching", ptr->variables_[cid].alert_latching);
|
||||
channel_item.insert("overspeed_latching", ptr->variables_[cid].overspeed_latching);
|
||||
channel_item.insert("normal_latching", ptr->variables_[cid].normal_latching);
|
||||
channel_item.insert("speed_peak", ptr->variables_[cid].speed_peek);
|
||||
channel_item.insert("default_speed", ptr->variables_[cid].default_speed);
|
||||
channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold);
|
||||
|
||||
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<KeyphaseData> ptr = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
||||
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
||||
channel_item.insert("active", ptr->variables_[cid].active);
|
||||
channel_item.insert("normal_voltage_range", voltage_range_array);
|
||||
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
||||
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
||||
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
||||
channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold);
|
||||
}
|
||||
slot_item[QString::number(cid + 1)] = channel_item;
|
||||
}
|
||||
slot_item["version"] = 1;
|
||||
}else{
|
||||
for(int ch = 0;ch < RELAY_COUNT;++ch){
|
||||
QJsonObject channel_item;
|
||||
if(card_type_[i] == kCardRelaySingleNOK){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<SingleRelayDataNOK> ptr = std::dynamic_pointer_cast<SingleRelayDataNOK>(base_ptr);
|
||||
if(ptr->single_relay_nok[ch].logic_expression != ""){
|
||||
qDebug() << "ch" << ch << ptr->single_relay_nok[ch].logic_expression;
|
||||
channel_item.insert("logic_expression", ptr->single_relay_nok[ch].logic_expression);
|
||||
}
|
||||
|
||||
}else if(card_type_[i] == kCardRelaySingle){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
|
||||
if(ptr->tmr_relay[ch].logic_expression != "")
|
||||
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
|
||||
}else if(card_type_[i] == kCardRelayTMRPrimary){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
|
||||
slot_item["sgcc_enable"] = ptr->sgcc_enable;
|
||||
if(ptr->tmr_relay[ch].logic_expression != ""){
|
||||
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
|
||||
}
|
||||
}
|
||||
if(!channel_item.isEmpty() ){
|
||||
slot_item[QString::number(ch + 1)] = channel_item;
|
||||
}
|
||||
}
|
||||
slot_item["version"] = 1;
|
||||
}
|
||||
doc_obj[QString::number(slot)] = slot_item;
|
||||
}
|
||||
doc_obj["card_type"] = card_type;
|
||||
// TODO: show success message box
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(doc_obj);
|
||||
QFile file(file_path);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
}
|
||||
|
||||
void ConfigMgr::Load(QString filename) {
|
||||
QFile file(filename);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
// TODO: show message box
|
||||
qDebug() << "Cannot open file for reading:" << filename;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
// TODO: show message box
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
// TODO: show message box
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
filename_ = filename;
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
// parse card_type
|
||||
QJsonArray card_type = json_obj["card_type"].toArray();
|
||||
int slot = 0;
|
||||
QJsonObject temp_obj;
|
||||
for (int i = 0; i < card_type.size(); ++i) {
|
||||
temp_obj = card_type[i].toObject();
|
||||
slot = temp_obj["slot"].toInt();
|
||||
card_type_[slot - 1] = static_cast<CardType>(temp_obj["type"].toInt());
|
||||
}
|
||||
// parse each slot
|
||||
QJsonObject channel;
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
if (card_type_[i] == kCardNone) {
|
||||
continue;
|
||||
}
|
||||
slot = i + 1;
|
||||
if (json_obj[QString::number(slot)].isNull() && card_type_[i] != kCardRelayTMRBackup) {
|
||||
continue;
|
||||
}
|
||||
temp_obj = json_obj[QString::number(slot)].toObject();
|
||||
if (card_type_[i] == kCardVibSingle) {
|
||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
vib_data->version_ = temp_obj["version"].toInt();
|
||||
vib_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
vib_data->slot_ = slot;
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = vib_data->GetChannelPtr(j + 1);
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
if(channel.isEmpty())
|
||||
continue;
|
||||
// base info
|
||||
vib_data->base_config_[j].standby = channel["standby"].toBool();
|
||||
vib_data->base_config_[j].active = channel["active"].toBool();
|
||||
vib_data->base_config_[j].rack_type = channel["rack_type"].toInt();
|
||||
// vib_data->base_config_[j].tmr_group = channel["tmr_group"].toString();
|
||||
vib_data->base_config_[j].channel_type = channel["channel_type"].toInt();
|
||||
vib_data->base_config_[j].transducer_id = channel["transducer_id"].toInt();
|
||||
vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble();
|
||||
vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
vib_data->base_config_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
vib_data->base_config_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
vib_data->base_config_[j].power = channel["power"].toBool();
|
||||
vib_data->base_config_[j].point_name = channel["point_name"].toString();
|
||||
vib_data->base_config_[j].chan_id = channel["chan_id"].toString();
|
||||
//setpoint
|
||||
QJsonObject setpoint_data = channel["setpoint"].toObject();
|
||||
vib_data->alert_danger[j].direct_upper = setpoint_data["direct_upper"].toDouble();
|
||||
vib_data->alert_danger[j].direct_enable = setpoint_data["direct_enable"].toBool();
|
||||
vib_data->alert_danger[j].x1_ampl_upper = setpoint_data["1x_ampl_upper"].toDouble();
|
||||
vib_data->alert_danger[j].x1_ampl_lower = setpoint_data["1x_ampl_lower"].toDouble();
|
||||
vib_data->alert_danger[j].x1_ampl_enable = setpoint_data["1x_ampl_enable"].toBool();
|
||||
vib_data->alert_danger[j].x2_ampl_upper = setpoint_data["2x_ampl_upper"].toDouble();
|
||||
vib_data->alert_danger[j].x2_ampl_lower = setpoint_data["2x_ampl_lower"].toDouble();
|
||||
vib_data->alert_danger[j].x2_ampl_enable = setpoint_data["2x_ampl_enable"].toBool();
|
||||
vib_data->alert_danger[j].danger_param = setpoint_data["danger_param"].toInt();
|
||||
vib_data->alert_danger[j].danger_upper = setpoint_data["danger_upper"].toDouble();
|
||||
vib_data->alert_danger[j].danger_enable = setpoint_data["danger_enable"].toBool();
|
||||
// variables
|
||||
QJsonObject tmp_variable = channel["variable"].toObject();
|
||||
switch (vib_data->base_config_[j].channel_type) {
|
||||
case kVibRadial: {
|
||||
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject direct = tmp_variable["direct"].toObject();
|
||||
variable->direct_.full_scale_range = direct["full_scale_range"].toInt();
|
||||
variable->direct_.clamp_value = direct["clamp_value"].toDouble();
|
||||
variable->direct_.custom = direct["custom"].toDouble();
|
||||
QJsonObject x1 = tmp_variable["x1"].toObject();
|
||||
variable->x1_.checked = x1["checked"].toBool();
|
||||
variable->x1_.full_scale_range = x1["full_scale_range"].toInt();
|
||||
variable->x1_.clamp_value = x1["clamp_value"].toDouble();
|
||||
variable->x1_.custom = x1["custom"].toDouble();
|
||||
variable->x1_.phase_lag = x1["phase_lag"].toInt();
|
||||
QJsonObject x2 = tmp_variable["x2"].toObject();
|
||||
variable->x2_.checked = x2["checked"].toBool();
|
||||
variable->x2_.full_scale_range = x2["full_scale_range"].toInt();
|
||||
variable->x2_.clamp_value = x2["clamp_value"].toDouble();
|
||||
variable->x2_.custom = x2["custom"].toDouble();
|
||||
variable->x2_.phase_lag = x2["phase_lag"].toInt();
|
||||
QJsonObject recorder_out = tmp_variable["recorder_out"].toObject();
|
||||
variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt();
|
||||
variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool();
|
||||
variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble();
|
||||
variable->recorder_out_.comparision = recorder_out["comparision"].toInt();
|
||||
variable->recorder_out_.percentage = recorder_out["percentage"].toInt();
|
||||
QJsonObject delay = tmp_variable["delay"].toObject();
|
||||
variable->delay_.alert = delay["alert"].toInt();
|
||||
variable->delay_.danger = delay["danger"].toDouble();
|
||||
variable->delay_.active_100ms = delay["active_100ms"].toBool();
|
||||
QJsonObject latching = tmp_variable["latching"].toObject();
|
||||
variable->alert_latching_ = latching["alert"].toBool();
|
||||
variable->danger_latching_ = latching["danger"].toBool();
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
case kVibVelocity:
|
||||
case kVibAcc: {
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
// filter
|
||||
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
||||
for (int k = 0; k < filter_array.size(); k++) {
|
||||
QJsonObject filter_ele = filter_array[k].toObject();
|
||||
variable->filter_[k].low = filter_ele["low"].toInt();
|
||||
variable->filter_[k].high = filter_ele["high"].toInt();
|
||||
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
||||
}
|
||||
variable->id_ = j + 1;
|
||||
QJsonObject direct = tmp_variable["direct"].toObject();
|
||||
variable->direct_.full_scale_range = direct["full_scale_range"].toInt();
|
||||
variable->direct_.clamp_value = direct["clamp_value"].toDouble();
|
||||
variable->direct_.custom = direct["custom"].toDouble();
|
||||
QJsonObject x1 = tmp_variable["x1"].toObject();
|
||||
variable->x1_.checked = x1["checked"].toBool();
|
||||
variable->x1_.full_scale_range = x1["full_scale_range"].toInt();
|
||||
variable->x1_.clamp_value = x1["clamp_value"].toDouble();
|
||||
variable->x1_.custom = x1["custom"].toDouble();
|
||||
variable->x1_.phase_lag = x1["phase_lag"].toInt();
|
||||
QJsonObject x2 = tmp_variable["x2"].toObject();
|
||||
variable->x2_.checked = x2["checked"].toBool();
|
||||
variable->x2_.full_scale_range = x2["full_scale_range"].toInt();
|
||||
variable->x2_.clamp_value = x2["clamp_value"].toDouble();
|
||||
variable->x2_.custom = x2["custom"].toDouble();
|
||||
variable->x2_.phase_lag = x2["phase_lag"].toInt();
|
||||
QJsonObject rms_integrate = tmp_variable["rms_integrate"].toObject();
|
||||
variable->rms_active_ = rms_integrate["rms_active"].toBool();
|
||||
variable->integrate_active_ = rms_integrate["integrate_active"].toBool();
|
||||
QJsonObject recorder_out = tmp_variable["recorder_out"].toObject();
|
||||
variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt();
|
||||
variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool();
|
||||
variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble();
|
||||
variable->recorder_out_.comparision = recorder_out["comparision"].toInt();
|
||||
variable->recorder_out_.percentage = recorder_out["percentage"].toInt();
|
||||
QJsonObject delay = tmp_variable["delay"].toObject();
|
||||
variable->delay_.alert = delay["alert"].toInt();
|
||||
variable->delay_.danger = delay["danger"].toDouble();
|
||||
variable->delay_.active_100ms = delay["active_100ms"].toBool();
|
||||
QJsonObject latching = tmp_variable["latching"].toObject();
|
||||
variable->alert_latching_ = latching["alert"].toBool();
|
||||
variable->danger_latching_ = latching["danger"].toBool();
|
||||
variable->timed_ok_ = latching["timed_ok"].toBool();
|
||||
vib_data->variables_.push_back(variable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cards_.push_back(vib_data);
|
||||
} else if (card_type_[i] == kCardSpeedSingle ||
|
||||
card_type_[i] == kCardSpeedTMRPrimary) {
|
||||
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
|
||||
speed_data->slot_ = slot;
|
||||
speed_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
speed_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
speed_data->variables_[j].active = channel["active"].toBool();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
speed_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
speed_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
speed_data->variables_[j].threshold = channel["threshold"].toDouble();
|
||||
speed_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
||||
speed_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
||||
speed_data->variables_[j].record_output = channel["record_output"].toInt();
|
||||
speed_data->variables_[j].two_ma_clamp = channel["two_ma_clamp"].toBool();
|
||||
speed_data->variables_[j].alert_latching = channel["alert_latching"].toBool();
|
||||
speed_data->variables_[j].overspeed_latching = channel["overspeed_latching"].toBool();
|
||||
speed_data->variables_[j].normal_latching = channel["normal_latching"].toBool();
|
||||
speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt();
|
||||
speed_data->variables_[j].default_speed = channel["default_speed"].toInt();
|
||||
speed_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
|
||||
|
||||
|
||||
QJsonObject setpoint_data = channel["setpoint"].toObject();
|
||||
speed_data->alert_danger[j].speed_upper = setpoint_data["speed_upper"].toDouble();
|
||||
speed_data->alert_danger[j].speed_lower = setpoint_data["speed_lower"].toDouble();
|
||||
speed_data->alert_danger[j].speed_upper_enable = setpoint_data["speed_upper_enable"].toBool();
|
||||
speed_data->alert_danger[j].speed_lower_enable = setpoint_data["speed_lower_enable"].toBool();
|
||||
speed_data->alert_danger[j].danger_speed_upper = setpoint_data["danger_speed_upper"].toDouble();
|
||||
}
|
||||
cards_.push_back(speed_data);
|
||||
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
||||
keyphase_data->slot_ = slot;
|
||||
keyphase_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
keyphase_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
keyphase_data->variables_[j].active = channel["active"].toBool();
|
||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||
keyphase_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
keyphase_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
keyphase_data->variables_[j].threshold = channel["threshold"].toDouble();
|
||||
keyphase_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
||||
keyphase_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
||||
keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
|
||||
}
|
||||
cards_.push_back(keyphase_data);
|
||||
}else if (card_type_[i] == kCardRelaySingleNOK ){
|
||||
std::shared_ptr<SingleRelayDataNOK> singlerelay_data = std::make_shared<SingleRelayDataNOK>();
|
||||
singlerelay_data->slot_ = slot;
|
||||
singlerelay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
singlerelay_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < RELAY_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
singlerelay_data->single_relay_nok[j].logic_expression = channel["logic_expression"].toString();
|
||||
}
|
||||
cards_.push_back(singlerelay_data);
|
||||
}else if(card_type_[i] == kCardRelaySingle){
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data->slot_ = slot;
|
||||
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
relay_data->version_ = temp_obj["version"].toInt();
|
||||
for (int j = 0; j < RELAY_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
relay_data->tmr_relay[j].logic_expression = channel["logic_expression"].toString();
|
||||
}
|
||||
cards_.push_back(relay_data);
|
||||
}else if(card_type_[i] == kCardRelayTMRPrimary){
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data->slot_ = slot;
|
||||
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
relay_data->version_ = temp_obj["version"].toInt();
|
||||
relay_data->sgcc_enable = temp_obj["sgcc_enable"].toBool();
|
||||
for (int j = 0; j < RELAY_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
relay_data->tmr_relay[j].logic_expression = channel["logic_expression"].toString();
|
||||
|
||||
}
|
||||
cards_.push_back(relay_data);
|
||||
}else if(card_type_[i] == kCardRelayTMRBackup){
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data->slot_ = slot;
|
||||
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
cards_.push_back(relay_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<CardBase> ConfigMgr::GetSlotPtr(int slot) {
|
||||
for (auto &item : cards_) {
|
||||
if (item->slot_ == slot) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ConfigMgr::AddCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.push_back(ptr);
|
||||
}
|
||||
void ConfigMgr::RemoveCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.erase(remove(cards_.begin(), cards_.end(), ptr));
|
||||
}
|
||||
136
config_mgr.h
Normal file
136
config_mgr.h
Normal file
@ -0,0 +1,136 @@
|
||||
#ifndef CONFIG_MGR_H
|
||||
#define CONFIG_MGR_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "cardbase.h"
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDebug>
|
||||
#include <QListWidget>
|
||||
#include <QStandardItemModel> //数据模型类
|
||||
#include <QTreeView>
|
||||
|
||||
class DraggableListWidget : public QListWidget {
|
||||
public:
|
||||
DraggableListWidget(QWidget *parent = nullptr) : QListWidget(parent) {
|
||||
setDragEnabled(true);
|
||||
}
|
||||
|
||||
protected:
|
||||
void startDrag(Qt::DropActions supportedActions) override {
|
||||
QListWidgetItem *item = currentItem();
|
||||
if (!item) return;
|
||||
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
|
||||
// 获取显示文本和 UserRole 数据
|
||||
QString visibleText = item->text();
|
||||
QString userData = item->data(Qt::UserRole).toString();
|
||||
|
||||
// 使用 QDataStream 打包数据
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
stream << visibleText << userData; // 包含显示文本和 UserRole 数据
|
||||
|
||||
mimeData->setData("application/x-custom", data); // 设置自定义 MIME 数据
|
||||
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->exec(Qt::CopyAction);
|
||||
}
|
||||
};
|
||||
class DropTreeModel : public QStandardItemModel {
|
||||
public:
|
||||
using QStandardItemModel::QStandardItemModel;
|
||||
|
||||
QStringList mimeTypes() const override {
|
||||
// 支持自定义类型和 QListWidget 默认类型
|
||||
return { "application/x-custom", "application/x-qabstractitemmodeldatalist" };
|
||||
}
|
||||
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override {
|
||||
QStandardItem *parentItem = this->itemFromIndex(parent);
|
||||
if (!parentItem)
|
||||
parentItem = this->invisibleRootItem();
|
||||
|
||||
if (data->hasFormat("application/x-custom")) {
|
||||
QByteArray rawData = data->data("application/x-custom");
|
||||
QString customText = QString::fromUtf8(rawData);
|
||||
|
||||
QStandardItem *newItem = new QStandardItem(customText);
|
||||
newItem->setData(customText, Qt::UserRole); // 假设 data 也就是内容
|
||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
|
||||
if (row < 0)
|
||||
parentItem->appendRow(newItem);
|
||||
else
|
||||
parentItem->insertRow(row, newItem);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||
QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist");
|
||||
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
int r, c;
|
||||
QMap<int, QVariant> roleDataMap;
|
||||
stream >> r >> c >> roleDataMap;
|
||||
|
||||
QString text = roleDataMap.value(Qt::DisplayRole).toString();
|
||||
QVariant userData = roleDataMap.value(Qt::UserRole);
|
||||
|
||||
QStandardItem *newItem = new QStandardItem(text);
|
||||
newItem->setData(userData, Qt::UserRole); // 保留附加数据
|
||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
|
||||
if (row < 0)
|
||||
parentItem->appendRow(newItem);
|
||||
else
|
||||
parentItem->insertRow(row, newItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::DropActions supportedDropActions() const override {
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
};
|
||||
class ConfigMgr {
|
||||
private:
|
||||
static ConfigMgr *instance;
|
||||
ConfigMgr() {
|
||||
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||
card_type_[i] = kCardNone;
|
||||
}
|
||||
}
|
||||
public:
|
||||
int card_type_[15];
|
||||
static ConfigMgr *Instance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new ConfigMgr();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
~ConfigMgr();
|
||||
void Save(QString & file_path);
|
||||
void Load(QString filename);
|
||||
std::shared_ptr<CardBase> GetSlotPtr(int slot);//1-15
|
||||
void AddCard(std::shared_ptr<CardBase> ptr);
|
||||
void RemoveCard(std::shared_ptr<CardBase> ptr);
|
||||
private:
|
||||
QString filename_;
|
||||
|
||||
std::vector<std::shared_ptr<CardBase>> cards_;
|
||||
};
|
||||
|
||||
#endif // CONFIG_MGR_H
|
||||
31
connect.cpp
Normal file
31
connect.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "connect.h"
|
||||
#include "ui_connect.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include "data_config.h"
|
||||
|
||||
Connect::Connect(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Connect)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
Connect::~Connect()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Connect::on_pushButton_connect_clicked()
|
||||
{
|
||||
g_strServerIp = ui->lineEdit_IP->text();
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
// 连接服务器
|
||||
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
||||
this->close();
|
||||
}
|
||||
|
||||
28
connect.h
Normal file
28
connect.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CONNECT_H
|
||||
#define CONNECT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "MyTcpClient.h"
|
||||
|
||||
namespace Ui {
|
||||
class Connect;
|
||||
}
|
||||
|
||||
class Connect : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Connect(QWidget *parent = nullptr);
|
||||
~Connect();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_connect_clicked();
|
||||
|
||||
private:
|
||||
Ui::Connect *ui;
|
||||
MyTcpClient* m_tcpClient;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECT_H
|
||||
58
connect.ui
Normal file
58
connect.ui
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Connect</class>
|
||||
<widget class="QWidget" name="Connect">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton_connect">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>190</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>80</y>
|
||||
<width>221</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>CPU IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_IP">
|
||||
<property name="text">
|
||||
<string>192.168.0.100</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
326
data_config.h
326
data_config.h
@ -10,15 +10,49 @@ typedef unsigned short uint16_t;
|
||||
|
||||
extern QString g_strServerIp; // 服务端IP
|
||||
|
||||
#define CHANNLE_COUNT 4
|
||||
typedef struct {
|
||||
#define SLOT_NUM 15
|
||||
#define CHANNEL_COUNT 4
|
||||
#define RELAY_COUNT 16
|
||||
|
||||
typedef enum {
|
||||
kCardNone = 0,
|
||||
kCardCpu = 1,
|
||||
|
||||
kCardVibSingle = 10,
|
||||
kCardVibTMRPrimary = 11,
|
||||
kCardVibTMRBackup = 12,
|
||||
kCardVibDoublePrimary = 13,
|
||||
kCardVibDoubleBackup = 14,
|
||||
|
||||
kCardSpeedSingle = 20,
|
||||
kCardSpeedTMRPrimary = 21,
|
||||
kCardSpeedTMRBackup = 22,
|
||||
|
||||
kCardKeyphaseSingle = 30,
|
||||
kCardKeyphaseDouble = 31,
|
||||
kCardRelaySingle = 32,
|
||||
kCardRelayTMRPrimary = 33,
|
||||
kCardRelayTMRBackup = 34,
|
||||
kCardRelaySingleNOK = 35,
|
||||
|
||||
} CardType;
|
||||
|
||||
// 振动板通道类型
|
||||
typedef enum {
|
||||
kVibRadial = 0, // 径向位移
|
||||
kVibAcc = 1, // 加速度
|
||||
kVibVelocity = 2 // 速度
|
||||
} VibChannelType;
|
||||
|
||||
typedef struct SlotConfig_{
|
||||
int slot;
|
||||
QString slot_type;
|
||||
QString chan_display;
|
||||
QString rack_type;
|
||||
QPushButton* slot_btn;
|
||||
QLabel* slot_label;
|
||||
}SlotConfig;
|
||||
QPushButton *slot_btn;
|
||||
QLabel *slot_label;
|
||||
SlotConfig_(){
|
||||
slot_type = "";
|
||||
}
|
||||
} SlotConfig;
|
||||
|
||||
enum CMTCommand {
|
||||
kEigenvalueCmd = 1,
|
||||
@ -27,61 +61,157 @@ enum CMTCommand {
|
||||
kGetVersionInfo = 4,
|
||||
kRelaySetting = 5,
|
||||
kRelayStatus = 6,
|
||||
kUpgradeProgress = 7
|
||||
kUpgradeProgress = 7,
|
||||
kCalibrationMode = 8,
|
||||
kGetDcValue = 9,
|
||||
kSetCalibrationCoe = 10,
|
||||
kGetCalibrationCoe = 11,
|
||||
kClearCalibrationCoe = 12,
|
||||
kGetWaveData = 13,
|
||||
kUploadConfigFile = 14,
|
||||
kDownloadConfigFile = 15,
|
||||
kConfigSubCard = 16, // 请求无包体,响应有包体
|
||||
kRS485BaudrateSet = 17, // RS485波特率配置
|
||||
kRS485BaudrateGet = 18, // RS485波特率获取
|
||||
kConfigIPv4 = 19, // 配置IP地址
|
||||
kConfigMac = 20, // 配置Mac地址
|
||||
kRebootCard = 21, // 重启板卡
|
||||
kGetCardDcValue = 22, // 获取子板平均值
|
||||
kGetRelayStatus = 23, // 获取继电器状态
|
||||
};
|
||||
enum RS485Baudrate {
|
||||
kBaudrate2400 = 0,
|
||||
kBaudrate4800 = 1,
|
||||
kBaudrate9600 = 2, // 默认值
|
||||
kBaudrate19200 = 3,
|
||||
kBaudrate38400 = 4,
|
||||
kBaudrate57600 = 5,
|
||||
kBaudrate115200 = 6
|
||||
};
|
||||
// 振动板采样率
|
||||
typedef enum {
|
||||
kVibSR16K = 0, // 16k
|
||||
kVibSR32K = 1, // 32k
|
||||
kVibSR64k = 2, // 64k
|
||||
kVibSR128K = 3, // 128k
|
||||
} VibSamplingRate;
|
||||
|
||||
// 振动板机架类型
|
||||
typedef enum {
|
||||
kVibRackSingle = 0, // 单一
|
||||
kVibRackTMR = 1 // 三冗余
|
||||
} VibRackType;
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
int id;
|
||||
QString channel_name;
|
||||
QString point_name;
|
||||
QString chan_id;
|
||||
bool standby;
|
||||
bool active;
|
||||
QString rack_type;
|
||||
QString tmr_group;
|
||||
QString channel_type;
|
||||
QString transducer_name;
|
||||
QString scale_factor;
|
||||
QString sample_rate;
|
||||
int rack_type; // VibRackType
|
||||
// char tmr_group[32];
|
||||
int channel_type; // VibChannelType
|
||||
int transducer_id;
|
||||
float scale_factor;
|
||||
int sampling_rate; // VibSamplingRate
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
}SeismicMonitor;
|
||||
bool power;
|
||||
} SeismicMonitor;
|
||||
|
||||
typedef struct{
|
||||
QString type;
|
||||
typedef enum {
|
||||
kFilterTypeLowPass = 0,
|
||||
kFilterTypeHighPass = 1,
|
||||
kFilterTypeBandPass = 2,
|
||||
} FilterType;
|
||||
|
||||
typedef struct {
|
||||
int low;
|
||||
int high;
|
||||
bool checked;
|
||||
} Filter;
|
||||
|
||||
typedef struct{
|
||||
//typedef struct {
|
||||
// Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
|
||||
//} AllFilter;
|
||||
|
||||
typedef struct {
|
||||
QString type;
|
||||
QString full_sacle_range;
|
||||
int full_sacle_range;
|
||||
int bias_voltage;
|
||||
float clamp_value;
|
||||
int phase_lag;
|
||||
bool checked;
|
||||
float custom;
|
||||
} Variables;
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
} DirectImpl;
|
||||
|
||||
typedef struct {
|
||||
bool checked;
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
int phase_lag;
|
||||
} XImpl;
|
||||
|
||||
typedef struct {
|
||||
bool checked;
|
||||
int full_scale_range;
|
||||
float clamp_value;
|
||||
float custom;
|
||||
} RadialImpl;
|
||||
|
||||
typedef struct {
|
||||
int alert;
|
||||
float danger;
|
||||
bool active_100ms;
|
||||
} Dealy;
|
||||
typedef struct{
|
||||
} Delay;
|
||||
|
||||
typedef struct {
|
||||
bool rms_active;
|
||||
bool integrate_active;
|
||||
bool alert_latching;
|
||||
bool danger_latching;
|
||||
bool timed_ok;
|
||||
QString recorder_output;
|
||||
int recorder_output;
|
||||
bool two_ma_clamp;
|
||||
float trip_multiply;
|
||||
QString comparision;
|
||||
int comparision_percentage;
|
||||
} Alert_Variables;
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
int recorder_output;
|
||||
bool two_ma_clamp;
|
||||
float trip_multiply;
|
||||
int comparision;
|
||||
int percentage;
|
||||
} RecorderOut;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
bool active;
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
int speed_peek;
|
||||
int default_speed;
|
||||
bool automatic_threshold;
|
||||
float threshold;
|
||||
float hysteresis;
|
||||
int events_per_revolution;
|
||||
int record_output;
|
||||
bool two_ma_clamp;
|
||||
bool alert_latching;
|
||||
bool overspeed_latching;
|
||||
bool normal_latching;
|
||||
} TachometerVariables;
|
||||
|
||||
typedef struct {
|
||||
bool active;
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
@ -89,24 +219,84 @@ typedef struct{
|
||||
float threshold;
|
||||
float hysteresis;
|
||||
int events_per_revolution;
|
||||
QString record_output;
|
||||
bool two_ma_clamp;
|
||||
bool alert_latching;
|
||||
bool overspeed_latching;
|
||||
bool normal_latching;
|
||||
int alert_response_time;
|
||||
int danger_response_time;
|
||||
}Tachometer_Variables;
|
||||
} KeyphaseVariables;
|
||||
|
||||
typedef struct {
|
||||
QString transducer_name;
|
||||
double scale_factor;
|
||||
} Transducer;
|
||||
|
||||
typedef struct VibAlertDanger_{
|
||||
float direct_upper;
|
||||
bool direct_enable;
|
||||
float x1_ampl_upper;
|
||||
float x1_ampl_lower;
|
||||
bool x1_ampl_enable;
|
||||
float x2_ampl_upper;
|
||||
float x2_ampl_lower;
|
||||
bool x2_ampl_enable;
|
||||
int danger_param; //0: 直接值,1: 1倍频幅值,2: 2倍频幅值
|
||||
float danger_upper;
|
||||
bool danger_enable;
|
||||
VibAlertDanger_(){
|
||||
direct_upper = 0.0;
|
||||
direct_enable = false;
|
||||
x1_ampl_upper = 0.0;
|
||||
x1_ampl_lower = 0.0;
|
||||
x1_ampl_enable = false;
|
||||
x2_ampl_upper = 0.0;
|
||||
x2_ampl_lower = 0.0;
|
||||
x2_ampl_enable = false;
|
||||
danger_upper = 0.0;
|
||||
danger_enable = false;
|
||||
}
|
||||
} VibAlertDanger;
|
||||
|
||||
typedef struct SpeedAlert_{
|
||||
int speed_upper;
|
||||
int speed_lower;
|
||||
bool speed_upper_enable;
|
||||
bool speed_lower_enable;
|
||||
int danger_speed_upper;
|
||||
SpeedAlert_(){
|
||||
speed_upper = 0;
|
||||
speed_lower = 0;
|
||||
danger_speed_upper = 0;
|
||||
speed_upper_enable = false;
|
||||
speed_lower_enable = false;
|
||||
}
|
||||
} SpeedAlert;
|
||||
|
||||
typedef struct SingleRelayNOK_{
|
||||
QString logic_expression;
|
||||
SingleRelayNOK_(){
|
||||
logic_expression = "";
|
||||
}
|
||||
} SingleRelayNOK;
|
||||
|
||||
typedef struct TMRRelay_{
|
||||
QString logic_expression;
|
||||
TMRRelay_(){
|
||||
logic_expression = "";
|
||||
}
|
||||
} TMRRelay;
|
||||
|
||||
#pragma pack(1)
|
||||
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 head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd;
|
||||
uint8_t code;
|
||||
int len;
|
||||
} CommonRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t card_id; // 0xff是本机,其它子卡是1~15
|
||||
char data[0];
|
||||
@ -144,6 +334,72 @@ typedef struct {
|
||||
uint8_t status; // 7 测试状态,8 手动状态,9 工作状态
|
||||
} RelayStatusRsp;
|
||||
|
||||
typedef struct {
|
||||
char data[0];
|
||||
} UploadConfigReq, DownloadConfigRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t code;
|
||||
} UploadConfigRsp, DownloadConfigReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t card_id;
|
||||
} ConfigSubCardReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t code; // 0: success 1: 无配置文件 2:失败
|
||||
} ConfigSubCardRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t baudrate; // kRS485BaudrateSet, kRS485BaudrateGet
|
||||
} BaudrateSetReq, BaudrateGetRsp;
|
||||
|
||||
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];
|
||||
char gw[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
|
||||
|
||||
21
displacement_ds.h
Normal file
21
displacement_ds.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef DISPLACEMENT_DS_H
|
||||
#define DISPLACEMENT_DS_H
|
||||
// 位移峰峰值的量程范围
|
||||
typedef enum {
|
||||
kDisPP100 = 0, // 0-100 um
|
||||
kDisPP150 = 1, // 0-150 um
|
||||
kDisPP200 = 2, // 0-200 um
|
||||
kDisPP400 = 3, // 0-400 um
|
||||
kDisPP500 = 4, // 0-500 um
|
||||
kDisPPCustom = 5 // custom
|
||||
} DisPPFullScaleRange;
|
||||
|
||||
// recorder out
|
||||
typedef enum {
|
||||
kDisRecorderOutNone = 0,
|
||||
kDisRecorderOutDirectAmpl = 1,
|
||||
kDisRecorderOut1XAmpl = 2,
|
||||
kDisRecorderOut2XAmpl = 3
|
||||
} DisRecorderOut;
|
||||
|
||||
#endif // DISPLACEMENT_DS_H
|
||||
@ -1,46 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"slot":1,
|
||||
"id":1,
|
||||
"rms_active":true,
|
||||
"integrate_active":true,
|
||||
"variables":[
|
||||
{
|
||||
"type":"direct",
|
||||
"full_sacle_range":"0-20 m/s^2 pk",
|
||||
"clamp_value":1.25
|
||||
},
|
||||
{
|
||||
"type":"bias_volt",
|
||||
"bias_voltage": -24,
|
||||
"clamp_value":1.25
|
||||
},
|
||||
{
|
||||
"type":"1x_ampl",
|
||||
"full_sacle_range":"0-2 m/s^2 pk",
|
||||
"clamp_value":1.25,
|
||||
"phase_lag":180,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"2x_ampl",
|
||||
"full_sacle_range":"0-2 m/s^2 pk",
|
||||
"clamp_value":1.25,
|
||||
"phase_lag":180,
|
||||
"checked":true
|
||||
}
|
||||
],
|
||||
"delay":{
|
||||
"alert":30,
|
||||
"danger":30.0,
|
||||
"100ms":true
|
||||
},
|
||||
"alert_latching":true,
|
||||
"danger_latching":true,
|
||||
"timed_ok":true,
|
||||
"recorder_output":"direct",
|
||||
"two_ma_clamp":true,
|
||||
"trip_mutiply":1.00,
|
||||
"comparision":"direct",
|
||||
"comparision_percentage":5
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
{
|
||||
"slot":1,
|
||||
"id":1,
|
||||
"filter":[
|
||||
{
|
||||
"type":"high_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"low_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
},
|
||||
{
|
||||
"type":"band_pass",
|
||||
"low":5,
|
||||
"high":1000,
|
||||
"checked":true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -7,49 +7,49 @@
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 1,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 2,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 3,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "振动",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 4,
|
||||
"slot_type": "HAM824"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 5,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 6,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "键相",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 7,
|
||||
"slot_type": "KPM834"
|
||||
},
|
||||
{
|
||||
"chan_display": "转速",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 8,
|
||||
"slot_type": "OPM844"
|
||||
},
|
||||
@ -73,25 +73,25 @@
|
||||
},
|
||||
{
|
||||
"chan_display": "继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "Single",
|
||||
"slot": 12,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR1",
|
||||
"slot": 13,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR2",
|
||||
"slot": 14,
|
||||
"slot_type": "DOM810"
|
||||
},
|
||||
{
|
||||
"chan_display": "三冗余继电器",
|
||||
"rack_type": "",
|
||||
"rack_type": "TMR3",
|
||||
"slot": 15,
|
||||
"slot_type": "DOM810"
|
||||
}
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
{
|
||||
"card_type": 1,
|
||||
"chan": [
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "acceleration",
|
||||
"id": 1,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "1-3",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "acceleration",
|
||||
"id": 2,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "1-3",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "velocity",
|
||||
"id": 3,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "3-5",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "velocity",
|
||||
"id": 4,
|
||||
"normal_voltage_range": [
|
||||
0,
|
||||
21
|
||||
],
|
||||
"rack_type": "TMR",
|
||||
"sample_rate": "32 k",
|
||||
"scale_factor": "10",
|
||||
"standby": true,
|
||||
"tmr_group": "3-5",
|
||||
"transducer_name": ""
|
||||
}
|
||||
],
|
||||
"slot": 3,
|
||||
"version": 1
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
{
|
||||
"card_type": 1,
|
||||
"chan": [
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"channel_name": "",
|
||||
"channel_type": "",
|
||||
"id": -1973791,
|
||||
"normal_voltage_range": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"rack_type": "",
|
||||
"sample_rate": "",
|
||||
"scale_factor": "",
|
||||
"standby": true,
|
||||
"tmr_group": "",
|
||||
"transducer_name": ""
|
||||
}
|
||||
],
|
||||
"slot": 4,
|
||||
"version": 1
|
||||
}
|
||||
4
doc/config/transducer.json
Normal file
4
doc/config/transducer.json
Normal file
@ -0,0 +1,4 @@
|
||||
[{"transducer_name":"测试1","scale_factor":1.25},
|
||||
{"transducer_name":"测试2","scale_factor":1.26},
|
||||
{"transducer_name":"测试3","scale_factor":1.27},
|
||||
{"transducer_name":"测试4","scale_factor":1.28}]
|
||||
49
ethconfig.cpp
Normal file
49
ethconfig.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "ethconfig.h"
|
||||
#include "ui_ethconfig.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
30
ethconfig.h
Normal file
30
ethconfig.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef ETHCONFIG_H
|
||||
#define ETHCONFIG_H
|
||||
|
||||
#include <QWidget>
|
||||
#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
|
||||
165
ethconfig.ui
Normal file
165
ethconfig.ui
Normal file
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EthConfig</class>
|
||||
<widget class="QWidget" name="EthConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>以太网配置</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>以太网:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_eth">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>40</y>
|
||||
<width>111</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eth2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>90</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>33</x>
|
||||
<y>120</y>
|
||||
<width>81</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>子网掩码:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>150</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>网关:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_IP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>90</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_netmask">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>120</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_gw">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>150</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>222</y>
|
||||
<width>71</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>222</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
380
keyphase.cpp
380
keyphase.cpp
@ -6,192 +6,262 @@
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_,QWidget *parent)
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "keyphase_data.h"
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_,int cardtype, 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_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
readJsonFile(filePath_keyphase);
|
||||
// QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||
// readJsonFile(filePath_keyphase);
|
||||
Init();
|
||||
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_1_clicked);
|
||||
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_2_clicked);
|
||||
connect(ui->radioButton_manual_threshold_3, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_3_clicked);
|
||||
connect(ui->radioButton_manual_threshold_4, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_4_clicked);
|
||||
}
|
||||
|
||||
KeyPhase::~KeyPhase()
|
||||
{
|
||||
KeyPhase::~KeyPhase() {
|
||||
delete ui;
|
||||
}
|
||||
void KeyPhase::readJsonFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
|
||||
void KeyPhase::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_1_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_2_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_3_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
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();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
keyphase_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
keyphase_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
keyphase_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||
keyphase_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||
keyphase_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||
keyphase_variables[i].record_output = temp_obj["record_output"].toString();
|
||||
keyphase_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||
keyphase_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||
keyphase_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||
keyphase_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::on_manual_threshold_4_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
|
||||
void KeyPhase::UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data) {
|
||||
keyphase_data->card_type_ = kCardKeyphaseSingle;
|
||||
keyphase_data->slot_ = slot_no;
|
||||
keyphase_data->version_ = 1;
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_1->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
} else if (i + 1 == 2) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_2->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
} else if (i + 1 == 3) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_3->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
} else if (i + 1 == 4) {
|
||||
keyphase_data->variables_[i].active = ui->checkBox_enable_4->isChecked();
|
||||
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyPhase::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
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)
|
||||
|
||||
void KeyPhase::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
||||
keyphase_data->card_type_ = car_type;
|
||||
keyphase_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(keyphase_data);
|
||||
UpdateData(keyphase_data);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
ui->checkBox_enable_1->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->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)
|
||||
{
|
||||
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)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 2) {
|
||||
ui->checkBox_enable_2->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->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){
|
||||
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)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_enable_3->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->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){
|
||||
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)
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
} else if (i + 1 == 4) {
|
||||
ui->checkBox_enable_4->setChecked(keyphase_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||
if (keyphase_data->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);
|
||||
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(keyphase_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||
}
|
||||
}
|
||||
}
|
||||
void KeyPhase::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
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();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
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){
|
||||
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();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
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){
|
||||
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();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
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){
|
||||
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();
|
||||
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
}
|
||||
}
|
||||
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))
|
||||
{
|
||||
qDebug() << "Could not open file for writing";
|
||||
void KeyPhase::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj;
|
||||
QJsonArray chan_array;
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("id", keyphase_variables[i].id);
|
||||
temp_obj.insert("active", keyphase_variables[i].active);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(keyphase_variables[i].normal_voltage_low);
|
||||
voltage_range_array.append(keyphase_variables[i].normal_voltage_high);
|
||||
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||
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);
|
||||
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);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
file.write(byte_array);
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||
UpdateData(keyphase_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_1_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_1->isChecked()){
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_1_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_1->isChecked()){
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_2_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_2->isChecked()){
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_2_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_2->isChecked()){
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_3_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_3->isChecked()){
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_3_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_3->isChecked()){
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_automatic_threshold_4_clicked()
|
||||
{
|
||||
if(ui->radioButton_automatic_threshold_4->isChecked()){
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyPhase::on_radioButton_manual_threshold_4_clicked()
|
||||
{
|
||||
if(ui->radioButton_manual_threshold_4->isChecked()){
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
39
keyphase.h
39
keyphase.h
@ -1,28 +1,49 @@
|
||||
#ifndef KEYPHASE_H
|
||||
#define KEYPHASE_H
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
#include "data_config.h"
|
||||
#include "keyphase_data.h"
|
||||
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_,int cardtype, QWidget *parent = nullptr);
|
||||
~KeyPhase();
|
||||
int slot_no;
|
||||
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_manual_threshold_1_clicked(bool checked);
|
||||
void on_manual_threshold_2_clicked(bool checked);
|
||||
void on_manual_threshold_3_clicked(bool checked);
|
||||
void on_manual_threshold_4_clicked(bool checked);
|
||||
void on_radioButton_manual_threshold_1_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_1_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_2_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_2_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_3_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_3_clicked();
|
||||
|
||||
void on_radioButton_automatic_threshold_4_clicked();
|
||||
|
||||
void on_radioButton_manual_threshold_4_clicked();
|
||||
|
||||
private:
|
||||
Ui::KeyPhase *ui;
|
||||
Tachometer_Variables keyphase_variables[4];
|
||||
void readJsonFile(const QString &filePath);
|
||||
void UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data);
|
||||
// TachometerVariables keyphase_variables[4];
|
||||
// void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
175
keyphase.ui
175
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>
|
||||
@ -119,7 +109,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -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">
|
||||
@ -373,6 +387,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
@ -428,6 +451,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -552,6 +578,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 +612,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">
|
||||
@ -744,6 +794,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="geometry">
|
||||
@ -799,6 +858,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -846,9 +908,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>
|
||||
@ -868,7 +933,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_5">
|
||||
<attribute name="title">
|
||||
@ -946,6 +1011,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 +1045,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">
|
||||
@ -1164,6 +1253,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="geometry">
|
||||
@ -1219,6 +1317,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -1301,6 +1402,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 +1436,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">
|
||||
@ -1490,6 +1615,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="geometry">
|
||||
@ -1545,6 +1679,9 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
@ -1628,7 +1765,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_standby">
|
||||
<property name="text">
|
||||
<string>5-6</string>
|
||||
<string>--</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
6
keyphase_data.cpp
Normal file
6
keyphase_data.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "keyphase_data.h"
|
||||
|
||||
KeyphaseData::KeyphaseData()
|
||||
{
|
||||
|
||||
}
|
||||
11
keyphase_data.h
Normal file
11
keyphase_data.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef KEYPHASEDATA_H
|
||||
#define KEYPHASEDATA_H
|
||||
|
||||
#include "cardbase.h"
|
||||
class KeyphaseData : public CardBase {
|
||||
public:
|
||||
KeyphaseData();
|
||||
KeyphaseVariables variables_[4];
|
||||
};
|
||||
|
||||
#endif // KEYPHASEDATA_H
|
||||
42
macconfig.cpp
Normal file
42
macconfig.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "macconfig.h"
|
||||
#include "ui_macconfig.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
29
macconfig.h
Normal file
29
macconfig.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef MACCONFIG_H
|
||||
#define MACCONFIG_H
|
||||
|
||||
#include <QWidget>
|
||||
#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
|
||||
74
macconfig.ui
Normal file
74
macconfig.ui
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MacConfig</class>
|
||||
<widget class="QWidget" name="MacConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>mac配置</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>80</y>
|
||||
<width>54</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MAC:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>80</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>212</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>212</y>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
853
mainwindow.cpp
853
mainwindow.cpp
File diff suppressed because it is too large
Load Diff
11
mainwindow.h
11
mainwindow.h
@ -45,6 +45,9 @@ private:
|
||||
QTcpSocket *socket;
|
||||
|
||||
QProgressBar *progressBar;
|
||||
CardType card_type;
|
||||
int current_slot;
|
||||
QString tsi_config_file;
|
||||
|
||||
void createMenu();
|
||||
void createMenu(const QString& rootTitle, QPushButton* button = nullptr);
|
||||
@ -56,13 +59,19 @@ private:
|
||||
void getVersion(int slot);
|
||||
void initStyle();
|
||||
void connectServer();
|
||||
|
||||
private slots:
|
||||
|
||||
void onDisConnected();
|
||||
void onConnected();
|
||||
void readData(const QByteArray&);
|
||||
void onerrorOccurred(const QString &errorMsg);
|
||||
void onMenuAction_relay();
|
||||
void OnButtonGroup(QAbstractButton *);
|
||||
void onConnect();
|
||||
void onDisconnect();
|
||||
void onEthConfig();
|
||||
void onMACConfig();
|
||||
|
||||
void onMenuActionTriggered();
|
||||
void on_pushButton_slot_clicked();
|
||||
@ -71,5 +80,7 @@ private slots:
|
||||
void on_pushButton_point_name_clicked();
|
||||
void on_pushButton_save_clicked();
|
||||
void on_pushButton_open_clicked();
|
||||
void on_pushButton_download_clicked();
|
||||
void on_pushButton_upload_clicked();
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
172
mainwindow.ui
172
mainwindow.ui
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>TSI_Config</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -50,7 +50,7 @@
|
||||
<widget class="QPushButton" name="pushButton_save">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<x>80</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -75,7 +75,7 @@
|
||||
<widget class="QPushButton" name="pushButton_open">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -94,35 +94,10 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_23">
|
||||
<widget class="QPushButton" name="pushButton_upload">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
@ -144,13 +119,13 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>上传</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_24">
|
||||
<widget class="QPushButton" name="pushButton_download">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<x>190</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
@ -169,82 +144,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_25">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>20</y>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>45</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>下载</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -831,7 +731,7 @@
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -850,7 +750,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -869,7 +769,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -888,7 +788,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1121,17 +1021,18 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1129</width>
|
||||
<height>21</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
<widget class="QMenu" name="menu_start">
|
||||
<property name="title">
|
||||
<string>文件</string>
|
||||
<string>开始</string>
|
||||
</property>
|
||||
<addaction name="actionNEW"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actiondaoru"/>
|
||||
<addaction name="actionlianjie"/>
|
||||
<addaction name="action_new"/>
|
||||
<addaction name="action_open"/>
|
||||
<addaction name="action_import"/>
|
||||
<addaction name="action_connect"/>
|
||||
<addaction name="action_disconnect"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_2">
|
||||
<property name="title">
|
||||
@ -1144,18 +1045,20 @@
|
||||
</property>
|
||||
<addaction name="action_realy"/>
|
||||
<addaction name="action_time"/>
|
||||
<addaction name="action_eth"/>
|
||||
<addaction name="action_mac"/>
|
||||
</widget>
|
||||
<addaction name="menu"/>
|
||||
<addaction name="menu_2"/>
|
||||
<addaction name="menu_start"/>
|
||||
<addaction name="menu_tool"/>
|
||||
<addaction name="menu_2"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionNEW">
|
||||
<action name="action_new">
|
||||
<property name="text">
|
||||
<string>新建</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<action name="action_open">
|
||||
<property name="text">
|
||||
<string>打开</string>
|
||||
</property>
|
||||
@ -1167,19 +1070,34 @@
|
||||
</action>
|
||||
<action name="action_time">
|
||||
<property name="text">
|
||||
<string>校时功能</string>
|
||||
<string>校时</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actiondaoru">
|
||||
<action name="action_import">
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionlianjie">
|
||||
<action name="action_connect">
|
||||
<property name="text">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_disconnect">
|
||||
<property name="text">
|
||||
<string>断开</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_eth">
|
||||
<property name="text">
|
||||
<string>网络配置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_mac">
|
||||
<property name="text">
|
||||
<string>MAC配置</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
56
pointname.cpp
Normal file
56
pointname.cpp
Normal file
@ -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>(cardtype);
|
||||
ui->label_slot->setText(QString::number(slot_no));
|
||||
Init();
|
||||
}
|
||||
|
||||
PointName::~PointName()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PointName::Init()
|
||||
{
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(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();
|
||||
}
|
||||
|
||||
31
pointname.h
Normal file
31
pointname.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef POINTNAME_H
|
||||
#define POINTNAME_H
|
||||
|
||||
#include <QWidget>
|
||||
#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
|
||||
211
pointname.ui
Normal file
211
pointname.ui
Normal file
@ -0,0 +1,211 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PointName</class>
|
||||
<widget class="QWidget" name="PointName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>槽位号:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_slot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>30</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>slot</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>232</y>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>232</y>
|
||||
<width>71</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>70</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>通道1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_1"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>110</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>通道2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>150</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>通道3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_3"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>190</y>
|
||||
<width>281</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>通道4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pointname_4"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -6,10 +6,13 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent)
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Radial::Radial(int slot_no_, int channel_, bool active, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Radial_vibration)
|
||||
{
|
||||
, ui(new Ui::Radial_vibration) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
@ -17,279 +20,188 @@ Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if(active)
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
else
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_filter);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_variables);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
Radial_vibration::~Radial_vibration()
|
||||
{
|
||||
Radial::~Radial() {
|
||||
delete ui;
|
||||
}
|
||||
void Radial_vibration::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
if(filePath.contains("filter_")){
|
||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
||||
for(int i = 0; i < filter_array.size(); i++){
|
||||
QJsonObject temp_obj = filter_array[i].toObject();
|
||||
filter[i].type = temp_obj["type"].toString();
|
||||
filter[i].low = temp_obj["low"].toInt();
|
||||
filter[i].high = temp_obj["high"].toInt();
|
||||
filter[i].checked = temp_obj["checked"].toBool();
|
||||
}
|
||||
}else if(filePath.contains("radial_vibration_variables_")){
|
||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||
for(int i = 0; i < variables_array.size(); i++){
|
||||
QJsonObject temp_obj = variables_array[i].toObject();
|
||||
variables[i].type = temp_obj["type"].toString();
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
}
|
||||
}
|
||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||
delay.alert = delay_obj["alert"].toInt();
|
||||
delay.danger = delay_obj["danger"].toDouble();
|
||||
delay.active_100ms = delay_obj["active_100ms"].toBool();
|
||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||
alert_variables.comparision = json_obj["comparision"].toString();
|
||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||
}
|
||||
|
||||
void Radial::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Radial_vibration::Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].type == "band_pass"){
|
||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||
}
|
||||
void Radial::on_checkBox_1x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_1x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "gap"){
|
||||
ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
ui->checkBox_1x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
ui->checkBox_2x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
ui->checkBox_not_1x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
ui->checkBox_smax_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value);
|
||||
}
|
||||
}
|
||||
ui->spinBox_alert_delay->setValue(delay.alert);
|
||||
ui->doubleSpinBox_danger_delay->setValue(delay.danger);
|
||||
ui->checkBox_100ms_delay->setChecked(delay.active_100ms);
|
||||
ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching);
|
||||
ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching);
|
||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||
ui->comboBox_1x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
void Radial_vibration::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].checked){
|
||||
if(filter[i].type == "band_pass"){
|
||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
}else if(variables[i].type == "gap"){
|
||||
variables[i].full_sacle_range = ui->comboBox_gap_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_gap_clamp->value();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "not_1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_not_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_not_1x_ampl->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_not_1x_ampl_clamp->value();
|
||||
}else if(variables[i].type == "smax_ampl"){
|
||||
variables[i].checked = ui->checkBox_smax_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_smax_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_smax_clamp->value();
|
||||
}
|
||||
}
|
||||
delay.alert = ui->spinBox_alert_delay->value();
|
||||
delay.danger = ui->doubleSpinBox_danger_delay->value();
|
||||
delay.active_100ms = ui->checkBox_100ms_delay->isChecked();
|
||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||
QJsonObject filter_obj,variables_obj;
|
||||
QJsonArray filter_array;
|
||||
for(int i = 0; i < 3; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",filter[i].type);
|
||||
temp_obj.insert("low",filter[i].low);
|
||||
temp_obj.insert("high",filter[i].high);
|
||||
temp_obj.insert("checked",filter[i].checked);
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 6; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",variables[i].type);
|
||||
if(variables[i].type == "direct"){
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}else if(variables[i].type == "gap"){
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
}else if(variables[i].type == "not_1x_ampl" || variables[i].type == "smax_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}
|
||||
variables_array.append(temp_obj);
|
||||
}
|
||||
variables_obj.insert("variables",variables_array);
|
||||
QJsonObject delay_obj;
|
||||
delay_obj.insert("alert",delay.alert);
|
||||
delay_obj.insert("danger",delay.danger);
|
||||
delay_obj.insert("100ms",delay.active_100ms);
|
||||
variables_obj.insert("delay",delay_obj);
|
||||
variables_obj.insert("alert_latching",alert_variables.alert_latching);
|
||||
variables_obj.insert("danger_latching",alert_variables.danger_latching);
|
||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||
variables_obj.insert("comparision",alert_variables.comparision);
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file_filter(filePath_filter);
|
||||
QFile file_variables(filePath_variables);
|
||||
if (!file_filter.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_filter;
|
||||
void Radial::on_checkBox_2x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_2x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if (!file_variables.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_variables;
|
||||
ui->comboBox_2x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
void Radial::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
QJsonDocument jsonDoc_filter(filter_obj);
|
||||
QJsonDocument jsonDoc_variables(variables_obj);
|
||||
file_filter.write(jsonDoc_filter.toJson());
|
||||
file_variables.write(jsonDoc_variables.toJson());
|
||||
file_filter.close();
|
||||
file_variables.close();
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibRadial) {
|
||||
qDebug() << "[Radial::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Radial::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RadialVariable> variable_ptr = std::dynamic_pointer_cast<RadialVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(variable_ptr->direct_.full_scale_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
|
||||
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
|
||||
// ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
// ui->comboBox_bias_volt_range->setCurrentIndex();
|
||||
ui->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag);
|
||||
ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag);
|
||||
ui->spinBox_alert->setValue(variable_ptr->delay_.alert);
|
||||
ui->doubleSpinBox_danger->setValue(variable_ptr->delay_.danger);
|
||||
ui->checkBox_100ms->setChecked(variable_ptr->delay_.active_100ms);
|
||||
ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_);
|
||||
ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_);
|
||||
ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage);
|
||||
}
|
||||
|
||||
void Radial::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Radial::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibRadial) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibRadial;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RadialVariable> variable = std::dynamic_pointer_cast<RadialVariable>(variable_base);
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Radial_vibration::on_pushButton_set_default_clicked()
|
||||
{
|
||||
|
||||
void Radial::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
|
||||
@ -7,28 +7,24 @@ namespace Ui {
|
||||
class Radial_vibration;
|
||||
}
|
||||
|
||||
class Radial_vibration : public QWidget
|
||||
{
|
||||
class Radial : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent = nullptr);
|
||||
~Radial_vibration();
|
||||
public:
|
||||
explicit Radial(int slot_no_, int channel_, bool active, QWidget *parent = nullptr);
|
||||
~Radial();
|
||||
int slot_no;
|
||||
int channel;
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_pushButton_set_default_clicked();
|
||||
|
||||
private:
|
||||
void on_checkBox_1x_ampl_toggled(bool checked);
|
||||
void on_checkBox_2x_ampl_toggled(bool checked);
|
||||
private:
|
||||
Ui::Radial_vibration *ui;
|
||||
|
||||
Filter filter[3];
|
||||
Dealy delay;
|
||||
Variables variables[6];
|
||||
Alert_Variables alert_variables;
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
@ -29,68 +29,6 @@
|
||||
<attribute name="title">
|
||||
<string>传感器和滤波配置</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>241</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>传感器方向</string>
|
||||
</property>
|
||||
<widget class="QSpinBox" name="spinBox_angle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>50</y>
|
||||
<width>61</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_direction_left">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>50</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 左</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_direction_right">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>70</y>
|
||||
<width>89</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 右</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>30</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>角度</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -438,9 +376,37 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
<string>0-100 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-150 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-500 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
@ -453,6 +419,12 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_gap_clamp">
|
||||
<property name="geometry">
|
||||
@ -463,8 +435,14 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_1x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -473,13 +451,44 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
<string>0-100 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-150 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-500 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -488,6 +497,12 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_76">
|
||||
<property name="geometry">
|
||||
@ -516,6 +531,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -528,10 +546,13 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -540,8 +561,14 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -554,10 +581,13 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_2x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -566,9 +596,37 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
<string>0-100 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-150 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-500 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
@ -581,87 +639,44 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_not_1x_ampl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>240</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>非1倍频幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_not_1x_ampl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>240</y>
|
||||
<width>111</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
<string>-24 Vdc</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_not_1x_ampl_clamp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>240</y>
|
||||
<width>62</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_smax_range">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>270</y>
|
||||
<width>111</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 500 um</string>
|
||||
<string>0-100 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-150 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-200 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-400 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-500 um</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_smax_ampl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>270</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Smax 幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_smax_clamp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>270</y>
|
||||
<width>62</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_12">
|
||||
<property name="geometry">
|
||||
@ -701,7 +716,7 @@
|
||||
<string> 危险</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_danger_delay">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_danger">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
@ -720,7 +735,7 @@
|
||||
<double>99.900000000000006</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_100ms_delay">
|
||||
<widget class="QCheckBox" name="checkBox_100ms">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
@ -759,7 +774,7 @@
|
||||
<string>1.0 - 60.0s</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_alert_delay">
|
||||
<widget class="QSpinBox" name="spinBox_alert">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
@ -863,17 +878,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>间隙</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -881,31 +891,11 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>非1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Smax幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_two_ma_clamp">
|
||||
<property name="geometry">
|
||||
@ -950,6 +940,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_comparision">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -960,17 +953,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>间隙</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -978,33 +966,16 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>非1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Smax幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_comparision_percentage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -1100,6 +1071,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
@ -1111,19 +1085,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_point_name">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
@ -1139,6 +1100,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
@ -1152,6 +1116,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
|
||||
171
rangeslider.cpp
Normal file
171
rangeslider.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
#include "rangeslider.h"
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
RangeSlider::RangeSlider(int style_,QWidget *parent)
|
||||
: QWidget(parent) {
|
||||
setMinimumSize(20, 240);
|
||||
style = style_;
|
||||
}
|
||||
|
||||
void RangeSlider::setRange(int min, int max) {
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_lower = qBound(m_min, m_lower, m_max);
|
||||
m_upper = qBound(m_lower, m_upper, m_max);
|
||||
update();
|
||||
}
|
||||
|
||||
void RangeSlider::setSliderWidth(int width) {
|
||||
sliderWidth = width;
|
||||
update(); // 更新界面
|
||||
}
|
||||
|
||||
float RangeSlider::lowerValue() const { return m_lower; }
|
||||
float RangeSlider::upperValue() const { return m_upper; }
|
||||
|
||||
float RangeSlider::valueToY(float value) const {
|
||||
double ratio = (value - m_min) / double(m_max - m_min);
|
||||
return height() - handleRadius - ratio * (height() - 2 * handleRadius);
|
||||
}
|
||||
|
||||
float RangeSlider::yToValue(float y) const {
|
||||
double ratio = (height() - handleRadius - y) / double(height() - 2 * handleRadius);
|
||||
ratio = qBound(0.0, ratio, 1.0);
|
||||
float rawValue = m_min + ratio * (m_max - m_min);
|
||||
float steppedValue = qRound(rawValue * 10) / 10.0f;
|
||||
return qBound(m_min, steppedValue, m_max);
|
||||
}
|
||||
|
||||
RangeSlider::HandleType RangeSlider::handleHitTest(float y) const {
|
||||
int yLower = valueToY(m_lower);
|
||||
int yUpper = valueToY(m_upper);
|
||||
if (qAbs(y - yLower) <= handleRadius + 2) return LowerHandle;
|
||||
if (qAbs(y - yUpper) <= handleRadius + 2) return UpperHandle;
|
||||
return NoHandle;
|
||||
}
|
||||
|
||||
void RangeSlider::mousePressEvent(QMouseEvent *event) {
|
||||
currentHandle = handleHitTest(event->pos().y());
|
||||
}
|
||||
|
||||
void RangeSlider::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (currentHandle == NoHandle) return;
|
||||
|
||||
float val = yToValue(event->pos().y());
|
||||
if (currentHandle == LowerHandle) {
|
||||
m_lower = qBound(m_min, val, m_upper);
|
||||
} else if (currentHandle == UpperHandle) {
|
||||
m_upper = qBound(m_lower, val, m_max);
|
||||
}
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
|
||||
void RangeSlider::mouseReleaseEvent(QMouseEvent *) {
|
||||
currentHandle = NoHandle;
|
||||
}
|
||||
|
||||
void RangeSlider::paintEvent(QPaintEvent *) {
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
int x = width() / 2;
|
||||
int yLower = valueToY(m_lower);
|
||||
int yUpper = valueToY(m_upper);
|
||||
|
||||
// Draw Temperature-style background (gradient)
|
||||
drawTemperatureStyle(&p);
|
||||
|
||||
// Draw selected range (green)
|
||||
// Draw selected range (green)
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(Qt::green);
|
||||
p.drawRect(x - sliderWidth / 2, yUpper, sliderWidth, yLower - yUpper);
|
||||
|
||||
// Draw simple black handles (lines)
|
||||
p.setPen(QPen(Qt::black, 2));
|
||||
p.drawLine(x - sliderWidth / 2, yLower, x + sliderWidth, yLower);
|
||||
p.drawLine(x - sliderWidth / 2, yUpper, x + sliderWidth, yUpper);
|
||||
|
||||
// Draw ticks
|
||||
drawTicks(&p);
|
||||
}
|
||||
void RangeSlider::setLowerValue(float val) {
|
||||
m_lower = qBound(m_min, val, m_upper);
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
|
||||
void RangeSlider::setUpperValue(float val) {
|
||||
m_upper = qBound(m_lower, val, m_max);
|
||||
update();
|
||||
emit rangeChanged(m_lower, m_upper);
|
||||
}
|
||||
void RangeSlider::drawTemperatureStyle(QPainter *p) {
|
||||
int x = width() / 2;
|
||||
int yTop = handleRadius;
|
||||
int yBottom = height() - handleRadius;
|
||||
|
||||
// Draw border (black)
|
||||
p->setPen(Qt::black);
|
||||
p->setBrush(Qt::NoBrush);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, yBottom - yTop);
|
||||
|
||||
// Draw yellow outside the range
|
||||
if(style != 0){
|
||||
p->setBrush(Qt::red);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, valueToY(m_lower) - yTop); // Above lower range
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, yBottom - valueToY(m_upper)); // Below upper range
|
||||
}else{
|
||||
p->setBrush(Qt::yellow);
|
||||
p->drawRect(x - sliderWidth / 2, yTop, sliderWidth, valueToY(m_lower) - yTop); // Above lower range
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, yBottom - valueToY(m_upper)); // Below upper range
|
||||
}
|
||||
|
||||
// Draw green inside the range
|
||||
p->setBrush(Qt::green);
|
||||
p->drawRect(x - sliderWidth / 2, valueToY(m_upper), sliderWidth, valueToY(m_lower) - valueToY(m_upper)); // Green area
|
||||
}
|
||||
int RangeSlider::niceStep(int range, int maxLabels) {
|
||||
double rawStep = static_cast<double>(range) / maxLabels;
|
||||
|
||||
// 取一个"好看"的步长
|
||||
double magnitude = pow(10, floor(log10(rawStep))); // 10 的整数次幂
|
||||
double residual = rawStep / magnitude;
|
||||
|
||||
double niceResidual;
|
||||
if (residual < 1.5)
|
||||
niceResidual = 1;
|
||||
else if (residual < 3)
|
||||
niceResidual = 2;
|
||||
else if (residual < 7)
|
||||
niceResidual = 5;
|
||||
else
|
||||
niceResidual = 10;
|
||||
|
||||
return static_cast<int>(niceResidual * magnitude);
|
||||
}
|
||||
void RangeSlider::drawTicks(QPainter *p) {
|
||||
int range = m_max - m_min;
|
||||
int labelStep = niceStep(range, 10);
|
||||
int minorStep = qMax(1, labelStep / 5);
|
||||
|
||||
int x = width() / 2 + handleRadius + 4;
|
||||
p->setFont(QFont("Arial", 8));
|
||||
|
||||
for (int val = m_min; val <= m_max; val += minorStep) {
|
||||
int y = valueToY(val);
|
||||
|
||||
if (val % labelStep == 0) {
|
||||
p->setPen(QPen(Qt::black, 1.5)); // 主刻度
|
||||
p->drawLine(x, y, x + 6, y);
|
||||
p->drawText(x + 10, y + 4, QString::number(val));
|
||||
} else {
|
||||
p->setPen(QPen(Qt::gray, 1)); // 次刻度
|
||||
p->drawLine(x, y, x + 3, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
rangeslider.h
Normal file
48
rangeslider.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef RANGESLIDER_H
|
||||
#define RANGESLIDER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class RangeSlider : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RangeSlider(int style_ = 0,QWidget *parent = nullptr);
|
||||
|
||||
void setRange(int min, int max);
|
||||
void setSliderWidth(int width); // 新增方法:设置宽度
|
||||
float lowerValue() const;
|
||||
float upperValue() const;
|
||||
void setLowerValue(float val);
|
||||
void setUpperValue(float val);
|
||||
float m_lower = 3.5;
|
||||
float m_upper = 6.5;
|
||||
int style = 0;
|
||||
signals:
|
||||
void rangeChanged(float lower, float upper);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseMoveEvent(QMouseEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
|
||||
private:
|
||||
float m_min = 0;
|
||||
float m_max = 10;
|
||||
|
||||
int sliderWidth = 10; // 默认宽度(可以根据需求调整)
|
||||
|
||||
int handleRadius = 8;
|
||||
enum HandleType { NoHandle, LowerHandle, UpperHandle };
|
||||
HandleType currentHandle = NoHandle;
|
||||
|
||||
float valueToY(float value) const;
|
||||
float yToValue(float y) const;
|
||||
HandleType handleHitTest(float y) const;
|
||||
int niceStep(int range, int maxLabels);
|
||||
void drawTicks(QPainter *p);
|
||||
void drawTemperatureStyle(QPainter *p);
|
||||
};
|
||||
|
||||
#endif // RANGESLIDER_H
|
||||
121
relaysetting.cpp
121
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";
|
||||
@ -98,19 +92,17 @@ void RelaySetting::readJsonFile(const QString &filePath)
|
||||
QJsonObject obj = value.toObject();
|
||||
slot_config.slot = obj["slot"].toInt();
|
||||
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 +111,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 ;
|
||||
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 ;
|
||||
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 +165,14 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button)
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelaySettingRsp relay_setting_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
memcpy(&relay_setting_rsp,response.data() + sizeof(PackageHead),sizeof(RelaySettingRsp));
|
||||
qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code << endl;
|
||||
memcpy(&header, response.data(), sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len ;
|
||||
memcpy(&relay_setting_rsp, response.data() + sizeof(PackageHead), sizeof(RelaySettingRsp));
|
||||
qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code ;
|
||||
}
|
||||
}
|
||||
|
||||
void RelaySetting::on_pushButton_status_clicked()
|
||||
{
|
||||
void RelaySetting::on_pushButton_status_clicked() {
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
socket.connectToHost(g_strServerIp, 10000);
|
||||
@ -188,18 +180,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 ;
|
||||
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 +199,17 @@ void RelaySetting::on_pushButton_status_clicked()
|
||||
QByteArray response = socket.readAll();
|
||||
PackageHead header;
|
||||
RelayStatusRsp relay_status_rsp;
|
||||
memcpy(&header,response.data(),sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len << endl;
|
||||
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)
|
||||
memcpy(&header, response.data(), sizeof(PackageHead));
|
||||
qDebug() << "header len" << header.len ;
|
||||
memcpy(&relay_status_rsp, response.data() + sizeof(PackageHead), sizeof(RelayStatusRsp));
|
||||
qDebug() << "relay_setting_rsp status" << relay_status_rsp.status ;
|
||||
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("工作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1024,17 +1024,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>绿色闪烁</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_TX_RX</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>绿色</string>
|
||||
<string>黄绿色闪烁</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_TX_RX</string>
|
||||
@ -1168,7 +1158,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="text">
|
||||
<string>绿色</string>
|
||||
<string>黄绿</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_OK</string>
|
||||
@ -1328,24 +1318,24 @@
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup_16"/>
|
||||
<buttongroup name="buttonGroup_12"/>
|
||||
<buttongroup name="buttonGroup_TX_RX"/>
|
||||
<buttongroup name="buttonGroup_OK"/>
|
||||
<buttongroup name="buttonGroup_9"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup_8"/>
|
||||
<buttongroup name="buttonGroup_TEST"/>
|
||||
<buttongroup name="buttonGroup_1"/>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup_6"/>
|
||||
<buttongroup name="buttonGroup_4"/>
|
||||
<buttongroup name="buttonGroup_7"/>
|
||||
<buttongroup name="buttonGroup_10"/>
|
||||
<buttongroup name="buttonGroup_14"/>
|
||||
<buttongroup name="buttonGroup_11"/>
|
||||
<buttongroup name="buttonGroup_5"/>
|
||||
<buttongroup name="buttonGroup_STATUS"/>
|
||||
<buttongroup name="buttonGroup_8"/>
|
||||
<buttongroup name="buttonGroup_6"/>
|
||||
<buttongroup name="buttonGroup_15"/>
|
||||
<buttongroup name="buttonGroup_OK"/>
|
||||
<buttongroup name="buttonGroup_7"/>
|
||||
<buttongroup name="buttonGroup_11"/>
|
||||
<buttongroup name="buttonGroup_3"/>
|
||||
<buttongroup name="buttonGroup_4"/>
|
||||
<buttongroup name="buttonGroup_TX_RX"/>
|
||||
<buttongroup name="buttonGroup_5"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup_TEST"/>
|
||||
<buttongroup name="buttonGroup_9"/>
|
||||
<buttongroup name="buttonGroup_12"/>
|
||||
<buttongroup name="buttonGroup_10"/>
|
||||
<buttongroup name="buttonGroup_13"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
@ -9,288 +9,328 @@
|
||||
#include "acceleration.h"
|
||||
#include "velocity.h"
|
||||
#include "radial_vibration.h"
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
Seismic_monitor::Seismic_monitor(int slot,QWidget *parent) :
|
||||
Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Seismic_monitor)
|
||||
{
|
||||
ui(new Ui::Seismic_monitor) {
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
ui->comboBox_chan_type_1->setView(new QListView());
|
||||
ui->comboBox_chan_type_2->setView(new QListView());
|
||||
ui->comboBox_chan_type_3->setView(new QListView());
|
||||
ui->comboBox_chan_type_4->setView(new QListView());
|
||||
ui->comboBox_transducer_name_1->setView(new QListView());
|
||||
ui->comboBox_transducer_name_2->setView(new QListView());
|
||||
ui->comboBox_transducer_name_3->setView(new QListView());
|
||||
ui->comboBox_transducer_name_4->setView(new QListView());
|
||||
ui->comboBox_sample_rate_1->setView(new QListView());
|
||||
ui->comboBox_sample_rate_2->setView(new QListView());
|
||||
ui->comboBox_sample_rate_3->setView(new QListView());
|
||||
ui->comboBox_sample_rate_4->setView(new QListView());
|
||||
slot_no = slot;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot_no_ = QString("%1").arg(slot_no);
|
||||
ui->label_slot_no->setText(slot_no_);
|
||||
|
||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||
readJsonFile(filePath);
|
||||
Init();
|
||||
}
|
||||
|
||||
Seismic_monitor::~Seismic_monitor()
|
||||
{
|
||||
Seismic_monitor::~Seismic_monitor() {
|
||||
delete ui;
|
||||
}
|
||||
void Seismic_monitor::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
|
||||
void Seismic_monitor::Init() {
|
||||
// for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
// ui->comboBox_transducer_name_1->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_2->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_3->addItem(vec_transducer[var].transducer_name);
|
||||
// ui->comboBox_transducer_name_4->addItem(vec_transducer[var].transducer_name);
|
||||
// }
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qDebug() << "base_ptr";
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
vib_data->slot_ = slot_no;
|
||||
vib_data->card_type_ = car_type;
|
||||
ConfigMgr::Instance()->AddCard(vib_data);
|
||||
UpdateData(vib_data);
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
qDebug() << vib_data->base_config_[i].channel_type ;
|
||||
ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->checkBox_standby_1->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_transducer_name_1->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_1->setValue(vib_data->base_config_[i].scale_factor);
|
||||
ui->checkBox_enable_1->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_1->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_1->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
ui->comboBox_sample_rate_1->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||
ui->checkBox_power_1->setChecked(vib_data->base_config_[i].power);
|
||||
} else if (i + 1 == 2) {
|
||||
ui->comboBox_chan_type_2->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_transducer_name_2->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_2->setValue(vib_data->base_config_[i].scale_factor);
|
||||
ui->checkBox_enable_2->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_2->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_2->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
ui->comboBox_sample_rate_2->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||
ui->checkBox_power_2->setChecked(vib_data->base_config_[i].power);
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_standby_2->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_transducer_name_3->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_3->setValue(vib_data->base_config_[i].scale_factor);
|
||||
ui->checkBox_enable_3->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_3->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_3->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
ui->comboBox_sample_rate_3->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||
ui->checkBox_power_3->setChecked(vib_data->base_config_[i].power);
|
||||
} else if (i + 1 == 4) {
|
||||
ui->comboBox_chan_type_4->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_transducer_name_4->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_4->setValue(vib_data->base_config_[i].scale_factor);
|
||||
ui->checkBox_enable_4->setChecked(vib_data->base_config_[i].active);
|
||||
ui->doubleSpinBox_low_4->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_4->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||
ui->comboBox_sample_rate_4->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||
ui->checkBox_power_4->setChecked(vib_data->base_config_[i].power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
if (var + 1 == 1) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_1->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_1->currentIndex();
|
||||
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_1->currentIndex();
|
||||
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_1->value();
|
||||
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_1->currentIndex();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
vib_data->base_config_[var].power = ui->checkBox_power_1->isChecked();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
} else if (var + 1 == 2) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_2->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_2->currentIndex();
|
||||
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_2->currentIndex();
|
||||
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_2->value();
|
||||
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_2->currentIndex();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
vib_data->base_config_[var].power = ui->checkBox_power_2->isChecked();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
} else if (var + 1 == 3) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_3->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_3->currentIndex();
|
||||
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_3->currentIndex();
|
||||
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_3->value();
|
||||
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_3->currentIndex();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
vib_data->base_config_[var].power = ui->checkBox_power_3->isChecked();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
} else if (var + 1 == 4) {
|
||||
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||
vib_data->base_config_[var].active = ui->checkBox_enable_4->isChecked();
|
||||
vib_data->base_config_[var].rack_type = 0;
|
||||
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_4->currentIndex();
|
||||
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_4->currentIndex();
|
||||
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_4->value();
|
||||
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_4->currentIndex();
|
||||
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
vib_data->base_config_[var].power = ui->checkBox_power_4->isChecked();
|
||||
vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
// std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||
// ConfigMgr::Instance()->AddCard(vib_data);
|
||||
// UpdateData(vib_data);
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
card_type = json_obj["card_type"].toInt();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
seismic_monitor[i].id = temp_obj["id"].toInt();
|
||||
seismic_monitor[i].channel_name = temp_obj["channle_name"].toString();
|
||||
seismic_monitor[i].standby = temp_obj["standby"].toBool();
|
||||
seismic_monitor[i].active = temp_obj["active"].toBool();
|
||||
seismic_monitor[i].rack_type = temp_obj["rack_type"].toString();
|
||||
seismic_monitor[i].tmr_group = temp_obj["tmr_group"].toString();
|
||||
seismic_monitor[i].channel_type = temp_obj["channel_type"].toString();
|
||||
seismic_monitor[i].transducer_name = temp_obj["transducer_name"].toString();
|
||||
seismic_monitor[i].scale_factor = temp_obj["scale_factor"].toString();
|
||||
seismic_monitor[i].sample_rate = temp_obj["sample_rate"].toString();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
seismic_monitor[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
seismic_monitor[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
if(seismic_monitor[i].id == 1){
|
||||
qDebug() << seismic_monitor[i].channel_type ;
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_1->setCurrentText("位移");
|
||||
}
|
||||
//ui->comboBox_transducer_name_1->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_1->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_1->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_1->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_1->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_1->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 2){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_2->setCurrentText("位移");
|
||||
}
|
||||
//ui->comboBox_transducer_name_2->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_2->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_2->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_2->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_2->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_2->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 3){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_3->setCurrentText("位移");
|
||||
}
|
||||
//ui->lineEdit_transducer_name_3->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_3->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_3->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_3->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_3->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_3->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
if(seismic_monitor[i].id == 4){
|
||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("加速度");
|
||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("速度");
|
||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||
ui->comboBox_chan_type_4->setCurrentText("位移");
|
||||
}
|
||||
//ui->lineEdit_transducer_name_4->setText(seismic_monitor[i].transducer_name);
|
||||
ui->lineEdit_scale_factor_4->setText(seismic_monitor[i].scale_factor);
|
||||
ui->checkBox_enable_4->setCheckable(seismic_monitor[i].active);
|
||||
ui->doubleSpinBox_low_4->setValue(seismic_monitor[i].normal_voltage_low);
|
||||
ui->doubleSpinBox_high_4->setValue(seismic_monitor[i].normal_voltage_high);
|
||||
if(seismic_monitor[i].sample_rate == "32000"){
|
||||
ui->comboBox_sample_rate_4->setCurrentText("32 k");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int var = 0; var < CHANNLE_COUNT; ++var){
|
||||
if(seismic_monitor[var].id == 1){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_1->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_1->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_1->isChecked();
|
||||
if(ui->comboBox_sample_rate_1->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
}else if(seismic_monitor[var].id == 2){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_2->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_2->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_2->isChecked();
|
||||
if(ui->comboBox_sample_rate_2->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
}else if(seismic_monitor[var].id == 3){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_3->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_3->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_3->isChecked();
|
||||
if(ui->comboBox_sample_rate_3->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
}else if(seismic_monitor[var].id == 4){
|
||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_4->currentText();
|
||||
seismic_monitor[var].scale_factor = ui->lineEdit_scale_factor_3->text();
|
||||
seismic_monitor[var].active = ui->checkBox_enable_4->isChecked();
|
||||
if(ui->comboBox_sample_rate_4->currentText() == "32 k")
|
||||
seismic_monitor[var].sample_rate = "32000";
|
||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
}
|
||||
}
|
||||
QJsonObject monitor_obj,item_obj;
|
||||
QJsonArray chan_array;
|
||||
for(int i = 0; i < CHANNLE_COUNT;i++){
|
||||
item_obj["id"] = seismic_monitor[i].id;
|
||||
item_obj["channel_name"] = seismic_monitor[i].channel_name;
|
||||
item_obj["standby"] = seismic_monitor[i].standby;
|
||||
item_obj["active"] = seismic_monitor[i].active;
|
||||
item_obj["rack_type"] = seismic_monitor[i].rack_type;
|
||||
item_obj["tmr_group"] = seismic_monitor[i].tmr_group;
|
||||
item_obj["channel_type"] = seismic_monitor[i].channel_type;
|
||||
item_obj["transducer_name"] = seismic_monitor[i].transducer_name;
|
||||
item_obj["scale_factor"] = seismic_monitor[i].scale_factor;
|
||||
item_obj["sample_rate"] = seismic_monitor[i].sample_rate;
|
||||
QJsonArray normal_voltage_array;
|
||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_low);
|
||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_high);
|
||||
item_obj["normal_voltage_range"] = normal_voltage_array;
|
||||
chan_array.append(item_obj);
|
||||
}
|
||||
monitor_obj["chan"] = chan_array;
|
||||
monitor_obj["slot"] = slot_no;
|
||||
monitor_obj["version"] = 1;
|
||||
monitor_obj["card_type"] = 1;
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(monitor_obj);
|
||||
QString file_name = QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||
QFile file(QCoreApplication::applicationDirPath() + file_name);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
UpdateData(vib_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_pushButton_set_default_clicked()
|
||||
{
|
||||
|
||||
void Seismic_monitor::on_pushButton_set_default_clicked() {
|
||||
}
|
||||
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_1_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_1_clicked() {
|
||||
channel = 1;
|
||||
if(ui->comboBox_chan_type_1->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
if (ui->comboBox_chan_type_1->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_1->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_1->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_1->isChecked());
|
||||
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_1->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_2_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_2_clicked() {
|
||||
channel = 2;
|
||||
if(ui->comboBox_chan_type_2->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
if (ui->comboBox_chan_type_2->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_2->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_2->currentText() == "速度"){
|
||||
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_2->isChecked());
|
||||
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_2->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}
|
||||
}
|
||||
void Seismic_monitor::on_pushButton_config_3_clicked()
|
||||
{
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_3_clicked() {
|
||||
channel = 3;
|
||||
if(ui->comboBox_chan_type_3->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
if (ui->comboBox_chan_type_3->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_3->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_3->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_3->isChecked());
|
||||
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_3->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_config_4_clicked()
|
||||
{
|
||||
void Seismic_monitor::on_pushButton_config_4_clicked() {
|
||||
channel = 4;
|
||||
if(ui->comboBox_chan_type_4->currentText() == "加速度"){
|
||||
Acceleration *acceleration = new Acceleration(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
if (ui->comboBox_chan_type_4->currentIndex() == kVibAcc) {
|
||||
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||
acceleration->show();
|
||||
}else if(ui->comboBox_chan_type_4->currentText() == "位移"){
|
||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibRadial) {
|
||||
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||
radial_vibration->show();
|
||||
}else if(ui->comboBox_chan_type_4->currentText() == "速度"){
|
||||
Velocity *velocity = new Velocity(slot_no,channel,ui->checkBox_enable_4->isChecked());
|
||||
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibVelocity) {
|
||||
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_4->isChecked());
|
||||
velocity->setWindowModality(Qt::ApplicationModal);
|
||||
velocity->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_1_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_1->currentIndex()) {
|
||||
case kVibRadial:
|
||||
ui->label_unit_1->setText("mV / mm");
|
||||
break;
|
||||
case kVibAcc:
|
||||
ui->label_unit_1->setText("mV / m/s^2");
|
||||
break;
|
||||
case kVibVelocity:
|
||||
ui->label_unit_1->setText("mV / mm/s");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_2->currentIndex()) {
|
||||
case kVibRadial:
|
||||
ui->label_unit_2->setText("mV / mm");
|
||||
break;
|
||||
case kVibAcc:
|
||||
ui->label_unit_2->setText("mV / m/s^2");
|
||||
break;
|
||||
case kVibVelocity:
|
||||
ui->label_unit_2->setText("mV / mm/s");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_3->currentIndex()) {
|
||||
case kVibRadial:
|
||||
ui->label_unit_3->setText("mV / mm");
|
||||
break;
|
||||
case kVibAcc:
|
||||
ui->label_unit_3->setText("mV / m/s^2");
|
||||
break;
|
||||
case kVibVelocity:
|
||||
ui->label_unit_3->setText("mV / mm/s");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_chan_type_4_currentTextChanged(const QString &arg1) {
|
||||
switch (ui->comboBox_chan_type_4->currentIndex()) {
|
||||
case kVibRadial:
|
||||
ui->label_unit_4->setText("mV / mm");
|
||||
break;
|
||||
case kVibAcc:
|
||||
ui->label_unit_4->setText("mV / m/s^2");
|
||||
break;
|
||||
case kVibVelocity:
|
||||
ui->label_unit_4->setText("mV / mm/s");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1) {
|
||||
for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
if (ui->comboBox_transducer_name_1->currentText() == vec_transducer[var].transducer_name) {
|
||||
ui->doubleSpinBox_scale_factor_1->setValue(vec_transducer[var].scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1) {
|
||||
for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
if (ui->comboBox_transducer_name_2->currentText() == vec_transducer[var].transducer_name) {
|
||||
ui->doubleSpinBox_scale_factor_2->setValue(vec_transducer[var].scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1) {
|
||||
for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
if (ui->comboBox_transducer_name_3->currentText() == vec_transducer[var].transducer_name) {
|
||||
ui->doubleSpinBox_scale_factor_3->setValue(vec_transducer[var].scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Seismic_monitor::on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1) {
|
||||
for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||
if (ui->comboBox_transducer_name_4->currentText() == vec_transducer[var].transducer_name) {
|
||||
ui->doubleSpinBox_scale_factor_4->setValue(vec_transducer[var].scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,21 +3,22 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
namespace Ui {
|
||||
class Seismic_monitor;
|
||||
}
|
||||
|
||||
class Seismic_monitor : public QWidget
|
||||
{
|
||||
class Seismic_monitor : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Seismic_monitor(int slot,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Seismic_monitor(int slot,int cardtype, QWidget *parent = nullptr);
|
||||
~Seismic_monitor();
|
||||
int slot_no;
|
||||
int channel;
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_set_default_clicked();
|
||||
@ -30,13 +31,31 @@ private slots:
|
||||
|
||||
void on_pushButton_config_4_clicked();
|
||||
|
||||
private:
|
||||
void on_comboBox_chan_type_1_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_3_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_chan_type_4_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
Ui::Seismic_monitor *ui;
|
||||
|
||||
void UpdateData(std::shared_ptr<VibrationData> vib_data);
|
||||
int card_type;
|
||||
void readJsonFile(const QString &filePath);
|
||||
SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
||||
|
||||
// void readJsonFile(const QString &filePath);
|
||||
// SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
||||
QVector<Transducer> vec_transducer;
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
2993
seismic_monitor.ui
2993
seismic_monitor.ui
File diff suppressed because it is too large
Load Diff
325
setpoint.cpp
325
setpoint.cpp
@ -1,14 +1,333 @@
|
||||
#include "Setpoint.h"
|
||||
#include "ui_Setpoint.h"
|
||||
#include "setpoint.h"
|
||||
#include "ui_setpoint.h"
|
||||
#include "config_mgr.h"
|
||||
#include <QDebug>
|
||||
#include "displacement_ds.h"
|
||||
#include "acceleration_ds.h"
|
||||
#include "velocity_ds.h"
|
||||
#include <QListView>
|
||||
|
||||
Setpoint::Setpoint(QWidget *parent) :
|
||||
Setpoint::Setpoint(int slot_no_,int cardtype,QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Setpoint)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
ui->label_slot->setText(QString::number(slot_no));
|
||||
ui->comboBox_chan->setView(new QListView());
|
||||
ui->comboBox_danger->setView(new QListView());
|
||||
Init();
|
||||
connect(ui->comboBox_chan, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &Setpoint::onComboBoxIndexChanged);
|
||||
current_index = ui->comboBox_chan->currentIndex();
|
||||
}
|
||||
|
||||
Setpoint::~Setpoint()
|
||||
{
|
||||
if(slider_direct != nullptr)
|
||||
delete slider_direct;
|
||||
if(slider_1x_ampl != nullptr)
|
||||
delete slider_1x_ampl;
|
||||
if(slider_2x_ampl != nullptr)
|
||||
delete slider_2x_ampl;
|
||||
if(slider_danger != nullptr)
|
||||
delete slider_danger;
|
||||
delete ui;
|
||||
}
|
||||
void Setpoint::Init(){
|
||||
|
||||
QVBoxLayout *layout_direct = new QVBoxLayout(ui->widget_direct);
|
||||
slider_direct = new RangeSlider;
|
||||
layout_direct->addWidget(slider_direct);
|
||||
|
||||
QVBoxLayout *layout_1x_ampl = new QVBoxLayout(ui->widget_1x_ampl);
|
||||
slider_1x_ampl = new RangeSlider;
|
||||
layout_1x_ampl->addWidget(slider_1x_ampl);
|
||||
|
||||
QVBoxLayout *layout_2x_ampl = new QVBoxLayout(ui->widget_2x_ampl);
|
||||
slider_2x_ampl = new RangeSlider;
|
||||
layout_2x_ampl->addWidget(slider_2x_ampl);
|
||||
|
||||
QVBoxLayout *layout_danger = new QVBoxLayout(ui->widget_danger);
|
||||
slider_danger = new RangeSlider(1);
|
||||
layout_danger->addWidget(slider_danger);
|
||||
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
vib_alert_ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
|
||||
|
||||
switch (car_type) {
|
||||
case kCardVibSingle:{
|
||||
update();
|
||||
}break;
|
||||
}
|
||||
QObject::connect(ui->lineEdit_direct_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_direct->setUpperValue(ui->lineEdit_direct_upper->text().toFloat());
|
||||
});
|
||||
QObject::connect(slider_direct, &RangeSlider::rangeChanged, [&](float low,float high) {
|
||||
ui->lineEdit_direct_upper->setText(QString::number(high));
|
||||
});
|
||||
|
||||
QObject::connect(slider_1x_ampl, &RangeSlider::rangeChanged, [&](float low, float high) {
|
||||
ui->lineEdit_1x_ampl_upper->setText(QString::number(high));
|
||||
ui->lineEdit_1x_ampl_lower->setText(QString::number(low));
|
||||
});
|
||||
QObject::connect(ui->lineEdit_1x_ampl_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_1x_ampl->setUpperValue(ui->lineEdit_1x_ampl_upper->text().toFloat());
|
||||
});
|
||||
QObject::connect(ui->lineEdit_1x_ampl_lower, &QLineEdit::editingFinished, [&]() {
|
||||
slider_1x_ampl->setLowerValue(ui->lineEdit_1x_ampl_lower->text().toFloat());
|
||||
});
|
||||
|
||||
QObject::connect(slider_2x_ampl, &RangeSlider::rangeChanged, [&](float low, float high) {
|
||||
ui->lineEdit_2x_ampl_upper->setText(QString::number(high));
|
||||
ui->lineEdit_2x_ampl_lower->setText(QString::number(low));
|
||||
});
|
||||
QObject::connect(ui->lineEdit_2x_ampl_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_1x_ampl->setUpperValue(ui->lineEdit_2x_ampl_upper->text().toFloat());
|
||||
});
|
||||
QObject::connect(ui->lineEdit_2x_ampl_lower, &QLineEdit::editingFinished, [&]() {
|
||||
slider_1x_ampl->setLowerValue(ui->lineEdit_2x_ampl_lower->text().toFloat());
|
||||
});
|
||||
|
||||
QObject::connect(slider_danger, &RangeSlider::rangeChanged, [&](float low,float high) {
|
||||
ui->lineEdit_danger_upper->setText(QString::number(high));
|
||||
});
|
||||
QObject::connect(ui->lineEdit_danger_upper, &QLineEdit::editingFinished, [&]() {
|
||||
slider_danger->setUpperValue(ui->lineEdit_danger_upper->text().toFloat());
|
||||
});
|
||||
}
|
||||
|
||||
void Setpoint::on_pushButton_confirm_clicked()
|
||||
{
|
||||
if (vib_alert_ptr == nullptr) {
|
||||
qCritical() << "[Setpoint::confirm] should not be here";
|
||||
return;
|
||||
}
|
||||
|
||||
vib_alert_ptr->alert_danger[current_index].direct_upper = ui->lineEdit_direct_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].direct_enable = ui->checkBox_direct->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_upper = ui->lineEdit_1x_ampl_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_lower = ui->lineEdit_1x_ampl_lower->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_enable = ui->checkBox_1x_ampl->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_upper = ui->lineEdit_2x_ampl_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_lower = ui->lineEdit_2x_ampl_lower->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_enable = ui->checkBox_2x_ampl->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_param = ui->comboBox_danger->currentIndex();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_enable = ui->checkBox_danger->checkState();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Setpoint::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void Setpoint::on_pushButton_set_default_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
void Setpoint::onComboBoxIndexChanged(int index){
|
||||
|
||||
vib_alert_ptr->alert_danger[current_index].direct_upper = ui->lineEdit_direct_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].direct_enable = ui->checkBox_direct->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_upper = ui->lineEdit_1x_ampl_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_lower = ui->lineEdit_1x_ampl_lower->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x1_ampl_enable = ui->checkBox_1x_ampl->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_upper = ui->lineEdit_2x_ampl_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_lower = ui->lineEdit_2x_ampl_lower->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].x2_ampl_enable = ui->checkBox_2x_ampl->checkState();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_param = ui->comboBox_danger->currentIndex();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat();
|
||||
vib_alert_ptr->alert_danger[current_index].danger_enable = ui->checkBox_danger->checkState();
|
||||
|
||||
current_index = index;
|
||||
update();
|
||||
}
|
||||
void Setpoint::update()
|
||||
{
|
||||
int chan = ui->comboBox_chan->currentIndex();
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
std::shared_ptr<VibrationData> setpoint_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
std::vector<std::shared_ptr<VariableBase>> variable_ = setpoint_data->variables_;
|
||||
if(!variable_[chan]->x1_.checked){
|
||||
ui->checkBox_1x_ampl->setEnabled(false);
|
||||
ui->lineEdit_1x_ampl_lower->setEnabled(false);
|
||||
ui->lineEdit_1x_ampl_upper->setEnabled(false);
|
||||
}
|
||||
if(!variable_[chan]->x2_.checked){
|
||||
ui->checkBox_2x_ampl->setEnabled(false);
|
||||
ui->lineEdit_2x_ampl_upper->setEnabled(false);
|
||||
ui->lineEdit_2x_ampl_lower->setEnabled(false);
|
||||
}
|
||||
if(setpoint_data->base_config_[chan].channel_type == kVibRadial){
|
||||
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,100);
|
||||
slider_danger->setRange(0,100);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,150);
|
||||
slider_danger->setRange(0,150);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,200);
|
||||
slider_danger->setRange(0,200);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||
slider_direct->setRange(0,400);
|
||||
slider_danger->setRange(0,400);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 4){
|
||||
slider_direct->setRange(0,500);
|
||||
slider_danger->setRange(0,500);
|
||||
}
|
||||
ui->label_direct->setText("um");
|
||||
ui->label_danger->setText("um");
|
||||
|
||||
}
|
||||
if(setpoint_data->base_config_[chan].channel_type == kVibAcc){
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,20);
|
||||
slider_danger->setRange(0,20);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,100);
|
||||
slider_danger->setRange(0,100);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||
slider_direct->setRange(0,200);
|
||||
slider_danger->setRange(0,200);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 4){
|
||||
slider_direct->setRange(0,250);
|
||||
slider_danger->setRange(0,250);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 5){
|
||||
slider_direct->setRange(0,400);
|
||||
slider_danger->setRange(0,400);
|
||||
}
|
||||
ui->label_direct->setText("m/s^2 pk");
|
||||
ui->label_danger->setText("m/s^2 pk");
|
||||
|
||||
if(av_ptr->rms_active_){
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,20);
|
||||
slider_danger->setRange(0,20);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,100);
|
||||
slider_danger->setRange(0,100);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||
slider_direct->setRange(0,200);
|
||||
slider_danger->setRange(0,200);
|
||||
}
|
||||
ui->label_direct->setText("m/s^2 rms");
|
||||
ui->label_danger->setText("m/s^2 rms");
|
||||
}
|
||||
|
||||
if(av_ptr->integrate_active_){
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,25);
|
||||
slider_danger->setRange(0,25);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,100);
|
||||
slider_danger->setRange(0,100);
|
||||
}
|
||||
ui->label_direct->setText("mm/s pk");
|
||||
ui->label_danger->setText("mm/s pk");
|
||||
}
|
||||
|
||||
if(av_ptr->rms_active_ && av_ptr->integrate_active_){
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,25);
|
||||
slider_danger->setRange(0,25);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}
|
||||
ui->label_direct->setText("mm/s rms");
|
||||
ui->label_danger->setText("mm/s rms");
|
||||
}
|
||||
|
||||
}
|
||||
if(setpoint_data->base_config_[chan].channel_type == kVibVelocity){
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,10);
|
||||
slider_danger->setRange(0,10);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,20);
|
||||
slider_danger->setRange(0,20);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}
|
||||
ui->label_direct->setText("mm/s pk");
|
||||
ui->label_danger->setText("mm/s pk");
|
||||
|
||||
if(av_ptr->rms_active_){
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,10);
|
||||
slider_danger->setRange(0,10);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,20);
|
||||
slider_danger->setRange(0,20);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,50);
|
||||
slider_danger->setRange(0,50);
|
||||
}
|
||||
ui->label_direct->setText("mm/s rms");
|
||||
ui->label_danger->setText("mm/s rms");
|
||||
}
|
||||
|
||||
if(av_ptr->integrate_active_){
|
||||
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||
slider_direct->setRange(0,100);
|
||||
slider_danger->setRange(0,100);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||
slider_direct->setRange(0,200);
|
||||
slider_danger->setRange(0,200);
|
||||
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||
slider_direct->setRange(0,500);
|
||||
slider_danger->setRange(0,500);
|
||||
}
|
||||
ui->label_direct->setText("um pp");
|
||||
ui->label_danger->setText("um pp");
|
||||
}
|
||||
|
||||
}
|
||||
ui->lineEdit_direct_upper->setText(QString::number(setpoint_data->alert_danger[chan].direct_upper));
|
||||
ui->checkBox_direct->setChecked(setpoint_data->alert_danger[chan].direct_enable);
|
||||
if(setpoint_data->alert_danger[chan].direct_upper > 0){
|
||||
slider_direct->m_upper = setpoint_data->alert_danger[chan].direct_upper;
|
||||
}
|
||||
ui->lineEdit_1x_ampl_upper->setText(QString::number(setpoint_data->alert_danger[chan].x1_ampl_upper));
|
||||
ui->lineEdit_1x_ampl_lower->setText(QString::number(setpoint_data->alert_danger[chan].x1_ampl_lower));
|
||||
ui->checkBox_1x_ampl->setChecked(setpoint_data->alert_danger[chan].x1_ampl_enable);
|
||||
if(setpoint_data->alert_danger[chan].x1_ampl_upper > 0 && setpoint_data->alert_danger[chan].x1_ampl_lower > 0){
|
||||
slider_1x_ampl->m_upper = setpoint_data->alert_danger[chan].x1_ampl_upper;
|
||||
slider_1x_ampl->m_lower = setpoint_data->alert_danger[chan].x1_ampl_lower;
|
||||
}
|
||||
ui->lineEdit_2x_ampl_upper->setText(QString::number(setpoint_data->alert_danger[chan].x2_ampl_upper));
|
||||
ui->lineEdit_2x_ampl_lower->setText(QString::number(setpoint_data->alert_danger[chan].x2_ampl_lower));
|
||||
ui->checkBox_2x_ampl->setChecked(setpoint_data->alert_danger[chan].x2_ampl_enable);
|
||||
if(setpoint_data->alert_danger[chan].x2_ampl_upper > 0 && setpoint_data->alert_danger[chan].x2_ampl_lower > 0){
|
||||
slider_2x_ampl->m_upper = setpoint_data->alert_danger[chan].x2_ampl_upper;
|
||||
slider_2x_ampl->m_lower = setpoint_data->alert_danger[chan].x2_ampl_lower;
|
||||
}
|
||||
ui->lineEdit_danger_upper->setText(QString::number(setpoint_data->alert_danger[chan].danger_upper));
|
||||
ui->checkBox_danger->setChecked(setpoint_data->alert_danger[chan].danger_enable);
|
||||
if(setpoint_data->alert_danger[chan].danger_upper > 0){
|
||||
slider_danger->m_upper = setpoint_data->alert_danger[chan].danger_upper;
|
||||
slider_danger->m_lower = 0;
|
||||
}
|
||||
}
|
||||
|
||||
29
setpoint.h
29
setpoint.h
@ -1,7 +1,10 @@
|
||||
#ifndef setpoint_H
|
||||
#define setpoint_H
|
||||
#ifndef SETPOINT_H
|
||||
#define SETPOINT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "data_config.h"
|
||||
#include "rangeslider.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
namespace Ui {
|
||||
class Setpoint;
|
||||
@ -12,11 +15,29 @@ class Setpoint : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Setpoint(QWidget *parent = nullptr);
|
||||
explicit Setpoint(int slot_no_,int cardtype,QWidget *parent = nullptr);
|
||||
~Setpoint();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_pushButton_set_default_clicked();
|
||||
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::Setpoint *ui;
|
||||
RangeSlider *slider_direct;
|
||||
RangeSlider *slider_1x_ampl;
|
||||
RangeSlider *slider_2x_ampl;
|
||||
RangeSlider *slider_danger;
|
||||
std::shared_ptr<VibrationData> vib_alert_ptr = nullptr;
|
||||
int current_index;
|
||||
void Init();
|
||||
void update();
|
||||
};
|
||||
|
||||
#endif // setpoint_H
|
||||
#endif // SETPOINT_H
|
||||
|
||||
777
setpoint.ui
777
setpoint.ui
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>722</width>
|
||||
<height>560</height>
|
||||
<width>734</width>
|
||||
<height>528</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>触发配置</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
@ -25,86 +25,117 @@
|
||||
<property name="title">
|
||||
<string>危险 / 警报 2</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboBox_4">
|
||||
<widget class="QComboBox" name="comboBox_danger">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>69</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>30</y>
|
||||
<width>69</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_5">
|
||||
<widget class="QLabel" name="label_danger">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<y>60</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_danger">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>415</y>
|
||||
<width>47</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>23</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_19">
|
||||
<widget class="QLineEdit" name="lineEdit_danger_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
<x>30</x>
|
||||
<y>90</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_danger" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>116</y>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -112,69 +143,126 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>520</y>
|
||||
<width>119</width>
|
||||
<height>22</height>
|
||||
<y>480</y>
|
||||
<width>666</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>槽位号2</string>
|
||||
<string>槽位号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_6">
|
||||
<widget class="QLabel" name="label_slot">
|
||||
<property name="text">
|
||||
<string>slot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_chan">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置为默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>500</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -187,257 +275,344 @@
|
||||
<property name="title">
|
||||
<string>告警 / 警报 1</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<widget class="QWidget" name="widget_1x_ampl" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
<x>100</x>
|
||||
<y>110</y>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>23</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>40</y>
|
||||
<x>121</x>
|
||||
<y>41</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_28">
|
||||
<widget class="QLineEdit" name="lineEdit_1x_ampl_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<x>121</x>
|
||||
<y>77</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_29">
|
||||
<widget class="QLabel" name="label_1x">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>420</y>
|
||||
<width>61</width>
|
||||
<x>130</x>
|
||||
<y>59</y>
|
||||
<width>50</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_1x_ampl_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>380</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_8">
|
||||
<widget class="QCheckBox" name="checkBox_1x_ampl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>197</x>
|
||||
<y>390</y>
|
||||
<width>21</width>
|
||||
<x>121</x>
|
||||
<y>420</y>
|
||||
<width>47</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_30">
|
||||
<widget class="QCheckBox" name="checkBox_2x_ampl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>140</y>
|
||||
<width>54</width>
|
||||
<height>231</height>
|
||||
<x>221</x>
|
||||
<y>420</y>
|
||||
<width>47</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 刻度</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>100</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>70</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>mil pp</string>
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>187</x>
|
||||
<y>40</y>
|
||||
<x>221</x>
|
||||
<y>41</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>520</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>复制</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_2x">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>59</y>
|
||||
<width>50</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_2x_ampl_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>221</x>
|
||||
<y>77</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_2x_ampl" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>110</y>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_2x_ampl_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>380</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_direct_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>80</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_direct" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>107</y>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_direct">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>25</x>
|
||||
<y>60</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>- -</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_direct">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>420</y>
|
||||
<width>65</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
125
setpoint_tachometer.cpp
Normal file
125
setpoint_tachometer.cpp
Normal file
@ -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>(cardtype);
|
||||
ui->label_slot->setText(QString::number(slot_no));
|
||||
Init();
|
||||
connect(ui->comboBox_chan, QOverload<int>::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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
speed_alert_ptr = std::dynamic_pointer_cast<TachometerData>(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<TachometerData> setpoint_data = std::dynamic_pointer_cast<TachometerData>(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();
|
||||
}
|
||||
|
||||
37
setpoint_tachometer.h
Normal file
37
setpoint_tachometer.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef SETPOINT_TACHOMETER_H
|
||||
#define SETPOINT_TACHOMETER_H
|
||||
|
||||
#include <QWidget>
|
||||
#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<TachometerData> speed_alert_ptr = nullptr;
|
||||
int current_index;
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // SETPOINT_TACHOMETER_H
|
||||
375
setpoint_tachometer.ui
Normal file
375
setpoint_tachometer.ui
Normal file
@ -0,0 +1,375 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Setpoint_Tachometer</class>
|
||||
<widget class="QWidget" name="Setpoint_Tachometer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>710</width>
|
||||
<height>522</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>触发配置</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>480</y>
|
||||
<width>666</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>槽位号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_slot">
|
||||
<property name="text">
|
||||
<string>slot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_chan">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>通道 4</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置为默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>540</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>危险 / 警报 2</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>rpm</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>80</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_danger" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>107</y>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>521</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>告警 / 警报 1</string>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>80</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_alert" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>107</y>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>260</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>20</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>36</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>rpm</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_alert_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>420</y>
|
||||
<width>65</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_alert_upper">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>65</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_lower">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>380</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
206
singlerelay.cpp
206
singlerelay.cpp
@ -1,14 +1,210 @@
|
||||
#include "singlerelay.h"
|
||||
#include "ui_singlerelay.h"
|
||||
#include "vibrationdata.h"
|
||||
|
||||
SingleRelay::SingleRelay(QWidget *parent)
|
||||
SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::SingleRelay)
|
||||
{
|
||||
, ui(new Ui::SingleRelay) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
ui->label_slot_no->setText(QString::number(slot_no));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
||||
list_widget_available = new QListWidget();
|
||||
layout_available->addWidget(list_widget_available);
|
||||
list_widget_available->setDragEnabled(true);
|
||||
|
||||
QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay);
|
||||
treeView_relay = new QTreeView;
|
||||
layout_relay->addWidget(treeView_relay);
|
||||
treeView_relay->setDragEnabled(true); // 启用拖动
|
||||
treeView_relay->setAcceptDrops(true); // 接受放下
|
||||
treeView_relay->setDropIndicatorShown(true); // 显示放置指示器
|
||||
treeView_relay->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
model_Relay = new DropTreeModel(this); //创建模型指定父类
|
||||
treeView_relay->setModel(model_Relay);
|
||||
treeView_relay->setHeaderHidden(true);
|
||||
|
||||
btnGroup_slot = new QButtonGroup(this);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot1);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot2);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot3);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot4);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot5);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot6);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot7);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot8);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot9);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot10);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot11);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot12);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot13);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot14);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot15);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot16);
|
||||
|
||||
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
||||
connect(ui->comboBox_relay_ch, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &SingleRelay::onComboBoxIndexChanged);
|
||||
Init();
|
||||
current_index = ui->comboBox_relay_ch->currentIndex();
|
||||
if(single_relay_nok_data->single_relay_nok[current_index].logic_expression != ""){
|
||||
QString channel_name = channelNameMap[single_relay_nok_data->single_relay_nok[current_index].logic_expression];
|
||||
QStandardItem *item = new QStandardItem(channel_name);
|
||||
item->setData(single_relay_nok_data->single_relay_nok[current_index].logic_expression,Qt::UserRole);
|
||||
model_Relay->appendRow(item);
|
||||
}
|
||||
}
|
||||
|
||||
SingleRelay::~SingleRelay()
|
||||
{
|
||||
SingleRelay::~SingleRelay() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SingleRelay::Init(){
|
||||
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 1; i < buttonList.count() + 1; i++) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i);
|
||||
if(base_ptr != nullptr){
|
||||
switch (base_ptr->card_type_) {
|
||||
case kCardVibSingle :{
|
||||
buttonList[i - 1]->setText("振动");
|
||||
break;
|
||||
}
|
||||
case kCardKeyphaseSingle:{
|
||||
buttonList[i - 1]->setText("键相");
|
||||
break;
|
||||
}
|
||||
case kCardSpeedSingle:{
|
||||
buttonList[i - 1]->setText("转速");
|
||||
break;
|
||||
}
|
||||
case kCardRelaySingle:
|
||||
case kCardRelaySingleNOK:
|
||||
case kCardRelayTMRPrimary:{
|
||||
buttonList[i - 1]->setText("继电器");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
single_relay_nok_data = std::make_shared<SingleRelayDataNOK>();
|
||||
single_relay_nok_data->card_type_ = car_type;
|
||||
single_relay_nok_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(single_relay_nok_data);
|
||||
return;
|
||||
}
|
||||
single_relay_nok_data = std::dynamic_pointer_cast<SingleRelayDataNOK>(base_ptr);
|
||||
for(int i = 0 ; i < SLOT_NUM ; i++){
|
||||
std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
|
||||
if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardVibSingle){
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(cardbase_ptr);
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
QString item_data,item_str;
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1P##NO").arg(ptr->base_config_[var].chan_id);
|
||||
channelNameMap[item_data] = item_str;
|
||||
}
|
||||
}else if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardSpeedSingle){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void SingleRelay::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||
if (slot_btn != NULL) {
|
||||
list_widget_available->clear();
|
||||
QString object_name = slot_btn->objectName();
|
||||
qDebug() << object_name ;
|
||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr->card_type_ == kCardVibSingle){
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if((vib_data->base_config_[var].standby && (var % 2)))
|
||||
continue;
|
||||
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(vib_data->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
QString item_data = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}else if(base_ptr->card_type_ == kCardSpeedSingle){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SingleRelay::on_pushButton_enter_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SingleRelay::on_pushButton_clr_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SingleRelay::on_pushButton_backspace_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
void SingleRelay::keyPressEvent(QKeyEvent *event) {
|
||||
// if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
|
||||
// removeLastElement();
|
||||
// return;
|
||||
// }
|
||||
// QTextEdit::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void SingleRelay::on_pushButton_confirm_clicked()
|
||||
{
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QStandardItem *topItem = root->child(0);
|
||||
QString finalExpr;
|
||||
QVariant userData = topItem->data(Qt::UserRole);
|
||||
QString user_text = userData.toString().trimmed();
|
||||
single_relay_nok_data->single_relay_nok[current_index].logic_expression = user_text;
|
||||
this->close();
|
||||
}
|
||||
void SingleRelay::onComboBoxIndexChanged(int index){
|
||||
|
||||
qDebug()<< "[SingleRelay]:index " << index;
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
if(root->rowCount() > 0){
|
||||
QStandardItem *topItem = root->child(0);
|
||||
QString finalExpr;
|
||||
QVariant userData = topItem->data(Qt::UserRole);
|
||||
QString user_text = userData.toString().trimmed();
|
||||
single_relay_nok_data->single_relay_nok[current_index].logic_expression = user_text;
|
||||
}
|
||||
current_index = index;
|
||||
|
||||
if(single_relay_nok_data->single_relay_nok[index].logic_expression != ""){
|
||||
model_Relay->clear();
|
||||
QString channel_name = channelNameMap[single_relay_nok_data->single_relay_nok[current_index].logic_expression];
|
||||
QStandardItem *item = new QStandardItem(channel_name);
|
||||
item->setData(single_relay_nok_data->single_relay_nok[current_index].logic_expression,Qt::UserRole);
|
||||
model_Relay->appendRow(item);
|
||||
}else{
|
||||
model_Relay->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,21 +2,53 @@
|
||||
#define SINGLERELAY_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTextEdit>
|
||||
#include <QButtonGroup>
|
||||
#include <QPushButton>
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "singlerelay_data.h"
|
||||
#include <QStandardItemModel> //数据模型类
|
||||
#include <QTreeView>
|
||||
|
||||
namespace Ui {
|
||||
class SingleRelay;
|
||||
}
|
||||
|
||||
class SingleRelay : public QDialog
|
||||
{
|
||||
class SingleRelay : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SingleRelay(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit SingleRelay(int slot,int cardtype,QWidget *parent = nullptr);
|
||||
~SingleRelay();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void on_pushButton_cancel_clicked();
|
||||
void OnButtonGroup(QAbstractButton *);
|
||||
|
||||
void on_pushButton_enter_clicked();
|
||||
|
||||
void on_pushButton_backspace_clicked();
|
||||
|
||||
void on_pushButton_clr_clicked();
|
||||
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::SingleRelay *ui;
|
||||
QButtonGroup * btnGroup_slot = nullptr;
|
||||
QListWidget *list_widget_available = nullptr;
|
||||
QTreeView *treeView_relay;
|
||||
QStandardItemModel *model_Relay;
|
||||
std::shared_ptr<SingleRelayDataNOK> single_relay_nok_data = nullptr;
|
||||
int current_index;
|
||||
QMap<QString, QString> channelNameMap;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // SINGLERELAY_H
|
||||
|
||||
268
singlerelay.ui
268
singlerelay.ui
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>943</width>
|
||||
<width>924</width>
|
||||
<height>569</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>继电器组态</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
@ -26,7 +26,7 @@
|
||||
<string>告警驱动逻辑:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_10">
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
@ -52,44 +52,11 @@
|
||||
<string>NCT6100T</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>690</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>或(*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>380</y>
|
||||
<width>551</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</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">
|
||||
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;">
|
||||
<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>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>30</y>
|
||||
<y>10</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@ -98,10 +65,13 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>可用的告警:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<x>420</x>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
@ -111,36 +81,6 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>打 印...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>50</y>
|
||||
<width>301</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C01P##NO (Slot 2 Channel 1 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C02P##NO (Slot 2 Channel 2 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C03P##NO (Slot 2 Channel 3 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S02C04P##NO (Slot 2 Channel 4 Not OK)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -153,7 +93,7 @@ li.checked::marker { content: "\2612"; }
|
||||
<property name="title">
|
||||
<string>继电器关联</string>
|
||||
</property>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<widget class="QComboBox" name="comboBox_relay_ch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
@ -270,58 +210,6 @@ li.checked::marker { content: "\2612"; }
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>690</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>113</x>
|
||||
<y>9</y>
|
||||
<width>31</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 13</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>与(*)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -335,10 +223,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>继电器槽位:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<widget class="QPushButton" name="pushButton_enter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>760</x>
|
||||
<x>630</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>71</height>
|
||||
@ -348,10 +236,13 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>Enter</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_12">
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
<x>520</x>
|
||||
<y>530</y>
|
||||
<width>81</width>
|
||||
<height>32</height>
|
||||
@ -361,10 +252,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>帮 助</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<widget class="QPushButton" name="pushButton_clr">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<x>710</x>
|
||||
<y>270</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
@ -374,10 +265,10 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>CLR</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<widget class="QPushButton" name="pushButton_backspace">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<x>710</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>31</height>
|
||||
@ -387,24 +278,11 @@ 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>
|
||||
<y>530</y>
|
||||
<width>71</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
@ -413,7 +291,7 @@ li.checked::marker { content: "\2612"; }
|
||||
<string>取 消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<widget class="QPushButton" name="pushButton_alert_signal">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
@ -798,7 +676,7 @@ li.checked::marker { content: "\2612"; }
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_17">
|
||||
<widget class="QPushButton" name="pushButton_slot1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -812,12 +690,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_18">
|
||||
<widget class="QPushButton" name="pushButton_slot2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -831,12 +709,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_20">
|
||||
<widget class="QPushButton" name="pushButton_slot3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -850,12 +728,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_19">
|
||||
<widget class="QPushButton" name="pushButton_slot4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -869,12 +747,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_24">
|
||||
<widget class="QPushButton" name="pushButton_slot5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -888,12 +766,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_23">
|
||||
<widget class="QPushButton" name="pushButton_slot6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -907,12 +785,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_22">
|
||||
<widget class="QPushButton" name="pushButton_slot7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -926,12 +804,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_21">
|
||||
<widget class="QPushButton" name="pushButton_slot8">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -945,12 +823,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_32">
|
||||
<widget class="QPushButton" name="pushButton_slot9">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -964,12 +842,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_31">
|
||||
<widget class="QPushButton" name="pushButton_slot10">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -983,12 +861,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_30">
|
||||
<widget class="QPushButton" name="pushButton_slot11">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1002,12 +880,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_27">
|
||||
<widget class="QPushButton" name="pushButton_slot12">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1021,12 +899,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_28">
|
||||
<widget class="QPushButton" name="pushButton_slot13">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1040,12 +918,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_25">
|
||||
<widget class="QPushButton" name="pushButton_slot14">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1059,12 +937,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_26">
|
||||
<widget class="QPushButton" name="pushButton_slot15">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1078,12 +956,12 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_29">
|
||||
<widget class="QPushButton" name="pushButton_slot16">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
@ -1097,7 +975,7 @@ li.checked::marker { content: "\2612"; }
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1106,6 +984,42 @@ li.checked::marker { content: "\2612"; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_relay" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>380</y>
|
||||
<width>561</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget_available" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>620</x>
|
||||
<y>40</y>
|
||||
<width>291</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_slot_no">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
4
singlerelay_data.cpp
Normal file
4
singlerelay_data.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "singlerelay_data.h"
|
||||
SingleRelayDataNOK::SingleRelayDataNOK(){
|
||||
|
||||
}
|
||||
11
singlerelay_data.h
Normal file
11
singlerelay_data.h
Normal file
@ -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
|
||||
479
tachometer.cpp
479
tachometer.cpp
@ -7,269 +7,306 @@
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonArray>
|
||||
|
||||
Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "tachometer_data.h"
|
||||
|
||||
Tachometer::Tachometer(int slot_no_,int cardtype, 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_;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_slot->setText(slot);
|
||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||
readJsonFile(filePath_tachometer);
|
||||
Init();
|
||||
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_1_clicked);
|
||||
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_2_clicked);
|
||||
connect(ui->radioButton_manual_threshold_3, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_3_clicked);
|
||||
connect(ui->radioButton_manual_threshold_4, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_4_clicked);
|
||||
}
|
||||
|
||||
Tachometer::~Tachometer()
|
||||
{
|
||||
|
||||
Tachometer::~Tachometer() {
|
||||
delete ui;
|
||||
}
|
||||
void Tachometer::readJsonFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
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();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
tachometer_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
tachometer_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
tachometer_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||
tachometer_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||
tachometer_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||
tachometer_variables[i].record_output = temp_obj["record_output"].toString();
|
||||
tachometer_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||
tachometer_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||
tachometer_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||
tachometer_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
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::on_manual_threshold_1_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
}
|
||||
void Tachometer::Init()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
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)
|
||||
|
||||
void Tachometer::on_manual_threshold_2_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::on_manual_threshold_3_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::on_manual_threshold_4_clicked(bool checked) {
|
||||
if (checked) {
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
}
|
||||
|
||||
void Tachometer::UpdateData(std::shared_ptr<TachometerData> &speed_data) {
|
||||
speed_data->card_type_ = kCardSpeedSingle;
|
||||
speed_data->slot_ = slot_no;
|
||||
speed_data->version_ = 1;
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_1->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_1->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_1->value();
|
||||
if(ui->radioButton_automatic_threshold_1->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_1->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
|
||||
} else if (i + 1 == 2) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_2->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_2->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_2->value();
|
||||
if(ui->radioButton_automatic_threshold_2->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_2->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||
} else if (i + 1 == 3) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_3->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_3->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_3->value();
|
||||
if(ui->radioButton_automatic_threshold_3->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_3->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||
} else if (i + 1 == 4) {
|
||||
speed_data->variables_[i].active = ui->checkBox_chan_4->isChecked();
|
||||
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||
speed_data->variables_[i].speed_peek = ui->full_scale_range_4->value();
|
||||
speed_data->variables_[i].default_speed = ui->default_value_4->value();
|
||||
if(ui->radioButton_automatic_threshold_4->isChecked()){
|
||||
speed_data->variables_[i].automatic_threshold = true;
|
||||
}else{
|
||||
speed_data->variables_[i].automatic_threshold = false;
|
||||
}
|
||||
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
speed_data->variables_[i].record_output = ui->comboBox_record_output_4->currentIndex();
|
||||
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
|
||||
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
|
||||
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tachometer::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
|
||||
speed_data->card_type_ = car_type;
|
||||
speed_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(speed_data);
|
||||
UpdateData(speed_data);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
if (i + 1 == 1) {
|
||||
ui->checkBox_chan_1->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_1->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_1->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_1->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_1->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
|
||||
} 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)
|
||||
ui->doubleSpinBox_threshold_1->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_1->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_1->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_1->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_1->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_1->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->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 (speed_data->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){
|
||||
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)
|
||||
}
|
||||
} else if (i + 1 == 2) {
|
||||
ui->checkBox_chan_2->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_2->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_2->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_2->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_2->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
|
||||
} 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)
|
||||
ui->doubleSpinBox_threshold_2->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_2->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_2->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_2->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_2->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_2->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->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 (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_2->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_2->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_2->setCheckable(false);
|
||||
}
|
||||
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)
|
||||
}
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_chan_3->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_3->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_3->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_3->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_3->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
|
||||
} 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)
|
||||
ui->doubleSpinBox_threshold_3->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_3->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_3->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_3->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_3->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_3->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->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 (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_3->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_3->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_3->setCheckable(false);
|
||||
}
|
||||
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)
|
||||
}
|
||||
} else if (i + 1 == 4) {
|
||||
ui->checkBox_chan_4->setChecked(speed_data->variables_[i].active);
|
||||
ui->doubleSpinBox_high_4->setValue(speed_data->variables_[i].normal_voltage_high);
|
||||
ui->doubleSpinBox_low_4->setValue(speed_data->variables_[i].normal_voltage_low);
|
||||
ui->full_scale_range_4->setValue(speed_data->variables_[i].speed_peek);
|
||||
ui->default_value_4->setValue(speed_data->variables_[i].default_speed);
|
||||
if (speed_data->variables_[i].automatic_threshold) {
|
||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||
else
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(false);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||
} 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)
|
||||
ui->doubleSpinBox_threshold_4->setEnabled(true);
|
||||
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBox_threshold_4->setValue(speed_data->variables_[i].threshold);
|
||||
ui->doubleSpinBox_hysteresis_4->setValue(speed_data->variables_[i].hysteresis);
|
||||
ui->spinBox_events_per_revolution_4->setValue(speed_data->variables_[i].events_per_revolution);
|
||||
ui->comboBox_record_output_4->setCurrentIndex(speed_data->variables_[i].record_output);
|
||||
ui->checkBox_two_ma_clamp_4->setChecked(speed_data->variables_[i].two_ma_clamp);
|
||||
if (speed_data->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 (speed_data->variables_[i].overspeed_latching) {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(true);
|
||||
else
|
||||
} else {
|
||||
ui->radioButton_overspeed_latching_4->setCheckable(false);
|
||||
if(tachometer_variables[i].normal_latching)
|
||||
ui->radioButton_normal_latching_4->setCheckable(true);
|
||||
else
|
||||
ui->radioButton_not_normal_latching_4->setCheckable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
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();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_1->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
|
||||
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){
|
||||
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();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_2->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_2->isChecked();
|
||||
}
|
||||
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();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_3->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_3->isChecked();
|
||||
}
|
||||
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();
|
||||
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||
tachometer_variables[i].record_output = ui->comboBox_record_output_4->currentText();
|
||||
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
|
||||
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
|
||||
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
|
||||
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_4->isChecked();
|
||||
}
|
||||
}
|
||||
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))
|
||||
{
|
||||
qDebug() << "Could not open file for writing";
|
||||
void Tachometer::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << " should not be here";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj;
|
||||
QJsonArray chan_array;
|
||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("id", tachometer_variables[i].id);
|
||||
temp_obj.insert("active", tachometer_variables[i].active);
|
||||
QJsonArray voltage_range_array;
|
||||
voltage_range_array.append(tachometer_variables[i].normal_voltage_low);
|
||||
voltage_range_array.append(tachometer_variables[i].normal_voltage_high);
|
||||
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||
temp_obj.insert("threshold", tachometer_variables[i].threshold);
|
||||
temp_obj.insert("hysteresis", tachometer_variables[i].hysteresis);
|
||||
temp_obj.insert("events_per_revolution", tachometer_variables[i].events_per_revolution);
|
||||
temp_obj.insert("record_output", tachometer_variables[i].record_output);
|
||||
temp_obj.insert("two_ma_clamp", tachometer_variables[i].two_ma_clamp);
|
||||
temp_obj.insert("alert_latching", tachometer_variables[i].alert_latching);
|
||||
temp_obj.insert("overspeed_latching", tachometer_variables[i].overspeed_latching);
|
||||
temp_obj.insert("normal_latching", tachometer_variables[i].normal_latching);
|
||||
temp_obj.insert("alert_response_time", tachometer_variables[i].alert_response_time);
|
||||
temp_obj.insert("danger_response_time", tachometer_variables[i].danger_response_time);
|
||||
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);
|
||||
QJsonDocument json_doc;
|
||||
json_doc.setObject(json_obj);
|
||||
QByteArray byte_array = json_doc.toJson();
|
||||
file.write(byte_array);
|
||||
file.close();
|
||||
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||
UpdateData(speed_data);
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Tachometer::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Tachometer::on_radioButton_automatic_threshold_1_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
24
tachometer.h
24
tachometer.h
@ -3,27 +3,35 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
#include "tachometer_data.h"
|
||||
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_,int cardtype, QWidget *parent = nullptr);
|
||||
~Tachometer();
|
||||
int slot_no;
|
||||
private slots:
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_manual_threshold_1_clicked(bool checked);
|
||||
void on_manual_threshold_2_clicked(bool checked);
|
||||
void on_manual_threshold_3_clicked(bool checked);
|
||||
void on_manual_threshold_4_clicked(bool checked);
|
||||
void on_radioButton_automatic_threshold_1_clicked();
|
||||
|
||||
private:
|
||||
Ui::Tachometer *ui;
|
||||
void UpdateData(std::shared_ptr<TachometerData> &speed_data);
|
||||
// Tachometer_Variables tachometer_variables[4];
|
||||
|
||||
Tachometer_Variables tachometer_variables[4];
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
// void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
644
tachometer.ui
644
tachometer.ui
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>转速配置</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget_body" native="true">
|
||||
<property name="geometry">
|
||||
@ -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">
|
||||
@ -314,7 +344,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
@ -405,6 +435,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="geometry">
|
||||
@ -460,8 +499,11 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -579,7 +621,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -587,13 +629,13 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<x>480</x>
|
||||
<y>10</y>
|
||||
<width>191</width>
|
||||
<height>91</height>
|
||||
@ -675,6 +717,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 +736,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>
|
||||
@ -707,53 +755,82 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>通道 2</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_13">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -787,6 +864,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">
|
||||
@ -809,6 +898,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">
|
||||
@ -899,7 +1000,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -907,7 +1008,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_31">
|
||||
@ -920,7 +1021,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_7">
|
||||
@ -1105,6 +1206,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1121,6 +1225,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1219,6 +1326,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="geometry">
|
||||
@ -1274,11 +1390,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@ -1317,6 +1507,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">
|
||||
@ -1339,6 +1541,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">
|
||||
@ -1429,7 +1643,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1437,7 +1651,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_39">
|
||||
@ -1450,7 +1664,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_22">
|
||||
@ -1596,48 +1810,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_27">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -1677,6 +1849,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1693,6 +1868,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -1791,6 +1969,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="geometry">
|
||||
@ -1846,11 +2033,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_26">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_46">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_47">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
@ -1889,6 +2150,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">
|
||||
@ -1911,6 +2184,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">
|
||||
@ -1993,7 +2281,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1 - 255</string>
|
||||
<string>1 - 10000</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_events_per_revolution_4">
|
||||
@ -2001,7 +2289,7 @@
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>310</y>
|
||||
<width>51</width>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2009,7 +2297,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_45">
|
||||
@ -2125,7 +2413,7 @@
|
||||
<widget class="QGroupBox" name="groupBox_34">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<x>490</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>91</height>
|
||||
@ -2168,48 +2456,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_35">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>正常模式</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="radioButton_normal_latching_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 锁存</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_not_normal_latching_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非锁存</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_36">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -2249,6 +2495,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_alert_response_time_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -2265,6 +2514,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_danger_response_time_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
@ -2363,6 +2615,15 @@
|
||||
<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>-5.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="geometry">
|
||||
@ -2418,11 +2679,85 @@
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_35">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>20</y>
|
||||
<width>191</width>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>转速</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>17</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_49">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>54</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="full_scale_range_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="default_value_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>40</y>
|
||||
<width>42</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_chan_2">
|
||||
@ -2441,19 +2776,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>
|
||||
|
||||
6
tachometer_data.cpp
Normal file
6
tachometer_data.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "tachometer_data.h"
|
||||
|
||||
TachometerData::TachometerData()
|
||||
{
|
||||
|
||||
}
|
||||
16
tachometer_data.h
Normal file
16
tachometer_data.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef TACHOMETERDATA_H
|
||||
#define TACHOMETERDATA_H
|
||||
|
||||
#include "cardbase.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class TachometerData : public CardBase {
|
||||
public:
|
||||
TachometerData();
|
||||
|
||||
TachometerVariables variables_[4];
|
||||
SpeedAlert alert_danger[CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
#endif // TACHOMETERDATA_H
|
||||
@ -1,14 +1,557 @@
|
||||
#include "tmrrelayassociation.h"
|
||||
#include "ui_tmrrelayassociation.h"
|
||||
#include "vibrationdata.h"
|
||||
#include <QStack>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
TMRRelayAssociation::TMRRelayAssociation(QWidget *parent)
|
||||
TMRRelayAssociation::TMRRelayAssociation(int slot,int cardtype,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::TMRRelayAssociation)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
slot_no = slot;
|
||||
car_type = static_cast<CardType>(cardtype);
|
||||
if(car_type == kCardRelaySingle){
|
||||
ui->checkBox_sgcc->setVisible(0);
|
||||
}
|
||||
ui->label_slot_no->setText(QString::number(slot_no));
|
||||
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
||||
list_widget_available = new QListWidget();
|
||||
layout_available->addWidget(list_widget_available);
|
||||
list_widget_available->setDragEnabled(true);
|
||||
|
||||
QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay);
|
||||
treeView_relay = new QTreeView;
|
||||
layout_relay->addWidget(treeView_relay);
|
||||
treeView_relay->setDragEnabled(true); // 启用拖动
|
||||
treeView_relay->setAcceptDrops(true); // 接受放下
|
||||
treeView_relay->setDropIndicatorShown(true); // 显示放置指示器
|
||||
treeView_relay->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
model_Relay = new DropTreeModel(this); //创建模型指定父类
|
||||
treeView_relay->setModel(model_Relay);
|
||||
treeView_relay->setHeaderHidden(true);
|
||||
|
||||
btnGroup_slot = new QButtonGroup(this);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot1);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot2);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot3);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot4);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot5);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot6);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot7);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot8);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot9);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot10);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot11);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot12);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot13);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot14);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot15);
|
||||
btnGroup_slot->addButton(ui->pushButton_slot16);
|
||||
|
||||
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
||||
connect(ui->comboBox_relay_ch, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &TMRRelayAssociation::onComboBoxIndexChanged);
|
||||
treeView_relay->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(treeView_relay,&QTreeView::customContextMenuRequested,this,&TMRRelayAssociation::on_treeView_Relay_customContextMenuRequested);
|
||||
current_index = ui->comboBox_relay_ch->currentIndex();
|
||||
Init();
|
||||
onComboBoxIndexChanged(current_index);
|
||||
// QString expr = "((S01C01A1 + S01C02A1 + (S02C01A1 * S02C01A2)) * (S02C01A2 + S02C01A1 + (S02C01A1 + S02C01A2)) * (S02C01A1 * S02C01A2))";
|
||||
// setExpressionToTreeView(treeView_relay, expr);
|
||||
}
|
||||
|
||||
TMRRelayAssociation::~TMRRelayAssociation()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void TMRRelayAssociation::Init(){
|
||||
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 1; i < buttonList.count() + 1; i++) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i);
|
||||
if(base_ptr != nullptr){
|
||||
switch (base_ptr->card_type_) {
|
||||
case kCardVibSingle :{
|
||||
buttonList[i - 1]->setText("振动");
|
||||
break;
|
||||
}
|
||||
case kCardKeyphaseSingle:{
|
||||
buttonList[i - 1]->setText("键相");
|
||||
break;
|
||||
}
|
||||
case kCardSpeedSingle:{
|
||||
buttonList[i - 1]->setText("转速");
|
||||
break;
|
||||
}
|
||||
case kCardRelaySingle:
|
||||
case kCardRelaySingleNOK:
|
||||
case kCardRelayTMRPrimary:{
|
||||
buttonList[i - 1]->setText("继电器");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
// do nothing or use template to init it.
|
||||
relay_data = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data->card_type_ = car_type;
|
||||
relay_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(relay_data);
|
||||
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data_backup = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data_backup->card_type_ = kCardRelayTMRBackup;
|
||||
relay_data_backup->slot_ = slot_no + 1;
|
||||
ConfigMgr::Instance()->AddCard(relay_data_backup);
|
||||
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data_backup2 = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data_backup2->card_type_ = kCardRelayTMRBackup;
|
||||
relay_data_backup2->slot_ = slot_no + 2;
|
||||
ConfigMgr::Instance()->AddCard(relay_data_backup2);
|
||||
|
||||
return;
|
||||
}
|
||||
relay_data = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
|
||||
|
||||
qDebug() << "logic" <<relay_data->tmr_relay[current_index].logic_expression;
|
||||
for(int i = 0 ; i < SLOT_NUM ; i++){
|
||||
std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
|
||||
if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardVibSingle){
|
||||
qDebug() << "i" << i;
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(cardbase_ptr);
|
||||
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||
QString item_data,item_str;
|
||||
if(ptr->alert_danger[var].direct_enable ||
|
||||
ptr->alert_danger[var].x1_ampl_enable ||
|
||||
ptr->alert_danger[var].x2_ampl_enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 警报)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A1").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
if(ptr->alert_danger[var].danger_enable){
|
||||
item_str = QString("%1 (槽位 %2 通道 %3 危险)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
|
||||
item_data = QString("%1A2").arg(ptr->base_config_[var].chan_id);
|
||||
}
|
||||
channelNameMap[item_data] = item_str;
|
||||
}
|
||||
}else if(cardbase_ptr != nullptr &&
|
||||
cardbase_ptr->card_type_ == kCardSpeedSingle){
|
||||
|
||||
}
|
||||
}
|
||||
ui->checkBox_sgcc->setChecked(relay_data->sgcc_enable);
|
||||
if(!relay_data->tmr_relay[current_index].logic_expression.isEmpty()){
|
||||
setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[current_index].logic_expression);
|
||||
}
|
||||
}
|
||||
|
||||
ExprNode* TMRRelayAssociation::parseExpression(const QString& expr, int& pos) {
|
||||
auto skipSpaces = [&]() {
|
||||
while (pos < expr.length() && expr[pos].isSpace()) pos++;
|
||||
};
|
||||
|
||||
QStack<ExprNode*> nodeStack;
|
||||
QStack<QString> opStack;
|
||||
|
||||
while (pos < expr.length()) {
|
||||
skipSpaces();
|
||||
if (pos >= expr.length()) break;
|
||||
|
||||
QChar ch = expr[pos];
|
||||
|
||||
if (ch == '(') {
|
||||
pos++;
|
||||
nodeStack.push(parseExpression(expr, pos));
|
||||
} else if (ch == ')') {
|
||||
pos++;
|
||||
break;
|
||||
} else if (ch == '+' || ch == '*') {
|
||||
opStack.push(QString(ch));
|
||||
pos++;
|
||||
} else {
|
||||
QString token;
|
||||
while (pos < expr.length() && expr[pos].isLetterOrNumber()) {
|
||||
token += expr[pos++];
|
||||
}
|
||||
nodeStack.push(new ExprNode{token, {}});
|
||||
}
|
||||
|
||||
while (opStack.size() > 0 && nodeStack.size() >= 2) {
|
||||
QString op = opStack.pop();
|
||||
ExprNode* right = nodeStack.pop();
|
||||
ExprNode* left = nodeStack.pop();
|
||||
|
||||
if (left->value == op) {
|
||||
left->children.append(right);
|
||||
nodeStack.push(left);
|
||||
} else if (right->value == op) {
|
||||
right->children.prepend(left);
|
||||
nodeStack.push(right);
|
||||
} else {
|
||||
ExprNode* parent = new ExprNode{op, {left, right}};
|
||||
nodeStack.push(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodeStack.isEmpty() ? nullptr : nodeStack.top();
|
||||
}
|
||||
QStandardItem* TMRRelayAssociation::buildItemTree(ExprNode* node) {
|
||||
if (!node) return nullptr;
|
||||
QString displayText;
|
||||
if (node->value == "+" || node->value == "*") {
|
||||
displayText = (node->value == "+") ? "OR" : "AND"; // 运算符显示
|
||||
} else {
|
||||
displayText = channelNameMap.value(node->value, node->value); // 显示名
|
||||
qDebug() << "display" <<displayText << node->value;
|
||||
}
|
||||
QStandardItem* item = new QStandardItem(displayText);
|
||||
item->setData(node->value, Qt::UserRole); // 原始表达式key
|
||||
for (ExprNode* child : node->children) {
|
||||
item->appendRow(buildItemTree(child));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
void TMRRelayAssociation::setExpressionToTreeView(QTreeView* treeView, const QString& expr) {
|
||||
int pos = 0;
|
||||
model_Relay->clear();
|
||||
ExprNode* root = parseExpression(expr, pos);
|
||||
QStandardItem* rootItem = buildItemTree(root);
|
||||
|
||||
model_Relay->appendRow(rootItem);
|
||||
treeView_relay->expandAll();
|
||||
}
|
||||
QString TMRRelayAssociation::buildLogicExpression(QStandardItem *item) {
|
||||
if (!item) return "";
|
||||
|
||||
int childCount = item->rowCount();
|
||||
QVariant userData = item->data(Qt::UserRole);
|
||||
QString text = userData.toString().trimmed();
|
||||
|
||||
if (childCount == 0) {
|
||||
// 叶子节点,直接返回表达式,比如 S01C01A1
|
||||
return text;
|
||||
}
|
||||
|
||||
// 判断当前是 +(OR)还是 *(AND)
|
||||
QString opStr = (text == "+") ? "+" :
|
||||
(text == "*") ? "*" : "";
|
||||
|
||||
// 如果不是 +/*,视为叶子节点
|
||||
if (opStr.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
|
||||
QStringList subExprs;
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
QStandardItem *child = item->child(i);
|
||||
subExprs << buildLogicExpression(child);
|
||||
}
|
||||
|
||||
return "(" + subExprs.join(" " + opStr + " ") + ")";
|
||||
}
|
||||
QStandardItem* TMRRelayAssociation::parseExpression(const QString &expr) {
|
||||
QStack<QStandardItem*> stack; // 用来存储节点
|
||||
QStack<QString> ops; // 用来存储操作符
|
||||
|
||||
int pos = 0;
|
||||
int length = expr.length();
|
||||
|
||||
while (pos < length) {
|
||||
QRegExp regex("(\\()|([A-Za-z0-9]+)|([+*])|(\\))");
|
||||
|
||||
if (regex.indexIn(expr, pos) != -1) {
|
||||
QString matchedText = regex.cap(0);
|
||||
QString group1 = regex.cap(1); // (
|
||||
QString group2 = regex.cap(2); // S01C01A1
|
||||
QString group3 = regex.cap(3); // + or *
|
||||
QString group4 = regex.cap(4); // )
|
||||
|
||||
// 处理左括号,表示子表达式的开始
|
||||
if (!group1.isEmpty()) {
|
||||
ops.push("("); // 推入栈
|
||||
}
|
||||
// 处理右括号,表示子表达式的结束
|
||||
else if (!group4.isEmpty()) {
|
||||
// 遇到右括号时开始弹出栈中的操作符,直到遇到左括号
|
||||
while (!ops.isEmpty() && ops.top() != "(") {
|
||||
QString op = ops.pop();
|
||||
QStandardItem* right = stack.pop();
|
||||
QStandardItem* left = stack.pop();
|
||||
QStandardItem* node = new QStandardItem(op);
|
||||
node->appendRow(left); // 左子树
|
||||
node->appendRow(right); // 右子树
|
||||
stack.push(node); // 将新的节点推入栈
|
||||
}
|
||||
ops.pop(); // 弹出左括号
|
||||
}
|
||||
// 处理操作符 + 和 *
|
||||
else if (!group3.isEmpty()) {
|
||||
ops.push(group3); // 操作符入栈
|
||||
}
|
||||
// 处理终端元素(比如 S01C01A1)
|
||||
else if (!group2.isEmpty()) {
|
||||
QStandardItem* item = new QStandardItem(group2);
|
||||
stack.push(item); // 将数据节点推入栈
|
||||
}
|
||||
|
||||
pos = regex.pos(0) + regex.matchedLength();
|
||||
} else {
|
||||
break; // 防止无限循环
|
||||
}
|
||||
}
|
||||
|
||||
// 最终合并栈中的所有内容
|
||||
while (!ops.isEmpty()) {
|
||||
QString op = ops.pop();
|
||||
QStandardItem* right = stack.pop();
|
||||
QStandardItem* left = stack.pop();
|
||||
QStandardItem* node = new QStandardItem(op);
|
||||
node->appendRow(left); // 左子树
|
||||
node->appendRow(right); // 右子树
|
||||
stack.push(node);
|
||||
}
|
||||
|
||||
// 返回栈顶的节点,应该是根节点
|
||||
return stack.isEmpty() ? nullptr : stack.pop();
|
||||
}
|
||||
|
||||
ExprValidationResult TMRRelayAssociation::validateLogicExpression(const QString& expr) {
|
||||
int bracketCount = 0;
|
||||
bool lastWasOperator = true;
|
||||
bool lastWasOpenParen = false;
|
||||
|
||||
for (int i = 0; i < expr.length(); ++i) {
|
||||
QChar ch = expr[i];
|
||||
|
||||
if (ch.isSpace()) continue;
|
||||
|
||||
if (ch == '(') {
|
||||
bracketCount++;
|
||||
lastWasOpenParen = true;
|
||||
lastWasOperator = true;
|
||||
} else if (ch == ')') {
|
||||
bracketCount--;
|
||||
if (bracketCount < 0) {
|
||||
return {false, i, "多余的右括号 ')'"};
|
||||
}
|
||||
lastWasOpenParen = false;
|
||||
lastWasOperator = false;
|
||||
} else if (ch == '+' || ch == '*') {
|
||||
if (lastWasOperator || lastWasOpenParen) {
|
||||
return {false, i, QString("无效的运算符 '%1' 的位置").arg(ch)};
|
||||
}
|
||||
lastWasOperator = true;
|
||||
lastWasOpenParen = false;
|
||||
} else if (ch.isLetterOrNumber()) {
|
||||
QString token;
|
||||
int start = i;
|
||||
while (i < expr.length() && expr[i].isLetterOrNumber()) {
|
||||
token += expr[i];
|
||||
++i;
|
||||
}
|
||||
--i; // 修正多读了一位
|
||||
if (token.isEmpty()) {
|
||||
return {false, start, "变量名称缺失"};
|
||||
}
|
||||
lastWasOperator = false;
|
||||
lastWasOpenParen = false;
|
||||
} else {
|
||||
return {false, i, QString("不支持的字符 '%1'").arg(ch)};
|
||||
}
|
||||
}
|
||||
|
||||
if (bracketCount != 0) {
|
||||
return {false, expr.length(), "括号不匹配"};
|
||||
}
|
||||
|
||||
if (lastWasOperator) {
|
||||
return {false, expr.length() - 1, "表达式不能以运算符结尾"};
|
||||
}
|
||||
|
||||
return {true, -1, ""};
|
||||
}
|
||||
|
||||
void TMRRelayAssociation::buildTreeFromExpression(QTreeView *treeView, const QString &expr) {
|
||||
QStandardItem* rootItem = parseExpression(expr);
|
||||
|
||||
if (rootItem) {
|
||||
model_Relay->appendRow(rootItem);
|
||||
}
|
||||
|
||||
treeView_relay->setModel(model_Relay);
|
||||
}
|
||||
|
||||
void TMRRelayAssociation::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||
if (slot_btn != NULL) {
|
||||
list_widget_available->clear();
|
||||
QString object_name = slot_btn->objectName();
|
||||
if(slot_btn->text().isEmpty())
|
||||
return;
|
||||
qDebug() << object_name;
|
||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
QListWidgetItem *item_and = new QListWidgetItem("AND");
|
||||
item_and->setData(Qt::UserRole, "*");
|
||||
list_widget_available->addItem(item_and);
|
||||
|
||||
QListWidgetItem *item_or = new QListWidgetItem("OR");
|
||||
item_or->setData(Qt::UserRole, "+");
|
||||
list_widget_available->addItem(item_or);
|
||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr->card_type_ == kCardVibSingle){
|
||||
QString item_data;
|
||||
if(ptr->base_config_[var].standby && (var % 2))
|
||||
continue;
|
||||
if(ptr->alert_danger[var].direct_enable ||
|
||||
ptr->alert_danger[var].x1_ampl_enable ||
|
||||
ptr->alert_danger[var].x2_ampl_enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 警报)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
if(ptr->alert_danger[var].danger_enable){
|
||||
QString item_str = QString("%1 (槽位 %3 通道 %4 危险)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
item->setData(Qt::UserRole, item_data);
|
||||
list_widget_available->addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void TMRRelayAssociation::on_pushButton_cancel_clicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void TMRRelayAssociation::on_pushButton_confirm_clicked()
|
||||
{
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QString finalExpr;
|
||||
for (int i = 0; i < root->rowCount(); ++i) {
|
||||
QStandardItem *topItem = root->child(i);
|
||||
QString expr = buildLogicExpression(topItem);
|
||||
finalExpr += expr;
|
||||
}
|
||||
ExprValidationResult result = validateLogicExpression(finalExpr);
|
||||
if (!result.isValid && !finalExpr.isEmpty()) {
|
||||
QMessageBox::warning(this, "表达式错误",
|
||||
QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg));
|
||||
return;
|
||||
}
|
||||
relay_data->tmr_relay[current_index].logic_expression = finalExpr;
|
||||
relay_data->sgcc_enable = ui->checkBox_sgcc->checkState();
|
||||
qDebug() << "逻辑表达式:" << finalExpr;
|
||||
this->close();
|
||||
}
|
||||
void TMRRelayAssociation::onComboBoxIndexChanged(int index){
|
||||
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QString finalExpr;
|
||||
for (int i = 0; i < root->rowCount(); ++i) {
|
||||
QStandardItem *topItem = root->child(i);
|
||||
QString expr = buildLogicExpression(topItem);
|
||||
finalExpr += expr;
|
||||
}
|
||||
ExprValidationResult result = validateLogicExpression(finalExpr);
|
||||
if (!result.isValid && !finalExpr.isEmpty()) {
|
||||
QMessageBox::warning(this, "表达式错误",
|
||||
QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg));
|
||||
return;
|
||||
}
|
||||
relay_data->tmr_relay[current_index].logic_expression = finalExpr;
|
||||
current_index = index;
|
||||
|
||||
if(relay_data->tmr_relay[index].logic_expression != "")
|
||||
setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[index].logic_expression);
|
||||
else
|
||||
model_Relay->clear();
|
||||
}
|
||||
|
||||
void TMRRelayAssociation::on_pushButton_and_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TMRRelayAssociation::on_pushButton_or_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
void TMRRelayAssociation::slotDeleteItem()
|
||||
{
|
||||
QModelIndex curIndex = treeView_relay->currentIndex();
|
||||
if(curIndex.isValid()){
|
||||
model_Relay->removeRow(curIndex.row(),curIndex.parent());
|
||||
}
|
||||
|
||||
}
|
||||
void TMRRelayAssociation::on_treeView_Relay_customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
qDebug() << "on_treeView_Relay_customContextMenuRequested" <<endl;
|
||||
QModelIndex curIndex = treeView_relay->indexAt(pos); //当前点击的元素的index
|
||||
QModelIndex index = curIndex.sibling(curIndex.row(),0); //该行的第1列元素的index
|
||||
QMenu menu(this);
|
||||
if (index.isValid()){
|
||||
//添加一行菜单,进行展开
|
||||
menu.addAction(QStringLiteral("删除"), this, SLOT(slotDeleteItem()));
|
||||
menu.addSeparator(); //添加一个分隔线
|
||||
}
|
||||
menu.exec(QCursor::pos()); //显示菜单
|
||||
}
|
||||
|
||||
void TMRRelayAssociation::on_checkBox_sgcc_stateChanged(int arg1)
|
||||
{
|
||||
if(ui->checkBox_sgcc->checkState()){
|
||||
treeView_relay->setEnabled(false);
|
||||
list_widget_available->setEnabled(false);
|
||||
ui->comboBox_relay_ch->setEnabled(false);
|
||||
ui->pushButton_logic->setEnabled(false);
|
||||
ui->textEdit_logic->setEnabled(false);
|
||||
}else{
|
||||
treeView_relay->setEnabled(true);
|
||||
list_widget_available->setEnabled(true);
|
||||
ui->comboBox_relay_ch->setEnabled(true);
|
||||
ui->pushButton_logic->setEnabled(true);
|
||||
ui->textEdit_logic->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TMRRelayAssociation::on_pushButton_logic_clicked()
|
||||
{
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||
if (!model) return;
|
||||
QStandardItem *root = model->invisibleRootItem();
|
||||
QString finalExpr;
|
||||
for (int i = 0; i < root->rowCount(); ++i) {
|
||||
QStandardItem *topItem = root->child(i);
|
||||
QString expr = buildLogicExpression(topItem);
|
||||
finalExpr += expr;
|
||||
}
|
||||
ExprValidationResult result = validateLogicExpression(finalExpr);
|
||||
if (!result.isValid && !finalExpr.isEmpty()) {
|
||||
QMessageBox::warning(this, "表达式错误",
|
||||
QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg));
|
||||
return;
|
||||
}
|
||||
ui->textEdit_logic->setPlainText(finalExpr);
|
||||
}
|
||||
|
||||
|
||||
@ -2,21 +2,75 @@
|
||||
#define TMRRELAYASSOCIATION_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QButtonGroup>
|
||||
#include <QPushButton>
|
||||
#include "data_config.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
#include "tmrrelayassociation_data.h"
|
||||
#include <QListWidget>
|
||||
|
||||
namespace Ui {
|
||||
class TMRRelayAssociation;
|
||||
}
|
||||
struct ExprNode {
|
||||
QString value;
|
||||
QList<ExprNode*> children;
|
||||
};
|
||||
struct ExprValidationResult {
|
||||
bool isValid;
|
||||
int errorPos;
|
||||
QString errorMsg;
|
||||
};
|
||||
|
||||
|
||||
class TMRRelayAssociation : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TMRRelayAssociation(QWidget *parent = nullptr);
|
||||
explicit TMRRelayAssociation(int slot,int cardtype,QWidget *parent = nullptr);
|
||||
~TMRRelayAssociation();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
void OnButtonGroup(QAbstractButton *);
|
||||
|
||||
|
||||
void on_pushButton_and_clicked();
|
||||
|
||||
void on_pushButton_or_clicked();
|
||||
|
||||
void on_treeView_Relay_customContextMenuRequested(const QPoint &pos);
|
||||
void slotDeleteItem();
|
||||
void on_checkBox_sgcc_stateChanged(int arg1);
|
||||
|
||||
void on_pushButton_logic_clicked();
|
||||
|
||||
private:
|
||||
Ui::TMRRelayAssociation *ui;
|
||||
QButtonGroup * btnGroup_slot = nullptr;
|
||||
QListWidget *list_widget_available = nullptr;
|
||||
int current_index;
|
||||
QTreeView *treeView_relay;
|
||||
QStandardItemModel *model_Relay;
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data = nullptr;
|
||||
QMap<QString, QString> channelNameMap;
|
||||
|
||||
void Init();
|
||||
void buildTreeFromExpression(QTreeView *treeView, const QString &expr);
|
||||
ExprNode* parseExpression(const QString& expr, int& pos);
|
||||
QStandardItem* buildItemTree(ExprNode* node);
|
||||
void setExpressionToTreeView(QTreeView* treeView, const QString& expr);
|
||||
QStandardItem* parseExpression(const QString &expr);
|
||||
QString buildLogicExpression(QStandardItem *item);
|
||||
ExprValidationResult validateLogicExpression(const QString& expr);
|
||||
};
|
||||
|
||||
#endif // TMRRELAYASSOCIATION_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
6
tmrrelayassociation_data.cpp
Normal file
6
tmrrelayassociation_data.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "tmrrelayassociation_data.h"
|
||||
|
||||
TmrrelayassociationData::TmrrelayassociationData()
|
||||
{
|
||||
|
||||
}
|
||||
14
tmrrelayassociation_data.h
Normal file
14
tmrrelayassociation_data.h
Normal file
@ -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
|
||||
496
velocity.cpp
496
velocity.cpp
@ -5,11 +5,14 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
#include "velocity_ds.h"
|
||||
#include "data_config.h"
|
||||
#include "vibrationdata.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
Velocity::Velocity(int slot_no_,int channel_,bool active,QWidget *parent)
|
||||
Velocity::Velocity(int slot_no_, int channel_, bool active, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Velocity)
|
||||
{
|
||||
, ui(new Ui::Velocity) {
|
||||
ui->setupUi(this);
|
||||
slot_no = slot_no_;
|
||||
channel = channel_;
|
||||
@ -17,267 +20,250 @@ Velocity::Velocity(int slot_no_,int channel_,bool active,QWidget *parent)
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
ui->label_channel->setText(chan);
|
||||
ui->label_slot->setText(slot);
|
||||
if(active)
|
||||
if (active) {
|
||||
ui->label_active->setText("(启用)");
|
||||
else
|
||||
} else {
|
||||
ui->label_active->setText("(停用)");
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_filter);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\velocity_variables_%2.json").arg(slot_no).arg(channel);
|
||||
readJsonFile(filePath_variables);
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
Velocity::~Velocity()
|
||||
{
|
||||
Velocity::~Velocity() {
|
||||
delete ui;
|
||||
}
|
||||
void Velocity::readJsonFile(const QString &filePath)
|
||||
{
|
||||
// 创建文件对象
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for reading:" << filePath;
|
||||
return;
|
||||
}
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QByteArray jsonData = content.toUtf8();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isNull()) {
|
||||
qDebug() << "Cannot parse JSON document";
|
||||
return;
|
||||
}
|
||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||
qDebug() << "JSON document is not an object or an array";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = jsonDoc.object();
|
||||
if(filePath.contains("filter_")){
|
||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
||||
for(int i = 0; i < filter_array.size(); i++){
|
||||
QJsonObject temp_obj = filter_array[i].toObject();
|
||||
filter[i].type = temp_obj["type"].toString();
|
||||
filter[i].low = temp_obj["low"].toInt();
|
||||
filter[i].high = temp_obj["high"].toInt();
|
||||
filter[i].checked = temp_obj["checked"].toBool();
|
||||
}
|
||||
}else if(filePath.contains("velocity_variables_")){
|
||||
|
||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||
for(int i = 0; i < variables_array.size(); i++){
|
||||
QJsonObject temp_obj = variables_array[i].toObject();
|
||||
variables[i].type = temp_obj["type"].toString();
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].bias_voltage = temp_obj["bias_voltage"].toInt();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = temp_obj["checked"].toBool();
|
||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||
}
|
||||
}
|
||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||
delay.alert = delay_obj["alert"].toInt();
|
||||
delay.danger = delay_obj["danger"].toDouble();
|
||||
delay.active_100ms = delay_obj["100ms"].toBool();
|
||||
alert_variables.rms_active = json_obj["rms_active"].toBool();
|
||||
alert_variables.integrate_active = json_obj["integrate_active"].toBool();
|
||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||
alert_variables.comparision = json_obj["comparision"].toString();
|
||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||
}
|
||||
}
|
||||
void Velocity::Init()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].checked){
|
||||
if(filter[i].type == "band_pass"){
|
||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage));
|
||||
ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
ui->checkBox_1x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
ui->checkBox_2x_ampl->setChecked(variables[i].checked);
|
||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||
}
|
||||
}
|
||||
ui->spinBox_alert->setValue(delay.alert);
|
||||
ui->doubleSpinBox_danger->setValue(delay.danger);
|
||||
ui->checkBox_100ms->setChecked(delay.active_100ms);
|
||||
ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching);
|
||||
ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching);
|
||||
ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok);
|
||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||
|
||||
}
|
||||
void Velocity::on_pushButton_confirm_clicked()
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if(filter[i].type == "band_pass"){
|
||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||
}else if(filter[i].type == "low_pass"){
|
||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||
}else if(filter[i].type == "high_pass"){
|
||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if(variables[i].type == "direct"){
|
||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value();
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText();
|
||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
}
|
||||
}
|
||||
delay.alert = ui->spinBox_alert->value();
|
||||
delay.danger = ui->doubleSpinBox_danger->value();
|
||||
delay.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
||||
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||
// 保存到文件
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QJsonObject filter_obj;
|
||||
QJsonArray filter_array;
|
||||
for(int i = 0; i < 3; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",filter[i].type);
|
||||
temp_obj.insert("low",filter[i].low);
|
||||
temp_obj.insert("high",filter[i].high);
|
||||
temp_obj.insert("checked",filter[i].checked);
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonDocument filter_doc;
|
||||
filter_doc.setObject(filter_obj);
|
||||
QByteArray filter_data = filter_doc.toJson();
|
||||
QFile filter_file(filePath_filter);
|
||||
if (!filter_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_filter;
|
||||
void Velocity::on_checkBox_rms_toggled(bool checked) {
|
||||
// TODO: 自定义的回调
|
||||
if (checked) {
|
||||
ui->checkBox_integrate->setEnabled(false);
|
||||
QStringList items = {"0-10 mm/s rms", "0-20 mm/s rms", "0-50 mm/s rms", "自定义"};
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(1);
|
||||
return;
|
||||
}
|
||||
filter_file.write(filter_data);
|
||||
filter_file.close();
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\velocity_variables_%2.json").arg(slot_no).arg(channel);
|
||||
QJsonObject variables_obj;
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 4; i++){
|
||||
QJsonObject temp_obj;
|
||||
temp_obj.insert("type",variables[i].type);
|
||||
if(variables[i].type == "direct"){
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
}else if(variables[i].type == "bias_volt"){
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("bias_voltage",variables[i].bias_voltage);
|
||||
}else if(variables[i].type == "1x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
}else if(variables[i].type == "2x_ampl"){
|
||||
temp_obj.insert("checked",variables[i].checked);
|
||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||
}
|
||||
variables_array.append(temp_obj);
|
||||
}
|
||||
variables_obj.insert("variables",variables_array);
|
||||
QJsonObject delay_obj;
|
||||
delay_obj.insert("alert",delay.alert);
|
||||
delay_obj.insert("danger",delay.danger);
|
||||
delay_obj.insert("100ms",delay.active_100ms);
|
||||
variables_obj.insert("delay",delay_obj);
|
||||
variables_obj.insert("rms_active",alert_variables.rms_active);
|
||||
variables_obj.insert("integrate_active",alert_variables.integrate_active);
|
||||
variables_obj.insert("alert_latching",alert_variables.alert_latching);
|
||||
variables_obj.insert("danger_latching",alert_variables.danger_latching);
|
||||
variables_obj.insert("timed_ok",alert_variables.timed_ok);
|
||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||
variables_obj.insert("comparision",alert_variables.comparision);
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("channel",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QJsonDocument variables_doc;
|
||||
variables_doc.setObject(variables_obj);
|
||||
QByteArray variables_data = variables_doc.toJson();
|
||||
QFile variables_file(filePath_variables);
|
||||
if (!variables_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "Cannot open file for writing:" << filePath_variables;
|
||||
return;
|
||||
}
|
||||
variables_file.write(variables_data);
|
||||
variables_file.close();
|
||||
ui->checkBox_integrate->setEnabled(true);
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void Velocity::on_checkBox_integrate_toggled(bool checked) {
|
||||
// TODO: 自定义的回调
|
||||
if (checked) {
|
||||
ui->checkBox_rms->setEnabled(false);
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
QStringList items = {"0-100 um pp", "0-200 um pp", "0-500 um pp", "自定义"};
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(1);
|
||||
return;
|
||||
}
|
||||
ui->checkBox_rms->setEnabled(true);
|
||||
ui->comboBox_direct_value_range->clear();
|
||||
QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"};
|
||||
ui->comboBox_direct_value_range->addItems(items);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_1x_value_range->clear();
|
||||
ui->comboBox_1x_value_range->addItems(items);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(1);
|
||||
ui->comboBox_2x_value_range->clear();
|
||||
ui->comboBox_2x_value_range->addItems(items);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void Velocity::on_pushButton_cancel_clicked() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Velocity::on_checkBox_1x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_1x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->comboBox_1x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
void Velocity::on_checkBox_2x_ampl_toggled(bool checked) {
|
||||
if (checked) {
|
||||
ui->comboBox_2x_value_range->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
ui->comboBox_2x_value_range->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false);
|
||||
}
|
||||
|
||||
void Velocity::Init() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Velocity::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if (ptr->base_config_[channel - 1].channel_type != kVibVelocity) {
|
||||
qDebug() << "[Velocity::Init] channel type changes";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "[Velocity::Init] no channel ptr";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
|
||||
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
|
||||
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
|
||||
ui->comboBox_direct_value_range->setCurrentIndex(variable_ptr->direct_.full_scale_range);
|
||||
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
|
||||
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
|
||||
// ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
|
||||
// ui->comboBox_bias_volt_range->setCurrentIndex();
|
||||
ui->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked);
|
||||
ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range);
|
||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value);
|
||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag);
|
||||
ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked);
|
||||
ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range);
|
||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value);
|
||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag);
|
||||
ui->spinBox_alert->setValue(variable_ptr->delay_.alert);
|
||||
ui->doubleSpinBox_danger->setValue(variable_ptr->delay_.danger);
|
||||
ui->checkBox_100ms->setChecked(variable_ptr->delay_.active_100ms);
|
||||
ui->checkBox_rms->setChecked(variable_ptr->rms_active_);
|
||||
ui->checkBox_integrate->setChecked(variable_ptr->integrate_active_);
|
||||
ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_);
|
||||
ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_);
|
||||
ui->checkBox_timed_ok->setChecked(variable_ptr->timed_ok_);
|
||||
ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output);
|
||||
ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp);
|
||||
ui->doubleSpinBox_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply);
|
||||
ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision);
|
||||
ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage);
|
||||
}
|
||||
|
||||
void Velocity::on_pushButton_confirm_clicked() {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||
if (base_ptr == nullptr) {
|
||||
qCritical() << "[Acceleration::Init] should not be here";
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||
if (variable_base == nullptr || variable_base->type_ != kVibVelocity) {
|
||||
if (variable_base == nullptr) {
|
||||
qDebug() << "no channel ptr";
|
||||
} else {
|
||||
ptr->RemoveChannel(channel);
|
||||
qDebug() << "channel type change";
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||
variable->id_ = channel;
|
||||
variable->type_ = kVibVelocity;
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->rms_active_ = ui->checkBox_rms->isChecked();
|
||||
variable->integrate_active_ = ui->checkBox_integrate->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
variable->timed_ok_ = ui->checkBox_timed_ok->isChecked();
|
||||
ptr->variables_.push_back(variable);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AccVelVariable> variable = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||
variable->direct_.custom = 0; // TODO:
|
||||
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||
variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
||||
variable->x1_.custom = 0; // TODO:
|
||||
variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
||||
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||
variable->x2_.custom = 0; // TODO:
|
||||
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||
variable->delay_.alert = ui->spinBox_alert->value();
|
||||
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||
variable->rms_active_ = ui->checkBox_rms->isChecked();
|
||||
variable->integrate_active_ = ui->checkBox_integrate->isChecked();
|
||||
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||
variable->timed_ok_ = ui->checkBox_timed_ok->isChecked();
|
||||
this->close();
|
||||
}
|
||||
|
||||
22
velocity.h
22
velocity.h
@ -8,28 +8,26 @@ namespace Ui {
|
||||
class Velocity;
|
||||
}
|
||||
|
||||
class Velocity : public QWidget
|
||||
{
|
||||
class Velocity : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Velocity(int slot_no_,int channel_,bool active,QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit Velocity(int slot_no_, int channel_, bool active, QWidget *parent = nullptr);
|
||||
~Velocity();
|
||||
int slot_no;
|
||||
int channel;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_checkBox_1x_ampl_toggled(bool checked);
|
||||
void on_checkBox_2x_ampl_toggled(bool checked);
|
||||
void on_checkBox_rms_toggled(bool checked);
|
||||
void on_checkBox_integrate_toggled(bool checked);
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::Velocity *ui;
|
||||
|
||||
Filter filter[3];
|
||||
Dealy delay;
|
||||
Variables variables[4];
|
||||
Alert_Variables alert_variables;
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
|
||||
357
velocity.ui
357
velocity.ui
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>754</width>
|
||||
<width>717</width>
|
||||
<height>582</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -376,9 +376,30 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>0-20 mm/s pk</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 20 mm/s</string>
|
||||
<string>0-10 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
@ -391,6 +412,9 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_bias_voltage">
|
||||
<property name="geometry">
|
||||
@ -419,6 +443,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_1x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -427,13 +454,34 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 20 mm/s</string>
|
||||
<string>0-10 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -442,6 +490,9 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_76">
|
||||
<property name="geometry">
|
||||
@ -470,6 +521,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -483,6 +537,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_ampl_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -491,8 +548,14 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_2x_phase_lag_clamp">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
@ -506,6 +569,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_2x_value_range">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
@ -514,9 +580,27 @@
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0 - 20 mm/s</string>
|
||||
<string>0-10 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-20 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0-50 mm/s pk</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>自定义</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
@ -762,17 +846,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>偏置电压</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -780,21 +859,11 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_two_ma_clamp">
|
||||
<property name="geometry">
|
||||
@ -816,7 +885,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>80</y>
|
||||
<y>60</y>
|
||||
<width>181</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@ -825,19 +894,6 @@
|
||||
<string> Timed OK channel Defeat</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox_not_ok">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>60</y>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 非正常锁定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_85">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -852,6 +908,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox_comparision">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -862,17 +921,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>直接值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>偏置电压</string>
|
||||
<string>直接幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -880,23 +934,16 @@
|
||||
<string>1倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频幅值</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2倍频相位</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinBox_comparision_percentage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
@ -980,138 +1027,88 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
<x>20</x>
|
||||
<y>530</y>
|
||||
<width>661</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>117</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置为默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_load_template">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>223</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> 加载预定义模板</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_point_name">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>329</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>测点名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>435</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>541</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>647</x>
|
||||
<y>531</y>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_confirm">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_set_default">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置为默认值</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_print">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打印</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
36
velocity_ds.h
Normal file
36
velocity_ds.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef VELOCITY_DS_H
|
||||
#define VELOCITY_DS_H
|
||||
|
||||
// 速度峰值的量程范围
|
||||
typedef enum {
|
||||
kVelPK10 = 0, // 0-10 mm/s pk
|
||||
kVelPK20 = 1, // 0-20 mm/s pk
|
||||
kVelPK50 = 2, // 0-50 mm/s pk
|
||||
kVelPKCustom = 3 // custom
|
||||
} VelPKFullScaleRange;
|
||||
|
||||
// 速度有效值的量程范围
|
||||
typedef enum {
|
||||
kVelRMS10 = 0, // 0-10 mm/s rms
|
||||
kVelRMS20 = 1, // 0-20 mm/s rms
|
||||
kVelRMS50 = 2, // 0-50 mm/s rms
|
||||
kVelRMSCustom = 3 // custom
|
||||
} VelRMSFullScaleRange;
|
||||
|
||||
// 位移峰峰值的量程范围
|
||||
typedef enum {
|
||||
kVelDisPP100 = 0, // 0-100 um pp
|
||||
kVelDisPP200 = 1, // 0-200 um pp
|
||||
kVelDisPP500 = 2, // 0-500 um pp
|
||||
kVelDisPPCustom = 3 // custom
|
||||
} VelDisPPFullScaleRange;
|
||||
|
||||
// recorder out
|
||||
typedef enum {
|
||||
kVelRecorderOutNone = 0,
|
||||
kVelRecorderOutDirectAmpl = 1,
|
||||
kVelRecorderOut1XAmpl = 2,
|
||||
kVelRecorderOut2XAmpl = 3
|
||||
} VelRecorderOut;
|
||||
|
||||
#endif // VELOCITY_DS_H
|
||||
24
vibrationdata.cpp
Normal file
24
vibrationdata.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "vibrationdata.h"
|
||||
|
||||
VibrationData::VibrationData() {
|
||||
}
|
||||
|
||||
std::shared_ptr<VariableBase> VibrationData::GetChannelPtr(int cid) {
|
||||
for (auto &item : variables_) {
|
||||
if (item->id_ == cid) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void VibrationData::RemoveChannel(int cid) {
|
||||
std::vector<std::shared_ptr<VariableBase>> tmp;
|
||||
for (auto &item : variables_) {
|
||||
if (item->id_ != cid) {
|
||||
tmp.push_back(item);
|
||||
}
|
||||
}
|
||||
variables_.clear();
|
||||
variables_ = tmp;
|
||||
}
|
||||
18
vibrationdata.h
Normal file
18
vibrationdata.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef VIBRATIONDATA_H
|
||||
#define VIBRATIONDATA_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "cardbase.h"
|
||||
|
||||
|
||||
class VibrationData : public CardBase {
|
||||
public:
|
||||
VibrationData();
|
||||
std::shared_ptr<VariableBase> GetChannelPtr(int cid);
|
||||
void RemoveChannel(int cid);
|
||||
SeismicMonitor base_config_[CHANNEL_COUNT];
|
||||
std::vector<std::shared_ptr<VariableBase>> variables_;
|
||||
VibAlertDanger alert_danger[CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
#endif // VIBRATIONDATA_H
|
||||
Loading…
x
Reference in New Issue
Block a user