34 using namespace OpcUa;
41 OpcTcp(OpcUa::Services::SharedPtr services,
const Common::Logger::SharedPtr & logger)
47 virtual void Process(OpcUa::IOChannel::SharedPtr clientChannel)
51 LOG_WARN(Logger,
"opc_tcp_processor| empty channel passed to endpoints opc binary protocol processor");
56 LOG_DEBUG(Logger,
"opc_tcp_processor| Hello client!");
58 std::shared_ptr<OpcTcpMessages> messageProcessor = std::make_shared<OpcTcpMessages>(
Server, clientChannel, Logger);
62 ProcessData(*clientChannel, *messageProcessor);
66 virtual void StopProcessing(OpcUa::IOChannel::SharedPtr clientChannel)
76 ProcessChunk(iStream, messageProcessor);
82 LOG_DEBUG(Logger,
"opc_tcp_processor| processing new chunk");
89 std::vector<char> buffer(hdr.MessageSize());
100 if (messageChannel.GetRemainSize())
102 LOG_ERROR(Logger,
"opc_tcp_processor| message has not been processed completely");
107 OpcUa::Services::SharedPtr Server;
108 Common::Logger::SharedPtr Logger;
118 : TcpAddon(tcpServer)
123 virtual void StartEndpoints(
const std::vector<EndpointDescription> & endpoints, OpcUa::Services::SharedPtr
server)
override 129 if (
uri.Scheme() ==
"opc.tcp")
131 std::shared_ptr<IncomingConnectionProcessor> processor(
new OpcTcp(server, Logger));
135 LOG_INFO(Logger,
"opc_tcp_processor| start to listen on port {}", tcpParams.
Port);
137 TcpAddon.Listen(tcpParams, processor);
138 Ports.push_back(tcpParams);
143 virtual void StopEndpoints()
override 147 TcpAddon.StopListen(params);
153 std::vector<TcpParameters> Ports;
154 Common::Logger::SharedPtr Logger;
167 virtual void Stop()
override;
175 OpcUa::Server::ServicesRegistry::SharedPtr InternalServer;
176 OpcUa::Server::TcpServer::SharedPtr
TcpServer;
177 OpcUa::Server::OpcUaProtocol::SharedPtr Protocol;
178 Common::Logger::SharedPtr Logger;
184 ApplyAddonParameters(params);
189 LOG_INFO(Logger,
"endpoint is: {}",
d.Endpoints.front().EndpointUrl);
192 std::vector<OpcUa::ApplicationDescription> applicationDescriptions;
193 std::vector<OpcUa::EndpointDescription> endpointDescriptions;
197 applicationDescriptions.push_back(application.Application);
198 endpointDescriptions.insert(endpointDescriptions.end(), application.Endpoints.begin(), application.Endpoints.end());
205 LOG_ERROR(Logger,
"cannot store endpoints information, endpoints service addon has not been registered");
209 endpointsAddon->AddEndpoints(endpointDescriptions);
210 endpointsAddon->AddApplications(applicationDescriptions);
216 Protocol->StartEndpoints(endpointDescriptions, InternalServer->GetServer());
219 void OpcUaProtocolAddon::Stop()
223 InternalServer.reset();
262 return Common::Addon::UniquePtr(new ::OpcUaProtocolAddon());
266 OpcUaProtocol::UniquePtr
CreateOpcUaProtocol(TcpServer & tcpServer,
const Common::Logger::SharedPtr & logger)
268 return OpcUaProtocol::UniquePtr(new ::OpcUaProtocol(tcpServer, logger));
Common::Addon * CreateAddon()
Addon interface definition GNU LGPL.
virtual const Logger::SharedPtr & GetLogger() const
const char EndpointsRegistryAddonId[]
#define LOG_WARN(__logger__,...)
Addon interface definition GNU LGPL.
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
#define LOG_ERROR(__logger__,...)
#define LOG_DEBUG(__logger__,...)
const char ServicesRegistryAddonId[]
bool ProcessMessage(Binary::MessageType msgType, Binary::IStreamBinary &iStream)
#define LOG_INFO(__logger__,...)
OPC UA Address space part. GNU LGPL.
std::string ToHexDump(const char *buf, std::size_t size)
std::vector< Server::ApplicationData > ParseEndpointsParameters(const std::vector< Common::ParametersGroup > &rootGroup, const Common::Logger::SharedPtr &logger)
#define DEFINE_CLASS_POINTERS(ClassName)
Exception declarations GNU LGPL.
std::vector< ParametersGroup > Groups
TcpServer::UniquePtr CreateTcpServer(const Common::Logger::SharedPtr &logger)
OpcUaProtocol::UniquePtr CreateOpcUaProtocol(TcpServer &tcpServer, const Common::Logger::SharedPtr &logger)