mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
39 lines
765 B
C
39 lines
765 B
C
|
|
#pragma once
|
|||
|
|
|
|||
|
|
#include <memory>
|
|||
|
|
#include <string>
|
|||
|
|
|
|||
|
|
#include "common/DataFields.h"
|
|||
|
|
|
|||
|
|
class CommEntity
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CommEntity() {}
|
|||
|
|
CommEntity(std::string type) : type(type) {}
|
|||
|
|
|
|||
|
|
void setType(std::string type) { this->type = type; }
|
|||
|
|
|
|||
|
|
// 启动通讯连接
|
|||
|
|
virtual int start() { return 0; };
|
|||
|
|
// 关闭通讯连接
|
|||
|
|
virtual void close() { isCloseRequest_ = true; };
|
|||
|
|
|
|||
|
|
std::string id() { return id_; }
|
|||
|
|
|
|||
|
|
bool isAlive() { return isAlive_; }
|
|||
|
|
bool isConnected() { return isConnected_; }
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
std::string id_;
|
|||
|
|
bool isAlive_ = false;
|
|||
|
|
bool isConnected_ = false;
|
|||
|
|
bool isCloseRequest_ = false;
|
|||
|
|
std::string type;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Communicator
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
static std::shared_ptr<CommEntity> createEntity(DataFields& data);
|
|||
|
|
};
|