Files
energy_storage/src/protocol/CommEntity.cpp

28 lines
607 B
C++
Raw Normal View History

2025-08-28 18:42:37 +08:00
#include "CommEntity.h"
#include "TcpEntity.h"
2025-08-28 18:42:37 +08:00
std::shared_ptr<CommEntity> CommEntity::create(Fields& data)
{
std::string commType = data.value("commType");
std::string ip = data.value("ip");
int port = data.get<int>("port");
int isclient = data.get<int>("isclient");
if (commType == "TCP")
{
auto entity = std::make_shared<TcpEntity>();
entity->setHost(ip, port, isclient);
return entity;
}
else if (commType == "MODBUS")
{
}
else if (commType == "ACTIVEX")
{
}
else if (commType == "SDK")
{
}
return nullptr;
}