69 lines
2.3 KiB
C++
Executable File
69 lines
2.3 KiB
C++
Executable File
/**
|
|
* Block/unblock topics
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2018-01-15
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include "logger.h"
|
|
#include "opm_db.h"
|
|
|
|
#include <DDS/Core/core_fts_types.h>
|
|
#include <DDS/Core/core_dts_types.h>
|
|
#include <DDS/Core/topic_lock_master.h>
|
|
#include <DDS/DTS/generic_dts_impl.h>
|
|
#include <DDS/FTS/generic_fts_impl.h>
|
|
|
|
|
|
namespace OperatorManagement
|
|
{
|
|
class MainHandler;
|
|
class HandlerLockedTopics final : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit HandlerLockedTopics(MainHandler &mainHandler,
|
|
QObject *parent = nullptr);
|
|
bool init();
|
|
|
|
void operatorLoggedIn(int operatorId, int workstationId) { operatorLoggedInOut(operatorId, workstationId); }
|
|
void operatorLoggedOut(int operatorId) { operatorLoggedInOut(operatorId, 0); }
|
|
|
|
private:
|
|
// we logged out - unlock all still locked topics (workstationId should be zero then)
|
|
// we logged in again - unlock all still locked topics which are not for current workstation
|
|
void operatorLoggedInOut(int operatorId, int workstationId);
|
|
|
|
/// Lock
|
|
void onTryLockEntityRequest(const rti::core::SampleIdentity &cookie, const Core::TryLockEntityRequest &request);
|
|
Core::TryLockEntityReply tryLock(const Core::TryLockEntityRequest &request);
|
|
//Core::TryLockEntityReply tryLockModify(const Core::TryLockEntityRequest &request);
|
|
|
|
/// Unlock
|
|
void onTryUnlockEntityRequest(const rti::core::SampleIdentity &cookie, const Core::TryUnlockEntityRequest &request);
|
|
Core::FunctionReply tryUnlock(const Core::TryUnlockEntityRequest &request);
|
|
|
|
//bool removeReleaseOutdatedLock(int topicId);
|
|
void unlockInDb(const Database::OpmLockedTopics &data);
|
|
static Database::OpmLockedTopics toDb(const Core::LockedEntityBase &request);
|
|
bool publishLockedEntity(const Core::LockedEntity &entity);
|
|
bool removeLockedEntity(int64_t id);
|
|
|
|
//Core::key topicIdToKey(long id);
|
|
void dumpLockedTopics(int line);
|
|
|
|
private:
|
|
QHash<Core::key, Database::OpmLockedTopics> m_lockedTopics;
|
|
|
|
MainHandler &m_mainHandler;
|
|
std::shared_ptr<DatabaseInterface> m_db;
|
|
std::unique_ptr<FTS::TryLockEntity> m_ftsTryLockEntity;
|
|
std::unique_ptr<FTS::TryUnlockEntity>m_ftsTryUnlockEntity;
|
|
std::unique_ptr<DTS::LockedEntity> m_dtsLockedEntity;
|
|
LOGGER_T m_logger;
|
|
};
|
|
} // namespace OperatorManagement
|