308 lines
8.8 KiB
C++
308 lines
8.8 KiB
C++
|
|
#include "mainwindow.h"
|
|||
|
|
#include "ui_mainwindow.h"
|
|||
|
|
#include <QIcon>
|
|||
|
|
#include "CommonSheet.h"
|
|||
|
|
#include "pub_utility_api/FileUtil.h"
|
|||
|
|
|
|||
|
|
MainWindow::MainWindow(CSystemResources *pSystemResources, QWidget *parent) :
|
|||
|
|
CustomUiMainWindow(parent),
|
|||
|
|
m_pSystemResources(pSystemResources),
|
|||
|
|
m_pFessim(NULL),
|
|||
|
|
m_pUpdateThread(NULL),
|
|||
|
|
m_pEventFormShow(NULL),
|
|||
|
|
ui(new Ui::MainWindow)
|
|||
|
|
{
|
|||
|
|
ui->setupUi(this);
|
|||
|
|
|
|||
|
|
//setMinimumSize(1200,755);
|
|||
|
|
setWindowTitle(tr("工程调试"));
|
|||
|
|
initDebugTool();
|
|||
|
|
|
|||
|
|
setTitleWidget(ui->mainmenu);
|
|||
|
|
connect(ui->stackedWidget,&QStackedWidget::currentChanged,this,&MainWindow::changeTab);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
MainWindow::~MainWindow()
|
|||
|
|
{
|
|||
|
|
//releaseResouce();
|
|||
|
|
if(m_pUpdateThread)
|
|||
|
|
{
|
|||
|
|
delete m_pUpdateThread;
|
|||
|
|
m_pUpdateThread =NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
delete ui;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
void MainWindow::initDebugTool()
|
|||
|
|
{
|
|||
|
|
initLogSystem();
|
|||
|
|
initVariable();
|
|||
|
|
initView();
|
|||
|
|
connectSignalSlot();
|
|||
|
|
|
|||
|
|
m_pUpdateThread->start();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void MainWindow::initVariable()
|
|||
|
|
{
|
|||
|
|
m_pRealDataSelect = new CRealDataSelect;
|
|||
|
|
m_pRealDataWatch = new CRealDataWatch;
|
|||
|
|
m_pRealDatabaseSelect = new CRealDatabaseSelect;
|
|||
|
|
m_pRealDatabaseShow = new CRealDatabaseShow;
|
|||
|
|
m_pUpdateThread = new CUpdateThread;
|
|||
|
|
m_pEventFormShow = new CEventFormShow;
|
|||
|
|
m_pCommTool = new CCommTool;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::initView()
|
|||
|
|
{
|
|||
|
|
addRealData();
|
|||
|
|
addRealAlarm();
|
|||
|
|
addRealEvent();
|
|||
|
|
addHistoryEvent();
|
|||
|
|
addRealDataBase();
|
|||
|
|
addCommTool();
|
|||
|
|
|
|||
|
|
initMenuView();
|
|||
|
|
|
|||
|
|
ui->splitter_2->setSizes(QList<int>()<<200<<900);
|
|||
|
|
ui->splitter->setSizes(QList<int>()<<200<<900);
|
|||
|
|
|
|||
|
|
ui->memuForm->setButtonClicked(1);
|
|||
|
|
ui->stackedWidget->setCurrentIndex(1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::initMenuView()
|
|||
|
|
{
|
|||
|
|
QPushButton* btn;
|
|||
|
|
|
|||
|
|
btn= new QPushButton();
|
|||
|
|
btn->setObjectName("btn_realdata");
|
|||
|
|
btn->setText(tr("实时数据"));
|
|||
|
|
ui->memuForm->addToolBtn(btn,1);
|
|||
|
|
|
|||
|
|
btn= new QPushButton();
|
|||
|
|
btn->setObjectName("btn_fessim");
|
|||
|
|
btn->setText(tr("前置数据"));
|
|||
|
|
ui->memuForm->addToolBtn(btn,3);
|
|||
|
|
|
|||
|
|
btn= new QPushButton();
|
|||
|
|
btn->setObjectName("btn_realdatabase");
|
|||
|
|
btn->setText(tr("实时库表"));
|
|||
|
|
ui->memuForm->addToolBtn(btn,2);
|
|||
|
|
|
|||
|
|
btn= new QPushButton();
|
|||
|
|
btn->setObjectName("btn_realalarm");
|
|||
|
|
btn->setText(tr("事件信息"));
|
|||
|
|
ui->memuForm->addToolBtn(btn,0);
|
|||
|
|
|
|||
|
|
btn = new QPushButton();
|
|||
|
|
btn->setObjectName("btn_commtool");
|
|||
|
|
btn->setText(tr("调试工具"));
|
|||
|
|
ui->memuForm->addToolBtn(btn,4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::addRealData()
|
|||
|
|
{
|
|||
|
|
QGridLayout *gridLayout = new QGridLayout(ui->groupBox_1);
|
|||
|
|
gridLayout->setSpacing(6);
|
|||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout->addWidget(m_pRealDataSelect, 0, 0, 1, 1);
|
|||
|
|
m_pRealDataSelect->setSystemResources(m_pSystemResources);
|
|||
|
|
m_pRealDataSelect->initSelect();
|
|||
|
|
|
|||
|
|
gridLayout = new QGridLayout(ui->groupBox_2);
|
|||
|
|
gridLayout->setSpacing(6);
|
|||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout->addWidget(m_pRealDataWatch, 0, 0, 1, 1);
|
|||
|
|
m_pRealDataWatch->setSystemResources(m_pSystemResources);
|
|||
|
|
m_pRealDataWatch->initWatch();
|
|||
|
|
ui->textEdit_status->setToolTip("具体状态");
|
|||
|
|
|
|||
|
|
m_pRealDataSelect->setRealDataWatch(m_pRealDataWatch);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
void MainWindow::addRealAlarm()
|
|||
|
|
{
|
|||
|
|
QGridLayout *gridLayout = new QGridLayout(ui->stackedWidgetPage1);
|
|||
|
|
ui->textEdit_status->setHidden(true);
|
|||
|
|
ui->stackedWidgetPage1->setLayout(gridLayout);
|
|||
|
|
gridLayout->setSpacing(6);
|
|||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout->addWidget(m_pEventFormShow, 0, 0, 1, 1);
|
|||
|
|
m_pEventFormShow->setSystemResources(m_pSystemResources);
|
|||
|
|
m_pEventFormShow->initRealModel();
|
|||
|
|
//m_pEventFormShow->setSystemResources(m_pSystemResources);
|
|||
|
|
// m_pAlarmFormShow->initSelect();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
void MainWindow::addRealEvent()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
void MainWindow::addHistoryEvent()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
void MainWindow::addRealDataBase()
|
|||
|
|
{
|
|||
|
|
QGridLayout *gridLayout4 = new QGridLayout(ui->groupBox_4);
|
|||
|
|
gridLayout4->setSpacing(6);
|
|||
|
|
gridLayout4->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout4->addWidget(m_pRealDatabaseSelect, 0, 0, 1, 1);
|
|||
|
|
m_pRealDatabaseSelect->initRealDb(m_pSystemResources);
|
|||
|
|
|
|||
|
|
QGridLayout * gridLayout5 = new QGridLayout(ui->groupBox_5);
|
|||
|
|
gridLayout5->setSpacing(6);
|
|||
|
|
gridLayout5->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout5->addWidget(m_pRealDatabaseShow, 0, 0, 1, 1);
|
|||
|
|
m_pRealDatabaseShow->initRealDatabaseShow(m_pSystemResources);
|
|||
|
|
}
|
|||
|
|
void MainWindow::addNodeStatus()
|
|||
|
|
{
|
|||
|
|
// QGridLayout *gridLayout = new QGridLayout(ui->tab_nodeStatus);
|
|||
|
|
// gridLayout->setSpacing(6);
|
|||
|
|
// gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
// gridLayout->addWidget(m_pNodeStatus, 0, 0, 1, 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::addFessim()
|
|||
|
|
{
|
|||
|
|
QGridLayout *gridLayout = new QGridLayout(ui->stackedWidgetPage4);
|
|||
|
|
gridLayout->setSpacing(6);
|
|||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout->addWidget(m_pFessim, 0, 0, 1, 1);
|
|||
|
|
m_pFessim->Init();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::addCommTool()
|
|||
|
|
{
|
|||
|
|
QGridLayout *gridLayout = new QGridLayout(ui->stackedWidgetPage5);
|
|||
|
|
gridLayout->setSpacing(6);
|
|||
|
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
|||
|
|
gridLayout->addWidget(m_pCommTool , 0 , 0 , 1 , 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::initLogSystem()
|
|||
|
|
{
|
|||
|
|
// QString app = QString::fromStdString(CN_AppName_BASE);
|
|||
|
|
// iot_public::StartLogSystem(app.toStdString().c_str(),CN_ProcName_debug_tool.c_str());
|
|||
|
|
// LOGINFO("initLogSystem()成功!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::initMsgBus()
|
|||
|
|
{
|
|||
|
|
//< 初始化消息总线库
|
|||
|
|
if (!(iot_net::initMsgBus("debugToolAppName", "debugToolProcessName")))
|
|||
|
|
{
|
|||
|
|
qDebug() << "Initialize message bus failed, exit !" << endl;
|
|||
|
|
LOGERROR("Initialize message bus failed, exit !");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
qDebug() << "Initialize message bus successed !" << endl;
|
|||
|
|
LOGINFO("Initialize message bus successed !");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
iot_service::CDpcdaForApp::initGlobalThread();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::releaseResouce()
|
|||
|
|
{
|
|||
|
|
iot_service::CDpcdaForApp::releaseGlobalThread();
|
|||
|
|
|
|||
|
|
//< 释放消息总线库
|
|||
|
|
iot_net::releaseMsgBus();
|
|||
|
|
|
|||
|
|
//< 停止日志系统
|
|||
|
|
//iot_public::StopLogSystem();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::connectSignalSlot()
|
|||
|
|
{
|
|||
|
|
qRegisterMetaType< QVector<SAddPointInfo> >("VectorAddPointInfoPtr");
|
|||
|
|
qRegisterMetaType<iot_idl::SRealTimeDataPkg>("iot_idl::SRealTimeDataPkg");
|
|||
|
|
|
|||
|
|
connect(m_pRealDataSelect,&CRealDataSelect::signal_batchAddPoint,
|
|||
|
|
m_pRealDataWatch,&CRealDataWatch::slot_batchAddPoint,Qt::UniqueConnection);
|
|||
|
|
|
|||
|
|
connect(m_pUpdateThread,&CUpdateThread::signal_updatePntRealData,
|
|||
|
|
m_pRealDataWatch,&CRealDataWatch::slot_updatePntRealData,Qt::UniqueConnection);
|
|||
|
|
|
|||
|
|
connect(m_pRealDatabaseSelect,SIGNAL(signal_showTable(QString,QVector<QString>*,int,int,int,int,QMap<int,bool>,QString,QString)),
|
|||
|
|
m_pRealDatabaseShow,SLOT(slot_showTable(QString,QVector<QString>*,int,int,int,int,QMap<int,bool>,QString,QString)));
|
|||
|
|
connect(m_pRealDatabaseSelect,SIGNAL(signal_showOrHideColumn(int,int)),
|
|||
|
|
m_pRealDatabaseShow,SLOT(slot_showOrHindColumn(int,int)));
|
|||
|
|
connect(m_pRealDataWatch,SIGNAL(signal_selectTextEdit(QString ,QString , int )),
|
|||
|
|
this,SLOT(slot_selectTextEdit(QString,QString, int )));
|
|||
|
|
connect(m_pRealDataWatch,SIGNAL(signal_paging()),m_pRealDataSelect,SLOT(slot_paging()));
|
|||
|
|
connect(m_pRealDatabaseShow,SIGNAL(signal_selectTextEdit(QString)),
|
|||
|
|
this,SLOT(slot_selectTextEdit(QString)));
|
|||
|
|
|
|||
|
|
connect(ui->memuForm, SIGNAL(buttonClicked(int)),ui->stackedWidget, SLOT(setCurrentIndex(int)));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::changeTab(int index)
|
|||
|
|
{
|
|||
|
|
switch (index) {
|
|||
|
|
case 0:
|
|||
|
|
ui->textEdit_status->setHidden(true);
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
ui->textEdit_status->setHidden(false);
|
|||
|
|
break;
|
|||
|
|
case 2:{
|
|||
|
|
ui->textEdit_status->setHidden(false);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 3:
|
|||
|
|
{
|
|||
|
|
ui->textEdit_status->setHidden(true);
|
|||
|
|
if(m_pFessim == NULL)
|
|||
|
|
{
|
|||
|
|
m_pFessim = new CFessim;
|
|||
|
|
addFessim();
|
|||
|
|
}
|
|||
|
|
//此处判断是否连接 若连接 则不做处理 若断开状态 则直接调用连接
|
|||
|
|
if(!m_pFessim->isConnect())
|
|||
|
|
{
|
|||
|
|
if(!m_pFessim->slot_connect())
|
|||
|
|
{
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
int index = m_pFessim->getCurrentIndex();
|
|||
|
|
m_pFessim->setActiveWindow(index);
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 4:{
|
|||
|
|
ui->textEdit_status->setHidden(true);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void MainWindow::slot_selectTextEdit(QString allStatus, QString m_allName, int m_value)
|
|||
|
|
{
|
|||
|
|
ui->textEdit_status->setReadOnly(true);
|
|||
|
|
ui->textEdit_status->setText("当前标签为"+m_allName+", 值为"
|
|||
|
|
+QString::number(m_value)+", 状态为"
|
|||
|
|
+allStatus);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
void MainWindow::slot_selectTextEdit(QString allQString)
|
|||
|
|
{ ui->textEdit_status->setReadOnly(true);
|
|||
|
|
ui->textEdit_status->setText(allQString);
|
|||
|
|
}
|