|
|
|
|
@ -4,7 +4,6 @@
|
|
|
|
|
#include <QStack>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QListView>
|
|
|
|
|
|
|
|
|
|
SingleRelay_NOK::SingleRelay_NOK(int slot,CardType cardtype,QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
@ -14,9 +13,6 @@ SingleRelay_NOK::SingleRelay_NOK(int slot,CardType cardtype,QWidget *parent) :
|
|
|
|
|
slot_no = slot;
|
|
|
|
|
car_type = cardtype;
|
|
|
|
|
ui->label_slot_no->setText(QString::number(slot_no));
|
|
|
|
|
ui->comboBox_relay_ch->setView(new QListView());
|
|
|
|
|
ui->comboBox_group->setView(new QListView());
|
|
|
|
|
current_slot_btn = nullptr;
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
|
|
|
|
list_widget_available = new QListWidget();
|
|
|
|
|
@ -186,74 +182,39 @@ void SingleRelay_NOK::on_pushButton_cancel_clicked()
|
|
|
|
|
{
|
|
|
|
|
this->close();
|
|
|
|
|
}
|
|
|
|
|
void SingleRelay_NOK::updateAvailable(QAbstractButton *slot_btn){
|
|
|
|
|
list_widget_available->clear();
|
|
|
|
|
QString object_name = slot_btn->objectName();
|
|
|
|
|
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);
|
|
|
|
|
if(ptr == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
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){
|
|
|
|
|
void SingleRelay_NOK::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();
|
|
|
|
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
|
|
|
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
|
|
|
|
|
if(variable_base == nullptr)
|
|
|
|
|
continue;
|
|
|
|
|
if(base_ptr->card_type_ == kCardVibSingle){
|
|
|
|
|
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").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);
|
|
|
|
|
QString item_data_nok = 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_nok);
|
|
|
|
|
list_widget_available->addItem(item);
|
|
|
|
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
|
|
|
|
if(ptr == nullptr)
|
|
|
|
|
return;
|
|
|
|
|
QListWidgetItem *item_and = new QListWidgetItem("AND");
|
|
|
|
|
item_and->setData(Qt::UserRole, "*");
|
|
|
|
|
list_widget_available->addItem(item_and);
|
|
|
|
|
|
|
|
|
|
QString item_data;
|
|
|
|
|
if(variable_base->alert_high.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
QListWidgetItem *item_or = new QListWidgetItem("OR");
|
|
|
|
|
item_or->setData(Qt::UserRole, "+");
|
|
|
|
|
list_widget_available->addItem(item_or);
|
|
|
|
|
|
|
|
|
|
if(variable_base->danger_high.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
|
|
|
|
|
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'));
|
|
|
|
|
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
|
|
|
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
|
|
|
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
|
|
|
|
|
if(variable_base == nullptr)
|
|
|
|
|
continue;
|
|
|
|
|
if(base_ptr->card_type_ == kCardVibSingle){
|
|
|
|
|
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").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(variable_base->danger_low.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
|
|
|
|
|
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%2A4").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(variable_base->alert_low.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
|
|
|
|
|
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%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
|
|
|
|
item->setData(Qt::UserRole, item_data);
|
|
|
|
|
QString item_data_nok = 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_nok);
|
|
|
|
|
list_widget_available->addItem(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void SingleRelay_NOK::OnButtonGroup(QAbstractButton *slot_btn) {
|
|
|
|
|
if (slot_btn != NULL) {
|
|
|
|
|
current_slot_btn = slot_btn;
|
|
|
|
|
updateAvailable(slot_btn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QString SingleRelay_NOK::buildLogicExpression(QStandardItem *item) {
|
|
|
|
|
if (!item) return "";
|
|
|
|
|
|
|
|
|
|
@ -316,8 +277,6 @@ void SingleRelay_NOK::onComboBoxIndexChanged(int index){
|
|
|
|
|
qDebug() << "active" << relay_data->single_relay[index].active;
|
|
|
|
|
ui->checkBox_active->setChecked(relay_data->single_relay[index].active);
|
|
|
|
|
|
|
|
|
|
if(current_slot_btn != nullptr)
|
|
|
|
|
updateAvailable(current_slot_btn);
|
|
|
|
|
}
|
|
|
|
|
ExprNode* SingleRelay_NOK::parseExpression(const QString& expr, int& pos) {
|
|
|
|
|
auto skipSpaces = [&]() {
|
|
|
|
|
|