2025-08-28 18:42:37 +08:00
|
|
|
#include "CommEntity.h"
|
2025-07-18 09:08:09 +08:00
|
|
|
#include "TcpEntity.h"
|
|
|
|
|
|
2025-08-28 18:42:37 +08:00
|
|
|
std::shared_ptr<CommEntity> CommEntity::create(Fields& data)
|
2025-07-18 09:08:09 +08:00
|
|
|
{
|
2025-08-22 19:06:50 +08:00
|
|
|
std::string commType = data.value("commType");
|
|
|
|
|
std::string ip = data.value("ip");
|
2025-08-26 18:36:25 +08:00
|
|
|
int port = data.get<int>("port");
|
|
|
|
|
int isclient = data.get<int>("isclient");
|
2025-07-18 09:08:09 +08:00
|
|
|
|
|
|
|
|
if (commType == "TCP")
|
|
|
|
|
{
|
|
|
|
|
auto entity = std::make_shared<TcpEntity>();
|
2025-08-31 14:38:53 +08:00
|
|
|
entity->setAddr(ip, port, isclient);
|
2025-07-18 09:08:09 +08:00
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
else if (commType == "MODBUS")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else if (commType == "ACTIVEX")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else if (commType == "SDK")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|