2023-04-14 19:30:30 +08:00
|
|
|
#include "BoardSetting.h"
|
|
|
|
|
#include "ui_boardsetting.h"
|
|
|
|
|
#include "global.h"
|
|
|
|
|
#include <QListView>
|
|
|
|
|
#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()
|
|
|
|
|
{
|
|
|
|
|
QString name = QCoreApplication::applicationDirPath() + "\\config\\UnitBoardsInfo.json";
|
|
|
|
|
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" <<strItems << endl;
|
|
|
|
|
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"));
|
|
|
|
|
QJsonArray jsonArray = arrayValue.toArray();
|
|
|
|
|
for (int i = 0; i < jsonArray.size() ; i++) {
|
|
|
|
|
QJsonValue arrayValue = jsonArray[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()
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
QString name = QCoreApplication::applicationDirPath() + "\\config\\UnitBoardsInfo.json";
|
|
|
|
|
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');").\
|
|
|
|
|
arg("NULL").arg(2).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("").\
|
2023-04-27 19:48:15 +08:00
|
|
|
arg("true").arg(strMAC).arg(0).arg(1000).arg(0).arg("Hamming").arg("15000").arg("0.5").arg(10).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("false").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("峰峰值");
|
2023-04-14 19:30:30 +08:00
|
|
|
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');").\
|
|
|
|
|
arg("NULL").arg(2).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("").\
|
2023-04-27 19:48:15 +08:00
|
|
|
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("false").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("平均值");
|
2023-04-14 19:30:30 +08:00
|
|
|
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');").\
|
|
|
|
|
arg("NULL").arg(2).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("").\
|
2023-04-27 19:48:15 +08:00
|
|
|
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).\
|
2023-04-14 19:30:30 +08:00
|
|
|
arg("mA").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("false").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');").\
|
|
|
|
|
arg("NULL").arg(2).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("").\
|
2023-04-27 19:48:15 +08:00
|
|
|
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).\
|
2023-04-14 19:30:30 +08:00
|
|
|
arg("").arg("").arg("").arg(0).arg(BoardNo).arg(i+1).arg("").arg("false").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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<ChannelSetting>().swap(g_channelSetting);
|
|
|
|
|
QVector<channelBaseInfo>().swap(g_ChannelBaseInfo);
|
|
|
|
|
QMap<QString,QMap<QString,QString>>().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);
|
|
|
|
|
QString fileName = QCoreApplication::applicationDirPath() + "\\config\\UnitWorkConditionsInfo.json";
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
QJsonDocument jsonDocTri;
|
|
|
|
|
QJsonObject TriObj;
|
|
|
|
|
TriObj["NULL"] = "";
|
|
|
|
|
jsonDocTri.setObject(TriObj);
|
|
|
|
|
QString fileNameTri = QCoreApplication::applicationDirPath() + "\\config\\TriggerSettings.json";
|
|
|
|
|
|
|
|
|
|
QFile fileTri(fileNameTri);
|
|
|
|
|
fileTri.open(QIODevice::WriteOnly);
|
|
|
|
|
fileTri.write(jsonDocTri.toJson());
|
|
|
|
|
fileTri.close();
|
|
|
|
|
|
|
|
|
|
QJsonDocument jsonDocUnit;
|
|
|
|
|
QJsonObject UnitObj;
|
|
|
|
|
UnitObj["NULL"] = "";
|
|
|
|
|
jsonDocUnit.setObject(UnitObj);
|
|
|
|
|
QString fileNameUnit = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations.json";
|
|
|
|
|
|
|
|
|
|
QFile fileUnit(fileNameUnit);
|
|
|
|
|
fileUnit.open(QIODevice::WriteOnly);
|
|
|
|
|
fileUnit.write(jsonDocUnit.toJson());
|
|
|
|
|
fileUnit.close();
|
|
|
|
|
|
|
|
|
|
g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting");
|
|
|
|
|
for (int i = 0; i < g_channelSetting.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
QMap<QString,QString> 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;
|
|
|
|
|
g_ChannelBaseInfo.append(tempchannelbaseinfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|