增加主视图通道自动对齐,警报描述精简化,触发条件和工况条件存储时增加当前条件的操作状态
This commit is contained in:
parent
5623d4844b
commit
77b7e2c846
@ -5,6 +5,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
|
|
||||||
CChannelList::CChannelList(QWidget *parent) :
|
CChannelList::CChannelList(QWidget *parent) :
|
||||||
@ -532,7 +533,18 @@ void CChannelList::slotRowDoubleClicked(const QModelIndex &index)
|
|||||||
SlowSpeeddialog->show();
|
SlowSpeeddialog->show();
|
||||||
|
|
||||||
}else if(g_channelSetting[m_nCurRow].boardType.toInt() == 6 && g_channelSetting[i].channelId == g_channelSetting[m_nCurRow].channelId){//开入开出板卡
|
}else if(g_channelSetting[m_nCurRow].boardType.toInt() == 6 && g_channelSetting[i].channelId == g_channelSetting[m_nCurRow].channelId){//开入开出板卡
|
||||||
|
QString strTips = "输入开入开出板卡通道名称";
|
||||||
|
bool ok;
|
||||||
|
QString channleName = QInputDialog::getText(this, tr("输入名称对话框"), strTips, QLineEdit::Normal,"",&ok);
|
||||||
|
if(!ok) return;
|
||||||
|
qDebug() << channleName << endl;
|
||||||
|
QString strUpdateSql = QString(" set channelName = '%1' where sensorModuleNo = %2 and sensorNo = %3 ")\
|
||||||
|
.arg(channleName).arg(g_channelSetting[m_nCurRow].sensorModuleNo).arg(g_channelSetting[m_nCurRow].sensorNo);
|
||||||
|
QString tableName = "t_ChannelSetting ";
|
||||||
|
g_SqliteDB->UpdateDataSql(tableName,strUpdateSql);
|
||||||
|
|
||||||
|
g_channelSetting = g_SqliteDB->GetDataMultiLine("t_ChannelSetting");
|
||||||
|
putJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,9 +61,7 @@ void CCharacteristicList::DisPlayCharacteristic()
|
|||||||
model->setRowCount( g_Charateristic.size());
|
model->setRowCount( g_Charateristic.size());
|
||||||
|
|
||||||
for (int i = 0; i < g_ChannelBaseInfo.size(); i++)
|
for (int i = 0; i < g_ChannelBaseInfo.size(); i++)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int j = 0; j < g_Charateristic.size(); j++) {
|
for (int j = 0; j < g_Charateristic.size(); j++) {
|
||||||
if(g_Charateristic[j].ChannelID == g_ChannelBaseInfo[i].channelID \
|
if(g_Charateristic[j].ChannelID == g_ChannelBaseInfo[i].channelID \
|
||||||
&& g_Charateristic[j].channelType != "DI" && g_Charateristic[j].channelType != "DO")
|
&& g_Charateristic[j].channelType != "DI" && g_Charateristic[j].channelType != "DO")
|
||||||
@ -81,7 +79,6 @@ void CCharacteristicList::DisPlayCharacteristic()
|
|||||||
}else if(g_ChannelBaseInfo[i].defaultDisplay == "转速"){
|
}else if(g_ChannelBaseInfo[i].defaultDisplay == "转速"){
|
||||||
model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].speedRPM,'f',g_Charateristic[j].ChUnitDot));
|
model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].speedRPM,'f',g_Charateristic[j].ChUnitDot));
|
||||||
}
|
}
|
||||||
//qDebug() << g_ChannelBaseInfo[i].boardType << g_Charateristic[j].DCValues <<endl;
|
|
||||||
if(g_ChannelBaseInfo[i].boardType == "5"){
|
if(g_ChannelBaseInfo[i].boardType == "5"){
|
||||||
model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].DCValues,'f',g_Charateristic[j].ChUnitDot));
|
model->setData(model->index(j,2,QModelIndex()),QString::number(g_Charateristic[j].DCValues,'f',g_Charateristic[j].ChUnitDot));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,19 +131,21 @@ void CConfiguration::Init()
|
|||||||
int xDangerOverEnabled = arrayConfig.at(k)["xDangerOverEnabled"].toInt();
|
int xDangerOverEnabled = arrayConfig.at(k)["xDangerOverEnabled"].toInt();
|
||||||
int xDangerUnderEnabled = arrayConfig.at(k)["xDangerUnderEnabled"].toInt();
|
int xDangerUnderEnabled = arrayConfig.at(k)["xDangerUnderEnabled"].toInt();
|
||||||
if(xAlertOverEnabled == 1){
|
if(xAlertOverEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"警报"));
|
item = new QStandardItem(QString(channelName + "-" + "高于警报值"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xAlertUnderEnabled == 1){
|
if(xAlertUnderEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"警报"));
|
item = new QStandardItem(QString(channelName + "-" + "低于警报值"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xDangerOverEnabled == 1){
|
if(xDangerOverEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"危险"));
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"危险"));
|
||||||
|
item = new QStandardItem(QString(channelName + "-" + "高于危险值"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xDangerUnderEnabled == 1){
|
if(xDangerUnderEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"危险"));
|
item = new QStandardItem(QString(channelName + "-" + "低于危险值"));
|
||||||
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"危险"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,13 +186,67 @@ void CConfiguration::LoadConfiguration()
|
|||||||
|
|
||||||
void CConfiguration::slotDeleteItem()
|
void CConfiguration::slotDeleteItem()
|
||||||
{
|
{
|
||||||
|
int BoardNo,ChannelNoInBoard;
|
||||||
|
QString ChannelId,ChannelName,SN;
|
||||||
|
QString strTableName = " t_UnitConfiguration ";
|
||||||
|
QJsonObject jsonObj;
|
||||||
|
QJsonObject logicObj,ConfiguraitonsObj,ConfiguraitonsWCObj;
|
||||||
|
QJsonArray logicExpressArray,ConfiguraitonsArray;
|
||||||
QModelIndex curIndex = ui->treeView_Relay->currentIndex();
|
QModelIndex curIndex = ui->treeView_Relay->currentIndex();
|
||||||
//QModelIndex index = curIndex.sibling(curIndex.row(),0); //同一行第一列元素的index
|
|
||||||
if(curIndex.isValid())
|
if(curIndex.isValid())
|
||||||
{
|
{
|
||||||
QStandardItem* item = model_Relay->itemFromIndex(curIndex);
|
QStandardItem* item = model_Relay->itemFromIndex(curIndex);
|
||||||
QString text = item->text();
|
QString nodeText = item->text();
|
||||||
qDebug() << text <<endl;
|
qDebug() << nodeText <<endl;
|
||||||
|
QString strWC = ui->comboBox_WC->currentText();
|
||||||
|
|
||||||
|
for (int i = 0; i < m_WorkCondition.size(); i++) {
|
||||||
|
if(m_WorkCondition[i].WorkConditionName == ui->comboBox_WC->currentText()){
|
||||||
|
SN = m_WorkCondition[i].SN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < g_ChannelBaseInfo.size(); i++) {
|
||||||
|
if(g_ChannelBaseInfo[i].bordNo == 10 && g_ChannelBaseInfo[i].channelNoInBoard == m_curentRLY){
|
||||||
|
BoardNo = g_ChannelBaseInfo[i].bordNo;
|
||||||
|
ChannelId = g_ChannelBaseInfo[i].channelID;
|
||||||
|
ChannelName = g_ChannelBaseInfo[i].channelName;
|
||||||
|
ChannelNoInBoard = g_ChannelBaseInfo[i].channelNoInBoard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nodeText.contains("logicOR") || nodeText.contains("logicAND")){
|
||||||
|
QString strSql = QString(" values('%1','%2',%3,%4,'',4)").arg(SN).arg(ChannelId).arg(BoardNo).arg(ChannelNoInBoard);
|
||||||
|
g_SqliteDB->InsertData(strTableName,strSql);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
QStandardItem* parantitem = item->parent();
|
||||||
|
QString paranNodeText = parantitem->text();
|
||||||
|
if(paranNodeText.contains("logicAND")){
|
||||||
|
|
||||||
|
if(nodeText.contains("警报")){
|
||||||
|
jsonObj["alarm"] = 1;
|
||||||
|
jsonObj["danger"] = 0;
|
||||||
|
}else if (nodeText.contains("危险")) {
|
||||||
|
jsonObj["danger"] = 1;
|
||||||
|
jsonObj["alarm"] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObj["triggerFeatureName"] = nodeText;
|
||||||
|
jsonObj["nodeType"] = 1;
|
||||||
|
jsonObj["displayTitle"] = nodeText;
|
||||||
|
for (int k = 0;k < g_ChannelBaseInfo.size(); k++) {
|
||||||
|
if(g_ChannelBaseInfo[k].channelName == nodeText.split("-")[0]){
|
||||||
|
jsonObj["channelId"] = g_ChannelBaseInfo[k].channelID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonObj["channelOperate"] = 3;
|
||||||
|
|
||||||
|
QJsonDocument doc(jsonObj);
|
||||||
|
QString strJson(doc.toJson(QJsonDocument::Compact));
|
||||||
|
QString strSql = QString(" values('%1','%2','%3','%4','%5',3)").arg(SN).arg(ChannelId).arg(BoardNo).arg(ChannelNoInBoard).arg(strJson);
|
||||||
|
g_SqliteDB->InsertData(strTableName,strSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
model_Relay->removeRow(curIndex.row(),curIndex.parent());
|
model_Relay->removeRow(curIndex.row(),curIndex.parent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,8 +300,8 @@ void CConfiguration::on_treeView_Relay_customContextMenuRequested(const QPoint &
|
|||||||
|
|
||||||
QJsonArray CConfiguration::GetItem(QStandardItem *item,int MinimumNumber)
|
QJsonArray CConfiguration::GetItem(QStandardItem *item,int MinimumNumber)
|
||||||
{
|
{
|
||||||
QJsonArray arrayAll;
|
QJsonArray arrayAll,arrayAll2;
|
||||||
QJsonObject jsonObj,inputObj,MinimumNumberObj;
|
QJsonObject jsonObj,inputObj,inputObj2,MinimumNumberObj;
|
||||||
QString strLogic;
|
QString strLogic;
|
||||||
if(item->hasChildren())
|
if(item->hasChildren())
|
||||||
{
|
{
|
||||||
@ -255,7 +311,7 @@ QJsonArray CConfiguration::GetItem(QStandardItem *item,int MinimumNumber)
|
|||||||
QStandardItem * childitem = item->child(i);
|
QStandardItem * childitem = item->child(i);
|
||||||
strLogic = childitem->text();
|
strLogic = childitem->text();
|
||||||
if(childitem->text().contains("logicOR") || childitem->text().contains("logicAND")){
|
if(childitem->text().contains("logicOR") || childitem->text().contains("logicAND")){
|
||||||
QJsonArray inputArray;
|
QJsonArray inputArray,inputArray2;
|
||||||
if(childitem->hasChildren()){
|
if(childitem->hasChildren()){
|
||||||
for(int i = 0;i < childitem->rowCount() ;i++){
|
for(int i = 0;i < childitem->rowCount() ;i++){
|
||||||
QStandardItem * childitem2 = childitem->child(i);
|
QStandardItem * childitem2 = childitem->child(i);
|
||||||
@ -269,30 +325,51 @@ QJsonArray CConfiguration::GetItem(QStandardItem *item,int MinimumNumber)
|
|||||||
jsonObj["triggerFeatureName"] = childitem2->text();
|
jsonObj["triggerFeatureName"] = childitem2->text();
|
||||||
jsonObj["nodeType"] = 1;
|
jsonObj["nodeType"] = 1;
|
||||||
jsonObj["displayTitle"] = childitem2->text();
|
jsonObj["displayTitle"] = childitem2->text();
|
||||||
jsonObj["channelId"] = childitem2->text().split("-")[3];
|
for (int k = 0;k < g_ChannelBaseInfo.size(); k++) {
|
||||||
|
if(g_ChannelBaseInfo[k].channelName == childitem2->text().split("-")[0]){
|
||||||
|
jsonObj["channelId"] = g_ChannelBaseInfo[k].channelID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inputArray.append(jsonObj);
|
inputArray.append(jsonObj);
|
||||||
|
inputArray2.append(jsonObj);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
QMessageBox::question(this, QStringLiteral("提示"), QStringLiteral("请选择正确的逻辑!"));
|
QMessageBox::question(this, QStringLiteral("提示"), QStringLiteral("请选择正确的逻辑!"));
|
||||||
return arrayAll;
|
return arrayAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString strTableName = " t_UnitConfiguration ";
|
||||||
|
QVector<UnitConfiguration_t> vecUnitConfiguration = g_SqliteDB->GetUnitConfigurationInfo(strTableName);
|
||||||
|
for (int i = 0; i < vecUnitConfiguration.size(); i++) {
|
||||||
|
if(vecUnitConfiguration[i].Operate == 3){
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson(vecUnitConfiguration[i].Input.toUtf8());
|
||||||
|
QJsonObject jsonObj = document.object();
|
||||||
|
inputArray2.append(jsonObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputObj2["Inputs"] = inputArray2;
|
||||||
inputObj["Inputs"] = inputArray;
|
inputObj["Inputs"] = inputArray;
|
||||||
|
|
||||||
MinimumNumber = childitem->data(Qt::UserRole + 1).toInt();
|
MinimumNumber = childitem->data(Qt::UserRole + 1).toInt();
|
||||||
qDebug()<< "MinimumNumber" <<MinimumNumber<< endl;
|
qDebug()<< "MinimumNumber" <<MinimumNumber<< endl;
|
||||||
MinimumNumberObj["MinimumNumber"] = MinimumNumber;
|
MinimumNumberObj["MinimumNumber"] = MinimumNumber;
|
||||||
inputObj["Combination"] = MinimumNumberObj;
|
inputObj["Combination"] = MinimumNumberObj;
|
||||||
|
inputObj2["Combination"] = MinimumNumberObj;
|
||||||
arrayAll.append(inputObj);
|
arrayAll.append(inputObj);
|
||||||
//qDebug() << "m_array"<<m_array << childitem->data(1) << endl;
|
arrayAll2.append(inputObj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QJsonObject jsonObjLogic;
|
QJsonObject jsonObjLogic,jsonObjLogic2;
|
||||||
qDebug() << "strLogic" << strLogic.left(strLogic.length()-3) << endl;
|
qDebug() << "strLogic" << strLogic.left(strLogic.length()-3) << endl;
|
||||||
jsonObjLogic[strLogic.left(strLogic.length()-3)] = arrayAll;
|
jsonObjLogic[strLogic.left(strLogic.length()-3)] = arrayAll;
|
||||||
|
jsonObjLogic2[strLogic.left(strLogic.length()-3)] = arrayAll2;
|
||||||
QJsonArray ret;
|
QJsonArray ret;
|
||||||
ret.append(jsonObjLogic);
|
ret.append(jsonObjLogic);
|
||||||
|
m_deleteInputArray.append(jsonObjLogic2);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
||||||
@ -351,6 +428,7 @@ QJsonObject CConfiguration::SelectChannel(int channelNo)
|
|||||||
ConfiguraitonsObj["ChannelId"] = g_ChannelBaseInfo[i].channelID;
|
ConfiguraitonsObj["ChannelId"] = g_ChannelBaseInfo[i].channelID;
|
||||||
ConfiguraitonsObj["ChannelName"] = g_ChannelBaseInfo[i].channelName;
|
ConfiguraitonsObj["ChannelName"] = g_ChannelBaseInfo[i].channelName;
|
||||||
ConfiguraitonsObj["ChannelNoInBoard"] = g_ChannelBaseInfo[i].channelNoInBoard;
|
ConfiguraitonsObj["ChannelNoInBoard"] = g_ChannelBaseInfo[i].channelNoInBoard;
|
||||||
|
ConfiguraitonsObj["ChannelOperate"] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ConfiguraitonsObj;
|
return ConfiguraitonsObj;
|
||||||
@ -379,8 +457,8 @@ void CConfiguration::on_pushButton_save_clicked()
|
|||||||
void CConfiguration::on_pushButton_confirm_clicked()
|
void CConfiguration::on_pushButton_confirm_clicked()
|
||||||
{
|
{
|
||||||
|
|
||||||
QJsonObject logicObj,ConfiguraitonsObj,ConfiguraitonsWCObj;
|
QJsonObject logicObj,logicObj2,ConfiguraitonsObj,ConfiguraitonsObj2,ConfiguraitonsWCObj,ConfiguraitonsWCObj2;
|
||||||
QJsonArray logicExpressArray,ConfiguraitonsArray;
|
QJsonArray logicExpressArray,logicExpressArray2,ConfiguraitonsArray,ConfiguraitonsArray2;
|
||||||
int flag = -1;
|
int flag = -1;
|
||||||
if(ui->radioButton_1->isChecked()){
|
if(ui->radioButton_1->isChecked()){
|
||||||
flag = 1;
|
flag = 1;
|
||||||
@ -440,21 +518,38 @@ void CConfiguration::on_pushButton_confirm_clicked()
|
|||||||
if(arrayAll.size() < 1)
|
if(arrayAll.size() < 1)
|
||||||
return;
|
return;
|
||||||
logicObj[item->text().left(7)] = arrayAll;
|
logicObj[item->text().left(7)] = arrayAll;
|
||||||
|
logicObj2[item->text().left(7)] = m_deleteInputArray;
|
||||||
logicExpressArray.append(logicObj);
|
logicExpressArray.append(logicObj);
|
||||||
|
logicExpressArray2.append(logicObj2);
|
||||||
}
|
}
|
||||||
|
ConfiguraitonsObj2 = ConfiguraitonsObj;
|
||||||
ConfiguraitonsObj["logicExpress"] = logicExpressArray;
|
ConfiguraitonsObj["logicExpress"] = logicExpressArray;
|
||||||
|
ConfiguraitonsObj2["logicExpress"] = logicExpressArray2;
|
||||||
|
|
||||||
|
QString strTableName = " t_UnitConfiguration ";
|
||||||
|
QVector<UnitConfiguration_t> vecUnitConfiguration = g_SqliteDB->GetUnitConfigurationInfo(strTableName);
|
||||||
|
for (int i = 0; i < vecUnitConfiguration.size(); i++) {
|
||||||
|
if(vecUnitConfiguration[i].Operate == 3){
|
||||||
|
ConfiguraitonsObj2["ChannelOperate"] = 3;
|
||||||
|
}else if(vecUnitConfiguration[i].Operate == 4){
|
||||||
|
ConfiguraitonsObj2["ChannelOperate"] = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "m_deleteInputObj" << ConfiguraitonsArray2 << endl;
|
||||||
ConfiguraitonsArray.append(ConfiguraitonsObj);
|
ConfiguraitonsArray.append(ConfiguraitonsObj);
|
||||||
|
ConfiguraitonsArray2.append(ConfiguraitonsObj2);
|
||||||
QJsonArray().swap(m_array);
|
QJsonArray().swap(m_array);
|
||||||
QJsonArray().swap(m_arrayAll);
|
QJsonArray().swap(m_arrayAll);
|
||||||
|
|
||||||
|
if(ui->lineEdit_2->text() == ""){
|
||||||
|
|
||||||
if(ui->lineEdit_2->text() == "")
|
|
||||||
ConfiguraitonsWCObj["SecondDelaySeconds"] = "0";
|
ConfiguraitonsWCObj["SecondDelaySeconds"] = "0";
|
||||||
else
|
ConfiguraitonsWCObj2["SecondDelaySeconds"] = "0";
|
||||||
|
}
|
||||||
|
else{
|
||||||
ConfiguraitonsWCObj["SecondDelaySeconds"] = ui->lineEdit_2->text();
|
ConfiguraitonsWCObj["SecondDelaySeconds"] = ui->lineEdit_2->text();
|
||||||
|
ConfiguraitonsWCObj2["SecondDelaySeconds"] = ui->lineEdit_2->text();
|
||||||
|
}
|
||||||
|
|
||||||
QString strCurrentSN = "";
|
QString strCurrentSN = "";
|
||||||
for (int i = 0; i < m_WorkCondition.size(); i++) {
|
for (int i = 0; i < m_WorkCondition.size(); i++) {
|
||||||
@ -462,9 +557,15 @@ void CConfiguration::on_pushButton_confirm_clicked()
|
|||||||
ConfiguraitonsWCObj["SN"] = m_WorkCondition[i].SN;
|
ConfiguraitonsWCObj["SN"] = m_WorkCondition[i].SN;
|
||||||
strCurrentSN = m_WorkCondition[i].SN;
|
strCurrentSN = m_WorkCondition[i].SN;
|
||||||
ConfiguraitonsWCObj["WorkConditionName"] = m_WorkCondition[i].WorkConditionName;
|
ConfiguraitonsWCObj["WorkConditionName"] = m_WorkCondition[i].WorkConditionName;
|
||||||
|
|
||||||
|
ConfiguraitonsWCObj2["SN"] = m_WorkCondition[i].SN;
|
||||||
|
ConfiguraitonsWCObj2["WorkConditionName"] = m_WorkCondition[i].WorkConditionName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConfiguraitonsWCObj["Configuraitons"] = ConfiguraitonsArray;
|
ConfiguraitonsWCObj["Configuraitons"] = ConfiguraitonsArray;
|
||||||
|
ConfiguraitonsWCObj2["Configuraitons"] = ConfiguraitonsArray2;
|
||||||
|
|
||||||
|
//防止点击重复应用
|
||||||
if(m_vecWorkConditionObj.size() > 0){
|
if(m_vecWorkConditionObj.size() > 0){
|
||||||
QVector<QJsonObject> vecWorkConditionObj = m_vecWorkConditionObj;
|
QVector<QJsonObject> vecWorkConditionObj = m_vecWorkConditionObj;
|
||||||
int flag = -1,flag2 = -1;
|
int flag = -1,flag2 = -1;
|
||||||
@ -498,6 +599,43 @@ void CConfiguration::on_pushButton_confirm_clicked()
|
|||||||
}else{
|
}else{
|
||||||
m_vecWorkConditionObj.append(ConfiguraitonsWCObj);
|
m_vecWorkConditionObj.append(ConfiguraitonsWCObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_vecWorkConditionObj2.size() > 0){
|
||||||
|
QVector<QJsonObject> vecWorkConditionObj = m_vecWorkConditionObj2;
|
||||||
|
int flag = -1,flag2 = -1;
|
||||||
|
for (int i = 0; i < vecWorkConditionObj.size(); i++){
|
||||||
|
if(vecWorkConditionObj.at(i)["SN"].toString() == strCurrentSN){
|
||||||
|
flag = 1;
|
||||||
|
QJsonArray configuraitonsArray = vecWorkConditionObj.at(i)["Configuraitons"].toArray();
|
||||||
|
QJsonArray tempArray = configuraitonsArray;
|
||||||
|
for (int j = 0; j < configuraitonsArray.size(); j++) {
|
||||||
|
if(ConfiguraitonsObj2["ChannelId"].toString() == configuraitonsArray.at(j)["ChannelId"].toString()){
|
||||||
|
flag2 = 1;
|
||||||
|
for (int ii = 0; ii < tempArray.size(); ii++) {
|
||||||
|
if(tempArray.at(ii)["ChannelId"].toString() == ConfiguraitonsObj2["ChannelId"].toString()){
|
||||||
|
tempArray.removeAt(ii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tempArray.append(ConfiguraitonsObj2);
|
||||||
|
}
|
||||||
|
if(j + 1 == configuraitonsArray.size() && flag2 == -1){
|
||||||
|
tempArray.append(ConfiguraitonsObj2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConfiguraitonsWCObj2["Configuraitons"] = tempArray;
|
||||||
|
m_vecWorkConditionObj2.removeAt(i);
|
||||||
|
m_vecWorkConditionObj2.append(ConfiguraitonsWCObj2);
|
||||||
|
}
|
||||||
|
if( i + 1 == vecWorkConditionObj.size() && flag == -1){
|
||||||
|
m_vecWorkConditionObj2.append(ConfiguraitonsWCObj2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
m_vecWorkConditionObj2.append(ConfiguraitonsWCObj2);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray().swap(m_deleteInputArray);
|
||||||
|
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("应用成功!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -540,21 +678,27 @@ void CConfiguration::on_comboBox_WC_currentTextChanged2(const QString &arg1)
|
|||||||
int xDangerOverEnabled = arrayConfig.at(k)["xDangerOverEnabled"].toInt();
|
int xDangerOverEnabled = arrayConfig.at(k)["xDangerOverEnabled"].toInt();
|
||||||
int xDangerUnderEnabled = arrayConfig.at(k)["xDangerUnderEnabled"].toInt();
|
int xDangerUnderEnabled = arrayConfig.at(k)["xDangerUnderEnabled"].toInt();
|
||||||
if(xAlertOverEnabled == 1){
|
if(xAlertOverEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"警报"));
|
|
||||||
|
item = new QStandardItem(QString(channelName + "-" + "高于警报值"));
|
||||||
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"警报"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xAlertUnderEnabled == 1){
|
if(xAlertUnderEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"警报"));
|
item = new QStandardItem(QString(channelName + "-" + "低于警报值"));
|
||||||
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"警报"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xDangerOverEnabled == 1){
|
if(xDangerOverEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"危险"));
|
item = new QStandardItem(QString(channelName + "-" + "高于危险值"));
|
||||||
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Over-"+"危险"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
if(xDangerUnderEnabled == 1){
|
if(xDangerUnderEnabled == 1){
|
||||||
item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"危险"));
|
item = new QStandardItem(QString(channelName + "-" + "低于危险值"));
|
||||||
|
//item = new QStandardItem(QString(channelName + "-" + str + "-Under-"+"危险"));
|
||||||
itemChannel->appendRow(item);
|
itemChannel->appendRow(item);
|
||||||
}
|
}
|
||||||
|
itemChannel->setData(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,38 +717,95 @@ void CConfiguration::PushData()
|
|||||||
}
|
}
|
||||||
m_isConfirm = -1;
|
m_isConfirm = -1;
|
||||||
|
|
||||||
|
QJsonArray WorkConditionConfiguraitonsArray2;
|
||||||
if(m_vecWorkConditionObj.size() > 0){
|
if(m_vecWorkConditionObj.size() > 0){
|
||||||
for (int i = 0; i < m_vecWorkConditionObj.size(); i++) {
|
for (int i = 0; i < m_vecWorkConditionObj.size(); i++) {
|
||||||
m_WorkConditionConfiguraitonsArray.append(m_vecWorkConditionObj[i]);
|
m_WorkConditionConfiguraitonsArray.append(m_vecWorkConditionObj[i]);
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < m_vecWorkConditionObj2.size(); i++) {
|
||||||
|
WorkConditionConfiguraitonsArray2.append(m_vecWorkConditionObj2[i]);
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
m_WorkConditionConfiguraitonsArray.append(m_ConfiguraitonsWCObj);
|
m_WorkConditionConfiguraitonsArray.append(m_ConfiguraitonsWCObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject WorkConditionConfiguraitonsObj,WorkConditionConfiguraitonsObj2;
|
||||||
QJsonObject WorkConditionConfiguraitonsObj;
|
|
||||||
WorkConditionConfiguraitonsObj["WorkConditionConfiguraitons"] = m_WorkConditionConfiguraitonsArray;
|
WorkConditionConfiguraitonsObj["WorkConditionConfiguraitons"] = m_WorkConditionConfiguraitonsArray;
|
||||||
//qDebug() << WorkConditionConfiguraitonsObj << endl;
|
WorkConditionConfiguraitonsObj2["WorkConditionConfiguraitons"] = WorkConditionConfiguraitonsArray2;
|
||||||
|
|
||||||
QJsonDocument jsonDoc;
|
QJsonDocument jsonDoc;
|
||||||
jsonDoc.setObject(WorkConditionConfiguraitonsObj);
|
jsonDoc.setObject(WorkConditionConfiguraitonsObj);
|
||||||
QString fileName = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations.json";
|
QString fileName = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations.json";
|
||||||
|
|
||||||
|
QJsonDocument jsonDoc2;
|
||||||
|
jsonDoc2.setObject(WorkConditionConfiguraitonsObj2);
|
||||||
|
QString fileName2 = QCoreApplication::applicationDirPath() + "\\config\\UnitConfigurations2.json";
|
||||||
|
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
file.write(jsonDoc.toJson());
|
file.write(jsonDoc.toJson());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
QFile file2(fileName2);
|
||||||
|
file2.open(QIODevice::WriteOnly);
|
||||||
|
file2.write(jsonDoc2.toJson());
|
||||||
|
file2.close();
|
||||||
|
|
||||||
|
// QString strTableName = " t_UnitConfiguration ";
|
||||||
|
// QVector<UnitConfiguration_t> vecUnitConfiguration = g_SqliteDB->GetUnitConfigurationInfo(strTableName);
|
||||||
|
|
||||||
|
// for (int i = 0; i < m_WorkConditionConfiguraitonsArray.size(); i++) {
|
||||||
|
// for (int j = 0; j < vecUnitConfiguration.size(); j++) {
|
||||||
|
// QJsonObject WorkConditionConfiguraitonsObj = m_WorkConditionConfiguraitonsArray.at(i).toObject();
|
||||||
|
// if(WorkConditionConfiguraitonsObj["SN"].toString() == vecUnitConfiguration[j].WorkConditionID){
|
||||||
|
// QJsonArray ConfiguraitonsArray = WorkConditionConfiguraitonsObj["Configuraitons"].toArray();
|
||||||
|
// for (int k = 0; k < ConfiguraitonsArray.size(); k++) {
|
||||||
|
// QJsonObject ConfiguraitonsObj = ConfiguraitonsArray[k].toObject();
|
||||||
|
// if(ConfiguraitonsObj["ChannelId"].toString() == vecUnitConfiguration[j].ChannelID){
|
||||||
|
// if(vecUnitConfiguration[j].Operate == 3){
|
||||||
|
// QJsonArray UnitConfigurationArray = m_WorkConditionConfiguraitonsArray.at(i).toArray();
|
||||||
|
// ConfiguraitonsObj["ChannelOperate"] = 3;
|
||||||
|
// ConfiguraitonsArray[k] = ConfiguraitonsObj;
|
||||||
|
// WorkConditionConfiguraitonsObj["Configuraitons"] = ConfiguraitonsArray;
|
||||||
|
// m_WorkConditionConfiguraitonsArray.removeAt(i);
|
||||||
|
// m_WorkConditionConfiguraitonsArray.insert(i, WorkConditionConfiguraitonsObj);
|
||||||
|
// }else if(vecUnitConfiguration[j].Operate == 4){
|
||||||
|
// QJsonArray UnitConfigurationArray = m_WorkConditionConfiguraitonsArray.at(i).toArray();
|
||||||
|
// ConfiguraitonsObj["ChannelOperate"] = 4;
|
||||||
|
// ConfiguraitonsArray[k] = ConfiguraitonsObj;
|
||||||
|
// WorkConditionConfiguraitonsObj["Configuraitons"] = ConfiguraitonsArray;
|
||||||
|
// m_WorkConditionConfiguraitonsArray.removeAt(i);
|
||||||
|
// m_WorkConditionConfiguraitonsArray.insert(i, WorkConditionConfiguraitonsObj);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
qDebug() << WorkConditionConfiguraitonsArray2 << endl;
|
||||||
|
qDebug() << m_WorkConditionConfiguraitonsArray << endl;
|
||||||
|
|
||||||
QJsonArray().swap(m_WorkConditionConfiguraitonsArray);
|
QJsonArray().swap(m_WorkConditionConfiguraitonsArray);
|
||||||
QJsonArray().swap(m_array);
|
QJsonArray().swap(m_array);
|
||||||
QJsonArray().swap(m_ConfiguraitonsArray);
|
QJsonArray().swap(m_ConfiguraitonsArray);
|
||||||
//QVector<QJsonObject>().swap(m_vecWorkConditionObj);
|
QJsonArray().swap(m_deleteInputArray);
|
||||||
|
QVector<QJsonObject>().swap(m_vecWorkConditionObj2);
|
||||||
|
|
||||||
|
|
||||||
|
QString tableName = " t_UnitConfiguration ";
|
||||||
|
g_SqliteDB->DeleteDataW(tableName,"");
|
||||||
|
|
||||||
QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations.json");
|
QString str = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations.json");
|
||||||
g_FtpClient->SetServerInfo(str);
|
g_FtpClient->SetServerInfo(str);
|
||||||
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
||||||
g_FtpClient->UpLoadFile(fileName,"UnitConfigurations.json");
|
g_FtpClient->UpLoadFile(fileName,"UnitConfigurations.json");
|
||||||
|
|
||||||
|
QString str2 = QString("ftp://%1/CIDW/qtconfig/%2").arg(IP).arg("UnitConfigurations2.json");
|
||||||
|
g_FtpClient->SetServerInfo(str2);
|
||||||
|
g_FtpClient->SetUserInfo("root","@#cidw!@123456");
|
||||||
|
g_FtpClient->UpLoadFile(fileName2,"UnitConfigurations2.json");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -837,60 +1038,70 @@ void CConfiguration::ViewRelay(int ChannelNoInBoard)
|
|||||||
void CConfiguration::on_radioButton_1_clicked()
|
void CConfiguration::on_radioButton_1_clicked()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_curentRLY = 3;
|
||||||
ViewRelay(3);
|
ViewRelay(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_2_clicked()
|
void CConfiguration::on_radioButton_2_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 4;
|
||||||
ViewRelay(4);
|
ViewRelay(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_3_clicked()
|
void CConfiguration::on_radioButton_3_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 5;
|
||||||
ViewRelay(5);
|
ViewRelay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_4_clicked()
|
void CConfiguration::on_radioButton_4_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 6;
|
||||||
ViewRelay(6);
|
ViewRelay(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_5_clicked()
|
void CConfiguration::on_radioButton_5_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 7;
|
||||||
ViewRelay(7);
|
ViewRelay(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_6_clicked()
|
void CConfiguration::on_radioButton_6_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 8;
|
||||||
ViewRelay(8);
|
ViewRelay(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_8_clicked()
|
void CConfiguration::on_radioButton_8_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 10;
|
||||||
ViewRelay(10);
|
ViewRelay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_7_clicked()
|
void CConfiguration::on_radioButton_7_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 9;
|
||||||
ViewRelay(9);
|
ViewRelay(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_9_clicked()
|
void CConfiguration::on_radioButton_9_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 11;
|
||||||
ViewRelay(11);
|
ViewRelay(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CConfiguration::on_radioButton_10_clicked()
|
void CConfiguration::on_radioButton_10_clicked()
|
||||||
{
|
{
|
||||||
|
m_curentRLY = 12;
|
||||||
ViewRelay(12);
|
ViewRelay(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,17 +70,21 @@ private:
|
|||||||
QJsonArray m_array;
|
QJsonArray m_array;
|
||||||
QJsonArray m_WorkConditionConfiguraitonsArray;
|
QJsonArray m_WorkConditionConfiguraitonsArray;
|
||||||
|
|
||||||
|
QJsonArray m_deleteInputArray;
|
||||||
|
QJsonArray m_deleteConfiguraitonsObj;
|
||||||
//QJsonArray m_ConfiguraitonsArray;
|
//QJsonArray m_ConfiguraitonsArray;
|
||||||
QJsonArray arrayTriggerConfig;
|
QJsonArray arrayTriggerConfig;
|
||||||
QJsonArray m_ConfiguraitonsArray;
|
QJsonArray m_ConfiguraitonsArray;
|
||||||
QJsonObject m_ConfiguraitonsWCObj;
|
QJsonObject m_ConfiguraitonsWCObj;
|
||||||
QVector<QJsonObject> m_vecWorkConditionObj;
|
QVector<QJsonObject> m_vecWorkConditionObj;
|
||||||
|
QVector<QJsonObject> m_vecWorkConditionObj2;
|
||||||
|
|
||||||
void LoadConfiguration();
|
void LoadConfiguration();
|
||||||
QJsonObject SelectChannel(int channelNo);
|
QJsonObject SelectChannel(int channelNo);
|
||||||
void ViewRelay(int ChannelNoInBoard);
|
void ViewRelay(int ChannelNoInBoard);
|
||||||
void PushData();
|
void PushData();
|
||||||
int m_isConfirm;
|
int m_isConfirm;
|
||||||
|
int m_curentRLY;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGURATION_H
|
#endif // CONFIGURATION_H
|
||||||
|
|||||||
@ -22,7 +22,7 @@ CHistoryAlarm::CHistoryAlarm(QWidget *parent) :
|
|||||||
model->setColumnCount(headerList.size());
|
model->setColumnCount(headerList.size());
|
||||||
ui->tableView->setModel(model);
|
ui->tableView->setModel(model);
|
||||||
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
|
||||||
ui->tableView->setColumnWidth(2, 500);
|
ui->tableView->setColumnWidth(2, 300);
|
||||||
ui->tableView->setColumnWidth(3, 200);
|
ui->tableView->setColumnWidth(3, 200);
|
||||||
ui->tableView->setColumnWidth(4, 200);
|
ui->tableView->setColumnWidth(4, 200);
|
||||||
ui->tableView->setAlternatingRowColors(true);
|
ui->tableView->setAlternatingRowColors(true);
|
||||||
@ -39,6 +39,8 @@ CHistoryAlarm::CHistoryAlarm(QWidget *parent) :
|
|||||||
|
|
||||||
ui->comboBox_channel->setView(new QListView());
|
ui->comboBox_channel->setView(new QListView());
|
||||||
|
|
||||||
|
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
|
||||||
connect(ui->comboBox_channel,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(on_comboBox_channel_currentTextChanged(const QString&)));
|
connect(ui->comboBox_channel,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(on_comboBox_channel_currentTextChanged(const QString&)));
|
||||||
|
|
||||||
ui->comboBox_channel->addItem("请选择通道...");
|
ui->comboBox_channel->addItem("请选择通道...");
|
||||||
@ -101,7 +103,20 @@ void CHistoryAlarm::on_pushButton_search_clicked()
|
|||||||
QString resetTime = "";
|
QString resetTime = "";
|
||||||
if(m_vecTriggerAlarmStatusInfo[i].resetTimestamp != 0)
|
if(m_vecTriggerAlarmStatusInfo[i].resetTimestamp != 0)
|
||||||
resetTime = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].resetTimestamp).toString("yyyy-MM-dd hh:mm:ss");
|
resetTime = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].resetTimestamp).toString("yyyy-MM-dd hh:mm:ss");
|
||||||
strRowItem << i + 1 << m_vecTriggerAlarmStatusInfo[i].triggerLevel << m_vecTriggerAlarmStatusInfo[i].triggerEventName << TStr << resetTime;
|
|
||||||
|
QString triggerLevel = "",triggerEventName = "";
|
||||||
|
if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "1"){
|
||||||
|
triggerLevel = "警报";
|
||||||
|
}else if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "2"){
|
||||||
|
triggerLevel = "危险";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Over")){
|
||||||
|
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + "高于" + triggerLevel + "值";
|
||||||
|
}else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Under")){
|
||||||
|
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + "低于" + triggerLevel + "值";
|
||||||
|
}
|
||||||
|
strRowItem << i + 1 << triggerLevel << triggerEventName << TStr << resetTime;
|
||||||
|
|
||||||
createRowItem(i,strRowItem);
|
createRowItem(i,strRowItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,26 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void doubleclick(QGraphicsSceneMouseEvent *event);
|
void doubleclick(QGraphicsSceneMouseEvent *event);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
// void mousePressEvent(QGraphicsSceneMouseEvent* event) override {
|
||||||
|
// // 当鼠标按下时,切换选中状态
|
||||||
|
// isSelected = !isSelected;
|
||||||
|
// update(); // 触发重绘
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override {
|
||||||
|
// QGraphicsItemGroup::paint(painter, option, widget);
|
||||||
|
|
||||||
|
// if (isSelected) {
|
||||||
|
// // 如果项被选中,绘制一个高亮边框
|
||||||
|
// painter->setPen(QPen(Qt::red));
|
||||||
|
// painter->drawRoundRect(boundingRect());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//private:
|
||||||
|
// bool isSelected = false; // 是否被选中
|
||||||
};
|
};
|
||||||
class LineItem : public QGraphicsItem
|
class LineItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,13 +34,13 @@ void CNTPServerConfig::on_pushButton_2_clicked()
|
|||||||
void CNTPServerConfig::slotNetMgr(QString sAddr, const QVariant &msg)
|
void CNTPServerConfig::slotNetMgr(QString sAddr, const QVariant &msg)
|
||||||
{
|
{
|
||||||
QJsonObject objec = msg.value<QJsonObject>();
|
QJsonObject objec = msg.value<QJsonObject>();
|
||||||
|
qDebug() << "msg" << msg << endl;
|
||||||
if(objec.contains("cmd"))
|
if(objec.contains("cmd"))
|
||||||
{
|
{
|
||||||
QJsonValue arrays_value = objec.take("cmd");
|
QJsonValue Json_value = objec.take("cmd");
|
||||||
if(arrays_value.toString() == "02")
|
if(Json_value.toString() == "02")
|
||||||
{
|
{
|
||||||
QJsonObject cmdBodyObj = objec["cmdBody"].toObject();
|
QString arrays_value = objec.take("type").toString();
|
||||||
QJsonValue arrays_value = cmdBodyObj.take("type");
|
|
||||||
if(arrays_value == "SET"){
|
if(arrays_value == "SET"){
|
||||||
bool Status = objec.take("success").toBool();
|
bool Status = objec.take("success").toBool();
|
||||||
QString strMessage = objec.take("message").toString();
|
QString strMessage = objec.take("message").toString();
|
||||||
@ -50,7 +50,7 @@ void CNTPServerConfig::slotNetMgr(QString sAddr, const QVariant &msg)
|
|||||||
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
|
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
|
||||||
}
|
}
|
||||||
}else if(arrays_value == "GET"){
|
}else if(arrays_value == "GET"){
|
||||||
int timestamp_value = cmdBodyObj.take("timeStamp").toInt();
|
int timestamp_value = objec.take("timeStamp").toInt();
|
||||||
QDateTime dateTime;
|
QDateTime dateTime;
|
||||||
|
|
||||||
dateTime.setSecsSinceEpoch(timestamp_value);
|
dateTime.setSecsSinceEpoch(timestamp_value);
|
||||||
@ -184,7 +184,7 @@ void CNTPServerConfig::on_pushButton_get_clicked()
|
|||||||
cmdBody.insert("type","GET");
|
cmdBody.insert("type","GET");
|
||||||
long timeStamp = QDateTime::currentDateTime().toTime_t();
|
long timeStamp = QDateTime::currentDateTime().toTime_t();
|
||||||
QString str = QString("%1").arg(timeStamp);
|
QString str = QString("%1").arg(timeStamp);
|
||||||
cmdBody["timeStamp"] = str.toInt();
|
//cmdBody["timeStamp"] = str.toInt();
|
||||||
allObj["cmdBody"] = cmdBody;
|
allObj["cmdBody"] = cmdBody;
|
||||||
QNetworkRequest req;
|
QNetworkRequest req;
|
||||||
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
||||||
|
|||||||
@ -272,12 +272,12 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>50</x>
|
||||||
<y>50</y>
|
<y>50</y>
|
||||||
<width>54</width>
|
<width>161</width>
|
||||||
<height>12</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>- -</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>905</width>
|
||||||
<height>580</height>
|
<height>580</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -263,7 +263,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>去零漂配置</string>
|
<string>去零漂配置</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
@ -349,7 +349,7 @@
|
|||||||
<widget class="QLineEdit" name="lineEdit_peaktopeak">
|
<widget class="QLineEdit" name="lineEdit_peaktopeak">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>100</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@ -22,7 +22,7 @@ CRealTimeAlarm::CRealTimeAlarm(QWidget *parent) :
|
|||||||
model->setHorizontalHeaderLabels(headerList);
|
model->setHorizontalHeaderLabels(headerList);
|
||||||
model->setColumnCount(headerList.size());
|
model->setColumnCount(headerList.size());
|
||||||
ui->tableView->setModel(model);
|
ui->tableView->setModel(model);
|
||||||
ui->tableView->setColumnWidth(2, 500);
|
ui->tableView->setColumnWidth(2, 300);
|
||||||
ui->tableView->setColumnWidth(3, 200);
|
ui->tableView->setColumnWidth(3, 200);
|
||||||
ui->tableView->setAlternatingRowColors(true);
|
ui->tableView->setAlternatingRowColors(true);
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ CRealTimeAlarm::CRealTimeAlarm(QWidget *parent) :
|
|||||||
// 必须要设置此项,否则样式表的hover无法生效
|
// 必须要设置此项,否则样式表的hover无法生效
|
||||||
ui->tableView->setMouseTracking(true);
|
ui->tableView->setMouseTracking(true);
|
||||||
m_strFileName = "";
|
m_strFileName = "";
|
||||||
|
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
initTable();
|
initTable();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -71,7 +72,19 @@ void CRealTimeAlarm::initTable()
|
|||||||
for (int i = 0; i < m_vecTriggerAlarmStatusInfo.size(); i++) {
|
for (int i = 0; i < m_vecTriggerAlarmStatusInfo.size(); i++) {
|
||||||
QVariantList strRowItem ;
|
QVariantList strRowItem ;
|
||||||
QString TStr = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].timestamp).toString("yyyy-MM-dd hh:mm:ss");
|
QString TStr = QDateTime::fromSecsSinceEpoch(m_vecTriggerAlarmStatusInfo[i].timestamp).toString("yyyy-MM-dd hh:mm:ss");
|
||||||
strRowItem << i + 1 << m_vecTriggerAlarmStatusInfo[i].triggerLevel << m_vecTriggerAlarmStatusInfo[i].triggerEventName << TStr;
|
QString triggerLevel = "",triggerEventName = "";
|
||||||
|
if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "1"){
|
||||||
|
triggerLevel = "警报";
|
||||||
|
}else if(m_vecTriggerAlarmStatusInfo[i].triggerLevel == "2"){
|
||||||
|
triggerLevel = "危险";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Over")){
|
||||||
|
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + "高于" + triggerLevel + "值";
|
||||||
|
}else if(m_vecTriggerAlarmStatusInfo[i].triggerEventName.contains("Under")){
|
||||||
|
triggerEventName = m_vecTriggerAlarmStatusInfo[i].channelName + "-" + "低于" + triggerLevel + "值";
|
||||||
|
}
|
||||||
|
strRowItem << i + 1 << triggerLevel << triggerEventName << TStr;
|
||||||
|
|
||||||
createRowItem(i,strRowItem);
|
createRowItem(i,strRowItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,6 +156,7 @@ void FtpClient::UpLoadFile(const QString fileSource, const QString fileName,int
|
|||||||
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("上传的文件不存在"));
|
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("上传的文件不存在"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
customLogMessageHandler(QtDebugMsg,fileName);
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
QByteArray data = file.readAll(); //转化编码
|
QByteArray data = file.readAll(); //转化编码
|
||||||
//QString result = QString::fromLatin1(fileDest.toStdString().c_str());
|
//QString result = QString::fromLatin1(fileDest.toStdString().c_str());
|
||||||
|
|||||||
9
global.h
9
global.h
@ -268,6 +268,15 @@ typedef struct _TriggerAlarmStatusInfo{
|
|||||||
}
|
}
|
||||||
}TriggerAlarmStatusInfo_t ;
|
}TriggerAlarmStatusInfo_t ;
|
||||||
|
|
||||||
|
typedef struct _UnitConfiguration{
|
||||||
|
QString WorkConditionID;
|
||||||
|
QString ChannelID;
|
||||||
|
int BoardNo;
|
||||||
|
int ChannelNoInBoard;
|
||||||
|
QString Input;
|
||||||
|
int Operate;
|
||||||
|
} UnitConfiguration_t;
|
||||||
|
|
||||||
typedef struct _Charateristic{
|
typedef struct _Charateristic{
|
||||||
double Amp1x;
|
double Amp1x;
|
||||||
double Phase1x;
|
double Phase1x;
|
||||||
|
|||||||
@ -88,7 +88,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
void MainWindow::LoadTrigerConfig()
|
void MainWindow::LoadTrigerConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
|
g_SqliteDB->GetTriggerConfig("t_TriggerConfig","");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +188,6 @@ void MainWindow::initWindow()
|
|||||||
g_MapChannelType.insert("DI","开入");
|
g_MapChannelType.insert("DI","开入");
|
||||||
g_MapChannelType.insert("DO","开出");
|
g_MapChannelType.insert("DO","开出");
|
||||||
g_MapChannelType.insert("AIRGAP","气隙");
|
g_MapChannelType.insert("AIRGAP","气隙");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initStyle()
|
void MainWindow::initStyle()
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <algorithm>
|
||||||
#include "customrectitem.h"
|
#include "customrectitem.h"
|
||||||
#include "mygraphicrectitem.h"
|
#include "mygraphicrectitem.h"
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ CRealTimeForm::CRealTimeForm(QWidget *parent) :
|
|||||||
m_pGraphicsScene->setSceneRect(0,0,600,550);
|
m_pGraphicsScene->setSceneRect(0,0,600,550);
|
||||||
ui->graphicsView->setScene(m_pGraphicsScene);
|
ui->graphicsView->setScene(m_pGraphicsScene);
|
||||||
ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
|
ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
|
||||||
|
ui->graphicsView->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
ui->graphicsView_2->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->graphicsView_2->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
QObject::connect(ui->graphicsView_2 ,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(on_graphView_customContextMenuRequested(const QPoint &)));
|
QObject::connect(ui->graphicsView_2 ,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(on_graphView_customContextMenuRequested(const QPoint &)));
|
||||||
|
|
||||||
@ -50,9 +51,6 @@ CRealTimeForm::CRealTimeForm(QWidget *parent) :
|
|||||||
|
|
||||||
m_pSocket = new QTcpSocket(this);
|
m_pSocket = new QTcpSocket(this);
|
||||||
|
|
||||||
|
|
||||||
//QObject::connect(m_pSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slotStateChanged(QAbstractSocket::SocketState)));
|
|
||||||
|
|
||||||
m_EditMode = 0;
|
m_EditMode = 0;
|
||||||
m_MachineStatus = 1;
|
m_MachineStatus = 1;
|
||||||
//读取ini
|
//读取ini
|
||||||
@ -175,6 +173,8 @@ void CRealTimeForm::on_graphView_customContextMenuRequested(const QPoint &pos)
|
|||||||
pActionRect2 = menu.addAction("矩形框");
|
pActionRect2 = menu.addAction("矩形框");
|
||||||
pActionPixmap = menu.addAction("添加图片");
|
pActionPixmap = menu.addAction("添加图片");
|
||||||
pActionText = menu.addAction("添加文字");
|
pActionText = menu.addAction("添加文字");
|
||||||
|
pActionAlignmentX = menu.addAction("水平分布");
|
||||||
|
pActionAlignmentY = menu.addAction("垂直分布");
|
||||||
pActionEdit = menu.addAction("编辑");
|
pActionEdit = menu.addAction("编辑");
|
||||||
pActionSave = menu.addAction("保存");
|
pActionSave = menu.addAction("保存");
|
||||||
|
|
||||||
@ -186,6 +186,8 @@ void CRealTimeForm::on_graphView_customContextMenuRequested(const QPoint &pos)
|
|||||||
pActionSave->setData(6);
|
pActionSave->setData(6);
|
||||||
pActionEdit->setData(7);
|
pActionEdit->setData(7);
|
||||||
pActionRect2->setData(8);
|
pActionRect2->setData(8);
|
||||||
|
pActionAlignmentX->setData(9);
|
||||||
|
pActionAlignmentY->setData(10);
|
||||||
|
|
||||||
connect(pActionVerticalLine, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
connect(pActionVerticalLine, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
connect(pActionHorizontalLine, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
connect(pActionHorizontalLine, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
@ -195,6 +197,8 @@ void CRealTimeForm::on_graphView_customContextMenuRequested(const QPoint &pos)
|
|||||||
connect(pActionSave, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
connect(pActionSave, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
connect(pActionEdit, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
connect(pActionEdit, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
connect(pActionRect2, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
connect(pActionRect2, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
|
connect(pActionAlignmentX, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
|
connect(pActionAlignmentY, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||||
|
|
||||||
menu.exec(QCursor::pos());
|
menu.exec(QCursor::pos());
|
||||||
//menu.exec(ui->graphicsView->mapToGlobal(pos));
|
//menu.exec(ui->graphicsView->mapToGlobal(pos));
|
||||||
@ -237,6 +241,12 @@ void CRealTimeForm::onTaskBoxContextMenuEvent()
|
|||||||
case 8:
|
case 8:
|
||||||
SetCurDrawType("Rect");
|
SetCurDrawType("Rect");
|
||||||
break;
|
break;
|
||||||
|
case 9:
|
||||||
|
SetAlignmentX();
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
SetAlignmentY();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +255,80 @@ void CRealTimeForm::SetEdit()
|
|||||||
m_EditMode = 1;
|
m_EditMode = 1;
|
||||||
LoadGraphicsConfig(1);
|
LoadGraphicsConfig(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRealTimeForm::SetAlignmentX()
|
||||||
|
{
|
||||||
|
if(!m_EditMode){
|
||||||
|
QMessageBox::information(this, QStringLiteral("提示"), "请先进入编辑模式!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMap<QGraphicsItem*,float> channleAxisX;
|
||||||
|
QList<QGraphicsItem *> items;
|
||||||
|
if(ui->tabWidget->currentIndex() == 0){
|
||||||
|
items = m_pGraphicsScene->items();
|
||||||
|
}else if(ui->tabWidget->currentIndex() == 1){
|
||||||
|
items = m_pGraphicsScene_2->items();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QGraphicsItem *item, items) {
|
||||||
|
QGraphicsItem* graphicsItem = static_cast<QGraphicsItem *>(item);
|
||||||
|
int itemType = graphicsItem->type();
|
||||||
|
if (itemType == 10) {
|
||||||
|
QGraphicsItem* graphicsItem = static_cast<QGraphicsItem *>(item);
|
||||||
|
qDebug() << "itemType" << graphicsItem->data(0) << graphicsItem->isSelected() << endl;
|
||||||
|
if(graphicsItem->isSelected()){
|
||||||
|
channleAxisX.insert(graphicsItem,graphicsItem->x());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QList<float> list = channleAxisX.values();
|
||||||
|
qSort(list);
|
||||||
|
float minValue = list.first();
|
||||||
|
qDebug() << "minValue" << minValue << endl;
|
||||||
|
|
||||||
|
QMap<QGraphicsItem*,float>::iterator iter = channleAxisX.begin();
|
||||||
|
for (; iter != channleAxisX.end(); iter++) {
|
||||||
|
iter.key()->setPos(minValue,iter.key()->y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRealTimeForm::SetAlignmentY()
|
||||||
|
{
|
||||||
|
if(!m_EditMode){
|
||||||
|
QMessageBox::information(this, QStringLiteral("提示"), "请先进入编辑模式!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMap<QGraphicsItem*,float> channleAxisY;
|
||||||
|
QList<QGraphicsItem *> items;
|
||||||
|
if(ui->tabWidget->currentIndex() == 0){
|
||||||
|
items = m_pGraphicsScene->items();
|
||||||
|
}else if(ui->tabWidget->currentIndex() == 1){
|
||||||
|
items = m_pGraphicsScene_2->items();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QGraphicsItem *item, items) {
|
||||||
|
QGraphicsItem* graphicsItem = static_cast<QGraphicsItem *>(item);
|
||||||
|
int itemType = graphicsItem->type();
|
||||||
|
if (itemType == 10) {
|
||||||
|
QGraphicsItem* graphicsItem = static_cast<QGraphicsItem *>(item);
|
||||||
|
if(graphicsItem->isSelected()){
|
||||||
|
channleAxisY.insert(graphicsItem,graphicsItem->y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QList<float> list = channleAxisY.values();
|
||||||
|
qSort(list);
|
||||||
|
float minValue = list.first();
|
||||||
|
qDebug() << "minValue" << minValue << endl;
|
||||||
|
|
||||||
|
QMap<QGraphicsItem*,float>::iterator iter = channleAxisY.begin();
|
||||||
|
int i = 0;
|
||||||
|
for (; iter != channleAxisY.end(); iter++,i++) {
|
||||||
|
iter.key()->setPos(iter.key()->x(),list[0] + i * 40 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo,QString str)
|
void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo,QString str)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -331,11 +415,11 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo,QString str)
|
|||||||
pTextUnits->setData(1,"units");
|
pTextUnits->setData(1,"units");
|
||||||
pTextChannel->setData(2,"channel");
|
pTextChannel->setData(2,"channel");
|
||||||
pTextValue->setData(3,"value");
|
pTextValue->setData(3,"value");
|
||||||
pTextValue->setData(4,str);
|
pTextValue->setData(4,str);//特征值
|
||||||
|
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setPixelSize(16);
|
font.setPixelSize(16);
|
||||||
QFont font2 ( "黑体", 18, 50);
|
QFont font2 ("黑体", 18, 50);
|
||||||
font.setFamily(QStringLiteral("黑体"));
|
font.setFamily(QStringLiteral("黑体"));
|
||||||
pTextUnits->setFont(font);
|
pTextUnits->setFont(font);
|
||||||
pTextUnits->setDefaultTextColor(QColor(27, 30, 35));
|
pTextUnits->setDefaultTextColor(QColor(27, 30, 35));
|
||||||
@ -614,7 +698,6 @@ void CRealTimeForm::SaveGraphicsConfig()
|
|||||||
TextjsonObject.insert("color",QString::number(mRgb, 16));
|
TextjsonObject.insert("color",QString::number(mRgb, 16));
|
||||||
if(itemData2 != "")
|
if(itemData2 != "")
|
||||||
TextjsonObject.insert("static", itemData2);
|
TextjsonObject.insert("static", itemData2);
|
||||||
//qDebug() << "group Text" << pGraphicTextItem->toPlainText();
|
|
||||||
if(itemData == "units")
|
if(itemData == "units")
|
||||||
temp.channelUnit = pGraphicTextItem->toPlainText();
|
temp.channelUnit = pGraphicTextItem->toPlainText();
|
||||||
else if(itemData == "channel")
|
else if(itemData == "channel")
|
||||||
@ -841,7 +924,6 @@ void CRealTimeForm::LoadGraphicsConfig(int type)
|
|||||||
}
|
}
|
||||||
proxy->setGeometry(QRectF(key["x"].toInt(),key["y"].toInt(),0,0));
|
proxy->setGeometry(QRectF(key["x"].toInt(),key["y"].toInt(),0,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// QGraphicsPixmapItem *pPixmap = new QGraphicsPixmapItem(QPixmap(":/image/1.png"));
|
// QGraphicsPixmapItem *pPixmap = new QGraphicsPixmapItem(QPixmap(":/image/1.png"));
|
||||||
// pPixmap->setPos(key["x"].toInt(), key["y"].toInt());
|
// pPixmap->setPos(key["x"].toInt(), key["y"].toInt());
|
||||||
|
|||||||
@ -102,6 +102,8 @@ private:
|
|||||||
QAction *pActionRect2 ;
|
QAction *pActionRect2 ;
|
||||||
QAction *pActionEdit ;
|
QAction *pActionEdit ;
|
||||||
QAction *pActionSave ;
|
QAction *pActionSave ;
|
||||||
|
QAction *pActionAlignmentX ;
|
||||||
|
QAction *pActionAlignmentY ;
|
||||||
int id1; //定时器1的唯一标示
|
int id1; //定时器1的唯一标示
|
||||||
int m_RealtimeLog;
|
int m_RealtimeLog;
|
||||||
int m_MachineStatus;//1 运行 0 停机
|
int m_MachineStatus;//1 运行 0 停机
|
||||||
@ -112,6 +114,8 @@ private:
|
|||||||
void InitChannelInfo();
|
void InitChannelInfo();
|
||||||
void SetCurDrawType(QString strType);
|
void SetCurDrawType(QString strType);
|
||||||
void SetEdit();
|
void SetEdit();
|
||||||
|
void SetAlignmentX();
|
||||||
|
void SetAlignmentY();
|
||||||
void LoadGraphicsConfig(int type);//0 正常,1 编辑 2 停机
|
void LoadGraphicsConfig(int type);//0 正常,1 编辑 2 停机
|
||||||
void SaveGraphicsConfig();
|
void SaveGraphicsConfig();
|
||||||
void UpdateCharacteristic(QVector<_Charateristic>& m_vecCharateristic);
|
void UpdateCharacteristic(QVector<_Charateristic>& m_vecCharateristic);
|
||||||
|
|||||||
57
sqlitedb.cpp
57
sqlitedb.cpp
@ -30,6 +30,13 @@ int SqliteDB::OpenDataBase()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
initTable();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteDB::initTable()
|
||||||
|
{
|
||||||
QString strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
|
QString strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
|
||||||
.arg("sqlite_master").arg("t_ChannelSetting").arg("confidenceDegree");
|
.arg("sqlite_master").arg("t_ChannelSetting").arg("confidenceDegree");
|
||||||
int iRet = ExeSqlData(strSql);
|
int iRet = ExeSqlData(strSql);
|
||||||
@ -65,21 +72,13 @@ int SqliteDB::OpenDataBase()
|
|||||||
strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer";
|
strSql = "ALTER TABLE t_TriggerConfig ADD COLUMN 'operate' integer";
|
||||||
ExeSqlData(strSql);
|
ExeSqlData(strSql);
|
||||||
}
|
}
|
||||||
// strSql = QString("select count(*) from %1 where name = '%2' and sql LIKE '%%3%' ")\
|
|
||||||
// .arg("sqlite_master").arg("t_WorkCondition").arg("operate");
|
|
||||||
// iRet = ExeSqlData(strSql);
|
|
||||||
// if(iRet == 0){
|
|
||||||
// strSql = "ALTER TABLE t_WorkCondition ADD COLUMN 'operate' integer";
|
|
||||||
// ExeSqlData(strSql);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
CreateDataBase();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int SqliteDB::CreateDataBase()
|
int SqliteDB::CreateDataBase()
|
||||||
{
|
{
|
||||||
|
QString strCreateSQL = QString("create table if not exists t_UnitConfiguration(WorkConditionID,ChannelID,BoardNo,ChannelNoInBoard,Input,Operate);");
|
||||||
|
ExeSqlData(strCreateSQL);
|
||||||
}
|
}
|
||||||
int SqliteDB::QueryData(QString& tablename, QString& column, QString& whereCon)
|
int SqliteDB::QueryData(QString& tablename, QString& column, QString& whereCon)
|
||||||
{
|
{
|
||||||
@ -507,6 +506,40 @@ SqliteDB::GetTriggerAlarmStatusInfo(QString tablename,QString whereCon)
|
|||||||
return vecResult;
|
return vecResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<UnitConfiguration_t>
|
||||||
|
SqliteDB::GetUnitConfigurationInfo(QString tablename,QString whereCon)
|
||||||
|
{
|
||||||
|
QSqlQuery sql_query;
|
||||||
|
|
||||||
|
QVector<UnitConfiguration_t> vecResult;
|
||||||
|
UnitConfiguration_t tempUnitConfigurationInfo;
|
||||||
|
QString strSql;
|
||||||
|
if(whereCon == "")
|
||||||
|
strSql = QString("SELECT * FROM %1 ;").arg(tablename);
|
||||||
|
else
|
||||||
|
strSql = QString("SELECT * FROM %1 where %2;").arg(tablename).arg(whereCon);
|
||||||
|
sql_query.exec(strSql);
|
||||||
|
qDebug() << "strSql" <<strSql << endl;
|
||||||
|
if(!sql_query.exec())
|
||||||
|
{
|
||||||
|
qDebug() << "Error: Fail to query table. " << sql_query.lastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(sql_query.next())
|
||||||
|
{
|
||||||
|
tempUnitConfigurationInfo.WorkConditionID = sql_query.value(0).toString();
|
||||||
|
tempUnitConfigurationInfo.ChannelID = sql_query.value(1).toString();
|
||||||
|
tempUnitConfigurationInfo.BoardNo = sql_query.value(2).toInt();
|
||||||
|
tempUnitConfigurationInfo.ChannelNoInBoard = sql_query.value(3).toInt();
|
||||||
|
tempUnitConfigurationInfo.Input = sql_query.value(4).toString();
|
||||||
|
tempUnitConfigurationInfo.Operate = sql_query.value(5).toInt();
|
||||||
|
|
||||||
|
vecResult.append(tempUnitConfigurationInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vecResult;
|
||||||
|
}
|
||||||
|
|
||||||
int SqliteDB::InsertData(QString& tablename,QString& sql)
|
int SqliteDB::InsertData(QString& tablename,QString& sql)
|
||||||
{
|
{
|
||||||
@ -613,7 +646,7 @@ int SqliteDB::DeleteData(QString& tablename, QString condColumnName, QVariant co
|
|||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SqliteDB::DeleteDataW(QString& tablename, QString& whereCon)
|
int SqliteDB::DeleteDataW(QString& tablename, QString whereCon)
|
||||||
{
|
{
|
||||||
QSqlQuery sql_query;
|
QSqlQuery sql_query;
|
||||||
int iRet = -1;
|
int iRet = -1;
|
||||||
|
|||||||
@ -32,10 +32,12 @@ public:
|
|||||||
QVector<TriggerConfig_t> GetTriggerConfig(QString tablename,QString whereCon = "");
|
QVector<TriggerConfig_t> GetTriggerConfig(QString tablename,QString whereCon = "");
|
||||||
QVector<TriggerEvent_t> GetTriggerEvent(QString tablename,QString whereCon = "");
|
QVector<TriggerEvent_t> GetTriggerEvent(QString tablename,QString whereCon = "");
|
||||||
QVector<TriggerAlarmStatusInfo_t> GetTriggerAlarmStatusInfo(QString tablename,QString whereCon = "");
|
QVector<TriggerAlarmStatusInfo_t> GetTriggerAlarmStatusInfo(QString tablename,QString whereCon = "");
|
||||||
|
QVector<UnitConfiguration_t> GetUnitConfigurationInfo(QString tablename,QString whereCon = "");
|
||||||
QString GetSingelLine(QString& tablename, QString& column, QString whereCon = "");
|
QString GetSingelLine(QString& tablename, QString& column, QString whereCon = "");
|
||||||
int DeleteData(QString& tablename, QString condColumnName = "", QVariant condColumnValue = "");
|
int DeleteData(QString& tablename, QString condColumnName = "", QVariant condColumnValue = "");
|
||||||
int DeleteDataW(QString& tablename, QString& whereCon);
|
int DeleteDataW(QString& tablename, QString whereCon = "");
|
||||||
int ExeSqlData(QString& strSql);
|
int ExeSqlData(QString& strSql);
|
||||||
|
int initTable();
|
||||||
|
|
||||||
};
|
};
|
||||||
extern SqliteDB* g_SqliteDB;
|
extern SqliteDB* g_SqliteDB;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user