add ch 1 & 2 config ,fix keyphase bugs

This commit is contained in:
zhangsheng 2026-01-06 17:56:23 +08:00
parent f7554909f8
commit 0770af3c7b
8 changed files with 484 additions and 267 deletions

View File

@ -61,40 +61,53 @@ void ConfigMgr::Save(QString & file_path) {
if( ptr->base_config_[cid].channel_type == -1){
continue;
}
channel_item["standby"] = ptr->base_config_[cid].standby;
channel_item["active"] = ptr->base_config_[cid].active;
// channel_item["rack_type"] = 0; // TODO:
if(ptr->base_config_[cid].channel_type == kVib12 ||
ptr->base_config_[cid].channel_type == kVib34){
channel_item["function"] = ptr->base_config_[cid].function;
if(ptr->base_config_[cid].function == kRST){
channel_item["fisrt_channel_angle"] = ptr->base_config_[cid].fisrt_channel_angle;
channel_item["second_channel_angle"] = ptr->base_config_[cid].second_channel_angle;
}else if(ptr->base_config_[cid].function == kDMF){
channel_item["dmf_function"] = ptr->base_config_[cid].dmf_function;
}
channel_item["function"] = ptr->base_config_[cid].function;
}else{
channel_item["standby"] = ptr->base_config_[cid].standby;
channel_item["active"] = ptr->base_config_[cid].active;
// channel_item["rack_type"] = 0; // TODO:
// 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;
channel_item["sensitivity_unit"] = ptr->base_config_[cid].sensitivity_unit;
channel_item["signal_sensitivity"] = ptr->base_config_[cid].signal_sensitivity;
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;
// output channel
QJsonObject dc_output_item;
if(ptr->dc_output[cid].output_channel != -1){
dc_output_item["output_channel"] = ptr->dc_output[cid].output_channel;
dc_output_item["minmum"] = ptr->dc_output[cid].minmum;
dc_output_item["maxmum"] = ptr->dc_output[cid].maxmum;
dc_output[QString::number(cid + 1)] = dc_output_item;
}
if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust ||
ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){
if(ptr->base_config_[cid].channel_type != kVibThrust){
channel_item["keyphase"] = ptr->base_config_[cid].keyphase;
channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot;
channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch;
}
}
}
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;
channel_item["sensitivity_unit"] = ptr->base_config_[cid].sensitivity_unit;
channel_item["signal_sensitivity"] = ptr->base_config_[cid].signal_sensitivity;
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;
// output channel
QJsonObject dc_output_item;
if(ptr->dc_output[cid].output_channel != -1){
dc_output_item["output_channel"] = ptr->dc_output[cid].output_channel;
dc_output_item["minmum"] = ptr->dc_output[cid].minmum;
dc_output_item["maxmum"] = ptr->dc_output[cid].maxmum;
dc_output[QString::number(cid + 1)] = dc_output_item;
}
if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust ||
ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){
if(ptr->base_config_[cid].channel_type != kVibThrust){
channel_item["keyphase"] = ptr->base_config_[cid].keyphase;
channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot;
channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch;
}
}
// if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){
// setpoint_data["low_upper"] = qRound(ptr->alert_danger_press[cid].low_upper * 10)/10.0;
// setpoint_data["low_enable"] = ptr->alert_danger_press[cid].low_enable;
@ -110,7 +123,7 @@ void ConfigMgr::Save(QString & file_path) {
// variables
QJsonObject variables;
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
if (base_channel_ptr == nullptr) {
if (base_channel_ptr == nullptr && cid < 4) {
continue;
}
if (ptr->base_config_[cid].channel_type == kVibRadial) {
@ -435,92 +448,6 @@ void ConfigMgr::Save(QString & file_path) {
processed_output["general"] = general;
processed_output["alarm"] = alarm;
variables["processed_output"] = processed_output;
}else if(ptr->base_config_[cid].channel_type == kVib12){
std::shared_ptr<DefaultVariable> av_ptr = std::dynamic_pointer_cast<DefaultVariable>(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;
// processed output
QJsonObject processed_output,general,alarm;
general["output_used"] = av_ptr->general.output_used;
general["engieneering_unit"] = av_ptr->general.engineering_unit;
general["rectifier_function"] = av_ptr->general.rectifier_function;
alarm["danger_high_level"] = av_ptr->danger_high.level;
alarm["danger_high_hysteresis"] = av_ptr->danger_high.hysteresis;
alarm["danger_high_delay"] = av_ptr->danger_high.delay;
alarm["danger_high_enable"] = av_ptr->danger_high.enable;
alarm["danger_high_latch"] = av_ptr->danger_high.latch;
alarm["alert_high_level"] = av_ptr->alert_high.level;
alarm["alert_high_hysteresis"] = av_ptr->alert_high.hysteresis;
alarm["alert_high_delay"] = av_ptr->alert_high.delay;
alarm["alert_high_enable"] = av_ptr->alert_high.enable;
alarm["alert_high_latch"] = av_ptr->alert_high.latch;
processed_output["general"] = general;
processed_output["alarm"] = alarm;
variables["processed_output"] = processed_output;
}else if(ptr->base_config_[cid].channel_type == kVib34){
std::shared_ptr<DefaultVariable> av_ptr = std::dynamic_pointer_cast<DefaultVariable>(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;
// processed output
QJsonObject processed_output,general,alarm;
general["output_used"] = av_ptr->general.output_used;
general["engieneering_unit"] = av_ptr->general.engineering_unit;
general["rectifier_function"] = av_ptr->general.rectifier_function;
alarm["danger_high_level"] = av_ptr->danger_high.level;
alarm["danger_high_hysteresis"] = av_ptr->danger_high.hysteresis;
alarm["danger_high_delay"] = av_ptr->danger_high.delay;
alarm["danger_high_enable"] = av_ptr->danger_high.enable;
alarm["danger_high_latch"] = av_ptr->danger_high.latch;
alarm["alert_high_level"] = av_ptr->alert_high.level;
alarm["alert_high_hysteresis"] = av_ptr->alert_high.hysteresis;
alarm["alert_high_delay"] = av_ptr->alert_high.delay;
alarm["alert_high_enable"] = av_ptr->alert_high.enable;
alarm["alert_high_latch"] = av_ptr->alert_high.latch;
processed_output["general"] = general;
processed_output["alarm"] = alarm;
variables["processed_output"] = processed_output;
}
channel_item["variable"] = variables;
} else if (card_type_[i] == kCardSpeedSingle || card_type_[i] == kCardSpeedTMRPrimary) {
@ -738,25 +665,37 @@ void ConfigMgr::Load(QString filename) {
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();
vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt();
vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble();
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
if(vib_data->base_config_[j].channel_type == kVib12 ||
vib_data->base_config_[j].channel_type == kVib34){
vib_data->base_config_[j].function = channel["function"].toInt();
if(vib_data->base_config_[j].function == kRST){
vib_data->base_config_[j].fisrt_channel_angle = channel["fisrt_channel_angle"].toDouble();
vib_data->base_config_[j].second_channel_angle = channel["second_channel_angle"].toDouble();
}else if(vib_data->base_config_[j].function == kDMF){
vib_data->base_config_[j].dmf_function = channel["dmf_function"].toInt();
}
}else{
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].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();
vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt();
vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble();
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
}
//setpoint
QJsonObject setpoint_data = channel["setpoint"].toObject();
if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust ||
@ -1049,49 +988,11 @@ void ConfigMgr::Load(QString filename) {
break;
}
case kVib12: {
std::shared_ptr<DefaultVariable> variable = std::make_shared<DefaultVariable>();
variable->id_ = j + 1;
QJsonObject processed_output, general, alarm;
processed_output = tmp_variable["processed_output"].toObject();
general = processed_output["general"].toObject();
alarm = processed_output["alarm"].toObject();
variable->general.output_used = general["output_used"].toBool();
variable->general.engineering_unit = general["engieneering_unit"].toInt();
variable->general.rectifier_function = general["rectifier_function"].toInt();
variable->danger_high.level = alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
variable->alert_high.level = alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
vib_data->variables_.push_back(variable);
break;
}
case kVib34: {
std::shared_ptr<DefaultVariable> variable = std::make_shared<DefaultVariable>();
variable->id_ = j + 1;
QJsonObject processed_output, general, alarm;
processed_output = tmp_variable["processed_output"].toObject();
general = processed_output["general"].toObject();
alarm = processed_output["alarm"].toObject();
variable->general.output_used = general["output_used"].toBool();
variable->general.engineering_unit = general["engieneering_unit"].toInt();
variable->general.rectifier_function = general["rectifier_function"].toInt();
variable->danger_high.level = alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
variable->alert_high.level = alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
vib_data->variables_.push_back(variable);
break;
}
}
@ -1147,6 +1048,7 @@ void ConfigMgr::Load(QString filename) {
keyphase_data->slot_ = slot;
keyphase_data->card_type_ = static_cast<CardType>(card_type_[i]);
keyphase_data->version_ = temp_obj["version"].toInt();
keyphase_data->relative_number = temp_obj["relative_number"].toInt();
keyphase_data->group = temp_obj["group"].toInt();
for (int j = 0; j < CHANNEL_COUNT_SPEED; ++j) {
channel = temp_obj[QString::number(j + 1)].toObject();

View File

@ -136,6 +136,15 @@ typedef enum{
kRMS = 6
} RectifierFuntion;
typedef enum{
kNoProcessing = 0,
kSMAX = 1,
kDHE = 2,
kRST = 3,
kRSC = 4,
kDMF = 5
}Funtion;
typedef enum{
kRMSSum = 0,
kRMSSubtraction = 1,
@ -228,7 +237,8 @@ enum CMTCommand {
kConfigMQTTBrokerInfo = 31, // 配置与获取MQTT broker信息
kConfigDeviceID = 32, // 配置设备编号编号范围为1~99
kGetVoltageRangeValue = 33, // 获取子板动态电压范围
kGetVibAuxProcessVersion = 34
kGetVibAuxProcessVersion = 34,
kGetProcessID = 38 // 获取进程号
};
enum RS485Baudrate {
kBaudrate2400 = 0,
@ -276,6 +286,7 @@ typedef struct SeismicMonitor_{
int function;
float fisrt_channel_angle;
float second_channel_angle;
int dmf_function;
SeismicMonitor_(){
standby = false;
active = false;
@ -897,6 +908,22 @@ typedef struct {
uint8_t aux_version; // 辅助进程版本号
} GetAuxProcessVersionRsp;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd; // kGetProcessID
uint8_t version; // 版本号默认为1
uint8_t card_id; // 0xff为cpu卡其它1-15
} GetCardProcessIDReq;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd; // kGetProcessID
uint8_t version; // 版本号默认为1
uint8_t code;
uint16_t pid1; // 主进程进程号
uint16_t pid2; // 辅助进程进程号,只有振动板有这个号
} GetCardProcessIDRsp;
struct BaseHeader {
uint8_t head[3]; // 固定 0xAA 0x55 0xAA
uint8_t cmd;

View File

@ -213,7 +213,8 @@ void KeyPhase::Init() {
ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution);
}
}
ui->comboBox_group->setCurrentIndex(base_ptr->group + 1);
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
ui->comboBox_group->setCurrentIndex(base_ptr->group -1);
}
void KeyPhase::on_pushButton_confirm_clicked() {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
@ -222,6 +223,8 @@ void KeyPhase::on_pushButton_confirm_clicked() {
return;
}
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
base_ptr->relative_number = ui->comboBox_relative_number->currentIndex();
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
UpdateData(keyphase_data);
this->close();

View File

@ -117,6 +117,107 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_44">
<item>
<widget class="QLabel" name="label_95">
<property name="text">
<string> 相对编号:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_relative_number">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>0</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>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>9</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
<item>
<property name="text">
<string>11</string>
</property>
</item>
<item>
<property name="text">
<string>12</string>
</property>
</item>
<item>
<property name="text">
<string>13</string>
</property>
</item>
<item>
<property name="text">
<string>14</string>
</property>
</item>
<item>
<property name="text">
<string>15</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -216,6 +216,7 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
QAction *get_sub_log = mainMenu->addAction("获取日志");
QAction *get_sub_card_voltage = mainMenu->addAction("获取电压范围");
QAction *get_vib_version = mainMenu->addAction("获取振动板卡辅助程序版本");
QAction *get_card_processID = mainMenu->addAction("获取进程号");
// 绑定 **鼠标事件过滤器**,确保只响应右键
// 设置右键菜单策略
@ -243,7 +244,7 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
QObject::connect(get_sub_log, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(get_sub_card_voltage, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(get_vib_version, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(get_card_processID, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
}
@ -355,6 +356,13 @@ void MainWindow::onMenuActionTriggered() {
return;
}
if (action->text() == "重置模块") {
QMessageBox *box = new QMessageBox(QMessageBox::Question, "提示", "是否重置板卡?", QMessageBox::Yes | QMessageBox::No, this);
box->button(QMessageBox::Yes)->setText("确认");
box->button(QMessageBox::No)->setText("取消");
int res = box->exec();
if(QMessageBox::No == res){
return;
}
if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRPrimary) {
map_slot_config[button_id].slot_type = "";
map_slot_config[button_id].slot_btn->setText("");
@ -417,6 +425,8 @@ void MainWindow::onMenuActionTriggered() {
GetVoltageRangeValue(button_id);
}else if(action->text() == "获取振动板卡辅助程序版本"){
GetVibVersion(button_id);
}else if(action->text() == "获取进程号"){
GetCardProcessID(button_id);
}
break; // 找到按钮后,跳出循环
}
@ -771,11 +781,13 @@ void MainWindow::sendUpgradePackage(int slot) {
}
qDebug() << "bytesSent" << bytesSent ;
m_tcpClient->waitForRead();
progressBar->reset();
progressBar->setVisible(true);
QString upgrade_text = QStringLiteral("正在上传板卡 [ %1 ] …… %p%").arg(slot);
progressBar->setTextVisible(true);
progressBar->setFormat(upgrade_text);
if (slot != 0){
progressBar->reset();
progressBar->setVisible(true);
QString upgrade_text = QStringLiteral("正在上传板卡 [ %1 ] …… %p%").arg(slot);
progressBar->setTextVisible(true);
progressBar->setFormat(upgrade_text);
}
file.close();
if (send_buf != NULL) {
free(send_buf);
@ -857,6 +869,15 @@ void MainWindow::GetVibVersion(int slot){
m_tcpClient->waitForRead();
qDebug() << "bytesWritten: " << bytesWritten;
}
void MainWindow::GetCardProcessID(int slot){
slot_no = slot;
GetCardProcessIDReq get_card_processID_req = { {0xAA, 0x55, 0xAA}, kGetProcessID, 1,0};
int length = sizeof(GetCardProcessIDReq);
get_card_processID_req.card_id = slot & 0xFF;
qint64 bytesWritten = m_tcpClient->sendData((char*)&get_card_processID_req, length);
m_tcpClient->waitForRead();
qDebug() << "bytesWritten: " << bytesWritten;
}
void MainWindow::readData(const QByteArray &data) {
qDebug() << "Received from server:" << data;
@ -970,6 +991,16 @@ void MainWindow::readData(const QByteArray &data) {
memcpy(&get_vib_version_rsp, data.data(), sizeof(GetAuxProcessVersionRsp));
QString str = QString("辅助程序版本: %1").arg(get_vib_version_rsp.aux_version);
QMessageBox::information(this, QStringLiteral("提示"), str);
}else if(cmd == kGetProcessID){
GetCardProcessIDRsp get_card_processID_rsp;
memcpy(&get_card_processID_rsp, data.data(), sizeof(GetCardProcessIDRsp));
QString message = "";
if(ConfigMgr::Instance()->card_type_[current_slot] == kCardVibSingle){
message = QString("主进程进程号: %1 \n辅助进程进程号: %2").arg(get_card_processID_rsp.pid1).arg(get_card_processID_rsp.pid2);
}else {
message = QString("主进程进程号: %1").arg(get_card_processID_rsp.pid1);
}
QMessageBox::information(this, QStringLiteral("提示"), message);
}
}
@ -1041,7 +1072,7 @@ void MainWindow::onSetTime(){
qDebug() << "bytesWritten: " << bytesWritten;
}
void MainWindow::UploadConfigFile(uint8_t sub_cmd){
QMessageBox *box = new QMessageBox(QMessageBox::Question, "提示", "确认上传配置文件?", QMessageBox::Yes | QMessageBox::No, this);
QMessageBox *box = new QMessageBox(QMessageBox::Question, "提示", "是否上传配置文件?", QMessageBox::Yes | QMessageBox::No, this);
box->button(QMessageBox::Yes)->setText("确认");
box->button(QMessageBox::No)->setText("取消");
int res = box->exec();
@ -1061,7 +1092,7 @@ void MainWindow::UploadConfigFile(uint8_t sub_cmd){
QByteArray fileData = file.readAll();
int fileSize = fileData.size();
if (fileSize > 10 * 1024 * 1024) {
QMessageBox::information(this, QStringLiteral("提示"), "文件大小超过10M,请重新选择!");
QMessageBox::information(this, QStringLiteral("提示"), "文件大小超过10MB,请重新选择!");
file.close();
return;
}

View File

@ -63,6 +63,7 @@ private:
void UploadConfigFile(uint8_t sub_cmd);
void GetVoltageRangeValue(int slot);
void GetVibVersion(int slot);
void GetCardProcessID(int slot);
private slots:

View File

@ -39,10 +39,14 @@ Seismic_monitor::Seismic_monitor(int slot,CardType cardtype, QWidget *parent) :
ui->lineEdit_first_2->setVisible(false);
ui->lineEdit_second_1->setVisible(false);
ui->lineEdit_second_2->setVisible(false);
ui->comboBox_dual_math_function->setVisible(false);
ui->comboBox_dual_math_function_2->setVisible(false);
ui->label_text_1->setVisible(false);
ui->label_text_2->setVisible(false);
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->label_text_5->setVisible(false);
ui->label_text_6->setVisible(false);
Init();
}
@ -135,16 +139,42 @@ void Seismic_monitor::Init() {
ui->doubleSpinBox_high_4->setValue(vib_data->base_config_[i].normal_voltage_high);
}else if (i + 1 == 5) {
vib_data->base_config_[i].function = ui->comboBox_function_1->currentIndex();
if(ui->comboBox_function_1->currentIndex() == 3){
vib_data->base_config_[i].fisrt_channel_angle = ui->lineEdit_first_1->text().toFloat();
vib_data->base_config_[i].second_channel_angle = ui->lineEdit_second_1->text().toFloat();
ui->comboBox_function_1->setCurrentIndex(vib_data->base_config_[i].function);
if(vib_data->base_config_[i].function == kRST){
ui->lineEdit_first_1->setVisible(true);
ui->lineEdit_second_1->setVisible(true);
ui->label_text_1->setVisible(true);
ui->label_text_2->setVisible(true);
ui->comboBox_dual_math_function->setVisible(false);
ui->label_text_5->setVisible(false);
ui->lineEdit_first_1->setText(QString::number(vib_data->base_config_[i].fisrt_channel_angle));
ui->lineEdit_second_1->setText(QString::number(vib_data->base_config_[i].second_channel_angle));
}else if(vib_data->base_config_[i].function == kDMF){
ui->lineEdit_first_2->setVisible(false);
ui->lineEdit_second_2->setVisible(false);
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->comboBox_dual_math_function->setVisible(true);
ui->label_text_5->setVisible(true);
}
}else if (i + 1 == 6) {
vib_data->base_config_[i].function = ui->comboBox_function_2->currentIndex();
if(ui->comboBox_function_2->currentIndex() == 3){
vib_data->base_config_[i].fisrt_channel_angle = ui->lineEdit_first_2->text().toFloat();
vib_data->base_config_[i].second_channel_angle = ui->lineEdit_second_2->text().toFloat();
ui->comboBox_function_2->setCurrentIndex(vib_data->base_config_[i].function);
if(vib_data->base_config_[i].function == kRST){
ui->lineEdit_first_2->setVisible(true);
ui->lineEdit_second_2->setVisible(true);
ui->label_text_3->setVisible(true);
ui->label_text_4->setVisible(true);
ui->comboBox_dual_math_function_2->setVisible(false);
ui->label_text_6->setVisible(false);
ui->lineEdit_first_2->setText(QString::number(vib_data->base_config_[i].fisrt_channel_angle));
ui->lineEdit_second_2->setText(QString::number(vib_data->base_config_[i].second_channel_angle));
}else if(vib_data->base_config_[i].function == kDMF){
ui->lineEdit_first_2->setVisible(false);
ui->lineEdit_second_2->setVisible(false);
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->comboBox_dual_math_function_2->setVisible(true);
ui->label_text_6->setVisible(true);
}
}
}
@ -229,13 +259,19 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
if(ui->comboBox_function_1->currentIndex() == 3){
vib_data->base_config_[var].fisrt_channel_angle = ui->lineEdit_first_1->text().toFloat();
vib_data->base_config_[var].second_channel_angle = ui->lineEdit_second_1->text().toFloat();
}else if(ui->comboBox_function_1->currentIndex() == 5){
vib_data->base_config_[var].dmf_function = ui->comboBox_dual_math_function->currentIndex();
}
vib_data->base_config_[var].channel_type = kVib12;
}else if (var + 1 == 6) {
vib_data->base_config_[var].function = ui->comboBox_function_2->currentIndex();
if(ui->comboBox_function_2->currentIndex() == 3){
vib_data->base_config_[var].fisrt_channel_angle = ui->lineEdit_first_2->text().toFloat();
vib_data->base_config_[var].second_channel_angle = ui->lineEdit_second_2->text().toFloat();
}else if(ui->comboBox_function_1->currentIndex() == 5){
vib_data->base_config_[var].dmf_function = ui->comboBox_dual_math_function->currentIndex();
}
vib_data->base_config_[var].channel_type = kVib34;
}
}
}
@ -613,21 +649,27 @@ void Seismic_monitor::on_comboBox_function_2_currentIndexChanged(int index)
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
if(index == 2){
ui->pushButton_config_3_4->setEnabled(false);
}else{
ui->pushButton_config_3_4->setEnabled(true);
}
if(index == 3){
ui->lineEdit_first_2->setVisible(true);
ui->lineEdit_second_2->setVisible(true);
ui->label_text_3->setVisible(true);
ui->label_text_4->setVisible(true);
ui->comboBox_dual_math_function_2->setVisible(false);
ui->label_text_6->setVisible(false);
}else if(index == 5){
ui->lineEdit_first_2->setVisible(false);
ui->lineEdit_second_2->setVisible(false);
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->comboBox_dual_math_function_2->setVisible(true);
ui->label_text_6->setVisible(true);
}else{
ui->lineEdit_first_2->setVisible(false);
ui->lineEdit_second_2->setVisible(false);
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->comboBox_dual_math_function_2->setVisible(false);
ui->label_text_6->setVisible(false);
}
current_config_3_4 = index;
}
@ -639,21 +681,27 @@ void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index)
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
if(index == 2){
ui->pushButton_config_1_2->setEnabled(false);
}else{
ui->pushButton_config_1_2->setEnabled(true);
}
if(index == 3){
ui->lineEdit_first_1->setVisible(true);
ui->lineEdit_second_1->setVisible(true);
ui->label_text_1->setVisible(true);
ui->label_text_2->setVisible(true);
ui->comboBox_dual_math_function->setVisible(false);
ui->label_text_5->setVisible(false);
}else if(index == 5){
ui->lineEdit_first_1->setVisible(false);
ui->lineEdit_second_1->setVisible(false);
ui->label_text_1->setVisible(false);
ui->label_text_2->setVisible(false);
ui->comboBox_dual_math_function->setVisible(true);
ui->label_text_5->setVisible(true);
}else{
ui->lineEdit_first_1->setVisible(false);
ui->lineEdit_second_1->setVisible(false);
ui->label_text_1->setVisible(false);
ui->label_text_2->setVisible(false);
ui->comboBox_dual_math_function->setVisible(false);
ui->label_text_5->setVisible(false);
}
current_config_1_2 = index;
}

View File

@ -1153,19 +1153,6 @@
<attribute name="title">
<string>通道1-通道2</string>
</attribute>
<widget class="QPushButton" name="pushButton_config_1_2">
<property name="geometry">
<rect>
<x>110</x>
<y>220</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>配置</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
@ -1231,47 +1218,12 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>329</width>
<height>23</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_44">
<item>
<widget class="QLineEdit" name="lineEdit_first_1">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_text_1">
<property name="text">
<string>第一通道安装角度</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>170</y>
<width>329</width>
<width>311</width>
<height>23</height>
</rect>
</property>
@ -1301,6 +1253,106 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>292</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_48">
<item>
<widget class="QComboBox" name="comboBox_dual_math_function">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>RMS Sum</string>
</property>
</item>
<item>
<property name="text">
<string>RMS Subtraction</string>
</property>
</item>
<item>
<property name="text">
<string>SUM</string>
</property>
</item>
<item>
<property name="text">
<string>SUBTRACTION</string>
</property>
</item>
<item>
<property name="text">
<string>X &amp; Y MIN</string>
</property>
</item>
<item>
<property name="text">
<string>X &amp; Y MAX</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_text_5">
<property name="text">
<string>双通道计算函数</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>21</x>
<y>131</y>
<width>304</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_44">
<item>
<widget class="QLineEdit" name="lineEdit_first_1">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_text_1">
<property name="text">
<string>第一通道安装角度</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
@ -2488,19 +2540,6 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton_config_3_4">
<property name="geometry">
<rect>
<x>100</x>
<y>220</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>配置</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry">
<rect>
@ -2571,6 +2610,71 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_5">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>292</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_49">
<item>
<widget class="QComboBox" name="comboBox_dual_math_function_2">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>RMS Sum</string>
</property>
</item>
<item>
<property name="text">
<string>RMS Subtraction</string>
</property>
</item>
<item>
<property name="text">
<string>SUM</string>
</property>
</item>
<item>
<property name="text">
<string>SUBTRACTION</string>
</property>
</item>
<item>
<property name="text">
<string>X &amp; Y MIN</string>
</property>
</item>
<item>
<property name="text">
<string>X &amp; Y MAX</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_text_6">
<property name="text">
<string>双通道计算函数</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>