添加代码,可以保存键相,转速,振动板卡数据
This commit is contained in:
parent
c1f45d3524
commit
0eb563da4e
@ -270,6 +270,7 @@ void Acceleration::on_pushButton_confirm_clicked() {
|
||||
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);
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "vibrationdata.h"
|
||||
#include "tachometer_data.h"
|
||||
#include "keyphase_data.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
ConfigMgr *ConfigMgr::instance = nullptr;
|
||||
|
||||
@ -32,7 +34,7 @@ void ConfigMgr::Save() {
|
||||
card_type_[i] != kCardVibTMRPrimary &&
|
||||
card_type_[i] != kCardSpeedSingle &&
|
||||
card_type_[i] != kCardSpeedTMRPrimary &&
|
||||
card_type_[i] != kCardKeyphase &&
|
||||
card_type_[i] != kCardKeyphaseSingle &&
|
||||
card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary) {
|
||||
continue;
|
||||
@ -57,6 +59,7 @@ void ConfigMgr::Save() {
|
||||
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;
|
||||
QJsonArray voltage_range;
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_low);
|
||||
voltage_range.append(ptr->base_config_[cid].normal_voltage_high);
|
||||
@ -64,6 +67,9 @@ void ConfigMgr::Save() {
|
||||
// variables
|
||||
QJsonObject variables;
|
||||
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
|
||||
if (base_channel_ptr == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (base_channel_ptr->type_ == kVibRadial) {
|
||||
std::shared_ptr<RadialVariable> radial_ptr = std::dynamic_pointer_cast<RadialVariable>(base_channel_ptr);
|
||||
// filter
|
||||
@ -214,7 +220,7 @@ void ConfigMgr::Save() {
|
||||
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);
|
||||
} else if (card_type_[i] == kCardKeyphase) {
|
||||
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||
if (base_ptr == nullptr) {
|
||||
continue;
|
||||
@ -231,7 +237,7 @@ void ConfigMgr::Save() {
|
||||
}
|
||||
slot_item[QString::number(cid + 1)] = channel_item;
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
// TODO: save relay data
|
||||
}
|
||||
doc_obj[QString::number(slot)] = slot_item;
|
||||
@ -240,6 +246,7 @@ void ConfigMgr::Save() {
|
||||
// TODO: show success message box
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(doc_obj);
|
||||
filename_ = QCoreApplication::applicationDirPath() + "\\config\\tsi_config_file.json";
|
||||
QFile file(filename_);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
@ -296,6 +303,8 @@ void ConfigMgr::Load(QString filename) {
|
||||
vib_data->slot_ = slot;
|
||||
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
||||
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();
|
||||
@ -308,6 +317,7 @@ void ConfigMgr::Load(QString filename) {
|
||||
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();
|
||||
// variables
|
||||
QJsonObject tmp_variable = channel["variable"].toObject();
|
||||
switch (vib_data->base_config_[j].channel_type) {
|
||||
@ -439,7 +449,7 @@ void ConfigMgr::Load(QString filename) {
|
||||
speed_data->variables_[j].default_speed = channel["default_speed"].toInt();
|
||||
}
|
||||
cards_.push_back(speed_data);
|
||||
} else if (card_type_[i] == kCardKeyphase) {
|
||||
} 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]);
|
||||
|
@ -13,6 +13,7 @@ class ConfigMgr {
|
||||
}
|
||||
}
|
||||
public:
|
||||
int card_type_[15];
|
||||
static ConfigMgr *Instance() {
|
||||
if (instance == nullptr) {
|
||||
instance = new ConfigMgr();
|
||||
@ -26,7 +27,7 @@ class ConfigMgr {
|
||||
void AddCard(std::shared_ptr<CardBase> ptr);
|
||||
private:
|
||||
QString filename_;
|
||||
int card_type_[15];
|
||||
|
||||
std::vector<std::shared_ptr<CardBase>> cards_;
|
||||
};
|
||||
|
||||
|
@ -20,15 +20,19 @@ typedef enum {
|
||||
kCardVibSingle = 10,
|
||||
kCardVibTMRPrimary = 11,
|
||||
kCardVibTMRBackup = 12,
|
||||
kCardVibDoublePrimary = 13,
|
||||
kCardVibDoubleBackup = 14,
|
||||
|
||||
kCardSpeedSingle = 20,
|
||||
kCardSpeedTMRPrimary = 21,
|
||||
kCardSpeedTMRBackup = 22,
|
||||
|
||||
kCardKeyphase = 30,
|
||||
kCardRelaySingle = 31,
|
||||
kCardRelayTMRPrimary = 32,
|
||||
kCardRelayTMRBackup = 33,
|
||||
kCardKeyphaseSingle = 30,
|
||||
kCardKeyphaseDouble = 31,
|
||||
kCardRelaySingle = 32,
|
||||
kCardRelayTMRPrimary = 33,
|
||||
kCardRelayTMRBackup = 34,
|
||||
|
||||
} CardType;
|
||||
|
||||
// 振动板通道类型
|
||||
@ -84,6 +88,7 @@ typedef struct {
|
||||
int sampling_rate; // VibSamplingRate
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
bool power;
|
||||
} SeismicMonitor;
|
||||
|
||||
typedef enum {
|
||||
|
@ -10,13 +10,14 @@
|
||||
#include "config_mgr.h"
|
||||
#include "keyphase_data.h"
|
||||
|
||||
KeyPhase::KeyPhase(int slot_no_, QWidget *parent)
|
||||
KeyPhase::KeyPhase(int slot_no_,int cardtype, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, 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);
|
||||
@ -77,7 +78,7 @@ void KeyPhase::on_manual_threshold_4_clicked(bool checked) {
|
||||
}
|
||||
|
||||
void KeyPhase::UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data) {
|
||||
keyphase_data->card_type_ = kCardKeyphase;
|
||||
keyphase_data->card_type_ = kCardKeyphaseSingle;
|
||||
keyphase_data->slot_ = slot_no;
|
||||
keyphase_data->version_ = 1;
|
||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||
@ -122,6 +123,8 @@ void KeyPhase::Init() {
|
||||
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;
|
||||
|
@ -12,10 +12,10 @@ class KeyPhase : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KeyPhase(int slot_no_, QWidget *parent = nullptr);
|
||||
explicit KeyPhase(int slot_no_,int cardtype, QWidget *parent = nullptr);
|
||||
~KeyPhase();
|
||||
int slot_no;
|
||||
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
119
mainwindow.cpp
119
mainwindow.cpp
@ -83,7 +83,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
list_label.push_back(ui->label_14);
|
||||
list_label.push_back(ui->label_15);
|
||||
ui->pushButton_slot->setChecked(true);
|
||||
readJsonFile(QCoreApplication::applicationDirPath() + "\\config\\main.json");
|
||||
createMenu();
|
||||
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
||||
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini", QSettings::IniFormat);
|
||||
@ -168,12 +167,19 @@ void MainWindow::readJsonFile(const QString &filePath) {
|
||||
void MainWindow::createMenu() {
|
||||
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 0; i < buttonList.count(); i++) {
|
||||
buttonList[i]->setText(map_slot_config[i].chan_display);
|
||||
createMenu(QString("%1").arg(i + 1), (QPushButton *)buttonList[i]);
|
||||
map_slot_config[i].slot_btn = (QPushButton *)buttonList[i];
|
||||
map_slot_config[i].slot_label = list_label[i];
|
||||
// else
|
||||
// createMenuSet(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]);
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i);
|
||||
if(base_ptr != nullptr){
|
||||
switch (base_ptr->card_type_) {
|
||||
case kCardVibSingle :
|
||||
buttonList[i]->setText("振动");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,14 +195,20 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
|
||||
QMenu *rpm_menu = new QMenu("/OPM844 转速板卡", monitors);
|
||||
// 创建第三层子菜单:/HAM824 单板卡、三冗余板卡
|
||||
QAction *proximitor_1 = proximitor_menu->addAction("/HAM824 单板卡");
|
||||
proximitor_1->setData(kCardVibSingle);
|
||||
QAction *proximitor_2 = proximitor_menu->addAction("/HAM824 三冗余板卡");
|
||||
proximitor_2->setData(kCardVibTMRPrimary);
|
||||
QAction *rpm_1 = rpm_menu->addAction("/OPM844 单板卡");
|
||||
// 创建第二层子菜单:/KPM834 键相模块
|
||||
QAction *keyphasor_1 = keyphasor->addAction("/KPM834 单板卡");
|
||||
keyphasor_1->setData(kCardKeyphaseSingle);
|
||||
QAction *keyphasor_2 = keyphasor->addAction("/KPM834 两板卡");
|
||||
keyphasor_2->setData(kCardKeyphaseDouble);
|
||||
// 创建第二层子菜单:/DOM810 继电器模块
|
||||
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
||||
relays_1->setData(kCardRelaySingle);
|
||||
QAction *relays_2 = relays->addAction("/DOM810 三冗余板卡");
|
||||
relays_2->setData(kCardRelayTMRPrimary);
|
||||
// 将子菜单加入上一级菜单
|
||||
monitors->addMenu(proximitor_menu); // 将第二层加入第一层
|
||||
monitors->addMenu(rpm_menu); // 第二层另一个子菜单
|
||||
@ -273,6 +285,8 @@ void MainWindow::onMenuActionTriggered() {
|
||||
qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text();
|
||||
QString slot_type = action->text().mid(1, 6);
|
||||
QString rack_type = action->text().right(action->text().length() - 8);
|
||||
qDebug() << "rack_type" << action->data();
|
||||
card_type = static_cast<CardType>(action->data().toInt());
|
||||
int button_id = button->objectName().right(button->objectName().length() - 15).toInt();
|
||||
qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id + 1].slot_type << map_slot_config[button_id + 2].slot_type ;
|
||||
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
||||
@ -283,12 +297,6 @@ void MainWindow::onMenuActionTriggered() {
|
||||
chan_display = "键相";
|
||||
} else if (slot_type == "HAM824") {
|
||||
chan_display = "振动";
|
||||
auto vibrationData = std::make_shared<VibrationData>();
|
||||
vibrationData->slot_ = button_id;
|
||||
if(rack_type == "单板卡"){
|
||||
vibrationData->card_type_ = kCardVibSingle;
|
||||
}
|
||||
ConfigMgr::Instance()->AddCard(vibrationData);
|
||||
} else if (slot_type == "OPM844") {
|
||||
chan_display = "转速";
|
||||
}
|
||||
@ -419,22 +427,41 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||
SlotConfig slot_config = map_slot_config[button_id];
|
||||
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
||||
if (slot_config.slot_type == "KPM834") { // 键相模块
|
||||
KeyPhase *key_phase = new KeyPhase(button_id);
|
||||
key_phase->setWindowModality(Qt::ApplicationModal);
|
||||
key_phase->show();
|
||||
} else if (slot_config.slot_type == "DOM810") { // 继电器模块
|
||||
SingleRelay *single_relay = new SingleRelay();
|
||||
single_relay->setWindowModality(Qt::ApplicationModal);
|
||||
single_relay->show();
|
||||
} else if (slot_config.slot_type == "HAM824") { // 振动模块
|
||||
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id);
|
||||
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
||||
seismic_monitor->show();
|
||||
} else if (slot_config.slot_type == "OPM844") { // 转速模块
|
||||
Tachometer *tachometer = new Tachometer(button_id);
|
||||
tachometer->setWindowModality(Qt::ApplicationModal);
|
||||
tachometer->show();
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr == nullptr){
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = card_type;
|
||||
if (slot_config.slot_type == "KPM834") { // 键相模块
|
||||
KeyPhase *key_phase = new KeyPhase(button_id,card_type);
|
||||
key_phase->setWindowModality(Qt::ApplicationModal);
|
||||
key_phase->show();
|
||||
} else if (slot_config.slot_type == "DOM810") { // 继电器模块
|
||||
SingleRelay *single_relay = new SingleRelay();
|
||||
single_relay->setWindowModality(Qt::ApplicationModal);
|
||||
single_relay->show();
|
||||
} else if (slot_config.slot_type == "HAM824") { // 振动模块
|
||||
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id,card_type);
|
||||
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
||||
seismic_monitor->show();
|
||||
} else if (slot_config.slot_type == "OPM844") { // 转速模块
|
||||
Tachometer *tachometer = new Tachometer(button_id,card_type);
|
||||
tachometer->setWindowModality(Qt::ApplicationModal);
|
||||
tachometer->show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
switch(base_ptr->card_type_){
|
||||
case kCardVibSingle:{
|
||||
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id,card_type);
|
||||
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
||||
seismic_monitor->show();
|
||||
break;
|
||||
}
|
||||
case kCardKeyphaseSingle:{
|
||||
KeyPhase *key_phase = new KeyPhase(button_id,card_type);
|
||||
key_phase->setWindowModality(Qt::ApplicationModal);
|
||||
key_phase->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) {
|
||||
@ -502,24 +529,34 @@ void MainWindow::onMenuAction_relay() {
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_save_clicked() {
|
||||
QJsonObject itemObj;
|
||||
QJsonArray slotArray;
|
||||
for (int i = 0; i < map_slot_config.size(); i++) {
|
||||
itemObj["slot"] = map_slot_config[i + 1].slot;
|
||||
itemObj["slot_type"] = map_slot_config[i + 1].slot_type;
|
||||
itemObj["chan_display"] = map_slot_config[i + 1].chan_display;
|
||||
itemObj["rack_type"] = map_slot_config[i + 1].rack_type;
|
||||
slotArray.append(itemObj);
|
||||
}
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setArray(slotArray);
|
||||
QFile file(QCoreApplication::applicationDirPath() + "\\config\\main.json");
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
ConfigMgr::Instance()->Save();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_open_clicked() {
|
||||
ConfigMgr::Instance()->Load(QCoreApplication::applicationDirPath() + "\\config\\tsi_config_file.json");
|
||||
|
||||
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||
for (int i = 0; i < buttonList.count(); i++) {
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
|
||||
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;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t calculate_crc(uint8_t c, const QByteArray &data) {
|
||||
|
@ -45,6 +45,7 @@ private:
|
||||
QTcpSocket *socket;
|
||||
|
||||
QProgressBar *progressBar;
|
||||
CardType card_type;
|
||||
|
||||
void createMenu();
|
||||
void createMenu(const QString& rootTitle, QPushButton* button = nullptr);
|
||||
|
@ -94,7 +94,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>打开</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_22">
|
||||
@ -831,7 +831,7 @@
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -850,7 +850,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -869,7 +869,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -888,7 +888,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>振动</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1121,7 +1121,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1129</width>
|
||||
<height>21</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
|
@ -198,6 +198,7 @@ void Radial::on_pushButton_confirm_clicked() {
|
||||
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);
|
||||
|
@ -13,7 +13,7 @@
|
||||
#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->setupUi(this);
|
||||
@ -31,6 +31,7 @@ Seismic_monitor::Seismic_monitor(int slot, QWidget *parent) :
|
||||
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);
|
||||
@ -116,8 +117,11 @@ void Seismic_monitor::Init() {
|
||||
// }
|
||||
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;
|
||||
@ -129,34 +133,38 @@ void Seismic_monitor::Init() {
|
||||
ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
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->setCheckable(vib_data->base_config_[i].active);
|
||||
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->setCheckable(vib_data->base_config_[i].active);
|
||||
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->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->setCheckable(vib_data->base_config_[i].active);
|
||||
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->setCheckable(vib_data->base_config_[i].active);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,6 +181,7 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
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();
|
||||
} 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();
|
||||
@ -183,6 +192,7 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
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();
|
||||
} 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();
|
||||
@ -193,6 +203,7 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
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();
|
||||
} 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();
|
||||
@ -203,6 +214,7 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,11 @@ class Seismic_monitor : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Seismic_monitor(int slot, QWidget *parent = nullptr);
|
||||
explicit Seismic_monitor(int slot,int cardtype, QWidget *parent = nullptr);
|
||||
~Seismic_monitor();
|
||||
int slot_no;
|
||||
int channel;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
|
||||
|
@ -463,7 +463,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
@ -731,6 +731,9 @@
|
||||
<property name="text">
|
||||
<string>是否供电</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -892,7 +895,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
@ -1157,6 +1160,9 @@
|
||||
<property name="text">
|
||||
<string>是否供电</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1494,7 +1500,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
@ -1908,7 +1914,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
|
@ -11,13 +11,14 @@
|
||||
#include "config_mgr.h"
|
||||
#include "tachometer_data.h"
|
||||
|
||||
Tachometer::Tachometer(int slot_no_, QWidget *parent)
|
||||
Tachometer::Tachometer(int slot_no_,int cardtype, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, 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);
|
||||
Init();
|
||||
@ -141,6 +142,8 @@ void Tachometer::Init() {
|
||||
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;
|
||||
|
@ -13,9 +13,10 @@ class Tachometer : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Tachometer(int slot_no_, QWidget *parent = nullptr);
|
||||
explicit Tachometer(int slot_no_,int cardtype, QWidget *parent = nullptr);
|
||||
~Tachometer();
|
||||
int slot_no;
|
||||
CardType car_type;
|
||||
private slots:
|
||||
void on_pushButton_confirm_clicked();
|
||||
void on_pushButton_cancel_clicked();
|
||||
|
@ -226,6 +226,7 @@ void Velocity::on_pushButton_confirm_clicked() {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user