#include "xitongshezhi.h" #include "mainwindow.h" #include "canshupeizhi.h" #include "wangluo.h" #include "ui_xitongshezhi.h" #include #include bool xtpz_flag=false; bool alarm_start=true; extern QString Wireless; extern uint8_t error_record_int;//错误文件日期 xitongshezhi::xitongshezhi(QWidget *parent) : QWidget(parent), ui(new Ui::xitongshezhi) { ui->setupUi(this); this->setFixedSize(this->geometry().size()); this->installEventFilter(this);//安装鼠标事件 setback_color(); ui->label_1->close(); ui->label_2->close(); ui->label_3->close(); ui->label_4->show(); label_xtsz_0_1=new QLabel(this); label_xtsz_0_2=new QLabel(this); label_xtsz_0_3=new QLabel(this); label_xtsz_0_1->installEventFilter(this);//安装鼠标事件 label_xtsz_0_2->installEventFilter(this);//安装鼠标事件 label_xtsz_0_3->installEventFilter(this);//安装鼠标事件 label_xtsz_0_1->setGeometry(180,143,120,39); label_xtsz_0_1->setAlignment(Qt::AlignCenter); label_xtsz_0_1->setText("智能终端设备"); label_xtsz_0_2->setGeometry(330,143,120,39); label_xtsz_0_2->setAlignment(Qt::AlignCenter); label_xtsz_0_2->setText("背景颜色设置"); label_xtsz_0_3->setGeometry(480,143,120,39); label_xtsz_0_3->setAlignment(Qt::AlignCenter); label_xtsz_0_3->setText("故障记录"); xtsz_page(1); xtsz_shebei_page(); xtsz_xianshi_page(); xtsz_error_record_page(); label_xtsz_1_show(1); label_xtsz_2_show(0); label_xtsz_3_show(0); } void xitongshezhi::label_xtsz_1_show(int a) { if(a==1) { tableView_error->hide(); label_xtsz_1_1->show(); label_xtsz_1_2->show(); label_xtsz_1_3->show(); button_xtsz_1_1->show(); } else { label_xtsz_1_1->close(); label_xtsz_1_2->close(); label_xtsz_1_3->close(); button_xtsz_1_1->close(); } } void xitongshezhi::label_xtsz_2_show(int a) { if(a==1) { tableView_error->hide(); label_xtsz_2_1->show(); button_xtsz_2_1->show(); button_xtsz_2_2->show(); button_xtsz_2_3->show(); button_xtsz_2_4->show(); button_xtsz_2_5->show(); } else { label_xtsz_2_1->close(); button_xtsz_2_1->close(); button_xtsz_2_2->close(); button_xtsz_2_3->close(); button_xtsz_2_4->close(); button_xtsz_2_5->close(); } } void xitongshezhi::label_xtsz_3_show(int a) { if(a==1) { label_xtsz_3_1->show(); QString error_file_name1=""; QString error_file_name2=""; QString error_file_name3=""; if(error_record_int==1) { error_file_name1="error_file_11"; error_file_name2="error_file_12"; error_file_name3="error_file_01"; } else if(error_record_int==2) { error_file_name1="error_file_12"; error_file_name2="error_file_01"; error_file_name3="error_file_02"; } else { error_file_name1="error_file_"+QString("%1").arg(error_record_int-2, 2, 10, QChar('0'));//自动补零 error_file_name2="error_file_"+QString("%1").arg(error_record_int-1, 2, 10, QChar('0')); error_file_name3="error_file_"+QString("%1").arg(error_record_int, 2, 10, QChar('0')); } uint16_t count=0; model_error->clear(); //count = file_read1.count(); QFile file_read1("/home/data/"+error_file_name1+".txt"); if(file_read1.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read1);//创建一个对象让它去读文件 while (!in.atEnd()) { /* 加载数据 */ model_error->setItem(count, 0, new QStandardItem(in.readLine())); QString error_type_name=in.readLine(); if(error_type_name=="error_door") model_error->setItem(count, 1, new QStandardItem("门触点")); if(error_type_name=="error_chaowen") model_error->setItem(count, 1, new QStandardItem("超温")); if(error_type_name=="error_chaosheng") model_error->setItem(count, 1, new QStandardItem("超声波异常")); if(error_type_name=="error_tev") model_error->setItem(count, 1, new QStandardItem("TEV异常")); if(error_type_name=="error_trip") model_error->setItem(count, 1, new QStandardItem("跳闸")); if(error_type_name=="error_rxy") model_error->setItem(count, 1, new QStandardItem("热像仪掉线")); if(error_type_name=="error_fengji") model_error->setItem(count, 1, new QStandardItem("风机故障")); if(error_type_name=="error_A_current") model_error->setItem(count, 1, new QStandardItem("A相电流线序反")); if(error_type_name=="error_B_current") model_error->setItem(count, 1, new QStandardItem("B相电流线序反")); if(error_type_name=="error_C_current") model_error->setItem(count, 1, new QStandardItem("C相电流线序反")); if(error_type_name=="error_ALL_voltage") model_error->setItem(count, 1, new QStandardItem("变压器失电")); if(error_type_name=="error_A_temp") model_error->setItem(count, 1, new QStandardItem("A相温控线断线")); if(error_type_name=="error_B_temp") model_error->setItem(count, 1, new QStandardItem("B相温控线断线")); if(error_type_name=="error_C_temp") model_error->setItem(count, 1, new QStandardItem("C相温控线断线")); if(error_type_name=="error_T_temp") model_error->setItem(count, 1, new QStandardItem("铁芯温控线断线")); if(error_type_name=="error_ALL_temp") model_error->setItem(count, 1, new QStandardItem("温控线未插")); if(error_type_name=="error_wuxian") model_error->setItem(count, 1, new QStandardItem("无线测温节点异常:"+Wireless)); if(error_type_name=="error_net") model_error->setItem(count, 1, new QStandardItem("通信故障")); count++; } } file_read1.close(); QFile file_read2("/home/data/"+error_file_name2+".txt"); if(file_read2.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read2);//创建一个对象让它去读文件 while (!in.atEnd()) { /* 加载数据 */ model_error->setItem(count, 0, new QStandardItem(in.readLine())); QString error_type_name=in.readLine(); if(error_type_name=="error_door") model_error->setItem(count, 1, new QStandardItem("门触点")); if(error_type_name=="error_chaowen") model_error->setItem(count, 1, new QStandardItem("超温")); if(error_type_name=="error_chaosheng") model_error->setItem(count, 1, new QStandardItem("超声波异常")); if(error_type_name=="error_tev") model_error->setItem(count, 1, new QStandardItem("TEV异常")); if(error_type_name=="error_trip") model_error->setItem(count, 1, new QStandardItem("跳闸")); if(error_type_name=="error_rxy") model_error->setItem(count, 1, new QStandardItem("热像仪掉线")); if(error_type_name=="error_fengji") model_error->setItem(count, 1, new QStandardItem("风机故障")); if(error_type_name=="error_A_current") model_error->setItem(count, 1, new QStandardItem("A相电流线序反")); if(error_type_name=="error_B_current") model_error->setItem(count, 1, new QStandardItem("B相电流线序反")); if(error_type_name=="error_C_current") model_error->setItem(count, 1, new QStandardItem("C相电流线序反")); if(error_type_name=="error_ALL_voltage") model_error->setItem(count, 1, new QStandardItem("变压器失电")); if(error_type_name=="error_A_temp") model_error->setItem(count, 1, new QStandardItem("A相温控线断线")); if(error_type_name=="error_B_temp") model_error->setItem(count, 1, new QStandardItem("B相温控线断线")); if(error_type_name=="error_C_temp") model_error->setItem(count, 1, new QStandardItem("C相温控线断线")); if(error_type_name=="error_T_temp") model_error->setItem(count, 1, new QStandardItem("铁芯温控线断线")); if(error_type_name=="error_ALL_temp") model_error->setItem(count, 1, new QStandardItem("温控线未插")); if(error_type_name=="error_wuxian") model_error->setItem(count, 1, new QStandardItem("无线测温节点异常:"+Wireless)); if(error_type_name=="error_net") model_error->setItem(count, 1, new QStandardItem("通信故障")); count++; } } file_read2.close(); QFile file_read3("/home/data/"+error_file_name3+".txt"); if(file_read3.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read3);//创建一个对象让它去读文件 while (!in.atEnd()) { /* 加载数据 */ model_error->setItem(count, 0, new QStandardItem(in.readLine())); QString error_type_name=in.readLine(); if(error_type_name=="error_door") model_error->setItem(count, 1, new QStandardItem("门触点")); if(error_type_name=="error_chaowen") model_error->setItem(count, 1, new QStandardItem("超温")); if(error_type_name=="error_chaosheng") model_error->setItem(count, 1, new QStandardItem("超声波异常")); if(error_type_name=="error_tev") model_error->setItem(count, 1, new QStandardItem("TEV异常")); if(error_type_name=="error_trip") model_error->setItem(count, 1, new QStandardItem("跳闸")); if(error_type_name=="error_rxy") model_error->setItem(count, 1, new QStandardItem("热像仪掉线")); if(error_type_name=="error_fengji") model_error->setItem(count, 1, new QStandardItem("风机故障")); if(error_type_name=="error_A_current") model_error->setItem(count, 1, new QStandardItem("A相电流线序反")); if(error_type_name=="error_B_current") model_error->setItem(count, 1, new QStandardItem("B相电流线序反")); if(error_type_name=="error_C_current") model_error->setItem(count, 1, new QStandardItem("C相电流线序反")); if(error_type_name=="error_ALL_voltage") model_error->setItem(count, 1, new QStandardItem("变压器失电")); if(error_type_name=="error_A_temp") model_error->setItem(count, 1, new QStandardItem("A相温控线断线")); if(error_type_name=="error_B_temp") model_error->setItem(count, 1, new QStandardItem("B相温控线断线")); if(error_type_name=="error_C_temp") model_error->setItem(count, 1, new QStandardItem("C相温控线断线")); if(error_type_name=="error_T_temp") model_error->setItem(count, 1, new QStandardItem("铁芯温控线断线")); if(error_type_name=="error_ALL_temp") model_error->setItem(count, 1, new QStandardItem("温控线未插")); if(error_type_name=="error_wuxian") model_error->setItem(count, 1, new QStandardItem("无线测温节点异常:"+Wireless)); if(error_type_name=="error_net") model_error->setItem(count, 1, new QStandardItem("通信故障")); count++; } } file_read3.close(); count=0; model_error->sort(0,Qt::DescendingOrder); tableView_error->show(); } else { tableView_error->hide(); label_xtsz_3_1->hide(); } } void xitongshezhi::xtsz_page(int a) { switch (a) { case 1: { label_xtsz_0_1->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_xtsz_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_xtsz_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 2: { label_xtsz_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_xtsz_0_2->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_xtsz_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 3: { label_xtsz_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_xtsz_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_xtsz_0_3->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); }; break; default: { }; break; } } void xitongshezhi::xtsz_shebei_page() { label_xtsz_1_1=new QLabel(this); label_xtsz_1_2=new QLabel(this); label_xtsz_1_3=new QLabel(this); button_xtsz_1_1=new QPushButton(this); label_xtsz_1_1->setGeometry(240,220,300,30); label_xtsz_1_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); label_xtsz_1_1->setAlignment(Qt::AlignCenter); label_xtsz_1_1->setText("设备序列号:123-45678"); label_xtsz_1_2->setGeometry(200,260,400,30); label_xtsz_1_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); label_xtsz_1_2->setAlignment(Qt::AlignCenter); label_xtsz_1_2->setText("出厂日期通讯地址:2010.3.3 江苏省XXXXXXXXXXX"); if(alarm_start) { button_xtsz_1_1->setGeometry(300,320,220,30); button_xtsz_1_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_1_1->setText("关闭报警弹窗"); } else { button_xtsz_1_1->setGeometry(300,320,220,30); button_xtsz_1_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_1_1->setText("开启报警弹窗"); } label_xtsz_1_3->setGeometry(300,370,220,30); label_xtsz_1_3->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); label_xtsz_1_3->setAlignment(Qt::AlignCenter); label_xtsz_1_3->setText(version); connect(button_xtsz_1_1,SIGNAL(clicked()),this,SLOT(button_xtsz_1_1_Clicked())); } void xitongshezhi::xtsz_xianshi_page() { label_xtsz_2_1=new QLabel(this); button_xtsz_2_1=new QPushButton(this); button_xtsz_2_2=new QPushButton(this); button_xtsz_2_3=new QPushButton(this); button_xtsz_2_4=new QPushButton(this); button_xtsz_2_5=new QPushButton(this); label_xtsz_2_1->setGeometry(200,250,400,40); label_xtsz_2_1->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); button_xtsz_2_1->setGeometry(235,255,50,30); button_xtsz_2_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_2_1->setText("背景1"); button_xtsz_2_2->setGeometry(305,255,50,30); button_xtsz_2_2->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_2_2->setText("背景2"); button_xtsz_2_3->setGeometry(375,255,50,30); button_xtsz_2_3->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_2_3->setText("背景3"); button_xtsz_2_4->setGeometry(445,255,50,30); button_xtsz_2_4->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_2_4->setText("背景4"); button_xtsz_2_5->setGeometry(515,255,50,30); button_xtsz_2_5->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_xtsz_2_5->setText("背景5"); connect(button_xtsz_2_1,SIGNAL(clicked()),this,SLOT(button_xtsz_2_1_Clicked())); connect(button_xtsz_2_2,SIGNAL(clicked()),this,SLOT(button_xtsz_2_2_Clicked())); connect(button_xtsz_2_3,SIGNAL(clicked()),this,SLOT(button_xtsz_2_3_Clicked())); connect(button_xtsz_2_4,SIGNAL(clicked()),this,SLOT(button_xtsz_2_4_Clicked())); connect(button_xtsz_2_5,SIGNAL(clicked()),this,SLOT(button_xtsz_2_5_Clicked())); } void xitongshezhi::xtsz_error_record_page() { label_xtsz_3_1=new QLabel(this); label_xtsz_3_1->setGeometry(240,190,400,30); label_xtsz_3_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); label_xtsz_3_1->setText("发生时间 故障类型"); tableView_error = new QTableView; /* 设置表格视图大小 */ tableView_error->setGeometry(200,230,420,200); tableView_error->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); /*所有行的默认列宽*/ tableView_error->horizontalHeader()->setDefaultSectionSize(180);//列宽 /* 不显示行数列数 */ tableView_error->horizontalHeader()->setVisible(false); /* 设置表格视图数据 */ tableView_error->setModel(model_error); /* 设置背景交替色 */ tableView_error->setAlternatingRowColors(true); } xitongshezhi::~xitongshezhi() { delete ui; } bool xitongshezhi::eventFilter(QObject *watch, QEvent *evn) { if(watch == label_xtsz_0_1 && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面 { label_xtsz_0_1_clicked(); } if(watch == label_xtsz_0_2 && evn->type() == QEvent::MouseButtonPress) { label_xtsz_0_2_clicked(); } if(watch == label_xtsz_0_3 && evn->type() == QEvent::MouseButtonPress) { label_xtsz_0_3_clicked(); } return QWidget::eventFilter(watch, evn); } void xitongshezhi::on_pushButton_zhujiemian_clicked() { where_page = 0; lowpower_mode_flag1=true; xtpz_flag=false; tableView_error->hide(); this->hide(); } void xitongshezhi::on_pushButton_wangluoxinxi_clicked() { where_page = 1; xtpz_flag=false; if(!wlpz_flag && !cspz_flag) { wlpz_flag=true; KeyBoard_Code=false; KeyBoard_ABC_Code=false; keyBoard_flag=false; keyBoard_ABC_flag=false; tableView_error->hide(); wangluo_thread->show(); wangluo_thread->wlxx_set_back_color(); wangluo_thread->mimaButton->show(); wangluo_thread->mimaline->show(); wangluo_thread->label_mima1->show(); wangluo_thread->label_mima2->show(); wangluo_thread->label_mimajiemian->show(); wangluo_thread->label_mimajiemian->raise(); wangluo_thread->mimaButton->raise(); wangluo_thread->mimaline->clear(); wangluo_thread->mimaline->raise(); wangluo_thread->label_mima1->raise(); wangluo_thread->label_mima2->clear(); wangluo_thread->label_mima2->raise(); this->hide(); } } void xitongshezhi::on_pushButton_canshushezhi_clicked() { where_page = 2; xtpz_flag=false; if(!wlpz_flag && !cspz_flag) { cspz_flag=true; cspz_flag=true; KeyBoard_Code=false; KeyBoard_ABC_Code=false; keyBoard_flag=false; tableView_error->hide(); canshupeizhi_thread->show(); canshupeizhi_thread->cspz_set_back_color(); canshupeizhi_thread->mimaButton->show(); canshupeizhi_thread->mimaline->show(); canshupeizhi_thread->label_mima1->show(); canshupeizhi_thread->label_mima2->show(); canshupeizhi_thread->label_mimajiemian->show(); canshupeizhi_thread->label_mimajiemian->raise(); canshupeizhi_thread->mimaButton->raise(); canshupeizhi_thread->mimaline->clear(); canshupeizhi_thread->mimaline->raise(); canshupeizhi_thread->label_mima1->raise(); canshupeizhi_thread->label_mima2->clear(); canshupeizhi_thread->label_mima2->raise(); this->hide(); } } void xitongshezhi::on_pushButton_xitongshezhi_clicked() { where_page = 3; } int back_color; void xitongshezhi::button_xtsz_1_1_Clicked() { if(button_xtsz_1_1->text()=="开启报警弹窗") { alarm_start=true; button_xtsz_1_1->setText("关闭报警弹窗"); } else { alarm_start=false; button_xtsz_1_1->setText("开启报警弹窗"); } } void xitongshezhi::button_xtsz_2_1_Clicked() { back_color=1; QFile file_write("/home/data/back_color");//文件路径 if(file_write.open(QFile::WriteOnly)) { QTextStream setLORA_data(&file_write); setLORA_data<label->setStyleSheet("background: rgb(244, 244, 244)"); }; break; case 2: { ui->label->setStyleSheet("background: rgb(148, 238, 213)"); }; break; case 3: { ui->label->setStyleSheet("background: rgb(255, 255, 96)"); }; break; case 4: { ui->label->setStyleSheet("background: rgb(209, 99, 191)"); }; break; case 5: { ui->label->setStyleSheet("background: rgb(87, 255, 78)"); }; break; default: { }; break; } } void xitongshezhi::label_xtsz_0_1_clicked()//页面1label点击槽函数 { xtsz_page(1);//显示第1页 label_xtsz_1_show(1);//页面1开启 label_xtsz_2_show(0);//页面2关闭 label_xtsz_3_show(0);//页面3关闭 } void xitongshezhi::label_xtsz_0_2_clicked()//页面2label点击槽函数 { xtsz_page(2); label_xtsz_1_show(0); label_xtsz_2_show(1); label_xtsz_3_show(0);//页面3关闭 } void xitongshezhi::label_xtsz_0_3_clicked()//页面3label点击槽函数 { xtsz_page(3); label_xtsz_1_show(0); label_xtsz_2_show(0); label_xtsz_3_show(1);//页面3开启 }