Adds q2 repos to migrate
This commit is contained in:
1 parent
ad1f62c4ee
commit
17f1c61c9e
991 files changed
+178451
No files matched your search
@@ -0,0 +1,371 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QAtomicInt>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QString>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include "PrtCnvThread.hpp"
|
||||
#include "PrtCnvRadioThread.hpp"
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace N_CoPrtCnv
|
||||
{
|
||||
class CoPrtCnvCentralTelegram;
|
||||
class CoPrtCnvRadioTelegram;
|
||||
}
|
||||
|
||||
namespace PrtCnv
|
||||
{
|
||||
class PrtCnvThreadStarter;
|
||||
class PrtCnvStoredCentralTelegram;
|
||||
class PrtCnvStoredRadioTelegram;
|
||||
class PrtCnvMember;
|
||||
|
||||
|
||||
class PrtCnvDbThread : public PrtCnvThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
|
||||
PrtCnvDbThread(const QString &dbDriver,
|
||||
const QString &dbHostName,
|
||||
const QString &dbDatabaseName,
|
||||
const QString &schemaName,
|
||||
const QString &dbUserName,
|
||||
const QString &dbPassword,
|
||||
PrtCnvThreadStarter* a_parent);
|
||||
~PrtCnvDbThread();
|
||||
|
||||
|
||||
|
||||
int32_t start() override;
|
||||
|
||||
|
||||
int32_t stop() override;
|
||||
|
||||
|
||||
int32_t create(NGL::Settings *settings) override;
|
||||
|
||||
|
||||
int32_t init() override;
|
||||
|
||||
|
||||
void ackCentralTelegrams(int32_t a_counter);
|
||||
|
||||
|
||||
|
||||
N_CoPrtCnv::CoPrtCnvCentralTelegram *getNextCentralTelegram(PrtCnvStoredCentralTelegram *& a_handle);
|
||||
|
||||
|
||||
|
||||
void centralTelegramSent(const int32_t a_counter, PrtCnvStoredCentralTelegram *a_handle);
|
||||
|
||||
|
||||
|
||||
void centralTelegramCouldNotBeSent(PrtCnvStoredCentralTelegram *a_handle);
|
||||
|
||||
|
||||
|
||||
void radioTelegramSent(const uint32_t a_sendCounter, PrtCnvStoredRadioTelegram *a_handle, const uint32_t a_broadcastIndex);
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> getNextRadioTelegram(PrtCnvStoredRadioTelegram *&a_handle);
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> getNextBroadcastTelegram();
|
||||
|
||||
|
||||
|
||||
void storeCentralTelegram(const std::shared_ptr<N_CoPrtCnv::CoPrtCnvCentralTelegram> &a_centralTelegram,
|
||||
const N_CoPrtCnv::CoPrtCnvRadioTelegram &a_radioTelegram);
|
||||
|
||||
|
||||
|
||||
void storeRadioTelegram(const std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> &a_telegram, const int32_t a_readCounter);
|
||||
|
||||
|
||||
|
||||
void centralCounterReadyForAck(const int32_t a_centralCounter);
|
||||
|
||||
|
||||
|
||||
void addSqlCommand(const QString &sql);
|
||||
|
||||
|
||||
|
||||
|
||||
void cleanAndInit();
|
||||
|
||||
|
||||
|
||||
bool resendCentralTelegrams(const int32_t a_lastSendCounter);
|
||||
|
||||
|
||||
|
||||
void prepareCentralTelegramsForReconnection();
|
||||
|
||||
|
||||
|
||||
void waitUntilDbWritten();
|
||||
|
||||
|
||||
|
||||
PrtCnvMember* getMemberByISSI(const uint32_t a_ISSI) const;
|
||||
|
||||
|
||||
|
||||
PrtCnvMember* getMemberById(const uint16_t a_id);
|
||||
|
||||
|
||||
|
||||
bool licenseMember(PrtCnvMember *a_member, const bool a_doLicense = true);
|
||||
|
||||
|
||||
|
||||
void updateExerciseIdForMember(PrtCnvMember *a_member, int newExerciseId);
|
||||
|
||||
|
||||
|
||||
PrtCnvMember* addMember(const int a_identity, const int a_ISSI);
|
||||
|
||||
|
||||
|
||||
void removeMember(PrtCnvMember* a_member);
|
||||
|
||||
|
||||
|
||||
uint8_t getResetCounter() const;
|
||||
|
||||
|
||||
|
||||
void setResetCounter(uint8_t newVal);
|
||||
|
||||
|
||||
|
||||
uint8_t getBattleFieldOperatingState() const;
|
||||
|
||||
|
||||
|
||||
void setPause(const bool a_doSet = true);
|
||||
|
||||
|
||||
|
||||
void setPositionSendTime(unsigned int sendTime);
|
||||
|
||||
|
||||
|
||||
void setAirLoad(PrtCnvRadioThread::E_TrafficLoad airLoad);
|
||||
|
||||
|
||||
|
||||
bool isEnvironmentResetCounterOld() const;
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<N_CoPrtCnv::CoPrtCnvRadioTelegram> getEnvironmentTelegram();
|
||||
|
||||
|
||||
|
||||
void setResetCounterOnEnvironment();
|
||||
|
||||
|
||||
|
||||
void incClaimCount(int a_identity);
|
||||
|
||||
|
||||
|
||||
std::map<int32_t, int32_t> getClaimStatistics() const;
|
||||
|
||||
|
||||
|
||||
void setMachineState(const int a_newMachineState);
|
||||
|
||||
|
||||
|
||||
bool mustProceedCleanup() const;
|
||||
|
||||
protected:
|
||||
void closeDb();
|
||||
|
||||
|
||||
|
||||
std::vector<PrtCnvStoredCentralTelegram*> m_CentralList;
|
||||
|
||||
|
||||
|
||||
mutable QMutex m_BattleFieldOpStateMutex;
|
||||
|
||||
|
||||
|
||||
mutable QMutex m_MemberListByIdMutex;
|
||||
|
||||
|
||||
|
||||
mutable QMutex m_CentralListMutex;
|
||||
|
||||
|
||||
|
||||
QSqlDatabase m_db;
|
||||
|
||||
|
||||
|
||||
QAtomicInt m_CentralAckCounter;
|
||||
|
||||
|
||||
unsigned int m_OldCentralAckCounter;
|
||||
|
||||
|
||||
std::list<PrtCnvStoredRadioTelegram*> m_RadioList;
|
||||
|
||||
|
||||
mutable QMutex m_RadioListMutex;
|
||||
|
||||
|
||||
std::vector<QString> m_SqlCommandList;
|
||||
|
||||
|
||||
mutable QMutex m_SqlCmdListMutex;
|
||||
|
||||
|
||||
mutable QMutex m_BroadcastMapMutex;
|
||||
|
||||
|
||||
std::list<PrtCnvStoredRadioTelegram*> m_BroadcastList;
|
||||
|
||||
|
||||
bool m_DoClean;
|
||||
|
||||
|
||||
bool m_DoWaitUntilSqlWritten;
|
||||
|
||||
|
||||
std::unordered_map<int,PrtCnvMember*> m_MemberListById;
|
||||
|
||||
|
||||
std::unordered_map<int,PrtCnvMember*> m_MemberListByISSI;
|
||||
|
||||
|
||||
bool m_DoStorePermanent;
|
||||
|
||||
|
||||
uint8_t m_ResetCounter;
|
||||
|
||||
|
||||
uint8_t m_BattleFieldOperatingState;
|
||||
|
||||
|
||||
PrtCnvStoredRadioTelegram* m_EnvironmentTelegram;
|
||||
|
||||
|
||||
bool m_DoProceedCleanup;
|
||||
|
||||
|
||||
int32_t m_OldCentralCounter;
|
||||
|
||||
|
||||
QBasicAtomicInt m_StorePermanentPending;
|
||||
|
||||
|
||||
|
||||
uint32_t m_NbrOfAttempts;
|
||||
|
||||
|
||||
|
||||
bool createDatabase();
|
||||
|
||||
|
||||
|
||||
void sendStorePermanentSignal();
|
||||
|
||||
|
||||
|
||||
void storeCentralTelegrams();
|
||||
|
||||
|
||||
|
||||
int32_t storeRadioTelegrams();
|
||||
|
||||
|
||||
|
||||
void handleSqlCommandList();
|
||||
|
||||
|
||||
|
||||
void deleteTelegramsFromDbById(const QString &table);
|
||||
|
||||
|
||||
void updateTelegramsWriteCounter(const QString &table);
|
||||
|
||||
|
||||
|
||||
void updateTelegramsBroadcast(const QString &table);
|
||||
|
||||
|
||||
|
||||
void reinitDatabase();
|
||||
|
||||
QString toCentralTableName() const { return tableName(QStringLiteral("prtcnv_to_central")); }
|
||||
QString toRadioTableName() const { return tableName(QStringLiteral("prtcnv_to_radio")); }
|
||||
QString memberTableName() const { return tableName(QStringLiteral("prtcnv_member")); }
|
||||
QString statusTableName() const { return tableName(QStringLiteral("prtcnv_status")); }
|
||||
QString versionTableName() const { return tableName(QStringLiteral("prtcnv_version")); }
|
||||
QString tableName(const QString &table) const { return m_dbSchemaName.isEmpty() ? table : m_dbSchemaName + QLatin1Char('.') + table; }
|
||||
protected slots:
|
||||
|
||||
|
||||
void storePermanent();
|
||||
|
||||
|
||||
void clean();
|
||||
|
||||
public:
|
||||
signals:
|
||||
|
||||
|
||||
void doStorePermanent();
|
||||
|
||||
|
||||
void permanentStored(int32_t a_centralCounter);
|
||||
|
||||
|
||||
void doClean();
|
||||
|
||||
void playerLicencedChanged(int equipNo, N_CoPrtCnv::E_LicensingKind kind);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
std::vector<int64_t> m_telegramsToDelete;
|
||||
std::vector<std::pair<int64_t, int32_t> > m_telegramsToUpdateCounter;
|
||||
std::vector<std::pair<int64_t, int32_t> > m_telegramsToUpdateBC;
|
||||
std::vector<std::pair<PrtCnvStoredCentralTelegram*, int64_t> > m_telegramsToInsert;
|
||||
QString m_dbDriver;
|
||||
QString m_dbHostName;
|
||||
QString m_dbDatabaseName;
|
||||
QString m_dbSchemaName;
|
||||
QString m_dbUserName;
|
||||
QString m_dbPassword;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user