739 lines
26 KiB
C++
739 lines
26 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include <QFile>
|
|
#include "quihelper.h"
|
|
#include "NetMgr.h"
|
|
#include "log.h"
|
|
#include "global.h"
|
|
#include "sqlitedb.h"
|
|
#include "form.h"
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::MainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
g_SqliteDB->OpenDataBase();
|
|
|
|
g_NetMgr = new NetMgr(this);
|
|
g_FtpClient = new FtpClient();
|
|
|
|
//读取ini
|
|
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat);
|
|
g_strVersion = settingsread.value("main/Version").toString();
|
|
g_strProject = settingsread.value("main/Project").toString();
|
|
g_strFre = settingsread.value("main/Fre").toString();
|
|
|
|
this->initWindow();
|
|
this->initStyle();
|
|
|
|
this->initLeft();
|
|
this->initLeft2();
|
|
this->initLeft3();
|
|
this->initLeft4();
|
|
myTimer = new QTimer(this);
|
|
myTimer->start(1000);
|
|
connect(myTimer,SIGNAL(timeout()),this,SLOT(GetDateTime()));
|
|
this ->setWindowFlags(Qt::Window);
|
|
//this ->showFullScreen();
|
|
pRealTimeForm = NULL;
|
|
pChannelSetting = NULL;
|
|
pUnitSetting = NULL;
|
|
pBoardSetting = NULL;
|
|
pChannelList = NULL;
|
|
pWorkCondition = NULL;
|
|
pTriggerConfig = NULL;
|
|
pFileServerConfig = NULL;
|
|
pNTPServerConfig = NULL;
|
|
pPSConfig = NULL;
|
|
pCharacteristcList = NULL;
|
|
pWaveDisPlay = NULL;
|
|
pConfiguration = NULL;
|
|
pRealTimeAlarm = NULL;
|
|
pHistoryAlarm = NULL;
|
|
pTrendGraph = NULL;
|
|
pTerminalInfo = NULL;
|
|
pSystemSelfcheck = NULL;
|
|
pDIOBoard = NULL;
|
|
pOtherConfig = NULL;
|
|
ui->tabWidget_main->tabBar()->hide();
|
|
ui->tabWidget_Configuration->tabBar()->hide();
|
|
ui->tabWidget_sysConfig->tabBar()->hide();
|
|
ui->tabWidget_accidentTracing->tabBar()->hide();
|
|
if(pRealTimeForm == NULL)
|
|
pRealTimeForm = new CRealTimeForm (this);
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
if(pCharacteristcList == NULL)
|
|
pCharacteristcList = new CCharacteristicList (this);
|
|
|
|
ui->tabWidget_main->addTab(pRealTimeForm,"");
|
|
ui->tabWidget_main->addTab(pCharacteristcList,"");
|
|
connect(pRealTimeForm,SIGNAL(sigWCStatus(QString&)), this, SLOT(slotWCStatus(QString&)));
|
|
connect(pRealTimeForm,SIGNAL(sigRPM(QString&)), this, SLOT(slotRPM(QString&)));
|
|
|
|
|
|
mqttclient = new MqttClient(this);
|
|
mqttclient->ConnectMQTT(IP);
|
|
|
|
|
|
id1 = startTimer(5000); //参数1 间隔 单位 毫秒
|
|
//定时器第二种方式
|
|
QTimer * timer = new QTimer(this);
|
|
//启动定时器
|
|
timer->start(500);
|
|
|
|
LoadTrigerConfig();
|
|
|
|
}
|
|
void MainWindow::LoadTrigerConfig()
|
|
{
|
|
|
|
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
|
|
}
|
|
|
|
|
|
void MainWindow::timerEvent(QTimerEvent *ev)
|
|
{
|
|
if(ev->timerId() == id1)
|
|
{
|
|
m_strTriggerEnevtTopic = QString("up/%1/trigger").arg(MAC);//订阅
|
|
m_triggerAlarmSatusTopic = QString("up/%1/triggerAlarmStatus").arg(MAC);
|
|
//m_strTriggerEnevtTopic = QString("up/%1/characteristic").arg(MAC);//订阅
|
|
mqttclient->subscribed(m_strTriggerEnevtTopic);
|
|
mqttclient->subscribed(m_triggerAlarmSatusTopic);
|
|
connect(mqttclient, SIGNAL(Recevive_sig(QString,QByteArray)), this, SLOT(mqttReceive_slot(QString,QByteArray)));
|
|
killTimer(id1);
|
|
}
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
void MainWindow::initWindow()
|
|
{
|
|
//设置无边框
|
|
//QUIHelper::setFramelessForm(this);
|
|
ui->widgetTitle->setProperty("form", "title");
|
|
//关联事件过滤器用于双击放大
|
|
ui->widgetTitle->installEventFilter(this);
|
|
ui->widgetTop->setProperty("nav", "top");
|
|
ui->widgetStatus->setProperty("nav", "bottom");
|
|
//ui->verticalLayout_2->setProperty("nav", "leftbtn");
|
|
ui->widgetLeft->setProperty("flag", "left");
|
|
ui->widgetLeft->setProperty("nav", "left");
|
|
ui->widgetLeft2->setProperty("nav", "left");
|
|
ui->widgetLeft2->setProperty("flag", "left");
|
|
ui->widgetLeft3->setProperty("nav", "left");
|
|
ui->widgetLeft3->setProperty("flag", "left");
|
|
ui->widgetLeft4->setProperty("nav", "left");
|
|
ui->widgetLeft4->setProperty("flag", "left");
|
|
|
|
this->resize(1024,768);
|
|
|
|
QFont font;
|
|
font.setPixelSize(15);
|
|
// ui->LOGO->setFont(font);
|
|
// ui->LOGO->setText("南瑞nari南瑞nari");
|
|
// ui->LOGO->setPixmap(QPixmap(":/image/logo.png").scaled(288, 108));
|
|
this->setWindowTitle("DataWatch3500");
|
|
|
|
font.setPixelSize(20);
|
|
font.setFamily(QStringLiteral("黑体"));
|
|
ui->label_Name->setFont(font);
|
|
|
|
|
|
font.setPixelSize(15);
|
|
ui->label_IP->setFont(font);
|
|
ui->label_Status->setFont(font);
|
|
QTextCodec* codec = QTextCodec::codecForName("UTF-8");//添加编码格式
|
|
ui->label_Status->setText(codec->toUnicode(g_strProject.toLatin1()));
|
|
ui->label_Name->setText(codec->toUnicode(g_strVersion.toLatin1()));
|
|
|
|
ui->label_invalid_ch->setFont(font);
|
|
|
|
if(QUIHelper::getLocalIPs().size() > 0)
|
|
ui->label_IP->setText("IP:" + QUIHelper::getLocalIPs()[0]);
|
|
else
|
|
ui->label_IP->setText("IP: 未获取到");
|
|
|
|
font.setPixelSize(15);
|
|
ui->label_RPM->setFont(font);
|
|
ui->label_RPM->setText("0");
|
|
//设置顶部导航按钮
|
|
QList<QAbstractButton *> tbtns = ui->widgetTop->findChildren<QAbstractButton *>();
|
|
foreach (QAbstractButton *btn, tbtns) {
|
|
//btn->setIconSize(icoSize);
|
|
//btn->setMinimumWidth(icoWidth);
|
|
btn->setCheckable(true);
|
|
connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick()));
|
|
}
|
|
QString tableName = "t_DeviceInfo";
|
|
QString col = "IP,MAC";
|
|
QString str = g_SqliteDB->GetSingelLine(tableName,col);
|
|
QStringList strList = str.split(",");
|
|
IP = strList[0];
|
|
MAC = strList[1];
|
|
qDebug() << "IP" << IP << "MAC" << MAC<< endl;
|
|
|
|
g_MapChannelType.insert("ACCELEROMETER","加速度");
|
|
g_MapChannelType.insert("MICROPHONE","声音");
|
|
g_MapChannelType.insert("THRUST","轴向位移");
|
|
g_MapChannelType.insert("VELOCITY","速度");
|
|
g_MapChannelType.insert("TACHOMETER","转速");
|
|
g_MapChannelType.insert("PROXIMETER","径向振动位移");
|
|
g_MapChannelType.insert("FAST_VOLTAGE","动态电压");
|
|
g_MapChannelType.insert("SLOW_CURRENT","低速电流");
|
|
g_MapChannelType.insert("PULSE_CURRENT","高速电流");
|
|
g_MapChannelType.insert("DI","开入");
|
|
g_MapChannelType.insert("DO","开出");
|
|
g_MapChannelType.insert("AIRGAP","气隙");
|
|
|
|
}
|
|
|
|
void MainWindow::initStyle()
|
|
{
|
|
//加载样式表
|
|
QString qss;
|
|
QFile file(":/qss/blacksoft.css");
|
|
if (file.open(QFile::ReadOnly)) {
|
|
qss = QLatin1String(file.readAll());
|
|
QString paletteColor = qss.mid(20, 7);
|
|
qApp->setPalette(QPalette(paletteColor));
|
|
qApp->setStyleSheet(qss);
|
|
file.close();
|
|
}
|
|
}
|
|
|
|
void MainWindow::initLeft()
|
|
{
|
|
btnsConfig << ui->mainMonitorBtn << ui->characBtn << ui->waveBtn << ui->DIOBtn ;
|
|
|
|
int count = btnsConfig.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QToolButton *btn = (QToolButton *)btnsConfig.at(i);
|
|
btn->setCheckable(true);
|
|
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftConfigClick()));
|
|
}
|
|
ui->mainMonitorBtn->setChecked(true);
|
|
}
|
|
|
|
void MainWindow::leftConfigClick()
|
|
{
|
|
QToolButton *b = (QToolButton *)sender();
|
|
QString name = b->text();
|
|
|
|
int count = btnsConfig.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QAbstractButton *btn = btnsConfig.at(i);
|
|
btn->setChecked(btn == b);
|
|
}
|
|
if(name == "主监视图"){
|
|
ui->tabWidget_main->setCurrentWidget(pRealTimeForm);
|
|
if(pWaveDisPlay){
|
|
delete pWaveDisPlay;
|
|
pWaveDisPlay = NULL;
|
|
}
|
|
}else if(name == "特征值列表"){
|
|
ui->tabWidget_main->setCurrentWidget(pCharacteristcList);
|
|
if(pWaveDisPlay){
|
|
delete pWaveDisPlay;
|
|
pWaveDisPlay = NULL;
|
|
}
|
|
|
|
}else if(name == "气隙监测"){
|
|
|
|
}else if(name == "波形图"){
|
|
if(pWaveDisPlay == NULL)
|
|
pWaveDisPlay = new CWaveDisPlay(this);
|
|
ui->tabWidget_main->addTab(pWaveDisPlay,"");
|
|
ui->tabWidget_main->setCurrentWidget(pWaveDisPlay);
|
|
|
|
}else if(name == "开入开出"){
|
|
// Form *dlg = new Form();
|
|
// dlg->setWindowModality(Qt::ApplicationModal);
|
|
// dlg->show();
|
|
if(pDIOBoard == NULL)
|
|
pDIOBoard = new CDIO_Board(this);
|
|
ui->tabWidget_main->addTab(pDIOBoard,"");
|
|
ui->tabWidget_main->setCurrentWidget(pDIOBoard);
|
|
if(pWaveDisPlay){
|
|
delete pWaveDisPlay;
|
|
pWaveDisPlay = NULL;
|
|
}
|
|
}
|
|
//ui->label->setText(name);
|
|
}
|
|
|
|
void MainWindow::initLeft2()
|
|
{
|
|
btnsConfig2 << ui->realTimeClockBtn << ui->historyClockBtn ;
|
|
|
|
int count = btnsConfig2.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QToolButton *btn = (QToolButton *)btnsConfig2.at(i);
|
|
btn->setCheckable(true);
|
|
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftConfigClick2()));
|
|
}
|
|
ui->realTimeClockBtn->setChecked(true);
|
|
}
|
|
|
|
void MainWindow::leftConfigClick2()
|
|
{
|
|
QToolButton *b = (QToolButton *)sender();
|
|
QString name = b->text();
|
|
qDebug() << "name" << name << endl;
|
|
int count = btnsConfig2.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QAbstractButton *btn = btnsConfig2.at(i);
|
|
btn->setChecked(btn == b);
|
|
}
|
|
|
|
if(name == "实时报警"){
|
|
ui->tabWidget_accidentTracing->setCurrentWidget(pRealTimeAlarm);
|
|
}else if(name == "历史报警"){
|
|
ui->tabWidget_accidentTracing->setCurrentWidget(pHistoryAlarm);
|
|
}else if(name == "趋势分析"){
|
|
ui->tabWidget_accidentTracing->setCurrentWidget(pTrendGraph);
|
|
}
|
|
}
|
|
|
|
void MainWindow::initLeft3()
|
|
{
|
|
btnsConfig3 << ui->unitSettingBtn << ui->boardSettingBtn << ui->channelSettingBtn \
|
|
<< ui->workConditionBtn << ui->triggerBtn << ui->configurationBtn;
|
|
|
|
int count = btnsConfig3.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QToolButton *btn = (QToolButton *)btnsConfig3.at(i);
|
|
btn->setCheckable(true);
|
|
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftConfigClick3()));
|
|
}
|
|
ui->unitSettingBtn->setChecked(true);
|
|
|
|
}
|
|
|
|
void MainWindow::leftConfigClick3()
|
|
{
|
|
QToolButton *b = (QToolButton *)sender();
|
|
QString name = b->text();
|
|
|
|
int count = btnsConfig3.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QAbstractButton *btn = btnsConfig3.at(i);
|
|
btn->setChecked(btn == b);
|
|
}
|
|
if(name == "机组配置"){
|
|
|
|
ui->tabWidget_Configuration->setCurrentWidget(pUnitSetting);
|
|
}else if(name == "板卡配置"){
|
|
if(pBoardSetting == NULL)
|
|
pBoardSetting = new CBoardSetting (this);
|
|
ui->tabWidget_Configuration->addTab(pBoardSetting,"");
|
|
ui->tabWidget_Configuration->setCurrentWidget(pBoardSetting);
|
|
if(pChannelList){
|
|
delete pChannelList;
|
|
pChannelList = NULL;
|
|
}
|
|
if(pWorkCondition){
|
|
delete pWorkCondition;
|
|
pWorkCondition = NULL;
|
|
}
|
|
if(pTriggerConfig){
|
|
delete pTriggerConfig;
|
|
pTriggerConfig = NULL;
|
|
}
|
|
if(pConfiguration){
|
|
delete pConfiguration;
|
|
pConfiguration = NULL;
|
|
}
|
|
}else if(name == "通道配置"){
|
|
if(pChannelList == NULL)
|
|
pChannelList = new CChannelList (this);
|
|
ui->tabWidget_Configuration->addTab(pChannelList,"");
|
|
ui->tabWidget_Configuration->setCurrentWidget(pChannelList);
|
|
if(pBoardSetting){
|
|
delete pBoardSetting;
|
|
pBoardSetting = NULL;
|
|
}
|
|
if(pWorkCondition){
|
|
delete pWorkCondition;
|
|
pWorkCondition = NULL;
|
|
}
|
|
if(pTriggerConfig){
|
|
delete pTriggerConfig;
|
|
pTriggerConfig = NULL;
|
|
}
|
|
// if(pUnitConfiguration){
|
|
// delete pUnitConfiguration;
|
|
// pUnitConfiguration = NULL;
|
|
// }
|
|
|
|
// if(pTestForm){
|
|
// delete pTestForm;
|
|
// pTestForm = NULL;
|
|
// }
|
|
|
|
}else if(name == "工况配置"){
|
|
if(pWorkCondition == NULL)
|
|
pWorkCondition = new CWorkingcondition (this);
|
|
ui->tabWidget_Configuration->addTab(pWorkCondition,"");
|
|
ui->tabWidget_Configuration->setCurrentWidget(pWorkCondition);
|
|
if(pBoardSetting){
|
|
delete pBoardSetting;
|
|
pBoardSetting = NULL;
|
|
}
|
|
if(pChannelList){
|
|
delete pChannelList;
|
|
pChannelList = NULL;
|
|
}
|
|
if(pTriggerConfig){
|
|
delete pTriggerConfig;
|
|
pTriggerConfig = NULL;
|
|
}
|
|
if(pConfiguration){
|
|
delete pConfiguration;
|
|
pConfiguration = NULL;
|
|
}
|
|
}else if(name == "触发配置"){
|
|
if(pTriggerConfig == NULL)
|
|
pTriggerConfig = new CTriggerConfig (this);
|
|
ui->tabWidget_Configuration->addTab(pTriggerConfig,"");
|
|
ui->tabWidget_Configuration->setCurrentWidget(pTriggerConfig);
|
|
if(pBoardSetting){
|
|
delete pBoardSetting;
|
|
pBoardSetting = NULL;
|
|
}
|
|
if(pChannelList){
|
|
delete pChannelList;
|
|
pChannelList = NULL;
|
|
}
|
|
if(pWorkCondition){
|
|
delete pWorkCondition;
|
|
pWorkCondition = NULL;
|
|
}
|
|
if(pConfiguration){
|
|
delete pConfiguration;
|
|
pConfiguration = NULL;
|
|
}
|
|
}else if(name == "组态报警"){
|
|
|
|
if(pConfiguration == NULL)
|
|
pConfiguration = new CConfiguration (this);
|
|
else
|
|
return;
|
|
|
|
//pConfiguration->Init();
|
|
ui->tabWidget_Configuration->addTab(pConfiguration,"");
|
|
ui->tabWidget_Configuration->setCurrentWidget(pConfiguration);
|
|
|
|
if(pBoardSetting){
|
|
delete pBoardSetting;
|
|
pBoardSetting = NULL;
|
|
}
|
|
if(pChannelList){
|
|
delete pChannelList;
|
|
pChannelList = NULL;
|
|
}
|
|
if(pWorkCondition){
|
|
delete pWorkCondition;
|
|
pWorkCondition = NULL;
|
|
}
|
|
if(pTriggerConfig){
|
|
delete pTriggerConfig;
|
|
pTriggerConfig = NULL;
|
|
}
|
|
}
|
|
//ui->label->setText(name);
|
|
}
|
|
|
|
void MainWindow::initLeft4()
|
|
{
|
|
btnsConfig4 << ui->serverConfigBtn << ui->NTPConfigBtn << \
|
|
ui->systemSelfinspectionBtn << ui->terminalDetailsBtn\
|
|
<< ui->channelCalibrationBtn << ui->otherConfigBtn ;
|
|
|
|
int count = btnsConfig4.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QToolButton *btn = (QToolButton *)btnsConfig4.at(i);
|
|
btn->setCheckable(true);
|
|
btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftConfigClick4()));
|
|
}
|
|
ui->serverConfigBtn->setChecked(true);
|
|
}
|
|
|
|
void MainWindow::leftConfigClick4()
|
|
{
|
|
QToolButton *b = (QToolButton *)sender();
|
|
QString name = b->text();
|
|
|
|
int count = btnsConfig4.count();
|
|
for (int i = 0; i < count; ++i) {
|
|
QAbstractButton *btn = btnsConfig4.at(i);
|
|
btn->setChecked(btn == b);
|
|
}
|
|
if(name == "网络配置"){
|
|
ui->tabWidget_sysConfig->setCurrentWidget(pFileServerConfig);
|
|
if(pTerminalInfo){
|
|
delete pTerminalInfo;
|
|
pTerminalInfo = NULL;
|
|
}
|
|
if(pOtherConfig){
|
|
delete pOtherConfig;
|
|
pOtherConfig = NULL;
|
|
}
|
|
}else if(name == "时间配置"){
|
|
ui->tabWidget_sysConfig->setCurrentWidget(pNTPServerConfig);
|
|
if(pTerminalInfo){
|
|
delete pTerminalInfo;
|
|
pTerminalInfo = NULL;
|
|
}
|
|
if(pOtherConfig){
|
|
delete pOtherConfig;
|
|
pOtherConfig = NULL;
|
|
}
|
|
}else if(name == "终端详情"){
|
|
if(pTerminalInfo == NULL)
|
|
pTerminalInfo = new CTerminalInfo (this);
|
|
ui->tabWidget_sysConfig->addTab(pTerminalInfo,"");
|
|
ui->tabWidget_sysConfig->setCurrentWidget(pTerminalInfo);
|
|
if(pOtherConfig){
|
|
delete pOtherConfig;
|
|
pOtherConfig = NULL;
|
|
}
|
|
}else if(name == "系统自检"){
|
|
ui->tabWidget_sysConfig->setCurrentWidget(pSystemSelfcheck);
|
|
if(pTerminalInfo){
|
|
delete pTerminalInfo;
|
|
pTerminalInfo = NULL;
|
|
}
|
|
if(pOtherConfig){
|
|
delete pOtherConfig;
|
|
pOtherConfig = NULL;
|
|
}
|
|
}else if(name == "通道标定"){
|
|
if(pTerminalInfo){
|
|
delete pTerminalInfo;
|
|
pTerminalInfo = NULL;
|
|
}
|
|
if(pOtherConfig){
|
|
delete pOtherConfig;
|
|
pOtherConfig = NULL;
|
|
}
|
|
QProcess process(this);
|
|
process.startDetached(".\\Calibration\\NARI3500Calibration.exe");
|
|
}else if(name == "其他配置"){
|
|
if(pOtherConfig == NULL)
|
|
pOtherConfig = new COtherConfig (this);
|
|
ui->tabWidget_sysConfig->addTab(pOtherConfig,"");
|
|
ui->tabWidget_sysConfig->setCurrentWidget(pOtherConfig);
|
|
if(pTerminalInfo){
|
|
delete pTerminalInfo;
|
|
pTerminalInfo = NULL;
|
|
}
|
|
}
|
|
//ui->label->setText(name);
|
|
}
|
|
|
|
void MainWindow::GetDateTime()
|
|
{
|
|
QDateTime timeNow = QDateTime::currentDateTime();
|
|
QFont font;
|
|
font.setPixelSize(20);
|
|
ui->label_Time->setFont(font);
|
|
ui->label_Time->setText(tr("%1").arg(timeNow.toString(" yyyy/MM/dd \nhh:mm:ss ddd")));
|
|
|
|
}
|
|
void MainWindow::buttonClick()
|
|
{
|
|
QAbstractButton *b = (QAbstractButton *)sender();
|
|
QString name = b->text();
|
|
|
|
QList<QAbstractButton *> tbtns = ui->widgetTop->findChildren<QAbstractButton *>();
|
|
foreach (QAbstractButton *btn, tbtns) {
|
|
btn->setChecked(btn == b);
|
|
}
|
|
|
|
if (name == "实时监测") {
|
|
if(pRealTimeForm == NULL)
|
|
pRealTimeForm = new CRealTimeForm (this);
|
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
} else if (name == "事故追溯") {
|
|
ui->stackedWidget->setCurrentIndex(1);
|
|
if(pRealTimeAlarm == NULL)
|
|
pRealTimeAlarm = new CRealTimeAlarm(this);
|
|
|
|
if(pHistoryAlarm == NULL)
|
|
pHistoryAlarm = new CHistoryAlarm(this);
|
|
|
|
if(pTrendGraph == NULL)
|
|
pTrendGraph = new CTrendGraph(this);
|
|
|
|
ui->tabWidget_accidentTracing->addTab(pRealTimeAlarm,"");
|
|
ui->tabWidget_accidentTracing->addTab(pHistoryAlarm,"");
|
|
ui->tabWidget_accidentTracing->addTab(pTrendGraph,"");
|
|
} else if (name == "数据组态") {
|
|
if(pUnitSetting == NULL){
|
|
pUnitSetting = new CUnitSetting (this);
|
|
ui->unitSettingBtn->setChecked(true);
|
|
ui->tabWidget_Configuration->addTab(pUnitSetting,"");
|
|
}
|
|
|
|
ui->stackedWidget->setCurrentIndex(2);
|
|
|
|
} else if (name == "系统设置") {
|
|
if(pFileServerConfig == NULL)
|
|
pFileServerConfig = new CFileServerConfig (this);
|
|
if(pNTPServerConfig == NULL)
|
|
pNTPServerConfig = new CNTPServerConfig (this);
|
|
// if(pTerminalInfo == NULL)
|
|
// pTerminalInfo = new CTerminalInfo (this);
|
|
if(pSystemSelfcheck == NULL)
|
|
pSystemSelfcheck = new CSystemSelfcheck (this);
|
|
if(pOtherConfig == NULL)
|
|
pOtherConfig = new COtherConfig (this);
|
|
ui->stackedWidget->setCurrentIndex(3);
|
|
ui->tabWidget_sysConfig->addTab(pFileServerConfig,"");
|
|
ui->tabWidget_sysConfig->addTab(pNTPServerConfig,"");
|
|
//ui->tabWidget_sysConfig->addTab(pTerminalInfo,"");
|
|
ui->tabWidget_sysConfig->addTab(pSystemSelfcheck,"");
|
|
ui->tabWidget_sysConfig->addTab(pOtherConfig,"");
|
|
}
|
|
}
|
|
|
|
void MainWindow::slotWCStatus(QString& strWCStatus)
|
|
{
|
|
QStringList strList = strWCStatus.split(",");
|
|
ui->label_WC->setText(strList[1]);
|
|
ui->label_Trg->setText(strList[0]);
|
|
ui->label_invalid_ch->setText(strList[2]);
|
|
}
|
|
|
|
void MainWindow::slotRPM(QString& str)
|
|
{
|
|
ui->label_RPM->setText(str);
|
|
}
|
|
|
|
void MainWindow::mqttReceive_slot(QString strTopic,QByteArray payload)
|
|
{
|
|
if(strTopic == m_strTriggerEnevtTopic){
|
|
QString strReceive = QString(payload);
|
|
qDebug() << strReceive.size() << endl;
|
|
customLogMessageHandler(QtDebugMsg,strReceive);
|
|
QJsonParseError parseJsonErr;
|
|
QJsonDocument document = QJsonDocument::fromJson(strReceive.toUtf8(), &parseJsonErr);
|
|
if (!(parseJsonErr.error == QJsonParseError::NoError)) {
|
|
QMessageBox::about(NULL, "提示", "读取文件错误!");
|
|
return;
|
|
}
|
|
QJsonObject TriggerObj = document.object();
|
|
if(TriggerObj.contains("FileName")){
|
|
QString strFileName = TriggerObj["FileName"].toString();
|
|
QJsonObject triggerInfoObj = TriggerObj["triggerInfo"].toObject();
|
|
QString strTableName = "t_TriggerEvent";
|
|
QString strSql = QString(" values ('%1','%2','%3','%4','%5','%6','%7',%8,%9,'%10','%11','%12','%13') ").arg(triggerInfoObj["triggeredChannelName"].toString()).\
|
|
arg(triggerInfoObj["triggeredType"].toString()).arg(triggerInfoObj["triggeredValue"].toDouble()).\
|
|
arg(triggerInfoObj["triggerNotification"].toString()).arg(triggerInfoObj["triggeredDataWatchNo"].toString()).arg(triggerInfoObj["triggeredDataWatchName"].toString()).\
|
|
arg(triggerInfoObj["triggeredChannelId"].toString()).arg(triggerInfoObj["triggerTime"].toString()).arg(triggerInfoObj["triggeredEquipmentId"].toInt()).\
|
|
arg(triggerInfoObj["triggerEventName"].toString()).arg(triggerInfoObj["triggerFeatureName"].toString()).arg(strFileName).arg(triggerInfoObj["triggerValue"].toDouble());
|
|
g_SqliteDB->InsertData(strTableName,strSql);
|
|
|
|
}else if(TriggerObj.contains("cmd")){
|
|
qDebug() << TriggerObj << endl;
|
|
}
|
|
|
|
|
|
}else if(strTopic == m_triggerAlarmSatusTopic){
|
|
QString strReceive = QString(payload);
|
|
customLogMessageHandler(QtDebugMsg,strReceive);
|
|
QJsonParseError parseJsonErr;
|
|
QJsonDocument document = QJsonDocument::fromJson(strReceive.toUtf8(), &parseJsonErr);
|
|
if (!(parseJsonErr.error == QJsonParseError::NoError)) {
|
|
QMessageBox::about(NULL, "提示", "读取文件错误!");
|
|
return;
|
|
}
|
|
QJsonObject TriggerObj = document.object();
|
|
if(TriggerObj.contains("alarmStatusInfo")){
|
|
QJsonArray alarmStatusInfo = TriggerObj["alarmStatusInfo"].toArray();
|
|
QString strTableName = "t_AlarmStatusInfo";
|
|
if(alarmStatusInfo.size() > 0){
|
|
for (int i = 0; i < alarmStatusInfo.size(); i++) {
|
|
if(alarmStatusInfo.at(i)["triggerStatus"].toInt() == 1){
|
|
QUuid id = QUuid::createUuid();
|
|
QString strId = id.toString();
|
|
strId.remove("{").remove("}").remove("-");
|
|
QString strSql = QString(" values ('%1','%2','%3','%4',%5,'%6','%7','%8','%9') ").arg(strId).arg(alarmStatusInfo.at(i)["channelId"].toString()).arg(alarmStatusInfo.at(i)["channelName"].toString()).\
|
|
arg(alarmStatusInfo.at(i)["flagOverUnder"].toInt()).arg(alarmStatusInfo.at(i)["timestamp"].toString()).arg("").arg(alarmStatusInfo.at(i)["triggerEventName"].toString()).\
|
|
arg(alarmStatusInfo.at(i)["triggerLevel"].toInt()).arg(alarmStatusInfo.at(i)["triggerStatus"].toInt());
|
|
g_SqliteDB->InsertData(strTableName,strSql);
|
|
if(pRealTimeAlarm == NULL)
|
|
return;
|
|
pRealTimeAlarm->initTable();
|
|
}else if(alarmStatusInfo.at(i)["triggerStatus"].toInt() == 3){
|
|
QString strSqlWhere = QString(" channelId = '%1' order by timestamp DESC LIMIT 1").arg(alarmStatusInfo.at(i)["channelId"].toString());
|
|
QString strCol = "uuid";
|
|
QString strUUID = g_SqliteDB->GetSingelLine(strTableName,strCol,strSqlWhere);
|
|
strUUID = strUUID.left(strUUID.size()-1);
|
|
QString strSql = QString(" set resetTimestamp = %1 where uuid = '%2' ;").arg(alarmStatusInfo.at(i)["timestamp"].toString()).arg(strUUID);
|
|
g_SqliteDB->UpdateDataSql(strTableName,strSql);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
void MainWindow::slotNetMgr(QString sAddr, const QVariant &msg)
|
|
{
|
|
QJsonObject objec = msg.value<QJsonObject>();
|
|
if(objec.contains("cmd"))
|
|
{
|
|
QJsonValue arrays_value = objec.take("cmd");
|
|
qDebug()<<"cmd ="<<arrays_value.toString();
|
|
{
|
|
bool Status = objec.take("success").toBool();
|
|
QString strMessage = objec.take("message").toString();
|
|
if(Status){
|
|
QJsonArray content = objec["content"].toArray();
|
|
QString str;
|
|
for (int i = 0; i < content.size(); i++) {
|
|
str += content[i].toString();
|
|
if(i + 1 == content.size())
|
|
break;
|
|
str += "\n";
|
|
}
|
|
QMessageBox myBox;
|
|
myBox.setText("请点击“show details”");
|
|
myBox.setDetailedText(str);
|
|
myBox.exec();
|
|
|
|
}else{
|
|
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
|
|
}
|
|
}
|
|
}
|
|
disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
|
}
|
|
void MainWindow::on_pushButton_detail_clicked()
|
|
{
|
|
QJsonDocument jsonDoc;
|
|
|
|
QNetworkRequest req;
|
|
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
|
|
|
QJsonObject allObj,cmdBody;
|
|
allObj.insert("cmd", "87");
|
|
req.setUrl(sUrl);
|
|
g_NetMgr->PostJson(req,allObj);
|
|
connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
|
|
}
|
|
|