Ref T554, check function for auto publishing

This commit is contained in:
Klaus Basan
2019-07-16 18:12:13 +02:00
committed by Mat Sutcliffe
parent fab65c23b1
commit ac22e1d17d
3 changed files with 45 additions and 1 deletions

View File

@@ -513,5 +513,23 @@ namespace BlackCore
textPartDebug.setBody(QString("ECLIPSE_DBGP").toUtf8());
return textPartDebug;
}
ChangedAutoPublishData CDatabaseUtils::autoPublishDataChanged(const QString &modelString, const PhysicalQuantities::CLength &cg, const CSimulatorInfo &simulator)
{
ChangedAutoPublishData changed;
if (!sApp || sApp->isShuttingDown() || !sApp->getWebDataServices()) { return changed; }
const CAircraftModel model = sApp->getWebDataServices()->getModelForModelString(modelString);
return CDatabaseUtils::autoPublishDataChanged(model, cg, simulator);
}
ChangedAutoPublishData CDatabaseUtils::autoPublishDataChanged(const CAircraftModel &model, const PhysicalQuantities::CLength &cg, const CSimulatorInfo &simulator)
{
ChangedAutoPublishData changed;
changed.modelKnown = model.hasValidDbKey();
if (!changed.modelKnown) { return changed; }
changed.changedCG = !(cg == model.getCG());
changed.changedSim = !(model.getSimulator().matchesAll(simulator));
return changed;
}
} // ns
} // ns

View File

@@ -11,9 +11,11 @@
#ifndef BLACKCORE_DB_DATABASEUTILS_H
#define BLACKCORE_DB_DATABASEUTILS_H
#include "blackcore/blackcoreexport.h"
#include "blackcore/progress.h"
#include "blackcore/blackcoreexport.h"
#include "blackmisc/simulation/aircraftmodel.h"
#include "blackmisc/simulation/autopublishdata.h"
#include <QHttpPart>
#include <QUrlQuery>
#include <QByteArray>
@@ -108,6 +110,14 @@ namespace BlackCore
//! Multipart with DEBUG FLAG for server
static QHttpPart getMultipartWithDebugFlag();
//! Which auto-publish data did change?
//! \sa CAutoPublishData::analyzeAgainstDBData
static BlackMisc::Simulation::ChangedAutoPublishData autoPublishDataChanged(const QString &modelString, const BlackMisc::PhysicalQuantities::CLength &cg, const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Which auto-publish data did change?
//! \sa CAutoPublishData::analyzeAgainstDBData
static BlackMisc::Simulation::ChangedAutoPublishData autoPublishDataChanged(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::PhysicalQuantities::CLength &cg, const BlackMisc::Simulation::CSimulatorInfo &simulator);
};
} // ns
} // ns

View File

@@ -42,6 +42,22 @@ namespace BlackMisc
};
}
//! Which data have changed
struct ChangedAutoPublishData
{
bool modelKnown = false; //!< model known in DB
bool changedCG = false; //!< CG changed
bool changedSim = false; //!< simulator changed
//! Set all to true;
void setAllTrue()
{
modelKnown = true;
changedCG = true;
changedSim = true;
}
};
//! Objects that can be use for auto-publishing.
//! Auto publishing means we sent those data to the DB.
class BLACKMISC_EXPORT CAutoPublishData