3500/RealTimeAlarm.cpp

632 lines
29 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "RealTimeAlarm.h"
#include "ui_RealTimeAlarm.h"
#include <QPushButton>
#include "QMyTableViewBtnDelegate.h"
#include "AlarmDetails.h"
#include "sqlitedb.h"
#include <QTimeZone>
#include "ftpclient.h"
CRealTimeAlarm::CRealTimeAlarm(QWidget *parent) :
QWidget(parent),
ui(new Ui::CRealTimeAlarm)
{
ui->setupUi(this);
ui->widget_alarm->setProperty("flag", "Button");
headerStr = QObject::tr("序号,级别,报警内容,报警时间,报警详情");
model = new QStandardItemModel(ui->tableView);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); //选中行
QStringList headerList = headerStr.split(",");
model->setHorizontalHeaderLabels(headerList);
model->setColumnCount(headerList.size());
ui->tableView->setModel(model);
ui->tableView->setColumnWidth(0, 50);
ui->tableView->setColumnWidth(1, 50);
ui->tableView->setColumnWidth(2, 370);
ui->tableView->setColumnWidth(3, 200);
ui->tableView->setAlternatingRowColors(true);
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
//ui->tableView->horizontalHeader()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
//ui->tableView->horizontalHeader()->setSectionResizeMode(4,QHeaderView::ResizeToContents);
// 必须要设置此项否则样式表的hover无法生效
ui->tableView->setMouseTracking(true);
m_strFileName = "";
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
initTable();
}
CRealTimeAlarm::~CRealTimeAlarm()
{
QVector<GroupData>().swap(m_vecGroupdata);
QVector<WAVE_INFO>().swap(m_vecWaveInfo);
QVector<WAVE_ALLDATA>().swap(m_vecAllData);
QMap<QString,QVector<WAVE_DATA>>::Iterator iter1 = mapWaveData.begin();
for(iter1 = mapWaveData.begin();iter1 != mapWaveData.end();iter1++){
QVector<WAVE_DATA>().swap(iter1.value());
mapWaveData.erase(iter1);
}
delete ui;
}
void CRealTimeAlarm::createRowItem(int Row,QVariantList RowItem)
{
model->setRowCount(Row+1);
for (int j = 0; j < RowItem.size(); ++j)
{
model->setData(model->index(Row,j,QModelIndex()),RowItem.at(j));
}
}
void CRealTimeAlarm::initTable()
{
qDebug() << "initTable1" << endl;
model->setRowCount(0);
qDebug() << "initTable2" << endl;
QString strTableName = "t_AlarmStatusInfo",strSql;
strSql = QString(" timestamp <> '' order by timestamp DESC limit 0,100");
m_vecTriggerAlarmStatusInfo = g_SqliteDB->GetTriggerAlarmStatusInfo(strTableName,strSql);
if(m_vecTriggerAlarmStatusInfo.size() > 0){
for (int i = 0; i < m_vecTriggerAlarmStatusInfo.size(); i++) {
QVariantList strRowItem ;
QDateTime dateTime = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].timestamp);
QTimeZone timeZone("Asia/Shanghai");
dateTime = dateTime.toTimeZone(timeZone);
QString TStr = dateTime.toString("yyyy-MM-dd hh:mm:ss");
QString triggerLevel = "",triggerEventName = "";
if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "1"){
triggerLevel = "警报";
}else if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "2"){
triggerLevel = "危险";
}
QString strFeatureName = "";
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MinValues"))
strFeatureName = "最小值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MaxValues"))
strFeatureName = "最大值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DCValues"))
strFeatureName = "偏置电压/Gap";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("RMSValues"))
strFeatureName = "有效值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DiagnosisPk2Pk"))
strFeatureName = "诊断峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratRMS"))
strFeatureName = "有效值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratPk2Pk"))
strFeatureName = "积分峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("SpeedProfileSpeed"))
strFeatureName = "转速";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratPk2Pk/2"))
strFeatureName = "峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DiagnosisPeak"))
strFeatureName = "峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MonitorPk2Pk"))
strFeatureName = "监测保护峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("InvertDanger") )
strFeatureName = "反时限危险值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("InvertAlarm"))
strFeatureName = "反时限警报值";
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Over")){
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + strFeatureName+ "-" + "高于" + triggerLevel + "";
}else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Under")){
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + strFeatureName+ "-" + "低于" + triggerLevel + "";
}
strRowItem << i + 1 << triggerLevel << triggerEventName << TStr;
createRowItem(i,strRowItem);
}
QMyTableViewBtnDelegate *m_btnDelegate = new QMyTableViewBtnDelegate(QStringList()<<"详情", this);
ui->tableView->setItemDelegateForColumn(4, m_btnDelegate);
connect(m_btnDelegate, SIGNAL(editData(const QModelIndex &)), this,SLOT(Details(const QModelIndex &)));
}else{
QMessageBox::information(this, "提示", QString("未查询到数据!"));
}
}
void CRealTimeAlarm::OpenDatFile(QString& strFileName)
{
QProgressDialog *progressDialog = new QProgressDialog(this);
progressDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
progressDialog->setWindowModality(Qt::WindowModal);
progressDialog->setWindowTitle(tr("Please Wait"));
progressDialog->setLabelText(tr("读取中..."));
progressDialog->setCancelButton(0);
progressDialog->show();
QTime startTime = QTime::currentTime();
m_vecGroupdata.clear();
m_vecWaveInfo.clear();
QVector<GroupData>().swap(m_vecGroupdata);
QVector<WAVE_INFO>().swap(m_vecWaveInfo);
QVector<WAVE_ALLDATA>().swap(m_vecAllData);
QMap<QString,QVector<WAVE_DATA>>::Iterator iter1 = mapWaveData.begin();
for(iter1 = mapWaveData.begin();iter1 != mapWaveData.end();iter1++){
QVector<WAVE_DATA>().swap(iter1.value());
mapWaveData.erase(iter1);
}
int channelwork[64];
int channelEnabled[64];
int theSize = 0; //通道数
//读12字节头文件
int iJsonSize, iChannelsize;
char equipNo[12]; //设备No 12字节
char time[10]; //数据起始时间 10字节
QFile file(strFileName);
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << "::MainWidget::ReadDatData() cannot open file for read";
return;
}
file.read((char*)&iChannelsize, sizeof(iChannelsize));
qDebug() << "::MainWidget::ReadDatData() Channelsize:" << iChannelsize;
int iCount; //存储dat文件原始数据秒数
file.read((char*)&iCount, sizeof(iCount));
qDebug() << "::MainWidget::ReadDatData() iCount:" << iCount;
file.read(equipNo, sizeof(equipNo));
QString sEquipNo(equipNo);
file.read(time, sizeof(time));
QString CollectTime(time);
file.read((char *)&iJsonSize, sizeof(iJsonSize));
qDebug() << "::MainWidget::ReadDatData() iJsonSize:" << iJsonSize;
//读json串
char *buf0 = (char *)malloc(sizeof(char) *iJsonSize);
file.read(buf0,iJsonSize);
QJsonParseError parseJsonErr;
QJsonDocument document = QJsonDocument::fromJson(buf0,&parseJsonErr);
if(!(parseJsonErr.error == QJsonParseError::NoError))
{
qDebug()<<tr("解析json文件错误");
delete progressDialog;
file.close();
return;
}
int channels = 0;
QJsonObject jsonObject = document.object();
QString strType = jsonObject["DeviceType"].toString();
if(jsonObject.contains(QStringLiteral("ChannelSettings"))){
QJsonValue arrayValue = jsonObject.value(QStringLiteral("ChannelSettings"));
if(arrayValue.isArray()){
QJsonArray array = arrayValue.toArray();
theSize = array.size();
for(int i = 0; i<array.size();i++){
WAVE_INFO waveInfo;
channelEnabled[i] = array.at(i)["isEnable"].toInt();
channelwork[i] = array.at(i)["isWork"].toInt();
QString strchannelType = array.at(i)["sensorType"].toString();
if(channelEnabled[i] && channelwork[i] && strchannelType != "DO" && strchannelType != "DI"){
waveInfo.channelId = array.at(i)["channelId"].toString();
waveInfo.channelType = array.at(i)["sensorType"].toString();
waveInfo.channelName = array.at(i)["channelName"].toString();
waveInfo.sensorType = array.at(i)["sensorType"].toString();
waveInfo.channelSamleRate = array.at(i)["samplingRate"].toInt();
waveInfo.pairChannelID = array.at(i)["pairChannelId"].toString();
waveInfo.equipmentName = array.at(i)["equipmentName"].toString();
waveInfo.sensorEngineeringUnit = array.at(i)["sensorEngineeringUnit"].toString();
waveInfo.speedRefChannelId = array.at(i)["speedRefChannelId"].toString();
waveInfo.tachAutoTach = array.at(i)["tachAutoTach"].toBool();
waveInfo.sensorGapVoltage = array.at(i)["sensorGapVoltage"].toDouble();
waveInfo.sensorSensitivity = array.at(i)["sensorSensitivity"].toDouble();
QString strtachTriggerEdge = array.at(i)["tachTriggerEdge"].toString();
if(strtachTriggerEdge == "rising"){
waveInfo.iTrigger = 0;
}else if(strtachTriggerEdge == "falling"){
waveInfo.iTrigger = 1;
}
waveInfo.iTrigger = 0;
waveInfo.iKeyCount = array.at(i)["tachTriggerPerRev"].toInt();
waveInfo.iTriggerValue = array.at(i)["tachTriggerVoltageLevel"].toDouble();
waveInfo.iHysteresis = array.at(i)["tachTriggerHysteresis"].toDouble();
qDebug() <<waveInfo.channelId<< "iKeyCount" << waveInfo.iKeyCount << "iTriggerValue" << waveInfo.iTriggerValue << "iHysteresis" << waveInfo.iHysteresis << endl;
m_vecWaveInfo.push_back(waveInfo);
channels ++ ;
qDebug() << waveInfo.sensorGapVoltage << waveInfo.sensorSensitivity << endl;
qDebug() << waveInfo.channelId << waveInfo.channelType <<waveInfo.channelName << waveInfo.pairChannelID << waveInfo.sensorEngineeringUnit << waveInfo.speedRefChannelId << waveInfo.iTriggerValue<<endl;
}
}
}
}if(jsonObject.contains(QStringLiteral("groups"))){
QJsonValue arrayValue = jsonObject.value(QStringLiteral("groups"));
if(arrayValue.isArray()){
QJsonArray array1 = arrayValue.toArray();
theSize = array1.size();
for(int i = 0; i<array1.size();i++){
QString strChannelType = array1.at(i)["ChannelType"].toString();
QString strChannelID = array1.at(i)["name"].toString();
//if(strChannelType == "TACHOMETER")
{
for(int ii = 0; ii < m_vecWaveInfo.size();ii++){
if(strChannelID == m_vecWaveInfo[ii].channelId){
QJsonValue arrayValue = array1.at(i)["channels"];
QJsonArray array2 = arrayValue.toArray();
for(int j = 0; j<array2.size();j++){
if("SpeedProfileSpeed" == array2.at(j)["name"].toString()){
QJsonArray arrayValue = array2.at(j)["data"].toArray();
for(int jj = 0; jj < arrayValue.size();jj++){
m_vecWaveInfo[ii].SpeedProfileSpeed.push_back(arrayValue[jj].toDouble());
}
}
if("RMSValues" == array2.at(j)["name"].toString()){
QJsonArray arrayValue = array2.at(j)["data"].toArray();
for(int jj = 0; jj < arrayValue.size();jj++){
m_vecWaveInfo[ii].RMSValue.push_back(arrayValue[jj].toDouble());
}
}
}
}
}
}
}
}
}
qDebug()<<"channels" <<channels<<endl;
//循环读出原始数据内容
WAVE_CHNDATA m_WaveChnData[15000];
int Count, waveSize,bufferSiz;
if(strType == "3500")
bufferSiz = 16;
else
bufferSiz = 15;
char buf[bufferSiz];
m_vecAllData.clear();
//QVector<WAVE_DATA> pData;
int j = 0;
int temCount = 0;
int flag = -1;
progressDialog->setRange(0, iCount * channels-1);
while (!file.atEnd()) {
file.read((char *)&Count, sizeof(Count));
//qDebug()<<"Count" << Count << "temCount" <<temCount<< endl;
if(Count > temCount && flag == 0)//过滤超出的秒数的数据
break;
if(Count == temCount && flag == 0)
flag = 1;
if(Count < temCount || flag == 1){//过滤原始数据中转速多余数据
file.read(buf, sizeof(buf));
file.read((char *)&waveSize, sizeof(waveSize));
float f = 0.0;
QVector<double> vecSpeed;
qDebug()<<"waveSize1" <<waveSize<<endl;
for (int i = 0; i < waveSize; i++) {
file.read((char *)&f, sizeof(f));
vecSpeed.push_back(f);
}
for(int ii = 0; ii < 2000;ii++){
if(m_WaveChnData[ii].Second == Count){
m_WaveChnData[ii].TimeStamp = vecSpeed;
}
}
flag = 0;
qDebug()<<"::MainWidget::ReadDatData()11 wave.channelId" << buf <<" wave.count"<<Count<<" wave.wavedata"<<m_WaveChnData[j].waveData.size()<<"waveSize"<<waveSize << "j"<<j<<endl;;
}else {
file.read(buf, sizeof(buf));
file.read((char *)&waveSize, sizeof(waveSize));
float f = 0.0;
WAVE_ALLDATA waveAll;
if(waveSize < 0 || waveSize > 131072){
qDebug() << "waveSize2" << waveSize << endl;
delete progressDialog;
file.close();
return;
}
for (int i = 0; i < waveSize; i++) {
file.read((char *)&f, sizeof(f));
m_WaveChnData[j].channelId = buf;
m_WaveChnData[j].waveData.push_back((double)f);
m_WaveChnData[j].Second = Count;
}
temCount = Count;
//qDebug()<<"::MainWidget::ReadDatData() wave.channelId" << m_WaveChnData[j].channelId<<" wave.count"<<Count<<" wave.wavedata"<<m_WaveChnData[j].waveData.size()<<"waveSize"<<waveSize << "j"<<j<<endl;;
}
progressDialog->setValue(j);
if (progressDialog->wasCanceled())
{
delete progressDialog;
file.close();
return ;
}
j++;
}
/*if(temCount != iCount){
MyMsgBox(QMessageBox::Warning,"警告","Dat文件采集秒数与实际读取秒数不一致");
iCount = temCount;
}*/
qDebug()<<m_vecAllData.size()<<m_vecAllData.capacity() << "iCount" <<iCount << "m_vecWaveInfo" << m_vecWaveInfo.size() <<endl;
QVector<WAVE_INFO>::iterator iter = m_vecWaveInfo.begin();
int linecolor = 0;
for (;iter != m_vecWaveInfo.end() ; iter++ ) {
WAVE_DATA wave;
int ii = 0;
QVector<WAVE_DATA> m_vecPushData1;
for(int i = 0; i < j; i++){
//qDebug() << "i" << iter->channelId.left(bufferSiz) << "j " << m_WaveChnData[i].channelId.left(bufferSiz) <<endl;
if(iter->channelId.left(bufferSiz) == m_WaveChnData[i].channelId.left(bufferSiz)){
wave.waveData = m_WaveChnData[i].waveData;
double sum = 0.0;
if(iter->sensorType == "ACCELEROMETER" || iter->sensorType == "MICROPHONE" ||
iter->sensorType == "PROXIMETER" || iter->sensorType == "VELOCITY" ||
iter->sensorType == "TACHOMETER" || iter->sensorType == "THRUST" ||
iter->sensorType == "FAST_VOLTAGE"){
sum = std::accumulate(std::begin(wave.waveData), std::end(wave.waveData), 0.0);
double size = m_WaveChnData[i].waveData.size();
wave.mean = sum/size;
}else{
sum = 0.0;
}
if(iter->sensorType == "TACHOMETER"){
wave.TimeStamp = m_WaveChnData[i].TimeStamp;
//qDebug()<< "iCount" <<iCount<<endl;
ii ++;
}
wave.SpeedProfileSpeed = iter->SpeedProfileSpeed;
wave.wavesize = wave.waveData.size();
wave.SamleRate = iter->channelSamleRate;
wave.sensorType = iter->sensorType;
wave.channelId = iter->channelId;
wave.channelNo = theSize;
wave.Time = iCount;
wave.channelName = iter->channelName;
wave.pairChannelID = iter->pairChannelID;
wave.sensorEngineeringUnit = iter->sensorEngineeringUnit;
wave.speedRefChannelId = iter->speedRefChannelId;
wave.RMSValue = iter->RMSValue;
wave.iTrigger = iter->iTrigger;
wave.iKeyCount = iter->iKeyCount;
wave.iTriggerValue = iter->iTriggerValue;
wave.iHysteresis = iter->iHysteresis;
wave.tachAutoTach = iter->tachAutoTach;
wave.sensorGapVoltage = iter->sensorGapVoltage;
wave.sensorSensitivity = iter->sensorSensitivity;
switch(linecolor){
case 0:
wave.linColor = Qt::green ;
break;
case 1:
wave.linColor = QColor(30,144,255) ;
break;
case 2:
wave.linColor = QColor(255,182,193) ;
break;
case 3:
wave.linColor = Qt::cyan ;
break;
case 4:
wave.linColor = Qt::magenta ;
break;
case 5:
wave.linColor = Qt::yellow ;
break;
case 6:
wave.linColor = QColor(255,69,0) ;
break;
case 7:
wave.linColor = QColor(0, 255, 127) ;
break;
case 8:
wave.linColor = QColor(255,140,0) ;
break;
case 9:
wave.linColor = QColor(0, 191, 255) ;
break;
case 10:
wave.linColor = Qt::darkMagenta ;
break;
case 11:
wave.linColor = Qt::lightGray ;
break;
case 12:
wave.linColor = Qt::darkYellow ;
break;
case 13:
wave.linColor = QColor(153, 51, 250);
break;
case 14:
wave.linColor = QColor(255, 218, 185) ;
break;
case 15:
wave.linColor = QColor(0,199,140) ;
break;
default:
break;
}
m_vecPushData1.push_back(wave);
}
}
linecolor++;
if(linecolor > 15){
linecolor = 0;
}
qDebug() << "channelId"<<iter->channelId << endl;
mapWaveData.insert(iter->channelId,m_vecPushData1);
m_iRealCount = m_vecPushData1.size();
qDebug() << "m_iRealCount"<<m_iRealCount << endl;
qDebug()<<"mapWaveData size"<<mapWaveData.size()<<endl;
}
file.close();
free(buf0);
//qDebug() << "=====waveSpeedData time=====" <<mapWaveData[strChannelID].at(0).Time <<mapWaveData[speedChannelID].at(0).Time << endl;
qDebug() << "m_iRealCount" << m_iRealCount << endl;
//设置播放进度条
m_iCount = 0;
m_iCount = m_iRealCount;
QTime stopTime = QTime::currentTime();
qDebug() << "Time: " << startTime.msecsTo(stopTime) << "ms" <<endl;
if(m_iRealCount < 1){
QMessageBox::information(this, "提示", QString("未读取到数据!"));
return;
}
delete progressDialog;
DateViewdialog = new CDataGraphView();
connect(DateViewdialog, SIGNAL(ItemCheckStateSignal(QString, bool)), this, SLOT(ItemCheckStateSlot(QString, bool)));
DateViewdialog->setWindowModality(Qt::ApplicationModal);
DateViewdialog->setAttribute(Qt::WA_DeleteOnClose);
DateViewdialog->show();
QStringList strIDList,strChannleType,strChannleNameList;
QMap<QString,QVector<WAVE_DATA>>::Iterator iter2 = mapWaveData.begin();
for (; iter2 != mapWaveData.end(); iter2 ++)
{
if(!strIDList.contains(iter2.key()))
strIDList.push_back(iter2.key());
strChannleType.push_back(iter2.value()[0].sensorType);
strChannleNameList.push_back(iter2.value()[0].channelName);
}
DateViewdialog->SetDataIDs(strIDList, tr("Data Watch "),strChannleType,strChannleNameList);
}
void CRealTimeAlarm::DownloadStatus_Slot()
{
OpenDatFile(g_LocalFile);
disconnect(g_FtpClient,SIGNAL(sigDownloadProcess(qint64 , qint64 )),this,SLOT(downloadProcess_Slot(qint64 , qint64)));
disconnect(g_FtpClient,SIGNAL(sigDownloadStatus()),this,SLOT(DownloadStatus_Slot()));
}
void CRealTimeAlarm::downloadProcess_Slot(qint64 byteSend, qint64 byteTotal)
{
downloadProgressDialog->setRange(0, byteTotal);
downloadProgressDialog->setValue(byteSend);
if(byteSend == byteTotal){
disconnect(g_FtpClient,SIGNAL(sigDownloadProcess(qint64 , qint64 )),this,SLOT(downloadProcess_Slot(qint64 , qint64)));
OpenDatFile(g_LocalFile);
}
}
void CRealTimeAlarm::Details(const QModelIndex &index)
{
int row = index.row();
QString strCol = "triggeredFileName";
QString strTimeStamp = QString("%1").arg(m_vecTriggerAlarmStatusInfo[row].timestamp);
QString strTableName = QString("t_TriggerEvent ORDER BY ABS(triggeredTime - %1) LIMIT 1").arg(m_vecTriggerAlarmStatusInfo[row].timestamp);
QString strFileName = g_SqliteDB->GetSingelLine(strTableName,strCol);
strFileName = strFileName.left(strFileName.size()-1);
QStringList strList = strFileName.split("/");
#ifdef Q_OS_WIN32
QString strPath = QCoreApplication::applicationDirPath() + "\\dat\\" + strList[5];
#endif
#ifdef Q_OS_LINUX
QString strPath = QCoreApplication::applicationDirPath() + "/dat/" + strList[5];
#endif
QFile file(strPath);
customLogMessageHandler(QtDebugMsg, "RealTimeAlarm:" + strPath);
g_LocalFile = strPath;
if(file.exists()){
qDebug() << "file1" << endl;
OpenDatFile(strPath);
}else{
downloadProgressDialog = new QProgressDialog(this);
downloadProgressDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
downloadProgressDialog->setWindowModality(Qt::WindowModal);
downloadProgressDialog->setWindowTitle(tr("Please Wait"));
downloadProgressDialog->setLabelText(tr("下载中..."));
//downloadProgressDialog->setCancelButton(0);
downloadProgressDialog->show();
qDebug() << "file2" << endl;
connect(g_FtpClient,SIGNAL(sigDownloadProcess(qint64 , qint64 )),this,SLOT(downloadProcess_Slot(qint64 , qint64)));
//connect(g_FtpClient,SIGNAL(sigDownloadStatus()),this,SLOT(DownloadStatus_Slot()));
QString str = QString("ftp://%1/").arg(IP);
g_FtpClient->SetServerInfo(str);
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
g_FtpClient->DownLoad(strFileName,strPath);
}
}
void CRealTimeAlarm::ItemCheckStateSlot(QString strID, bool bChecked)
{
DateViewdialog->ViewData(strID,mapWaveData[strID]);
}
void CRealTimeAlarm::on_pushButton_refresh_clicked()
{
model->setRowCount(0);
qDebug() << "initTable2" << endl;
QString strTableName = "t_AlarmStatusInfo",strSql;
strSql = QString(" timestamp <> '' order by timestamp DESC limit 0,100");
m_vecTriggerAlarmStatusInfo = g_SqliteDB->GetTriggerAlarmStatusInfo(strTableName,strSql);
if(m_vecTriggerAlarmStatusInfo.size() > 0){
for (int i = 0; i < m_vecTriggerAlarmStatusInfo.size(); i++) {
QVariantList strRowItem ;
QDateTime dateTime = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].timestamp);
QTimeZone timeZone("Asia/Shanghai");
dateTime = dateTime.toTimeZone(timeZone);
QString TStr = dateTime.toString("yyyy-MM-dd hh:mm:ss");
QString triggerLevel = "",triggerEventName = "";
if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "1"){
triggerLevel = "警报";
}else if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "2"){
triggerLevel = "危险";
}
QString strFeatureName = "";
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MinValues"))
strFeatureName = "最小值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MaxValues"))
strFeatureName = "最大值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DCValues"))
strFeatureName = "偏置电压/Gap";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("RMSValues"))
strFeatureName = "有效值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DiagnosisPk2Pk"))
strFeatureName = "诊断峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratRMS"))
strFeatureName = "有效值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratPk2Pk"))
strFeatureName = "积分峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("SpeedProfileSpeed"))
strFeatureName = "转速";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("IntegratPk2Pk/2"))
strFeatureName = "峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("DiagnosisPeak"))
strFeatureName = "峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("MonitorPk2Pk"))
strFeatureName = "监测保护峰峰值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("InvertDanger") )
strFeatureName = "反时限危险值";
else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("InvertAlarm"))
strFeatureName = "反时限警报值";
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Over")){
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + strFeatureName+ "-" + "高于" + triggerLevel + "";
}else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Under")){
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + strFeatureName+ "-" + "低于" + triggerLevel + "";
}
strRowItem << i + 1 << triggerLevel << triggerEventName << TStr;
createRowItem(i,strRowItem);
}
QMyTableViewBtnDelegate *m_btnDelegate = new QMyTableViewBtnDelegate(QStringList()<<"详情", this);
ui->tableView->setItemDelegateForColumn(4, m_btnDelegate);
connect(m_btnDelegate, SIGNAL(editData(const QModelIndex &)), this,SLOT(Details(const QModelIndex &)));
}else{
QMessageBox::information(this, "提示", QString("未查询到数据!"));
}
}