#include "mainwindow.h" #include mcu_arm1 *ARM_1;//调用串口通信 QString line_lan_ip,line_4G_ip;//LAN的IP地址 QString wireless_name[60]; bool WIFI_HOST_state; QString WIFI_HOST_Name; QString WIFI_HOST_code; bool lowpower_mode_flag=false; bool lowpower_mode_flag1=true; bool kaiji_flag_ok=false; wangluo *wangluo_thread=nullptr; canshupeizhi *canshupeizhi_thread=nullptr; xitongshezhi *xitongshezhi_thread=nullptr; ModuleWifi * wifi=nullptr; QsLogging::Logger &logger = QsLogging::Logger::instance(); QString Wireless="";//无线测温节点 uint8_t error_record_int=0;//错误文件日期 QNetworkConfigurationManager mgr;//网络检测 int main_back_color; int where_page; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); this->setFixedSize(this->geometry().size()); this->installEventFilter(this);//安装鼠标事件 where_page = 0; QFile wireless_namecheck("/home/data/wireless_name.txt"); if(wireless_namecheck.exists()) { if(wireless_namecheck.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&wireless_namecheck);//创建一个对象让它去读文件 wireless_name[0]=in.readLine(); wireless_name[1]=in.readLine(); wireless_name[2]=in.readLine(); wireless_name[3]=in.readLine(); wireless_name[4]=in.readLine(); wireless_name[5]=in.readLine(); wireless_name[6]=in.readLine(); wireless_name[7]=in.readLine(); wireless_name[8]=in.readLine(); wireless_name[9]=in.readLine(); wireless_name[10]=in.readLine(); wireless_name[11]=in.readLine(); wireless_name[12]=in.readLine(); wireless_name[13]=in.readLine(); wireless_name[14]=in.readLine(); wireless_name[15]=in.readLine(); wireless_name[16]=in.readLine(); wireless_name[17]=in.readLine(); wireless_name[18]=in.readLine(); wireless_name[19]=in.readLine(); wireless_name[20]=in.readLine(); wireless_name[21]=in.readLine(); wireless_name[22]=in.readLine(); wireless_name[23]=in.readLine(); wireless_name[24]=in.readLine(); wireless_name[25]=in.readLine(); wireless_name[26]=in.readLine(); wireless_name[27]=in.readLine(); wireless_name[28]=in.readLine(); wireless_name[29]=in.readLine(); wireless_name[30]=in.readLine(); wireless_name[31]=in.readLine(); wireless_name[32]=in.readLine(); wireless_name[33]=in.readLine(); wireless_name[34]=in.readLine(); wireless_name[35]=in.readLine(); wireless_name[36]=in.readLine(); wireless_name[37]=in.readLine(); wireless_name[38]=in.readLine(); wireless_name[39]=in.readLine(); wireless_name[40]=in.readLine(); wireless_name[41]=in.readLine(); wireless_name[42]=in.readLine(); wireless_name[43]=in.readLine(); wireless_name[44]=in.readLine(); wireless_name[45]=in.readLine(); wireless_name[46]=in.readLine(); wireless_name[47]=in.readLine(); wireless_name[48]=in.readLine(); wireless_name[49]=in.readLine(); wireless_name[50]=in.readLine(); wireless_name[51]=in.readLine(); wireless_name[52]=in.readLine(); wireless_name[53]=in.readLine(); wireless_name[54]=in.readLine(); wireless_name[55]=in.readLine(); wireless_name[56]=in.readLine(); wireless_name[57]=in.readLine(); wireless_name[58]=in.readLine(); wireless_name[59]=in.readLine(); for (int i = 0;i<60;i++) { if(wireless_name[i] == "") { wireless_name[i] = "节点" + QString::number(i+1); } } } wireless_namecheck.close(); }else{ wireless_name[0]="节点1"; wireless_name[1]="节点2"; wireless_name[2]="节点3"; wireless_name[3]="节点4"; wireless_name[4]="节点5"; wireless_name[5]="节点6"; wireless_name[6]="节点7"; wireless_name[7]="节点8"; wireless_name[8]="节点9"; wireless_name[9]="节点10"; wireless_name[10]="节点11"; wireless_name[11]="节点12"; wireless_name[12]="节点13"; wireless_name[13]="节点14"; wireless_name[14]="节点15"; wireless_name[15]="节点16"; wireless_name[16]="节点17"; wireless_name[17]="节点18"; wireless_name[18]="节点19"; wireless_name[19]="节点20"; wireless_name[20]="节点21"; wireless_name[21]="节点22"; wireless_name[22]="节点23"; wireless_name[23]="节点24"; wireless_name[24]="节点25"; wireless_name[25]="节点26"; wireless_name[26]="节点27"; wireless_name[27]="节点28"; wireless_name[28]="节点29"; wireless_name[29]="节点30"; wireless_name[30]="节点31"; wireless_name[31]="节点32"; wireless_name[32]="节点33"; wireless_name[33]="节点34"; wireless_name[34]="节点35"; wireless_name[35]="节点36"; wireless_name[36]="节点37"; wireless_name[37]="节点38"; wireless_name[38]="节点39"; wireless_name[39]="节点40"; wireless_name[40]="节点41"; wireless_name[41]="节点42"; wireless_name[42]="节点43"; wireless_name[43]="节点44"; wireless_name[44]="节点45"; wireless_name[45]="节点46"; wireless_name[46]="节点47"; wireless_name[47]="节点48"; wireless_name[48]="节点49"; wireless_name[49]="节点50"; wireless_name[50]="节点51"; wireless_name[51]="节点52"; wireless_name[52]="节点53"; wireless_name[53]="节点54"; wireless_name[54]="节点55"; wireless_name[55]="节点56"; wireless_name[56]="节点57"; wireless_name[57]="节点58"; wireless_name[58]="节点59"; wireless_name[59]="节点60"; if(wireless_namecheck.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&wireless_namecheck); setWIFI_data<<""<centralwidget); widget_page->setObjectName(QString::fromUtf8("widget_page")); widget_page->setGeometry(QRect(10, 260, 781, 250)); mP_A_V = new mainpage_A_V(widget_page); mP_A_V->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageOneDataUpdate(float,float,float)), mP_A_V, SLOT(onPageOneDataUpdate(float,float,float))); connect(mP_A_V, SIGNAL(sigDispByqAlarm(bool)), this, SLOT(onDispByqAlarm(bool))); connect(this, SIGNAL(sigPageOneDataLabelUpdate()), mP_A_V, SLOT(onPageOneDataLabelUpdate())); mP_A_V->hide(); mP_Power = new mainpage_Power(widget_page); mP_Power->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageTwoDataUpdate(float,float,float)), mP_Power, SLOT(onPageTwoDataUpdate(float,float,float))); mP_Power->hide(); mP_Quality = new mainpage_Quality(widget_page); mP_Quality->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageThreeDataUpdate()), mP_Quality, SLOT(onPageThreeDataUpdate())); connect(mP_Quality, SIGNAL(sigPageThreeSend()), this, SLOT(onPageThreeSend())); mP_Quality->hide(); mP_Data = new mainpage_Data(widget_page); mP_Data->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageFourDataUpdate()), mP_Data, SLOT(onPageFourDataUpdate())); mP_Data->hide(); mP_Temp = new mainpage_Temp(widget_page); mP_Temp->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageFiveDataUpdate()), mP_Temp, SLOT(onPageFiveDataUpdate())); connect(mP_Temp, SIGNAL(sigPageFiveSend()), this, SLOT(onPageFiveSend())); connect(this, SIGNAL(sigWirelessStateCheck()), mP_Temp, SLOT(onWirelessStateCheck())); connect(mP_Temp, SIGNAL(sigDispWirelessAlarm(bool)), this, SLOT(onDispWirelessAlarm(bool))); connect(mP_Temp, SIGNAL(sigCountSend(int)), this, SLOT(onCountSend(int))); mP_Temp->hide(); mP_JfParameter = new mainpage_JfParameter(widget_page); mP_JfParameter->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageSevenDataUpdate()), mP_JfParameter, SLOT(onPageSevenDataUpdate())); connect(this, SIGNAL(sigJuFangStateCheck()), mP_JfParameter, SLOT(onJuFangStateCheck())); connect(mP_JfParameter, SIGNAL(sigDispJuFangAlarm(bool)), this, SLOT(onDispJuFangAlarm(bool))); mP_JfParameter->hide(); mP_Rxy = new mainpage_Rxy(widget_page); mP_Rxy->setGeometry(QRect(0, 0, 781, 250)); connect(this, SIGNAL(sigPageEightDataUpdate()), mP_Rxy, SLOT(onPageEightDataUpdate())); connect(mP_Rxy, SIGNAL(sigDispRxyAlarm(bool,bool)), this, SLOT(onDispRxyAlarm(bool,bool))); connect(mP_Rxy, SIGNAL(sigPageEightSend()), this, SLOT(onPageEightSend())); connect(this, SIGNAL(sigRxyLabelSet()), mP_Rxy, SLOT(onRxyLabelSet())); connect(this, SIGNAL(sigRxyButtonShow()), mP_Rxy, SLOT(onRxyButtonShow())); mP_Rxy->hide(); ui->pushButton_zhujiemian->hide(); ui->pushButton_canshushezhi->hide(); ui->pushButton_wangluoxinxi->hide(); ui->pushButton_xitongshezhi->hide(); ui->label_1->hide(); ui->label_2->hide(); ui->label_3->hide(); ui->label_4->hide(); mian_page=3; cspz_flag=0; wlpz_flag=0; xtpz_flag=0; share_num = 0; net_ok = true; Pop_alarm_T_err_flag = true; sharememery_test = new QSharedMemory; sharememery_test->setKey("share_test"); if (!sharememery_test->attach(QSharedMemory::ReadWrite)) { sharememery_test->create(512, QSharedMemory::ReadWrite); } chan1 = new QStandardItem(); chan2 = new QStandardItem(); chan3 = new QStandardItem(); chan4 = new QStandardItem(); chan5 = new QStandardItem(); chan6 = new QStandardItem(); chan7 = new QStandardItem(); chan8 = new QStandardItem(); chan9 = new QStandardItem(); chan10 = new QStandardItem(); chan11 = new QStandardItem(); chan12 = new QStandardItem(); label_alarm_back=new QLabel(this); label_alarm_back->setGeometry(50,180,700,260); label_alarm_back->hide(); logger.setLoggingLevel(QsLogging::TraceLevel); const QString sLogPath(QDir(QApplication::applicationDirPath()).filePath("data/log.txt")); QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination( sLogPath, QsLogging::EnableLogRotation, QsLogging::MaxSizeBytes(512*1024), QsLogging::MaxOldLogCount(5))); logger.addDestination(fileDestination); QLOG_TRACE() << "--trace msg MainWindow Constructor start"; Pop_alarm_temp_A=new QPushButton(this); Pop_alarm_temp_A->setGeometry(60,190,110,30); Pop_alarm_temp_A->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_temp_A->hide(); connect(Pop_alarm_temp_A,SIGNAL(clicked()), this,SLOT(Pop_alarm_temp_A_Clicked())); Pop_alarm_temp_B=new QPushButton(this); Pop_alarm_temp_B->setGeometry(60,230,110,30); Pop_alarm_temp_B->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_temp_B->hide(); connect(Pop_alarm_temp_B,SIGNAL(clicked()), this,SLOT(Pop_alarm_temp_B_Clicked())); Pop_alarm_temp_C=new QPushButton(this); Pop_alarm_temp_C->setGeometry(60,270,110,30); Pop_alarm_temp_C->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_temp_C->hide(); connect(Pop_alarm_temp_C,SIGNAL(clicked()), this,SLOT(Pop_alarm_temp_C_Clicked())); Pop_alarm_temp_T=new QPushButton(this); Pop_alarm_temp_T->setGeometry(60,310,110,30); Pop_alarm_temp_T->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_temp_T->hide(); connect(Pop_alarm_temp_T,SIGNAL(clicked()), this,SLOT(Pop_alarm_temp_T_Clicked())); Pop_alarm_Wireless_Temperature=new QPushButton(this); Pop_alarm_Wireless_Temperature->setGeometry(60,350,680,90); Pop_alarm_Wireless_Temperature->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_Wireless_Temperature->hide(); connect(Pop_alarm_Wireless_Temperature,SIGNAL(clicked()), this,SLOT(Pop_alarm_Wireless_Temperature_Clicked())); Pop_alarm_current_A=new QPushButton(this); Pop_alarm_current_A->setGeometry(180,190,110,30); Pop_alarm_current_A->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_current_A->hide(); connect(Pop_alarm_current_A,SIGNAL(clicked()), this,SLOT(Pop_alarm_current_A_Clicked())); Pop_alarm_current_B=new QPushButton(this); Pop_alarm_current_B->setGeometry(180,230,110,30); Pop_alarm_current_B->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_current_B->hide(); connect(Pop_alarm_current_B,SIGNAL(clicked()), this,SLOT(Pop_alarm_current_B_Clicked())); Pop_alarm_current_C=new QPushButton(this); Pop_alarm_current_C->setGeometry(180,270,110,30); Pop_alarm_current_C->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_current_C->hide(); connect(Pop_alarm_current_C,SIGNAL(clicked()), this,SLOT(Pop_alarm_current_C_Clicked())); Pop_alarm_voltage_A=new QPushButton(this); Pop_alarm_voltage_A->setGeometry(300,190,110,30); Pop_alarm_voltage_A->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_voltage_A->hide(); connect(Pop_alarm_voltage_A,SIGNAL(clicked()), this,SLOT(Pop_alarm_voltage_A_Clicked())); Pop_alarm_over_temperature=new QPushButton(this); Pop_alarm_over_temperature->setGeometry(420,190,100,40); Pop_alarm_over_temperature->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_over_temperature->hide(); connect(Pop_alarm_over_temperature,SIGNAL(clicked()), this,SLOT(Pop_alarm_over_temperature_Clicked())); Pop_alarm_trip=new QPushButton(this); Pop_alarm_trip->setGeometry(420,240,100,40); Pop_alarm_trip->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_trip->hide(); connect(Pop_alarm_trip,SIGNAL(clicked()), this,SLOT(Pop_alarm_trip_Clicked())); Pop_alarm_chaosheng=new QPushButton(this); Pop_alarm_chaosheng->setGeometry(420,290,100,40); Pop_alarm_chaosheng->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_chaosheng->hide(); connect(Pop_alarm_chaosheng,SIGNAL(clicked()), this,SLOT(Pop_alarm_chaosheng_Clicked())); Pop_alarm_door=new QPushButton(this); Pop_alarm_door->setGeometry(530,190,100,40); Pop_alarm_door->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_door->hide(); connect(Pop_alarm_door,SIGNAL(clicked()), this,SLOT(Pop_alarm_door_Clicked())); Pop_alarm_communicate=new QPushButton(this); Pop_alarm_communicate->setGeometry(530,240,100,40); Pop_alarm_communicate->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_communicate->hide(); connect(Pop_alarm_communicate,SIGNAL(clicked()), this,SLOT(Pop_alarm_communicate_Clicked())); Pop_alarm_tev=new QPushButton(this); Pop_alarm_tev->setGeometry(530,290,100,40); Pop_alarm_tev->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_tev->hide(); connect(Pop_alarm_tev,SIGNAL(clicked()), this,SLOT(Pop_alarm_tev_Clicked())); Pop_alarm_rxy_disconnect=new QPushButton(this); Pop_alarm_rxy_disconnect->setGeometry(640,190,100,40); Pop_alarm_rxy_disconnect->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_rxy_disconnect->hide(); connect(Pop_alarm_rxy_disconnect,SIGNAL(clicked()), this,SLOT(Pop_alarm_rxy_disconnect_Clicked())); Pop_alarm_fan=new QPushButton(this); Pop_alarm_fan->setGeometry(640,240,100,40); Pop_alarm_fan->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); Pop_alarm_fan->hide(); connect(Pop_alarm_fan,SIGNAL(clicked()), this,SLOT(Pop_alarm_fan_Clicked())); canshupeizhi_thread=new canshupeizhi(); wangluo_thread=new wangluo(); xitongshezhi_thread=new xitongshezhi(); Mainwindows_File_Init();//文件初始化 Mainwindows_Init();//界面初始化 Mainwindows_QTime_Init();//定时器初始化 Mainwindows_USBFile_Init();//USB文件插入响应 Mainwindows_Title_Init();//标题跳转初始化 Mainwindows_rxy_Init();//初始化热像仪 Mainwindows_temperature_Init();//初始化ABC相温度读取 Mainwindows_excel_Init();//初始化EXCEL表格(导入变压器参数) #ifdef LINUX std::system("i2cset -y 1 0x27 0xff");//led指示灯初始化 #endif main_page(3); label_3_show(1);//页面1电压电流显示开启 kaiji=new QLabel(this); kaiji->setGeometry(10,183,780,252); kaiji->setStyleSheet("background: rgb(244, 244, 244);font: 17pt 黑体 bold;color: rgb(0, 171, 171)"); kaiji->setAlignment(Qt::AlignCenter); kaiji->setText("开机自检中,请稍后..."); kaiji->show(); pProgressBar = new QProgressBar(this); pProgressBar->setAlignment(Qt::AlignHCenter); pProgressBar->setGeometry(210,370,360,25); pProgressBar->setOrientation(Qt::Horizontal); // 水平方向 pProgressBar->setRange(0,300); pProgressBar->setValue(0); pProgressBar->setStyleSheet("QProgressBar{height:22px; text-align:center; font-size:14px; color:white; border-radius:11px; background:#1D5573;}" "QProgressBar::chunk{border-radius:11px;background:qlineargradient(spread:pad,x1:0,y1:0,x2:1,y2:0,stop:0 #99ffff,stop:1 #41d6ff);}"); systime = new ModuleSysTime(); systime->moveToThread(&threadSystime); threadSystime.start(); connect(systime, SIGNAL(sigArmRtcTimeUpdate(bool)), this, SLOT(onRtcUpdate(bool))); connect(wangluo_thread, SIGNAL(onWifiTuBiaoState(bool)), this, SLOT(onWifiTuBiaoStateUpdate(bool))); wifi = new ModuleWifi(); wifi->moveToThread(&threadWifi); threadWifi.start(); connect(wangluo_thread, SIGNAL(sigWifiConnect(QString , QString )), wifi, SLOT(onConnect(QString , QString ))); connect(wangluo_thread, SIGNAL(sigWifiDisconect()), wifi, SLOT(onDisconnect())); connect(wifi, SIGNAL(sigStateChanged(bool)), wangluo_thread, SLOT(onWifiStateUpdate(bool))); connect(this, SIGNAL(sigWifiAutoConnect(QString , QString )), wifi, SLOT(onConnect(QString , QString ))); postDataMod = new modulePostData(); postDataMod->moveToThread(&threadPostData); threadPostData.start(); connect(this,SIGNAL(sigPostDigData()),postDataMod,SLOT(onPostDigData())); QLOG_TRACE() << "--trace msg MainWindow Constructor end"; // QLOG_TRACE() << "1-trace msg"; // QLOG_DEBUG() << "2-debug msg"; // QLOG_INFO() << "3-info msg"; // QLOG_WARN() << "4-warn msg"; // QLOG_ERROR() << "5-error msg"; // QLOG_FATAL() << "6-fatal msg"; } MainWindow::~MainWindow() { delete ui; if(chan1 != nullptr){ delete chan1; chan1 = nullptr; } if(chan2 != nullptr){ delete chan2; chan2 = nullptr; } if(chan3 != nullptr){ delete chan3; chan3 = nullptr; } if(chan4 != nullptr){ delete chan4; chan4 = nullptr; } if(chan5 != nullptr){ delete chan5; chan5 = nullptr; } if(chan6 != nullptr){ delete chan6; chan6 = nullptr; } if(chan7 != nullptr){ delete chan7; chan7 = nullptr; } if(chan8 != nullptr){ delete chan8; chan8 = nullptr; } if(chan9 != nullptr){ delete chan9; chan9 = nullptr; } if(chan10 != nullptr){ delete chan10; chan10 = nullptr; } if(chan11 != nullptr){ delete chan11; chan11 = nullptr; } if(chan12 != nullptr){ delete chan12; chan12 = nullptr; } delete sharememery_test; QsLogging::Logger::destroyInstance(); } void MainWindow::Mainwindows_Init() { label_lowpower_mode_back=new QLabel(this);//低功耗背景 label_lowpower_mode_back->setGeometry(0,0,800,480); label_lowpower_mode_back->setStyleSheet("background: rgb(0, 0, 0);"); label_lowpower_mode_back->hide(); label_lowpower_mode_back->installEventFilter(this); button_buzzer=new QPushButton(this);//蜂鸣器 button_buzzer->setGeometry(20,20,320,100); button_buzzer->setStyleSheet("background: rgb(0, 171, 171);font: 50pt 黑体 bold;color: rgb(255, 255, 255)"); button_buzzer->setText("消音"); button_buzzer->hide(); connect(button_buzzer,SIGNAL(clicked()), this,SLOT(button_buzzer_Clicked())); label_sys_time=new QLabel(this);//系统时间 label_sys_time->setGeometry(700,441,80,17); label_sys_time->setStyleSheet("font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); } void MainWindow::Mainwindows_File_Init() { // 检查目录是否存在,若不存在则新建文件/home/data QDir dir; if(!dir.exists("/home/data")) { dir.mkpath("/home/data"); } QFile fileTemp("/home/data/usb_fime_name");//删除USB路径文件,防止重复进入 fileTemp.remove(); QFile file_write("/home/data/net_ok.txt");//初始化网络状态文件,防止开机错误显示网络连接状态 if(file_write.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write); setWIFI_data<<"0"<start(100); QTimer::singleShot(60000, this, SLOT(Sys_time())); QTimer::singleShot(300000, this, SLOT(Lowpower_mode())); QTimer::singleShot(5000, this, SLOT(timerTimeout_share())); } void MainWindow::Mainwindows_USBFile_Init() { label_usb_file_title=new QLabel(this); label_usb_file_back=new QLabel(this); combobox_usb_file=new QComboBox(this); button_usb_file=new QPushButton(this); label_usb_file_back->setGeometry(0,0,800,480); label_usb_file_back->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); label_usb_file_title->setGeometry(350,140,200,50); label_usb_file_title->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); label_usb_file_title->setText("USB文件选择"); combobox_usb_file->setGeometry(300,200,200,50); combobox_usb_file->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); button_usb_file->setGeometry(350,260,100,50); button_usb_file->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(255, 255, 255)"); button_usb_file->setText("确定"); combobox_usb_file->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);//添加下拉框滑动条 combobox_usb_file->setStyle(QStyleFactory::create("Windows"));//改成windows风格,不然linux下不显示滑动条 combobox_usb_file->setMaxVisibleItems(7); connect(button_usb_file,SIGNAL(clicked()),this,SLOT(Button_usb_file_clicked())); label_usb_file_title->close(); label_usb_file_back->close(); combobox_usb_file->close(); button_usb_file->close(); } void MainWindow::Mainwindows_Title_Init() { label_0_1=new QLabel(this); label_0_3=new QLabel(this); label_0_4=new QLabel(this); label_0_5=new QLabel(this); label_0_6=new QLabel(this); label_0_7=new QLabel(this); label_0_8=new QLabel(this); label_0_9=new QLabel(this); label_0_1->installEventFilter(this);//安装鼠标事件 label_0_3->installEventFilter(this); label_0_4->installEventFilter(this); label_0_5->installEventFilter(this); label_0_6->installEventFilter(this); label_0_7->installEventFilter(this); label_0_8->installEventFilter(this); label_0_9->installEventFilter(this); label_0_1->setGeometry(600,186,150,32); label_0_1->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_1->setAlignment(Qt::AlignCenter); label_0_1->setText("电能数据"); label_0_3->setGeometry(50,186,150,32); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setAlignment(Qt::AlignCenter); label_0_3->setText("变压器电压电流"); label_0_4->setGeometry(240,186,150,32); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setAlignment(Qt::AlignCenter); label_0_4->setText("变压器功率"); label_0_5->setGeometry(420,186,150,32); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setAlignment(Qt::AlignCenter); label_0_5->setText("电能质量"); label_0_6->setGeometry(50,222,150,32); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setAlignment(Qt::AlignCenter); label_0_6->setText("无线测温"); label_0_7->setGeometry(240,222,150,32); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setAlignment(Qt::AlignCenter); label_0_7->setText("变压器实验报告"); label_0_8->setGeometry(420,222,150,32); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setAlignment(Qt::AlignCenter); label_0_8->setText("局放参数"); label_0_9->setGeometry(600,222,150,32); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setAlignment(Qt::AlignCenter); label_0_9->setText("热像仪图片"); } void MainWindow::Mainwindows_rxy_Init() { rxy_alarm_picture=new QLabel(this); rxy_alarm_picture->setGeometry(0,190,400,250); rxy_alarm_picture->hide(); rxy_alarm_picture->installEventFilter(this);//安装鼠标事件 rxy_alarm_picture1=new QLabel(this); rxy_alarm_picture1->setGeometry(400,190,400,250); rxy_alarm_picture1->hide(); rxy_alarm_picture1->installEventFilter(this);//安装鼠标事件 } void MainWindow::Mainwindows_temperature_Init() { label_A_temperature=new QLabel(this); label_B_temperature=new QLabel(this); label_C_temperature=new QLabel(this); label_T_temperature=new QLabel(this); label_A_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_B_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_C_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_T_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_A_temperature->setGeometry(22,142,181,31); label_B_temperature->setGeometry(219,142,181,31); label_C_temperature->setGeometry(409,142,181,31); label_T_temperature->setGeometry(599,142,181,31); label_A_temperature->setAlignment(Qt::AlignCenter); label_B_temperature->setAlignment(Qt::AlignCenter); label_C_temperature->setAlignment(Qt::AlignCenter); label_T_temperature->setAlignment(Qt::AlignCenter); } void MainWindow::Mainwindows_excel_Init() { /* 表格视图 */ tableView = new QTableView; /* 设置表格视图大小 */ tableView->setGeometry(10,270,780,150); tableView->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)"); /* 加载数据 */ model->setItem(0, 0, new QStandardItem("产品代号")); model->setItem(0, 1, new QStandardItem(""));//产品代号 model->setItem(0, 2, new QStandardItem("额定容量(kVA)")); model->setItem(0, 3, new QStandardItem(""));//额定容量 model->setItem(0, 4, new QStandardItem("标准代号")); model->setItem(0, 5, new QStandardItem(""));//标准代号 model->setItem(0, 6, new QStandardItem("联接组别")); model->setItem(0, 7, new QStandardItem(""));//联接组别 model->setItem(1, 0, new QStandardItem("产品型号")); model->setItem(1, 1, new QStandardItem(""));//产品型号 model->setItem(2, 0, new QStandardItem("额定电压")); model->setItem(2, 1, new QStandardItem("高压(kV)")); model->setItem(2, 2, new QStandardItem(""));//高压电压 model->setItem(2, 4, new QStandardItem("低压(kV)")); model->setItem(2, 5, new QStandardItem(""));//低压电压 model->setItem(3, 0, new QStandardItem("额定电流")); model->setItem(3, 1, new QStandardItem("高压(A)")); model->setItem(3, 2, new QStandardItem(""));//高压电流 model->setItem(3, 4, new QStandardItem("低压(A)")); model->setItem(3, 5, new QStandardItem(""));//低压电流 model->setItem(4, 0, new QStandardItem("空载损耗(kW)")); model->setItem(4, 1, new QStandardItem(""));//空载损耗 model->setItem(4, 4, new QStandardItem("负载损耗(kW)")); model->setItem(4, 5, new QStandardItem(""));//负载损耗 /* 自适应所有列,让它布满空间 */ tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); /* 不显示行数列数 */ tableView->horizontalHeader()->setVisible(false); tableView->verticalHeader()->setVisible(false); /* 合并单元格 */ tableView->setSpan(0,2,2,1); tableView->setSpan(0,3,2,1); tableView->setSpan(0,4,2,1); tableView->setSpan(0,6,2,1); tableView->setSpan(0,7,2,1); tableView->setSpan(2,2,1,2); tableView->setSpan(2,5,1,3); tableView->setSpan(3,2,1,2); tableView->setSpan(3,5,1,3); tableView->setSpan(4,1,1,3); tableView->setSpan(4,5,1,3); /* 指定列宽 */ tableView->setColumnWidth(1, 200); /* 设置表格视图数据 */ tableView->setModel(model); } void MainWindow::OnSilencingKeyClick() { ARM_1->setBuzzerState(0);//消音 } void MainWindow::onDispByqAlarm(bool state) { if(state){ alarm_flag9=true; Pop_alarm_voltage_A->setText("变压器失电"); }else{ alarm_flag9=false; Pop_alarm_voltage_A->hide(); } } void MainWindow::onPageThreeSend() { lowpower_mode_flag=false; } void MainWindow::onPageFiveSend() { lowpower_mode_flag=false; } void MainWindow::onDispWirelessAlarm(bool state) { if(state){ disconncet_wuxian=true; }else{ disconncet_wuxian=false; } } void MainWindow::onCountSend(int countsend) { countrcv = countsend; } void MainWindow::onDispJuFangAlarm(bool state) { if(state){ disconncet_jufang=true; }else{ disconncet_jufang=false; } } void MainWindow::onDispRxyAlarm(bool state_rxy1, bool state_rxy2) { if(state_rxy1){ disconncet_rxy1 = true; }else{ disconncet_rxy1 = false; } if(state_rxy2){ disconncet_rxy2 = true; }else{ disconncet_rxy2 = false; } } void MainWindow::onPageEightSend() { lowpower_mode_flag=false; } void MainWindow::dispAlarmBackground() { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 #define ALARM_BASE_GRP_FLAGS (alarm_flag1|alarm_flag2|alarm_flag3|alarm_flag4|alarm_flag5|alarm_flag6|alarm_flag7|alarm_flag8|alarm_flag9|alarm_flag12|alarm_flag13|alarm_flag14|alarm_flag16|alarm_flag17|alarm_flag18|alarm_flag19) if(ALARM_BASE_GRP_FLAGS|alarm_flag15) { if(ALARM_BASE_GRP_FLAGS) { if(alarm_start && kaiji_flag_ok) { tableView->hide();//表格 label_alarm_back->show(); label_alarm_back->raise(); alarm_back_flag=true; if(lowpower_mode_flag){ Lowpower_state(); } } else { Pop_alarm_temp_T->hide(); label_alarm_back->hide(); alarm_back_flag=false; if(mian_page == 7 && where_page == 0) { tableView->show(); } } }else{ QFile file_readtx1("/home/data/select_tiexin.txt");//文件路径 if(file_readtx1.open(QFile::ReadOnly)) { QTextStream setWIFI_data(&file_readtx1); if(setWIFI_data.readLine() == "0") { Pop_alarm_temp_T->hide(); label_alarm_back->hide(); alarm_back_flag=false; Pop_alarm_T_err_flag = false; }else{ Pop_alarm_T_err_flag = true; if(alarm_start && kaiji_flag_ok && alarm_flag15) { tableView->hide();//表格 label_alarm_back->show(); label_alarm_back->raise(); alarm_back_flag=true; if(lowpower_mode_flag){ Lowpower_state(); } } else { Pop_alarm_temp_T->hide(); label_alarm_back->hide(); alarm_back_flag=false; if(mian_page == 7 && where_page == 0) { tableView->show(); } } } file_readtx1.close(); } } } else { Pop_alarm_temp_T->hide(); label_alarm_back->hide(); alarm_back_flag=false; } QLOG_TRACE() << "--trace msg dispAlarmBackground :"<setText("A相断开:---°C"); if(alarm_start) { Pop_alarm_temp_A->setText("A相温控线断线"); Pop_alarm_temp_A->show(); Pop_alarm_temp_A->raise(); } }else{ label_A_temperature->setText("A相温度:0 °C "); Pop_alarm_temp_A->hide(); } } else label_A_temperature->setText("A相温度:加载中"); } else if(((A_temp3>250) | (A_temp3 < -40)) && kaiji_flag_ok) { label_A_temperature->setText("A相断开:---°C"); if(alarm_start && alarm_flag12) { Pop_alarm_temp_A->setText("A相温控线断线"); Pop_alarm_temp_A->show(); Pop_alarm_temp_A->raise(); } } else if(A_temp3 <= 250 && A_temp3 >= -40) { label_A_temperature->setText("A相温度:"+QString::number(A_temp3,'f',1)+"°C");//10进制转字符串 Pop_alarm_temp_A->hide(); } if(B_temp3==0) { if(kaiji_flag_ok) { if(alarm_flag13){ label_B_temperature->setText("B相断开:---°C"); if(alarm_start) { Pop_alarm_temp_B->setText("B相温控线断线"); Pop_alarm_temp_B->show(); Pop_alarm_temp_B->raise(); } }else{ label_B_temperature->setText("B相温度:0 °C"); Pop_alarm_temp_B->hide(); } } else label_B_temperature->setText("B相温度:加载中"); } else if(((B_temp3>250) | (B_temp3 < -40)) && kaiji_flag_ok) { label_B_temperature->setText("B相断开:---°C"); if(alarm_start && alarm_flag13) { Pop_alarm_temp_B->setText("B相温控线断线"); Pop_alarm_temp_B->show(); Pop_alarm_temp_B->raise(); } } else if(B_temp3<=250 && B_temp3 >= -40) { label_B_temperature->setText("B相温度:"+QString::number(B_temp3,'f',1)+"°C");//10进制转字符串 Pop_alarm_temp_B->hide(); } if(C_temp3==0) { if(kaiji_flag_ok) { if(alarm_flag14){ label_C_temperature->setText("C相断开:---°C"); if(alarm_start) { Pop_alarm_temp_C->setText("C相温控线断线"); Pop_alarm_temp_C->show(); Pop_alarm_temp_C->raise(); } }else{ label_C_temperature->setText("C相温度:0 °C"); Pop_alarm_temp_C->hide(); } } else label_C_temperature->setText("C相温度:加载中"); } else if(((C_temp3>250) | (C_temp3 < -40)) && kaiji_flag_ok) { label_C_temperature->setText("C相断开:---°C"); if(alarm_start && alarm_flag14) { Pop_alarm_temp_C->setText("C相温控线断线"); Pop_alarm_temp_C->show(); Pop_alarm_temp_C->raise(); } } else if(C_temp3<=250 && C_temp3 >= -40) { label_C_temperature->setText("C相温度:"+QString::number(C_temp3,'f',1)+"°C");//10进制转字符串 Pop_alarm_temp_C->hide(); } QLOG_TRACE() << "--trace msg dispTemperature :"<show(); if(T_temp3==0) { if(kaiji_flag_ok) { if(alarm_flag15){ label_T_temperature->setText("铁芯断开:---°C"); if(alarm_start) { Pop_alarm_temp_T->setText("铁芯温控线断线"); Pop_alarm_temp_T->show(); Pop_alarm_temp_T->raise(); } }else{ label_T_temperature->setText("铁芯温度:0 °C"); Pop_alarm_temp_T->hide(); } } else label_T_temperature->setText("铁芯温度:加载中"); } else if(((T_temp3>250) | (T_temp3 < -40))&& kaiji_flag_ok) { label_T_temperature->setText("铁芯断开:---°C"); if(alarm_start && alarm_flag15) { Pop_alarm_temp_T->setText("铁芯温控线断线"); Pop_alarm_temp_T->show(); Pop_alarm_temp_T->raise(); } } else if(T_temp3<=250 && T_temp3 >= -40) { label_T_temperature->setText("铁芯温度:"+QString::number(T_temp3,'f',1)+"°C");//10进制转字符串 Pop_alarm_temp_T->hide(); } } if(line1=="0") { label_T_temperature->hide(); } } file_read_tx.close(); if(alarm_flag12 && alarm_flag13 && alarm_flag14 && alarm_flag15 && kaiji_flag_ok && alarm_start) { Pop_alarm_temp_A->setText("温控线未插"); Pop_alarm_temp_A->show(); Pop_alarm_temp_A->raise(); Pop_alarm_temp_B->hide(); Pop_alarm_temp_C->hide(); Pop_alarm_temp_T->hide(); } QLOG_TRACE() << "--trace msg dispTempCtrlLine :"<float{ QString transition1 = array.toHex(); int transition2 = transition1.toUInt(&ok,16); return (float)transition2*1.0/q; }; //case 1:电能数据界面 emit sigPageFourDataUpdate(); //case 3:变压器电压电流界面 /*轮显电流显示*/ A_Current3 = get_right_minus(SEC.SecWheelVolAA,1000); ANA.A_Current = A_Current3; B_Current3 = get_right_minus(SEC.SecWheelVolBB,1000); ANA.B_Current = B_Current3; C_Current2 = get_right_minus(SEC.SecWheelVolCC,1000); ANA.C_Current = C_Current2; emit sigPageOneDataUpdate(A_Current3,B_Current3,C_Current2); //case 4:变压器功率界面 /*功率因数*/ QString A_PowerFactor1 = SEC.SecWheelPowerFactorAA.toHex(); int A_PowerFactor2 = A_PowerFactor1.toUInt(&ok,16); A_PowerFactor3 = A_PowerFactor2*1.0000/10000; QString B_PowerFactor1 = SEC.SecWheelPowerFactorBB.toHex(); int B_PowerFactor2 = B_PowerFactor1.toUInt(&ok,16); B_PowerFactor3 = B_PowerFactor2*1.0000/10000; QString C_PowerFactor = SEC.SecWheelPowerFactorCC.toHex(); int C_PowerFactor1 = C_PowerFactor.toUInt(&ok,16); C_PowerFactor2 = C_PowerFactor1*1.0000/10000; emit sigPageTwoDataUpdate(A_PowerFactor3,B_PowerFactor3,C_PowerFactor2); //case 5:电能质量界面 emit sigPageThreeDataUpdate(); //case 6:无线测温界面 /*无线测温*/ emit sigPageFiveDataUpdate(); //case 8:局放 emit sigPageSevenDataUpdate(); switch (mian_page) { case 3: { emit sigPageOneDataLabelUpdate(); }; break; case 7: { QFile file_read_excel("/home/data/excel_data");//空负载损耗 if(file_read_excel.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read_excel);//创建一个对象让它去读文件 QString daihao=in.readLine(); QString xinghao=in.readLine(); QString rongliang=in.readLine(); QString bzdaihao1=in.readLine(); QString bzdaihao2=in.readLine(); QString zubie=in.readLine(); QString H_vol=in.readLine(); QString H_current=in.readLine(); QString L_vol=in.readLine(); QString L_current=in.readLine(); QString kongzai=in.readLine(); QString fuzai=in.readLine(); /* 加载数据 */ chan1->setText(daihao); model->setItem(0, 1, chan1);//产品代号 chan2->setText(xinghao); model->setItem(1, 1, chan2);//产品型号 chan3->setText(rongliang); model->setItem(0, 3, chan3);//额定容量 chan4->setText(bzdaihao1); model->setItem(0, 5, chan4);//标准代号 chan5->setText(bzdaihao2); model->setItem(1, 5, chan5);//标准代号 chan6->setText(zubie); model->setItem(0, 7, chan6);//联接组别 chan7->setText(H_vol); model->setItem(2, 2, chan7);//高压电压 chan8->setText(H_current); model->setItem(3, 2, chan8);//高压电流 chan9->setText(L_vol); model->setItem(2, 5, chan9);//低压电压 chan10->setText(L_current); model->setItem(3, 5, chan10);//低压电流 chan11->setText(kongzai); model->setItem(4, 1, chan11);//空载损耗 chan12->setText(fuzai); model->setItem(4, 5, chan12);//负载损耗 } file_read_excel.close(); }; break; case 9: { if(kaiji_flag_ok && alarm_start) { } else { emit sigPageEightDataUpdate(); } }; break; default: break; } QLOG_TRACE() << "--trace msg dispMainPages :"<hide(); } QFile fileall("/home/data/V_0_state.txt"); if(fileall.exists()) { if(fileall.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&fileall); if(in.readLine()=="0" && alarm_flag9 == true) { alarm_flag9=true; Pop_alarm_voltage_A->setText("变压器失电"); Pop_alarm_voltage_A->show(); Pop_alarm_voltage_A->raise(); }else{ alarm_flag9=false; Pop_alarm_voltage_A->hide(); } fileall.close(); } }else{ alarm_flag9=false; Pop_alarm_voltage_A->hide(); } if(disconncet_jufang) { } else { QFileInfo file_alarm18("/home/data/Pop_ult.txt"); if(file_alarm18.exists() == true)//超声波 { alarm_flag18=true; DIG.alarm_Pop_ult = 1; Pop_alarm_chaosheng->show(); Pop_alarm_chaosheng->raise(); Pop_alarm_chaosheng->setText("超声波异常"); } else { DIG.alarm_Pop_ult = 0; alarm_flag18=false; Pop_alarm_chaosheng->hide(); } QFileInfo file_alarm19("/home/data/Pop_tev.txt"); if(file_alarm19.exists() == true)//tev { alarm_flag19=true; DIG.alarm_Tev = 1; Pop_alarm_tev->show(); Pop_alarm_tev->raise(); Pop_alarm_tev->setText("TEV异常"); } else { DIG.alarm_Tev = 0; alarm_flag19=false; Pop_alarm_tev->hide(); } } if(disconncet_rxy1 | disconncet_rxy2) { alarm_flag4=false; Pop_alarm_rxy_disconnect->hide(); } else { QFileInfo file_alarm6_1("/home/data/Pop_rxy1.txt"); QFileInfo file_alarm6_2("/home/data/Pop_rxy2.txt"); if(file_alarm6_1.exists() == true || file_alarm6_2.exists() == true) //热像仪掉线 { alarm_flag4=true; DIG.alarm_rxy = 1; Pop_alarm_rxy_disconnect->show(); Pop_alarm_rxy_disconnect->raise(); Pop_alarm_rxy_disconnect->setText("热像仪掉线"); ARM_1->rxy_state(); //向下位机发送警报 23.8.16 } else { DIG.alarm_rxy = 0; alarm_flag4=false; Pop_alarm_rxy_disconnect->hide(); } } /*无线测温弹窗*/ QString WirelessT_alarm = SEC.wirelessTData_State.toHex(); bool WirelessT_alarm_flag=false; Wireless = ""; for(int i=0;ishow(); Pop_alarm_Wireless_Temperature->raise(); Pop_alarm_Wireless_Temperature->setText("无线测温节点异常:"+Wireless); } } else { alarm_flag17=false; Pop_alarm_Wireless_Temperature->hide(); } /*通信故障*/ if(net_ok == false) { if(alarm_start) { alarm_flag16=true; Pop_alarm_communicate->show(); Pop_alarm_communicate->raise(); Pop_alarm_communicate->setText("通信故障"); } else { alarm_flag16=false; Pop_alarm_communicate->hide(); } }else{ alarm_flag16=false; Pop_alarm_communicate->hide(); } } else { Pop_alarm_door->hide(); Pop_alarm_over_temperature->hide(); Pop_alarm_chaosheng->hide(); Pop_alarm_tev->hide(); Pop_alarm_trip->hide(); Pop_alarm_rxy_disconnect->hide(); Pop_alarm_current_A->hide(); Pop_alarm_current_B->hide(); Pop_alarm_current_C->hide(); Pop_alarm_voltage_A->hide(); Pop_alarm_Wireless_Temperature->hide(); Pop_alarm_temp_A->hide(); Pop_alarm_temp_B->hide(); Pop_alarm_temp_C->hide(); Pop_alarm_temp_T->hide(); Pop_alarm_communicate->hide(); label_alarm_back->hide(); Pop_alarm_fan->hide(); alarm_back_flag=false; } if((DIGCOMPARE.alarm_rxy != DIG.alarm_rxy) | (DIGCOMPARE.rxy_img1 != DIG.rxy_img1) | (DIGCOMPARE.rxy_img2 != DIG.rxy_img2) | DIG.McuState_flag | DIG.McuAlarmState_flag | DIG.policeDataDig_flag | DIG.McuConnectState_flag | DIG.wirelessTData_State_flag) { emit sigPostDigData(); } QLOG_TRACE() << "--trace msg dispPopWindwows :"<hide(); mP_A_V->hide(); mP_Power->hide(); mP_Quality->hide(); mP_Data->show(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->hide(); } } void MainWindow::label_3_show(int a) { if(a==1) { tableView->hide(); mP_A_V->show(); mP_Power->hide(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->hide(); // if(widget){ // delete widget; // } // widget = new mainpage_A_V(widget_page); // widget->setObjectName(QString::fromUtf8("widget1")); // widget->setGeometry(QRect(9, 259, 781, 181)); // widget->show(); // widget->raise(); } } void MainWindow::label_4_show(int a) { if(a==1) { tableView->hide(); mP_A_V->hide(); mP_Power->show(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->hide(); } } void MainWindow::label_5_show(int a) { if(a==1) { tableView->hide(); mP_A_V->hide(); mP_Power->hide(); mP_Quality->show(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->hide(); } } void MainWindow::label_6_show(int a) { if(a==1) { tableView->hide(); mP_A_V->hide(); mP_Power->hide(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->show(); mP_JfParameter->hide(); mP_Rxy->hide(); emit sigWirelessStateCheck(); } } void MainWindow::label_7_show(int a) { if(a==1) { tableView->show();//表格 tableView->raise(); mP_A_V->hide(); mP_Power->hide(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->hide(); } } void MainWindow::label_8_show(int a) { if(a==1) { tableView->hide(); emit sigJuFangStateCheck(); mP_A_V->hide(); mP_Power->hide(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->show(); mP_Rxy->hide(); } } void MainWindow::label_9_show(int a) { tableView->hide(); if(a==1) { mP_A_V->hide(); mP_Power->hide(); mP_Quality->hide(); mP_Data->hide(); mP_Temp->hide(); mP_JfParameter->hide(); mP_Rxy->show(); emit sigRxyButtonShow(); } } void MainWindow::main_page(int a) { switch (a) { case 1: { label_0_1->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 2: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 3: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 4: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 5: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 6: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 7: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 8: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); label_0_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); }; break; case 9: { label_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)"); label_0_9->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)"); }; break; default: { }; break; } } bool MainWindow::eventFilter(QObject *watch, QEvent *evn)//鼠标事件,判断触摸是左滑还是右滑 { if(watch == label_lowpower_mode_back && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面 { lowpower_mode_flag=false; label_lowpower_mode_back->close(); label_A_temperature->setGeometry(22,142,181,31); label_A_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_B_temperature->setGeometry(219,142,181,31); label_B_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_C_temperature->setGeometry(409,142,181,31); label_C_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_T_temperature->setGeometry(599,142,181,31); label_T_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); } if(watch == label_0_1 && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面 { lowpower_mode_flag=false; label_0_1_clicked(); } if(watch == label_0_3 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; label_0_3_clicked(); } if(watch == label_0_4 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; label_0_4_clicked(); } if(watch == label_0_5 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; label_0_5_clicked(); } if(watch == label_0_6 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; label_0_6_clicked(); } if(watch == label_0_9 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; label_0_9_clicked(); } if(watch == label_0_8 && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面 { lowpower_mode_flag=false; label_cspz_0_2_clicked(); } if(watch == label_0_7 && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面 { lowpower_mode_flag=false; label_cspz_0_4_clicked(); } if(watch == rxy_alarm_picture && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; rxy_alarm_picture->close(); } if(watch == rxy_alarm_picture1 && evn->type() == QEvent::MouseButtonPress) { lowpower_mode_flag=false; rxy_alarm_picture1->close(); } return QWidget::eventFilter(watch,evn); } void MainWindow::on_pushButton_zhujiemian_clicked() { where_page = 0; } void MainWindow::on_pushButton_wangluoxinxi_clicked() { lowpower_mode_flag1=false;//不进入低功耗模式 where_page = 1; if(!wlpz_flag && !cspz_flag && !xtpz_flag) { wlpz_flag=true; KeyBoard_Code=false; KeyBoard_ABC_Code=false; keyBoard_flag=false; keyBoard_ABC_flag=false; tableView->hide(); wangluo_thread->wlxx_set_back_color(); wangluo_thread->show(); 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(); } } void MainWindow::on_pushButton_canshushezhi_clicked() { where_page = 2; lowpower_mode_flag1=false;//不进入低功耗模式 if(!wlpz_flag && !cspz_flag && !xtpz_flag) { cspz_flag=true; KeyBoard_Code=false; KeyBoard_ABC_Code=false; keyBoard_flag=false; keyBoard_ABC_flag=false; tableView->hide(); canshupeizhi_thread->cspz_set_back_color(); canshupeizhi_thread->show(); 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(); } } void MainWindow::on_pushButton_xitongshezhi_clicked() { where_page = 3; lowpower_mode_flag1=false;//不进入低功耗模式 if(!wlpz_flag && !cspz_flag && !xtpz_flag) { xtpz_flag=true; keyBoard_flag=false; tableView->hide(); xitongshezhi_thread->show(); xitongshezhi_thread->xtsz_page(1); xitongshezhi_thread->label_xtsz_1_show(1); xitongshezhi_thread->label_xtsz_2_show(0); xitongshezhi_thread->label_xtsz_3_show(0); } } void MainWindow::main_set_back_color()//改背景色 { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 QString data; /*文件读取*/ QFile file_read("/home/data/back_color"); if(file_read.open(QFile::ReadOnly)) { QTextStream in(&file_read);//创建一个对象让它去读文件 data=in.readAll(); } main_back_color=data.toInt(); file_read.close(); switch(main_back_color) { case 1: { ui->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; } QLOG_TRACE() << "--trace msg main_set_back_color :"<lock(); // memcpy(sharememery_test->data(), &share_num, sizeof(int)); // sharememery_test->unlock(); // QTimer::singleShot(5000, this, SLOT(timerTimeout_share())); } void MainWindow::Lowpower_state() { lowpower_mode_flag=false; label_lowpower_mode_back->close(); label_A_temperature->setGeometry(22,142,181,31); label_A_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_B_temperature->setGeometry(219,142,181,31); label_B_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_C_temperature->setGeometry(409,142,181,31); label_C_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); label_T_temperature->setGeometry(599,142,181,31); label_T_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 15pt 黑体 bold;color: rgb(0, 171, 171)"); } void MainWindow::onBuzzerClose() { ARM_1->setBuzzerState(0);//消音 onBuzzerCtrl(false); } void MainWindow::onBuzzerCtrl(bool state) { if(state)//蜂鸣器 { button_buzzer->show(); button_buzzer->raise(); }else{ button_buzzer->hide(); } } bool alarm_pop=false; void MainWindow::timerTimeout(void)//修改温度 { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 dispBuzzer(); QFileInfo file_usb("/home/data/usb_fime_name"); if(file_usb.exists()) { }else{ dispAlarmBackground(); dispFan(alarm_flag5); dispOverTemp(alarm_flag2); dispTrip(alarm_flag3); dispDoor(alarm_flag1); dispPopWindwows(); } dispTemperature(); dispTempCtrlLine(); dispMainPages(); if(lowpower_mode_flag | file_usb.exists() ){ }else{ main_set_back_color();//改背景色 QFile file_write_byq("/home/data/cspz_byqfuhe");//变压器负荷 if(file_write_byq.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write_byq); float byq_data=(A_vol2*A_Current3*A_PowerFactor3)+(B_vol3*B_Current3*B_PowerFactor3)+(C_vol3*C_Current2*C_PowerFactor2); setWIFI_data<<(QString::number(byq_data,'f',0)); } file_write_byq.close(); if(alarm_pop)//报警弹窗背景 { alarm_pop=false; label_alarm_back->setStyleSheet("background: rgb(255, 70, 24)"); } else { alarm_pop=true; label_alarm_back->setStyleSheet("background: rgb(55, 255, 71)"); } } if(file_usb.exists() == true)//检测是否存在usb_fime_name文件 { usb_file_selcet(); } QFileInfo file_tempera("/home/data/temperature.txt"); if(file_tempera.exists() == true)//检测是否存在热像仪报警文件 { Thermal_imager_Alarm_fun(); } QFileInfo file_tempera1("/home/data/temperature1.txt"); if(file_tempera1.exists() == true)//检测是否存在热像仪报警文件 { Thermal_imager_Alarm_fun1(); } /*网络状态*/ QFile file_net_read("/home/data/net_ok.txt"); if(file_net_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_net_read);//创建一个对象让它去读文件 if(in.readLine() == "1") { net_ok = true; } else { net_ok = false; } } file_net_read.close(); SEC.Wifi_quality = wifi->getquality(); QLOG_TRACE() << "--trace msg timerTimeout :"<setText(sys_time.right(5)); error_record="/home/data/error_file_"+sys_time.mid(5,2)+".txt"; error_record_int=sys_time.mid(5,2).toInt(&ok, 10); } file_read.close(); label_sys_time->show(); if(rxy_count==2) { kaiji_flag_ok=true; } if(rxy_count==3)//每3分钟记录一次报警错误 { rxy_count=0; if(alarm_flag1) { QFile file_write_error(error_record);//报警记录文件路径 if(file_write_error.open(QFile::WriteOnly | QFile::Append)) { QTextStream set4G_data(&file_write_error); set4G_data<hide(); label_lowpower_mode_back->show(); label_lowpower_mode_back->raise(); label_A_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 24pt 黑体 bold;color: rgb(0, 171, 171)"); label_A_temperature->setGeometry(250,100,300,50); label_A_temperature->show(); label_A_temperature->raise(); label_B_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 24pt 黑体 bold;color: rgb(0, 171, 171)"); label_B_temperature->setGeometry(250,160,300,50); label_B_temperature->show(); label_B_temperature->raise(); label_C_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 24pt 黑体 bold;color: rgb(0, 171, 171)"); label_C_temperature->setGeometry(250,220,300,50); label_C_temperature->show(); label_C_temperature->raise(); QFile file_read4("/home/data/select_tiexin.txt"); if(file_read4.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read4);//创建一个对象让它去读文件 QString line1=in.readLine(); if(line1=="1") { label_T_temperature->setStyleSheet("background: rgb(244, 244, 244);font: 24pt 黑体 bold;color: rgb(0, 171, 171)"); label_T_temperature->setGeometry(250,280,300,50); label_T_temperature->show(); label_T_temperature->raise(); } else { label_T_temperature->hide(); } } }else{ if(mian_page == 7 && where_page == 0) { tableView->show(); } } if(lowpower_mode_flag1) lowpower_mode_flag=true; QTimer::singleShot(300000, this, SLOT(Lowpower_mode())); QLOG_TRACE() << "--trace msg Lowpower_mode :"<setValue(jindutiao_count); } else { jindutiao_count=0; timer_jindutiao->stop(); emit sigRxyLabelSet(); } } void Delay_MSec3(unsigned int msec) { QEventLoop eventloop; QTimer::singleShot((int)msec, &eventloop, SLOT(quit())); eventloop.exec(); } void MainWindow::usb_file_selcet() { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 if(usb_file_first) { usb_file_first=0; QString usb_file_name=""; /*文件读取*/ QFile file_read("/home/data/usb_fime_name"); if(file_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read);//创建一个对象让它去读文件 usb_file_name=in.readLine(); } file_read.close(); QString usb_file_path1=usb_file_name.replace("/dev/","");//字符串前5位(/dev/) //读取指定路径下的所有文件 QDir dir("/run/media/"+usb_file_path1); QStringList nameFilters; QStringList files_usb = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); for (int i = 0; i < files_usb.size(); ++i) { QString usb_file_name=files_usb.at(i); QByteArray cdata = usb_file_name.toLocal8Bit();//修复中文乱码 combobox_usb_file->addItem(QString(cdata));//显示所有文件 } tableView->hide(); label_sys_time->close(); label_0_1->close(); label_0_3->close(); label_0_4->close(); label_0_5->close(); label_0_6->close(); label_0_7->close(); label_0_8->close(); label_0_9->close(); if(combobox_usb_file->currentText()=="") { Delay_MSec3(200); /*文件读取*/ QFile file_read("/home/data/usb_fime_name"); if(file_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read);//创建一个对象让它去读文件 usb_file_name=in.readLine(); } file_read.close(); QString usb_file_path1=usb_file_name.replace("/dev/","");//字符串前5位(/dev/) //读取指定路径下的所有文件 QDir dir("/run/media/"+usb_file_path1); QStringList nameFilters; QStringList files_usb = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); for (int i = 0; i < files_usb.size(); ++i) { QString usb_file_name=files_usb.at(i); QByteArray cdata = usb_file_name.toLocal8Bit();//修复中文乱码 combobox_usb_file->addItem(QString(cdata));//显示所有文件 } } label_usb_file_title->show(); label_usb_file_back->show(); combobox_usb_file->show(); button_usb_file->show(); label_usb_file_title->raise(); label_usb_file_back->raise(); combobox_usb_file->raise(); button_usb_file->raise(); } QLOG_TRACE() << "--trace msg usb_file_selcet :"<currentText()<close(); label_usb_file_back->close(); combobox_usb_file->clear(); combobox_usb_file->close(); button_usb_file->close(); label_0_1->show(); label_0_3->show(); label_0_4->show(); label_0_5->show(); label_0_6->show(); label_0_7->show(); label_0_8->show(); label_0_9->show(); label_0_1_clicked(); QFile fileTemp("/home/data/usb_fime_name");//删除USB路径文件,防止重复进入 fileTemp.remove(); label_sys_time->show(); usb_file_first=1;//防止多次进入 } void MainWindow::Thermal_imager_Alarm_fun(void) { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 QFileInfo file1("/home/data/temperature.txt"); if(file1.exists() == true)//检测是否存在IMAGE1文件 { QFile file_read("/home/data/temperature.txt"); QString Thermal_imager_Alarm_file; if(file_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read);//创建一个对象让它去读文件 Thermal_imager_Alarm_file=in.readLine(); DIG.rxy_img1 = Thermal_imager_Alarm_file; } file_read.close(); QPixmap *pixmap = nullptr; pixmap = new QPixmap(Thermal_imager_Alarm_file); pixmap->scaled(rxy_alarm_picture->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 rxy_alarm_picture->setScaledContents(true); rxy_alarm_picture->setPixmap(*pixmap); rxy_alarm_picture->show(); rxy_alarm_picture->raise(); QFile fileTemp("/home/data/temperature.txt");//删除热像仪报警文件 fileTemp.remove(); if(pixmap != nullptr) { delete pixmap; pixmap = nullptr; } } QFileInfo file("/home/data/IMAGE/");//删文件夹IMAGE if(file.exists() == true)//检测是否存在IMAGE文件 { #ifdef LINUX std::system("rm -rf /home/data/IMAGE/"); #endif } #ifdef LINUX std::system("mkdir /home/data/IMAGE/"); #endif //实时温度部分 数据正常读取,调用串口发送数据 QFile file_temperature("/home/data/Real-TimeTemperature.txt"); if(file_temperature.exists()) { if(file_temperature.open(QIODevice::ReadOnly)) { QTextStream in(&file_temperature); QString maxTemperature = in.readLine(); QString minTemperature = in.readLine(); QString averageTemperature = in.readLine(); qDebug() << maxTemperature << endl <Realtime_temperature(max,min,ave); } file_temperature.close(); } QFile file_temperature_temp("/home/data/Real-TimeTemperature.txt");//删除温度存储部分 file_temperature_temp.remove(); QLOG_TRACE() << "--trace msg Thermal_imager_Alarm_fun :"<scaled(rxy_alarm_picture1->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 rxy_alarm_picture1->setScaledContents(true); rxy_alarm_picture1->setPixmap(*pixmap); rxy_alarm_picture1->show(); rxy_alarm_picture1->raise(); QFile fileTemp("/home/data/temperature1.txt");//删除热像仪报警文件 fileTemp.remove(); if(pixmap != nullptr) { delete pixmap; pixmap = nullptr; } } QFileInfo file("/home/data/IMAGE1/");//删文件夹IMAGE if(file.exists() == true)//检测是否存在IMAGE文件 { #ifdef LINUX std::system("rm -rf /home/data/IMAGE1/"); #endif } #ifdef LINUX std::system("mkdir /home/data/IMAGE1/"); #endif //实时温度部分 数据正常读取,调用串口发送数据 QFile file_temperature("/home/data/Real-TimeTemperature1.txt"); if(file_temperature.exists()) { if(file_temperature.open(QIODevice::ReadOnly)) { QTextStream in(&file_temperature); QString maxTemperature = in.readLine(); QString minTemperature = in.readLine(); QString averageTemperature = in.readLine(); qDebug() << maxTemperature << endl <Realtime_temperature1(max,min,ave); } file_temperature.close(); } QFile file_temperature_temp("/home/data/Real-TimeTemperature1.txt");//删除温度存储部分 file_temperature_temp.remove(); QLOG_TRACE() << "--trace msg Thermal_imager_Alarm_fun1 :"<scaled(ui->label_tubiao_wifi->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_wifi->setScaledContents(true); ui->label_tubiao_wifi->setPixmap(*pixmap); if(pixmap != nullptr) { delete pixmap; pixmap = nullptr; } } void MainWindow::WIFI_tubiao_connect() { QPixmap *pixmap = nullptr; pixmap = new QPixmap(":/image/image/WIFI2.png"); pixmap->scaled(ui->label_tubiao_wifi->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_wifi->setScaledContents(true); ui->label_tubiao_wifi->setPixmap(*pixmap); if(pixmap != nullptr) { delete pixmap; pixmap = nullptr; } } void MainWindow::onRtcUpdate(bool flag) { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 if(flag){ ARM_1->setTime(); }else { ARM_1->GetRtcTime(); } QDateTime date_time=QDateTime::currentDateTimeUtc(); long nowtime = date_time.toTime_t() + 28800; struct tm *timp; timp = gmtime(&nowtime); int year = 1900 + timp->tm_year; int mouth = 1 + timp->tm_mon; QString ass_month,ass_day,ass_hour,ass_minute; if(mouth<10){ ass_month = "0"+QString::number(mouth); }else{ ass_month =QString::number(mouth); } if(timp->tm_mday<10){ ass_day = "0"+QString::number(timp->tm_mday); }else{ ass_day =QString::number(timp->tm_mday); } if(timp->tm_hour<10){ ass_hour = "0"+QString::number(timp->tm_hour); }else{ ass_hour =QString::number(timp->tm_hour); } if(timp->tm_min<10){ ass_minute = "0"+QString::number(timp->tm_min); }else{ ass_minute =QString::number(timp->tm_min); } QString str = QString::number(year) + "-" + ass_month + "-" + ass_day + " " + ass_hour + ":" + ass_minute; QFile file_write_time("/home/data/time");//文件路径 if(file_write_time.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write_time); setWIFI_data<scaled(ui->label_tubiao_4g->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_4g->setScaledContents(true); ui->label_tubiao_4g->setPixmap(*pixmap_4G); if(pixmap_4G != nullptr){ delete pixmap_4G; pixmap_4G =nullptr; } } void MainWindow::dispFan(bool ctrl) { if(ctrl) { Pop_alarm_fan->show(); Pop_alarm_fan->raise(); Pop_alarm_fan->setText("风机故障"); }else { Pop_alarm_fan->hide(); } } void MainWindow::dispOverTemp(bool ctrl) { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 if(ctrl) { Pop_alarm_over_temperature->show(); Pop_alarm_over_temperature->raise(); Pop_alarm_over_temperature->setText("超温"); }else { Pop_alarm_over_temperature->hide(); } QLOG_TRACE() << "--trace msg dispOverTemp :"<show(); Pop_alarm_trip->raise(); Pop_alarm_trip->setText("跳闸"); }else { Pop_alarm_trip->hide(); } } void MainWindow::dispDoor(bool ctrl) { if(ctrl) { Pop_alarm_door->setText("门触点"); Pop_alarm_door->show(); Pop_alarm_door->raise(); }else { Pop_alarm_door->hide(); } } void MainWindow::screenBright(bool ctrl) { QElapsedTimer timedebuge;//声明一个时钟对象 timedebuge.start();//开始计时 if(ctrl) { if(screen_bflag == false) { std::system("echo 0 > /sys/class/backlight/backlight/brightness"); screen_bflag = true; } }else { if(screen_bflag) { std::system("echo 6 > /sys/class/backlight/backlight/brightness"); screen_bflag = false; } } QLOG_TRACE() << "--trace msg dispDoor :"<powerlost(); } } void MainWindow::onSelfTestCheck(uint32_t data_alarm) { alarm_flag15 = (data_alarm & BIT(6)) ? false: true; alarm_flag14 = (data_alarm & BIT(5)) ? false: true; alarm_flag13 = (data_alarm & BIT(4)) ? false: true; alarm_flag12 = (data_alarm & BIT(3)) ? false: true; } void MainWindow::onLanTuBiaoStateUpdate(bool state) { QPixmap *pixmap = nullptr; if(state){ pixmap = new QPixmap(":/image/image/yitaiyang.png"); }else { pixmap = new QPixmap(":/image/image/yitaiyang_disconnect.png"); } pixmap->scaled(ui->label_tubiao_youxian->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_youxian->setScaledContents(true); ui->label_tubiao_youxian->setPixmap(*pixmap); if(pixmap != nullptr){ delete pixmap; pixmap =nullptr; } } void MainWindow::fun_4G_start() { QString line_4G_ip1; Delay_MSec3(10000);//等待PPP0加载 #ifdef LINUX std::system("ifconfig ppp0 | grep \"inet addr\" | awk '{ print $2}' | awk -F: '{print $2}' > /home/4G_IP"); #endif Delay_MSec3(1000); QFile file_read3("/home/4G_IP"); if(file_read3.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read3);//创建一个对象让它去读文件 line_4G_ip=in.readLine(); } file_read3.close(); if(line_4G_ip == "") { #ifdef LINUX std::system("killall pppd"); Delay_MSec3(3000); std::system("pppd call Neoway-pppdial &"); Delay_MSec3(3000); std::system("ifconfig ppp0 | grep \"inet addr\" | awk '{ print $2}' | awk -F: '{print $2}' > /home/4G_IP"); #endif Delay_MSec3(1000); if(file_read3.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read3);//创建一个对象让它去读文件 line_4G_ip=in.readLine(); } file_read3.close(); } QString IP_4G_set="route add default dev ppp0 metric 10 gw "+line_4G_ip; QString IP_4G_reset="route del default gw "+line_4G_ip; kaiji->setText("4G网络配置中,请稍后..."); #ifdef LINUX std::system("timeout 2s cat /dev/ttyUSB2 > /home/data/4G_quility &"); Delay_MSec3(1000); std::system("echo \"AT+CSQ\" > /dev/ttyUSB2");//获取SIM质量 #endif Delay_MSec3(1200); QFile file_read("/home/data/4G_quility"); if(file_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read);//创建一个对象让它去读文件 in.readLine(); in.readLine(); in.readLine(); QString sim_quility=in.readLine(); int sim_quility_long = sim_quility.length();//获取质量 SEC.SIM_quality = sim_quility_long; if(sim_quility_long<11)//信号差 { state_4G=false; QPixmap *pixmap = new QPixmap(":/image/image/4G_low_quility.png"); pixmap->scaled(ui->label_tubiao_4g->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_4g->setScaledContents(true); ui->label_tubiao_4g->setPixmap(*pixmap); } else state_4G=true; } file_read.close(); #ifdef LINUX std::system("timeout 2s cat /dev/ttyUSB2 > /home/data/4G_quility &"); Delay_MSec3(1000); std::system("echo \"AT+CCID\" > /dev/ttyUSB2");//获取SIM卡ID #endif Delay_MSec3(1200); QFile file_read4("/home/data/4G_quility"); if(file_read4.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read4);//创建一个对象让它去读文件 in.readLine(); in.readLine(); in.readLine(); QString SIM_ok=in.readLine(); if(SIM_ok=="ERROR")//无SIM卡 { QPixmap *pixmap = new QPixmap(":/image/image/4G_disconnect.png"); pixmap->scaled(ui->label_tubiao_4g->size(), Qt::KeepAspectRatio);//设置图片适应lable大小 ui->label_tubiao_4g->setScaledContents(true); ui->label_tubiao_4g->setPixmap(*pixmap); } } file_read4.close(); kaiji->setText("WIFI网络配置中,请稍后..."); first_statr_wifi();//开机连WIFI Delay_MSec3(10000); kaiji->setText("正在加载热像仪模块,请稍后..."); Delay_MSec3(5000); if(line_4G_ip != "") { #ifdef LINUX std::system(IP_4G_reset.toLatin1()); Delay_MSec3(1000); std::system(IP_4G_set.toLatin1()); Delay_MSec3(1000); #endif } CCID_check = new module4g(); CCID_check->moveToThread(&thread4g); thread4g.start(); connect(CCID_check, SIGNAL(sig4gstate(bool)), this, SLOT(onGgTuBiaoStateUpdate(bool))); connect(CCID_check, SIGNAL(sigLanState(bool)), this, SLOT(onLanTuBiaoStateUpdate(bool))); } void MainWindow::first_statr_wifi()//开机连WIFI { QString wifi_name; QString wifi_password; #ifdef LINUX std::system("killall wpa_supplicant"); Delay_MSec3(1000); std::system("ifconfig mlan0 down");//初始化wlan0 std::system("ifconfig mlan0 up");//初始化wlan0 #endif Delay_MSec3(1000); QFile file_read("/home/data/wlxx_wificonnect"); if(file_read.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read);//创建一个对象让它去读文件 wifi_name="\""+in.readLine()+"\""; wifi_password="\""+in.readLine()+"\""; } file_read.close(); QFile fileTemp("/etc/sta.conf");//删除旧的wifi信息文件 fileTemp.remove(); /*修改wifi信息文件-wifi_name*/ QString wifi_file; wifi_file="ctrl_interface=/var/run/wpa_supplicant\nnetwork={\nssid="+wifi_name+"\npsk="+wifi_password+"\n}\n"; QFile file_write_wifi_connect("/etc/sta.conf");//文件路径 if(file_write_wifi_connect.open(QFile::WriteOnly)) { QTextStream set_wifi_connect(&file_write_wifi_connect); set_wifi_connect< /home/WIFI_IP"); #endif QFile file_read_wifi_ip("/home/WIFI_IP"); QString wifi_ip; if(file_read_wifi_ip.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file_read_wifi_ip);//创建一个对象让它去读文件 wifi_ip=in.readLine(); } file_read_wifi_ip.close(); // int local = wifi_ip.indexOf('.',9,Qt::CaseInsensitive);//意思是从第9位往后找,找到的第一个‘.’所在的位置 // wifi_ip=wifi_ip.left(local+1);//从左向右截取n个字符串 // wifi_ip=wifi_ip+"1"; if(wifi_ip != "") { QString wifi_ip_reset="route del default gw "+wifi_ip; Delay_MSec3(1000); #ifdef LINUX std::system(wifi_ip_reset.toLatin1()); Delay_MSec3(1000); QString wifi_ip_set="route add default dev mlan0 metric 20 gw "+wifi_ip; std::system(wifi_ip_set.toLatin1()); #endif } } void MainWindow::button_buzzer_Clicked() { QTimer::singleShot(200,this,SLOT(onBuzzerClose())); lowpower_mode_flag=false; } void MainWindow::Pop_alarm_door_Clicked() { lowpower_mode_flag=false; alarm_flag1=false; Pop_alarm_door->hide(); } void MainWindow::Pop_alarm_over_temperature_Clicked() { lowpower_mode_flag=false; alarm_flag2=false; Pop_alarm_over_temperature->hide(); } void MainWindow::Pop_alarm_chaosheng_Clicked() { lowpower_mode_flag=false; alarm_flag18=false; Pop_alarm_chaosheng->hide(); QFile fileTemp("/home/data/Pop_ult.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_tev_Clicked() { lowpower_mode_flag=false; alarm_flag19=false; Pop_alarm_tev->hide(); QFile fileTemp("/home/data/Pop_tev.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_trip_Clicked() { lowpower_mode_flag=false; alarm_flag3=false; Pop_alarm_trip->hide(); } void MainWindow::Pop_alarm_communicate_Clicked() { lowpower_mode_flag=false; alarm_flag16=false; Pop_alarm_communicate->hide(); } void MainWindow::Pop_alarm_Wireless_Temperature_Clicked() { lowpower_mode_flag=false; alarm_flag17=false; Pop_alarm_Wireless_Temperature->hide(); } void MainWindow::Pop_alarm_rxy_disconnect_Clicked() { QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked start"; lowpower_mode_flag=false; if(alarm_start) { QFile file_write2("/home/data/change_set.txt");//文件路径 if(file_write2.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write2); QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked creat /home/data/change_set.txt"; } file_write2.close(); QFile file_write3("/home/data/change_set1.txt");//文件路径 if(file_write3.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write3); QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked creat /home/data/change_set1.txt"; } file_write3.close(); } else { Pop_alarm_rxy_disconnect->hide(); } QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked end"; } void MainWindow::Pop_alarm_fan_Clicked() { lowpower_mode_flag=false; alarm_flag5=false; Pop_alarm_fan->hide(); QFile fileTemp("/home/data/Fanfail.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_current_A_Clicked() { lowpower_mode_flag=false; alarm_flag6=false; Pop_alarm_current_A->hide(); QFile fileTemp("/home/data/Pop_reverseA.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_current_B_Clicked() { lowpower_mode_flag=false; alarm_flag7=false; Pop_alarm_current_B->hide(); QFile fileTemp("/home/data/Pop_reverseB.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_current_C_Clicked() { lowpower_mode_flag=false; alarm_flag8=false; Pop_alarm_current_C->hide(); QFile fileTemp("/home/data/Pop_reverseC.txt"); fileTemp.remove(); } void MainWindow::Pop_alarm_voltage_A_Clicked() { lowpower_mode_flag=false; alarm_flag9=false; Pop_alarm_voltage_A->hide(); } void MainWindow::Pop_alarm_temp_A_Clicked() { lowpower_mode_flag=false; alarm_flag12=false; Pop_alarm_temp_A->hide(); } void MainWindow::Pop_alarm_temp_B_Clicked() { lowpower_mode_flag=false; alarm_flag13=false; Pop_alarm_temp_B->hide(); } void MainWindow::Pop_alarm_temp_C_Clicked() { lowpower_mode_flag=false; alarm_flag14=false; Pop_alarm_temp_C->hide(); } void MainWindow::Pop_alarm_temp_T_Clicked() { lowpower_mode_flag=false; alarm_flag15=false; Pop_alarm_temp_T->hide(); }