#include "BoardSetting.h" #include "ui_boardsetting.h" #include "global.h" #include #include "sqlitedb.h" CBoardSetting::CBoardSetting(QWidget *parent) : QWidget(parent), ui(new Ui::CBoardSetting) { ui->setupUi(this); initReadConfig(); ui->Slot1->setView(new QListView()); ui->Slot2->setView(new QListView()); ui->Slot3->setView(new QListView()); ui->Slot4->setView(new QListView()); ui->Slot5->setView(new QListView()); ui->Slot6->setView(new QListView()); ui->Slot7->setView(new QListView()); ui->Slot8->setView(new QListView()); ui->Slot9->setView(new QListView()); ui->Slot10->setView(new QListView()); ui->widget_2->setProperty("flag", "Title"); ui->widget_3->setProperty("flag", "normal"); } CBoardSetting::~CBoardSetting() { delete ui; } void CBoardSetting::initReadConfig() { #ifdef Q_OS_WIN32 QString name = QCoreApplication::applicationDirPath() + "\\config\\UnitBoardsInfo.json"; #endif #ifdef Q_OS_LINUX QString name = QCoreApplication::applicationDirPath() + "/config/UnitBoardsInfo.json"; #endif QFile loadFile(name); if(!loadFile.open(QIODevice::ReadOnly)) { qDebug() << "could't open projects json"; return; } QString value = loadFile.readAll(); loadFile.close(); QJsonParseError parseJsonErr; QJsonDocument document = QJsonDocument::fromJson(value.toUtf8(), &parseJsonErr); if (!(parseJsonErr.error == QJsonParseError::NoError)) { QMessageBox::about(NULL, "提示", "读取文件错误!"); return; } QJsonObject jsonObject = document.object(); QStringList strItems; if (jsonObject.contains(QStringLiteral("BoardType"))) { QJsonValue jsonValue = jsonObject.value(QStringLiteral("BoardType")); QString strContent = jsonValue["content"].toString(); m_arrayValue = jsonValue["Options"].toArray(); for (int i = 0; i < m_arrayValue.size() ; i++) { QJsonValue jsonValue = m_arrayValue[i]; strItems << jsonValue["BoardTypeName"].toString(); } } qDebug() << "Items" <Slot1->clear(); ui->Slot2->clear(); ui->Slot3->clear(); ui->Slot4->clear(); ui->Slot5->clear(); ui->Slot6->clear(); ui->Slot7->clear(); ui->Slot8->clear(); ui->Slot9->clear(); ui->Slot10->clear(); ui->Slot1->addItems(strItems); ui->Slot2->addItems(strItems); ui->Slot3->addItems(strItems); ui->Slot4->addItems(strItems); ui->Slot5->addItems(strItems); ui->Slot6->addItems(strItems); ui->Slot7->addItems(strItems); ui->Slot8->addItems(strItems); ui->Slot9->addItems(strItems); ui->Slot10->addItems(strItems); if (jsonObject.contains(QStringLiteral("UnitBoards"))) { QJsonValue arrayValue = jsonObject.value(QStringLiteral("UnitBoards")); m_arrayUnitBoards = arrayValue.toArray(); for (int i = 0; i < m_arrayUnitBoards.size() ; i++) { QJsonValue arrayValue = m_arrayUnitBoards[i]; int SN = arrayValue["BoardNo"].toInt(); QString strBoardType = arrayValue["BoardTypeName"].toString(); if(SN == 1){ ui->Slot1->setCurrentText(strBoardType); }else if(SN == 2){ ui->Slot2->setCurrentText(strBoardType); }else if(SN == 3){ ui->Slot3->setCurrentText(strBoardType); }else if(SN == 4){ ui->Slot4->setCurrentText(strBoardType); }else if(SN == 5){ ui->Slot5->setCurrentText(strBoardType); }else if(SN == 6){ ui->Slot6->setCurrentText(strBoardType); }else if(SN == 7){ ui->Slot7->setCurrentText(strBoardType); }else if(SN == 8){ ui->Slot8->setCurrentText(strBoardType); }else if(SN == 9){ ui->Slot9->setCurrentText(strBoardType); }else if(SN == 10){ ui->Slot10->setCurrentText(strBoardType); } } } } void CBoardSetting::removeJsonObj(QJsonObject objValue) { // if(!objValue.isEmpty()){ // tempOptions.append(tempObj); // QStringList strList = objValue.keys(); // foreach(auto key,strList){ // objValue.remove(key); // } // } } void CBoardSetting::on_Btn_Confirm_clicked() { connect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); g_NetMgr->DetectNet(); } void CBoardSetting::PushData() { QMessageBox:: StandardButton iResult = QMessageBox::question(this, QStringLiteral("提示"), QStringLiteral("确认后将初始化通道配置信息!"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); switch (iResult) { case QMessageBox::Yes: break; case QMessageBox::No: return; break; default: break; } QVector vecBoardNo; QJsonArray tempOptions; QJsonObject UnitBoardsInfoObj; for (int i = 0; i < m_arrayValue.size(); i++) { QJsonObject tempObj; if(ui->Slot1->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 1; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot2->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 2; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot3->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 3; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot4->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 4; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot5->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 5; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot6->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 6; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot7->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 7; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot8->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 8; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot9->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 9; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot10->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 10; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } } for (int i = 0; i < tempOptions.size(); i++) { for (int j = 0; j < m_arrayUnitBoards.size(); j++) { if(tempOptions.at(i)["BoardNo"].toInt() == m_arrayUnitBoards.at(j)["BoardNo"].toInt()){ if(tempOptions.at(i)["BoardTypeNo"].toInt() == m_arrayUnitBoards.at(j)["BoardTypeNo"].toInt()){ vecBoardNo.append(tempOptions.at(i)["BoardNo"].toInt()); } } } } m_objValue["Options"] = m_arrayValue; UnitBoardsInfoObj["BoardType"] = m_objValue; UnitBoardsInfoObj["UnitBoards"] = tempOptions; qDebug() << UnitBoardsInfoObj << endl; QJsonDocument jsonDoc; jsonDoc.setObject(UnitBoardsInfoObj); #ifdef Q_OS_WIN32 QString name = QCoreApplication::applicationDirPath() + "\\config\\UnitBoardsInfo.json"; #endif #ifdef Q_OS_LINUX QString name = QCoreApplication::applicationDirPath() + "/config/UnitBoardsInfo.json"; #endif QFile file(name); file.open(QIODevice::WriteOnly); file.write(jsonDoc.toJson()); file.close(); QString strMAC = MAC; QString taleName = "t_ChannelSetting"; long timeStamp = QDateTime::currentDateTime().toTime_t(); int flag = 0; for (int ii = 0; ii < tempOptions.size(); ii++) { for (int jj = 0; jj < vecBoardNo.size(); jj++) { if(tempOptions.at(ii)["BoardNo"].toInt() == vecBoardNo[jj]){ flag = 1; break; } } if(flag){ flag = 0; continue; } g_SqliteDB->DeleteData(taleName,"sensorModuleNo",tempOptions.at(ii)["BoardNo"].toInt()); if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 2 || tempOptions.at(ii)["BoardTypeNo"].toInt() == 3){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0'));//保留2位小数 QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(30).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ arg("m/s^2").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("2032").arg("1").arg("-2").arg("-20").arg("10.2").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("30").arg("").arg("-30").arg("30").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg("峰峰值"); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 4){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0'));//保留2位小数 QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(12).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ arg("m/s^2").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("2032").arg("1").arg("-2").arg("-20").arg("10.2").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("12").arg("").arg("-12").arg("12").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg("峰峰值"); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 1){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("PULSE_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ arg("mA").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("20").arg("").arg("4").arg("4").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg("平均值"); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 5){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("SLOW_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(64).arg("").arg("").arg(timeStamp).\ arg("mA").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("20").arg("").arg("4").arg("4").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg(""); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 6){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName ; QString strchannelType; if(i < 12){ strchannelType = "DI"; strChannelName = QString("开入%1-%2").arg(BoardNo).arg(i+1); }else{ strchannelType = "DO"; strChannelName = QString("开出%1-%2").arg(BoardNo).arg(i+1); } QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','',0);").\ arg("NULL").arg(0).arg("false").arg(strchannelType).arg("0").arg("").arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg(0).arg(0).arg(""). arg(0).arg("").arg(0).arg("").arg(0).arg(strChannelID).arg("").arg(strChannelName).arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("").arg("").arg("").arg(10).arg("").arg("").arg(0).arg(0).arg("0").arg("").arg(0).arg("").arg("").arg("0").arg(0).arg("").arg("").arg(timeStamp).\ arg("").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("").arg("").arg(2).arg("").arg("").arg("").arg("").arg("").arg("").arg("").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg(""); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } } } m_arrayUnitBoards = tempOptions; QVector().swap(g_channelSetting); QVector().swap(g_ChannelBaseInfo); QMap>().swap(g_MapChannel); QString strTableName = "t_WorkConditionChannels"; QString strSql = QString(" set ChannelId = '%1',BoardNo = %2,ChannelName = '%3',ChannelNoInBoard = %4 ").arg("").arg(0).\ arg("").arg(0); g_SqliteDB->UpdateDataSql(strTableName,strSql); QJsonObject WorkConditionsInfoObj; WorkConditionsInfoObj["WorkConditionsInfo"] = ""; QJsonDocument jsonDoc2; jsonDoc2.setObject(WorkConditionsInfoObj); #ifdef Q_OS_WIN32 QString fileName = QCoreApplication::applicationDirPath() + "\\config\\UnitWorkConditionsInfo.json"; #endif #ifdef Q_OS_LINUX QString fileName = QCoreApplication::applicationDirPath() + "/config/UnitWorkConditionsInfo.json"; #endif QFile file2(fileName); file2.open(QIODevice::WriteOnly); file2.write(jsonDoc2.toJson()); file2.close(); QString strTablename = "t_WorkCondition"; g_SqliteDB->DeleteData(strTablename); strTablename = "t_WorkConditionRules"; g_SqliteDB->DeleteData(strTablename); strTablename = "t_TriggerConfig"; g_SqliteDB->DeleteData(strTablename); QString strURL = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitWorkConditionsInfo.json"); // g_FtpClient->SetServerInfo(strURL); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileName,"UnitWorkConditionsInfo.json"); g_FtpClient->uploadFile(strURL,fileName,"UnitWorkConditionsInfo.json"); QJsonDocument jsonDocUnit; QJsonObject UnitObj; UnitObj["NULL"] = ""; jsonDocUnit.setObject(UnitObj); #ifdef Q_OS_WIN32 QString fileNameUnit = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations.json"; #endif #ifdef Q_OS_LINUX QString fileNameUnit = QCoreApplication::applicationDirPath() + "/config/UnitConfigurations.json"; #endif QFile fileUnit(fileNameUnit); fileUnit.open(QIODevice::WriteOnly); fileUnit.write(jsonDocUnit.toJson()); fileUnit.close(); QString str2 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations.json"); // g_FtpClient->SetServerInfo(str2); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameUnit,"UnitConfigurations.json"); g_FtpClient->uploadFile(str2,fileNameUnit,"UnitConfigurations.json"); #ifdef Q_OS_WIN32 QString fileNameUnit2 = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations2.json"; #endif #ifdef Q_OS_LINUX QString fileNameUnit2 = QCoreApplication::applicationDirPath() + "/config/UnitConfigurations2.json"; #endif QFile fileUnit2(fileNameUnit2); fileUnit2.open(QIODevice::WriteOnly); fileUnit2.write(jsonDocUnit.toJson()); fileUnit2.close(); QString str22 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations2.json"); // g_FtpClient->SetServerInfo(str22); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameUnit2,"UnitConfigurations2.json"); g_FtpClient->uploadFile(str22,fileNameUnit2,"UnitConfigurations2.json"); g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); for (int i = 0; i < g_channelSetting.size(); i++) { QMap mapChannelType; mapChannelType.insert(g_channelSetting[i].sensorType,g_channelSetting[i].channelName); g_MapChannel.insert(g_channelSetting[i].channelId,mapChannelType); channelBaseInfo tempchannelbaseinfo; tempchannelbaseinfo.bordNo = g_channelSetting[i].sensorModuleNo; tempchannelbaseinfo.channelID = g_channelSetting[i].channelId; tempchannelbaseinfo.channelNoInBoard = g_channelSetting[i].sensorNo; tempchannelbaseinfo.channelName = g_channelSetting[i].channelName; tempchannelbaseinfo.channelType = g_channelSetting[i].sensorType; tempchannelbaseinfo.sensorEngineeringUnit = g_channelSetting[i].sensorEngineeringUnit; tempchannelbaseinfo.pairChannelId = g_channelSetting[i].pairChannelId; tempchannelbaseinfo.speedRefChannelId = g_channelSetting[i].speedRefChannelId; tempchannelbaseinfo.isEnable = g_channelSetting[i].isEnable; tempchannelbaseinfo.ChUnitDot = g_channelSetting[i].ChUnitDot; tempchannelbaseinfo.defaultDisplay = g_channelSetting[i].defaultDisplay; tempchannelbaseinfo.boardType = g_channelSetting[i].boardType; g_ChannelBaseInfo.append(tempchannelbaseinfo); } QJsonDocument jsonDocTri; QJsonArray triArray,m_channeltriggerArray; QJsonObject triggerConfigObj; #ifdef Q_OS_WIN32 QString fileNameTri = QCoreApplication::applicationDirPath() + "\\config\\TriggerSettings.json"; #endif #ifdef Q_OS_LINUX QString fileNameTri = QCoreApplication::applicationDirPath() + "/config/TriggerSettings.json"; #endif for (int ii = 0; ii < g_ChannelBaseInfo.size(); ii++) { QJsonObject tempObj; tempObj["channelId"] = g_ChannelBaseInfo[ii].channelID; tempObj["channelName"] = g_ChannelBaseInfo[ii].channelName; triArray.append(tempObj); } triggerConfigObj["triggerSettings"] = triArray; m_channeltriggerArray.append(triggerConfigObj); jsonDocTri.setArray(m_channeltriggerArray); QFile fileTri(fileNameTri); fileTri.open(QIODevice::WriteOnly); fileTri.write(jsonDocTri.toJson()); fileTri.close(); QString str1 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("TriggerSettings.json"); // g_FtpClient->SetServerInfo(str1); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameTri,"TriggerSettings.json"); g_FtpClient->uploadFile(str1,fileNameTri,"TriggerSettings.json"); #ifdef Q_OS_WIN32 QString fileNameTri2 = QCoreApplication::applicationDirPath() + "\\config\\TriggerSettings2.json"; #endif #ifdef Q_OS_LINUX QString fileNameTri2 = QCoreApplication::applicationDirPath() + "/config/TriggerSettings2.json"; #endif QFile fileTri2(fileNameTri2); fileTri2.open(QIODevice::WriteOnly); fileTri2.write(jsonDocTri.toJson()); fileTri2.close(); QString strTri2 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("TriggerSettings2.json"); // g_FtpClient->SetServerInfo(strTri2); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameTri2,"TriggerSettings2.json"); g_FtpClient->uploadFile(strTri2,fileNameTri2,"TriggerSettings2.json"); QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitBoardsInfo.json"); // g_FtpClient->SetServerInfo(str); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json"); g_FtpClient->uploadFile(str,name,"UnitBoardsInfo.json"); disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); } void CBoardSetting::slotNetMgr(QString sAddr, const QVariant &msg) { QJsonObject objec = msg.value(); if(objec.contains("cmd")) { QJsonValue arrays_value = objec.take("cmd"); //qDebug()<<"cmd ="<Slot1->setCurrentText("未使用"); ui->Slot2->setCurrentText("未使用"); ui->Slot3->setCurrentText("未使用"); ui->Slot4->setCurrentText("未使用"); ui->Slot5->setCurrentText("未使用"); ui->Slot6->setCurrentText("未使用"); ui->Slot7->setCurrentText("未使用"); ui->Slot8->setCurrentText("未使用"); ui->Slot9->setCurrentText("未使用"); ui->Slot10->setCurrentText("未使用"); QVector vecBoardNo; QJsonArray tempOptions; QJsonObject UnitBoardsInfoObj; for (int i = 0; i < m_arrayValue.size(); i++) { QJsonObject tempObj; if(ui->Slot1->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 1; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot2->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 2; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot3->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 3; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot4->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 4; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot5->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 5; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot6->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 6; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot7->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 7; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot8->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 8; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot9->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 9; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } if(ui->Slot10->currentText() == m_arrayValue.at(i)["BoardTypeName"].toString()){ tempObj = m_arrayValue.at(i).toObject(); tempObj["BoardNo"] = 10; } if(!tempObj.isEmpty()){ tempOptions.append(tempObj); QStringList strList = tempObj.keys(); foreach(auto key,strList){ tempObj.remove(key); } } } m_objValue["Options"] = m_arrayValue; UnitBoardsInfoObj["BoardType"] = m_objValue; UnitBoardsInfoObj["UnitBoards"] = tempOptions; qDebug() << UnitBoardsInfoObj << endl; QJsonDocument jsonDoc; jsonDoc.setObject(UnitBoardsInfoObj); #ifdef Q_OS_WIN32 QString name = QCoreApplication::applicationDirPath() + "\\config\\UnitBoardsInfo.json"; #endif #ifdef Q_OS_LINUX QString name = QCoreApplication::applicationDirPath() + "/config/UnitBoardsInfo.json"; #endif QFile file(name); file.open(QIODevice::WriteOnly); file.write(jsonDoc.toJson()); file.close(); QString strMAC = MAC; QString taleName = "t_ChannelSetting"; g_SqliteDB->DeleteData(taleName); long timeStamp = QDateTime::currentDateTime().toTime_t(); for (int ii = 0; ii < tempOptions.size(); ii++) { if(tempOptions.at(ii)["BoardTypeNo"].toInt() > 1 && tempOptions.at(ii)["BoardTypeNo"].toInt() < 5 && tempOptions.at(ii)["BoardTypeNo"].toInt() != 0){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0'));//保留2位小数 QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("ACCELEROMETER").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("CTC-AC102").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(10).arg("5000").arg("").arg(1).arg(1).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ arg("m/s^2").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("2032").arg("1").arg("-2").arg("-20").arg("10.2").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("").arg("").arg("").arg("").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg("峰峰值"); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 1){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("PULSE_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(1).arg(1).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(1024).arg("").arg("").arg(timeStamp).\ arg("mA").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("20").arg("").arg("4").arg("4").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg("平均值"); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 5){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName = QString("第%1板卡第%2通道").arg(BoardNo).arg(i+1); QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',98,1,'','',0);").\ arg("NULL").arg(0).arg("true").arg("SLOW_CURRENT").arg("0").arg("Bottom").arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg("false").arg(0).arg(0).arg(0).arg("false"). arg(0).arg("false").arg(0).arg("false").arg(0).arg(strChannelID).arg("NONE").arg(strChannelName).arg("false").arg(0).arg("false").arg(0).arg("RMSValue").arg("").arg(0).arg("false").arg(0).arg("电流变送器").arg("false").arg(0).arg("false").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("").arg("").arg(20).arg("5000").arg("").arg(0).arg(0).arg("0").arg("60000").arg(0).arg("NONE").arg("").arg("0").arg(64).arg("").arg("").arg(timeStamp).\ arg("mA").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("true").arg("").arg(0).arg("").arg("").arg("").arg("20").arg("").arg("4").arg("4").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg(""); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } }else if(tempOptions.at(ii)["BoardTypeNo"].toInt() == 6){ int BoardNo = tempOptions.at(ii)["BoardNo"].toInt(); int BoardTypeNo = tempOptions.at(ii)["BoardTypeNo"].toInt(); int ChannelsInBoard = tempOptions.at(ii)["ChannelsInBoard"].toInt(); for (int i = 0; i < ChannelsInBoard; i++) { QString strChannelID = QString("%1%2%3").arg(MAC).arg(BoardNo,2, 10, QLatin1Char('0')).arg(i+1,2, 10, QLatin1Char('0')); QString strChannelName ; QString strchannelType; if(i < 12){ strchannelType = "DI"; strChannelName = QString("开入%1-%2").arg(BoardNo).arg(i+1); }else{ strchannelType = "DO"; strChannelName = QString("开出%1-%2").arg(BoardNo).arg(i+1); } QString str = QString(" values('%1','%2','%3','%4',%5,'%6','%7',%8,'%9',%10,'%11',%12,'%13',%14,'%15',%16,'%17',%18,%19,%20,'%21',%22,'%23',%24,\ '%25',%26,'%27','%28','%29','%30',%31,'%32',%33,'%34','%35',%36,'%37',%38,'%39','%40',%41,'%42',%43,'%44',\ '%45','%46',%47,%48,%49,'%50','%51','%52',%53,'%54','%55',%56,%57,'%58','%59',%60,'%61','%62','%63',%64,'%65','%66','%67',\ '%68','%69','%70',%71,%72,%73,'%74','%75','%76','%77','%78','%79','%80','%81','%82','%83','%84',%85,'%86','%87','%88','%89','%90','%91','%92','%93','%94','%95','',0,0,'','',0);").\ arg("NULL").arg(0).arg("false").arg(strchannelType).arg("0").arg("").arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg("").arg(0).arg(0).arg(0).arg(""). arg(0).arg("").arg(0).arg("").arg(0).arg(strChannelID).arg("").arg(strChannelName).arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").arg("").arg(0).arg("").arg(0).arg("").\ arg("true").arg(MAC).arg(0).arg(1000).arg(0).arg("").arg("").arg("").arg(10).arg("").arg("").arg(0).arg(0).arg("0").arg("").arg(0).arg("").arg("").arg("0").arg(0).arg("").arg("").arg(timeStamp).\ arg("").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("1").arg("-2").arg("-20").arg("0").arg("").arg("").arg("").arg("").arg("").arg("").arg(2).arg("").arg("").arg("").arg("").arg("").arg("").arg("").arg(tempOptions.at(ii)["BoardTypeNo"].toInt()).arg("").arg(""); qDebug() << "str" << str << endl; g_SqliteDB->InsertData(taleName,str); } } } m_arrayUnitBoards = tempOptions; QVector().swap(g_channelSetting); QVector().swap(g_ChannelBaseInfo); QMap>().swap(g_MapChannel); QString strTableName = "t_WorkConditionChannels"; QString strSql = QString(" set ChannelId = '%1',BoardNo = %2,ChannelName = '%3',ChannelNoInBoard = %4 ").arg("").arg(0).\ arg("").arg(0); g_SqliteDB->UpdateDataSql(strTableName,strSql); QJsonObject WorkConditionsInfoObj; WorkConditionsInfoObj["WorkConditionsInfo"] = ""; QJsonDocument jsonDoc2; jsonDoc2.setObject(WorkConditionsInfoObj); #ifdef Q_OS_WIN32 QString fileName = QCoreApplication::applicationDirPath() + "\\config\\UnitWorkConditionsInfo.json"; #endif #ifdef Q_OS_LINUX QString fileName = QCoreApplication::applicationDirPath() + "/config/UnitWorkConditionsInfo.json"; #endif QFile file2(fileName); file2.open(QIODevice::WriteOnly); file2.write(jsonDoc2.toJson()); file2.close(); QString strTablename = "t_WorkCondition"; g_SqliteDB->DeleteData(strTablename); strTablename = "t_WorkConditionRules"; g_SqliteDB->DeleteData(strTablename); strTablename = "t_TriggerConfig"; g_SqliteDB->DeleteData(strTablename); // QString strURL = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitWorkConditionsInfo.json"); // g_FtpClient->SetServerInfo(strURL); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileName,"UnitWorkConditionsInfo.json"); customLogMessageHandler(QtDebugMsg,"初始化工况配置信息推送完成!"); QJsonDocument jsonDocUnit; QJsonObject UnitObj; UnitObj["NULL"] = ""; jsonDocUnit.setObject(UnitObj); #ifdef Q_OS_WIN32 QString fileNameUnit = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations.json"; #endif #ifdef Q_OS_LINUX QString fileNameUnit = QCoreApplication::applicationDirPath() + "/config/UnitConfigurations.json"; #endif QFile fileUnit(fileNameUnit); fileUnit.open(QIODevice::WriteOnly); fileUnit.write(jsonDocUnit.toJson()); fileUnit.close(); // QString str2 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations.json"); // g_FtpClient->SetServerInfo(str2); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameUnit,"UnitConfigurations.json"); customLogMessageHandler(QtDebugMsg,"初始化机组配置信息推送完成!"); g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); g_ChannelBaseInfo.clear(); QVector().swap(g_ChannelBaseInfo); for (int i = 0; i < g_channelSetting.size(); i++) { QMap mapChannelType; mapChannelType.insert(g_channelSetting[i].sensorType,g_channelSetting[i].channelName); g_MapChannel.insert(g_channelSetting[i].channelId,mapChannelType); channelBaseInfo tempchannelbaseinfo; tempchannelbaseinfo.bordNo = g_channelSetting[i].sensorModuleNo; tempchannelbaseinfo.channelID = g_channelSetting[i].channelId; tempchannelbaseinfo.channelNoInBoard = g_channelSetting[i].sensorNo; tempchannelbaseinfo.channelName = g_channelSetting[i].channelName; tempchannelbaseinfo.channelType = g_channelSetting[i].sensorType; tempchannelbaseinfo.sensorEngineeringUnit = g_channelSetting[i].sensorEngineeringUnit; tempchannelbaseinfo.pairChannelId = g_channelSetting[i].pairChannelId; tempchannelbaseinfo.speedRefChannelId = g_channelSetting[i].speedRefChannelId; tempchannelbaseinfo.isEnable = g_channelSetting[i].isEnable; tempchannelbaseinfo.ChUnitDot = g_channelSetting[i].ChUnitDot; tempchannelbaseinfo.defaultDisplay = g_channelSetting[i].defaultDisplay; tempchannelbaseinfo.boardType = g_channelSetting[i].boardType; g_ChannelBaseInfo.append(tempchannelbaseinfo); } QJsonDocument jsonDocTri; QJsonArray triArray,m_channeltriggerArray; QJsonObject triggerConfigObj; #ifdef Q_OS_WIN32 QString fileNameTri = QCoreApplication::applicationDirPath() + "\\config\\TriggerSettings.json"; #endif #ifdef Q_OS_LINUX QString fileNameTri = QCoreApplication::applicationDirPath() + "/config/TriggerSettings.json"; #endif for (int ii = 0; ii < g_ChannelBaseInfo.size(); ii++) { QJsonObject tempObj; tempObj["channelId"] = g_ChannelBaseInfo[ii].channelID; tempObj["channelName"] = g_ChannelBaseInfo[ii].channelName; triArray.append(tempObj); } triggerConfigObj["triggerSettings"] = triArray; m_channeltriggerArray.append(triggerConfigObj); jsonDocTri.setArray(m_channeltriggerArray); QFile fileTri(fileNameTri); fileTri.open(QIODevice::WriteOnly); fileTri.write(jsonDocTri.toJson()); fileTri.close(); // QString str1 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("TriggerSettings.json"); // g_FtpClient->SetServerInfo(str1); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(fileNameTri,"TriggerSettings.json"); // QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitBoardsInfo.json"); // g_FtpClient->SetServerInfo(str); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(name,"UnitBoardsInfo.json"); customLogMessageHandler(QtDebugMsg,"初始化机组板卡配置信息推送完成!"); #ifndef NO_FILTER QJsonObject sendData; sendData["cmd"] = "111"; QNetworkRequest req; QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP); req.setUrl(sUrl); g_NetMgr->PostJson(req,sendData); #endif putJson(); } void CBoardSetting::putJson() { QJsonArray channelArray; for(int i = 0; i < g_channelSetting.size();i++){ QJsonObject channelObj; channelObj["ChUnitCoeff"] = g_channelSetting[i].ChUnitCoeff; channelObj["ChUnitDot"] = g_channelSetting[i].ChUnitDot; channelObj["sensorICP"] = g_channelSetting[i].sensorICP; channelObj["bearingClearance"] = g_channelSetting[i].bearingClearance.toDouble(); channelObj["bearingStartPosition"] = g_channelSetting[i].bearingStartPosition; channelObj["channel1P5XAMP"] = g_channelSetting[i].channel1P5XAMP; channelObj["channel1P5XAMPDefaultValue"] = g_channelSetting[i].channel1P5XAMPDefaultValue; channelObj["channel1xAmpl"] = g_channelSetting[i].channel1xAmpl; channelObj["channel1xAmpleDefaultValue"] = g_channelSetting[i].channel1xAmpleDefaultValue; channelObj["channel2P5XAMP"] = g_channelSetting[i].channel2P5XAMP; channelObj["channel2P5XAMPDefaultValue"] = g_channelSetting[i].channel2P5XAMPDefaultValue; channelObj["channel2p5xAmpl"] = g_channelSetting[i].channel2p5xAmpl; channelObj["channel2p5xAmplDefaultValue"] = g_channelSetting[i].channel2p5xAmplDefaultValue; channelObj["channel2xAmpl"] = g_channelSetting[i].channel2xAmpl; channelObj["channel2xAmplDefaultValue"] = g_channelSetting[i].channel2xAmplDefaultValue; channelObj["channel3XAmpl"] = g_channelSetting[i].channel3XAmpl; channelObj["channel3XAmplDefaultValue"] = g_channelSetting[i].channel3XAmplDefaultValue; channelObj["channelACHighpassband"] = g_channelSetting[i].channelACHighpassband; channelObj["channelDefaultValueEU"] = g_channelSetting[i].channelDefaultValueEU; channelObj["channelDirect"] = g_channelSetting[i].channelDirect; channelObj["channelDirectDefaultValue"] = g_channelSetting[i].channelDirectDefaultValue; channelObj["channelElement"] = g_channelSetting[i].channelElement; channelObj["channelElementDefaultValue"] = g_channelSetting[i].channelElementDefaultValue; channelObj["channelGapVoltage"] = g_channelSetting[i].channelGapVoltage; channelObj["channelGapVoltageDefaultValue"] = g_channelSetting[i].channelGapVoltageDefaultValue; channelObj["channelId"] = g_channelSetting[i].channelId; channelObj["channelIntDiff"] = g_channelSetting[i].channelIntDiff; channelObj["channelName"] = g_channelSetting[i].channelName; channelObj["channelNot1xAmp"] = g_channelSetting[i].channelNot1xAmp; channelObj["channelNot1xAmpDefaultValue"] = g_channelSetting[i].channelNot1xAmpDefaultValue; channelObj["channelOP5XAMP"] = g_channelSetting[i].channelOP5XAMP; channelObj["channelOP5XAMPDefaultValue"] = g_channelSetting[i].channelOP5XAMPDefaultValue; channelObj["channelRMSPkPk2Pk"] = g_channelSetting[i].channelRMSPkPk2Pk; channelObj["channelRecorderOutput"] = g_channelSetting[i].channelRecorderOutput; channelObj["channelRecorderOutputDefaultVal"] = g_channelSetting[i].channelRecorderOutputDefaultVal; channelObj["channelRotor"] = g_channelSetting[i].channelRotor; channelObj["channelRotorDefaultValue"] = g_channelSetting[i].channelRotorDefaultValue; channelObj["channelSensorType"] = g_channelSetting[i].channelSensorType; channelObj["channelSmax"] = g_channelSetting[i].channelSmax; channelObj["channelSmaxDefaultValue"] = g_channelSetting[i].channelSmaxDefaultValue; channelObj["channelSpike"] = g_channelSetting[i].channelSpike; channelObj["channelSpikeDefaultValue"] = g_channelSetting[i].channelSpikeDefaultValue; channelObj["comments"] = g_channelSetting[i].comments; channelObj["couplingACDC"] = g_channelSetting[i].couplingACDC; channelObj["dataWatchNo"] = g_channelSetting[i].dataWatchNo; channelObj["envelopeHighpassband"] = g_channelSetting[i].envelopeHighpassband; channelObj["envelopeLowpassband"] = g_channelSetting[i].envelopeLowpassband; channelObj["equipmentId"] = g_channelSetting[i].equipmentId; channelObj["filter"] = g_channelSetting[i].filter; channelObj["frequencyRangeMax"] = g_channelSetting[i].frequencyRangeMax.toDouble(); channelObj["frequencyRangeMin"] = g_channelSetting[i].frequencyRangeMin.toDouble(); channelObj["fullScalePosition"] = g_channelSetting[i].fullScalePosition; channelObj["highPassFrequency"] = g_channelSetting[i].highPassFrequency.toDouble(); channelObj["installMethod"] = g_channelSetting[i].installMethod; channelObj["isEnable"] = g_channelSetting[i].isEnable; channelObj["isWork"] = g_channelSetting[i].isWork; channelObj["lowPassFrequency"] = g_channelSetting[i].lowPassFrequency.toDouble(); channelObj["measuringRange"] = g_channelSetting[i].measuringRange.toDouble(); channelObj["offset"] = g_channelSetting[i].offset; channelObj["pairChannelId"] = g_channelSetting[i].pairChannelId; channelObj["pairChannelName"] = g_channelSetting[i].pairChannelName; channelObj["rpmMultiplier"] = g_channelSetting[i].rpmMultiplier.toDouble(); channelObj["samplingRate"] = g_channelSetting[i].samplingRate; channelObj["sensor1xAmplitudeRunout"] = g_channelSetting[i].sensor1xAmplitudeRunout.toDouble(); channelObj["sensor1xPhaseRunout"] = g_channelSetting[i].sensor1xPhaseRunout.toDouble(); channelObj["sensorConfigureDate"] = g_channelSetting[i].sensorConfigureDate.toInt(); channelObj["sensorEngineeringUnit"] = g_channelSetting[i].sensorEngineeringUnit; channelObj["sensorGapVoltage"] = g_channelSetting[i].sensorGapVoltage.toDouble(); channelObj["sensorLeftOrRight"] = g_channelSetting[i].sensorLeftOrRight; channelObj["sensorLocationInDegree"] = g_channelSetting[i].sensorLocationInDegree; channelObj["sensorModuleNo"] = g_channelSetting[i].sensorModuleNo; channelObj["sensorNo"] = g_channelSetting[i].sensorNo; channelObj["sensorRange"] = g_channelSetting[i].sensorRange; channelObj["sensorRangeCheck"] = g_channelSetting[i].sensorRangeCheck; channelObj["sensorRangeMax"] = g_channelSetting[i].sensorRangeMax.toDouble(); channelObj["sensorRangeMin"] = g_channelSetting[i].sensorRangeMin.toDouble(); channelObj["sensorSensitivity"] = g_channelSetting[i].sensorSensitivity.toDouble(); channelObj["sensorType"] = g_channelSetting[i].sensorType; channelObj["shaftRotationDirection"] = g_channelSetting[i].shaftRotationDirection; channelObj["speedRefChannelId"] = g_channelSetting[i].speedRefChannelId; channelObj["startBrands"] = g_channelSetting[i].startBrands; channelObj["stopBrands"] = g_channelSetting[i].stopBrands; channelObj["tachAutoTach"] = g_channelSetting[i].tachAutoTach; channelObj["tachTriggerEdge"] = g_channelSetting[i].tachTriggerEdge; channelObj["tachTriggerHysteresis"] = g_channelSetting[i].tachTriggerHysteresis; channelObj["tachTriggerPerRev"] = g_channelSetting[i].tachTriggerPerRev.toInt(); channelObj["tachTriggerVoltageLevel"] = g_channelSetting[i].tachTriggerVoltageLevel; channelObj["thermalCoupleType"] = g_channelSetting[i].thermalCoupleType; channelObj["xFullScalePosition"] = g_channelSetting[i].xFullScalePosition.toDouble(); channelObj["xProcessVariableName"] = g_channelSetting[i].xProcessVariableName; channelObj["xZeroScalePosition"] = g_channelSetting[i].xZeroScalePosition.toDouble(); channelObj["zeroScalePosition"] = g_channelSetting[i].zeroScalePosition.toDouble(); channelObj["boardType"] = g_channelSetting[i].boardType; channelObj["defaultDisplay"] = g_channelSetting[i].defaultDisplay; channelObj["sectionNum"] = g_channelSetting[i].sectionNum; channelObj["confidenceDegree"] = g_channelSetting[i].confidenceDegree; channelObj["firstPoleNum"] = g_channelSetting[i].firstPoleNum; channelArray.append(channelObj); } QJsonDocument jsonDoc; jsonDoc.setArray(channelArray); #ifdef Q_OS_WIN32 QString name = QCoreApplication::applicationDirPath() + "\\config\\ChannelSettings.json"; #endif #ifdef Q_OS_LINUX QString name = QCoreApplication::applicationDirPath() + "/config/ChannelSettings.json"; #endif QFile file(name); file.open(QIODevice::WriteOnly); file.write(jsonDoc.toJson()); file.close(); QVector().swap(g_channelSetting); QVector().swap(g_ChannelBaseInfo); QMap>().swap(g_MapChannel); g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting"); for (int i = 0; i < g_channelSetting.size(); i++) { QMap mapChannelType; mapChannelType.insert(g_channelSetting[i].sensorType,g_channelSetting[i].channelName); g_MapChannel.insert(g_channelSetting[i].channelId,mapChannelType); channelBaseInfo tempchannelbaseinfo; tempchannelbaseinfo.bordNo = g_channelSetting[i].sensorModuleNo; tempchannelbaseinfo.channelID = g_channelSetting[i].channelId; tempchannelbaseinfo.channelNoInBoard = g_channelSetting[i].sensorNo; tempchannelbaseinfo.channelName = g_channelSetting[i].channelName; tempchannelbaseinfo.channelType = g_channelSetting[i].sensorType; tempchannelbaseinfo.sensorEngineeringUnit = g_channelSetting[i].sensorEngineeringUnit; tempchannelbaseinfo.defaultDisplay = g_channelSetting[i].defaultDisplay; tempchannelbaseinfo.speedRefChannelId = g_channelSetting[i].speedRefChannelId; tempchannelbaseinfo.boardType = g_channelSetting[i].boardType; tempchannelbaseinfo.isEnable = g_channelSetting[i].isEnable; tempchannelbaseinfo.ChUnitDot = g_channelSetting[i].ChUnitDot; g_ChannelBaseInfo.append(tempchannelbaseinfo); } initReadConfig(); // QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("ChannelSettings.json"); // g_FtpClient->SetServerInfo(str); // g_FtpClient->SetUserInfo("root","@#cidw!@123456"); // g_FtpClient->UpLoadFile(name,"ChannelSettings.json"); customLogMessageHandler(QtDebugMsg,"初始化通道配置信息推送完成!"); disconnect(g_NetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&))); }