25 explicit BufferedInput(
const Common::Logger::SharedPtr & logger);
26 virtual std::size_t
Receive(
char * data, std::size_t size);
27 void AddBuffer(
const char * buf, std::size_t size);
56 std::size_t totalConsumedSize = 0;
58 while (totalConsumedSize < size)
69 else if (!event.owns_lock())
88 const std::size_t sizeToConsume = std::min(size - totalConsumedSize,
Buffer.size());
92 auto endIt =
Buffer.begin() + sizeToConsume;
93 std::copy(begin(
Buffer), endIt, data + totalConsumedSize);
95 totalConsumedSize += sizeToConsume;
98 return totalConsumedSize;
128 throw std::logic_error(
"conversation through connection stopped");
139 BufferedIO(
const char * channelId, std::weak_ptr<InputChannel> input, std::weak_ptr<BufferedInput>
output,
const Common::Logger::SharedPtr & logger)
147 virtual std::size_t
Receive(
char * data, std::size_t size)
151 if (std::shared_ptr<InputChannel> input =
Input.lock())
153 return input->Receive(data, size);
159 virtual void Send(
const char *
message, std::size_t size)
163 if (std::shared_ptr<BufferedInput> output =
Output.lock())
165 output->AddBuffer(message, size);
171 if (std::shared_ptr<BufferedInput> output =
Output.lock())
174 if (std::shared_ptr<InputChannel> input =
Input.lock())
175 {
return input->Stop(); }
179 std::weak_ptr<InputChannel>
Input;
180 std::weak_ptr<BufferedInput>
Output;
182 Common::Logger::SharedPtr
Logger;
186 void Process(std::shared_ptr<OpcUa::Server::IncomingConnectionProcessor> processor, std::shared_ptr<OpcUa::IOChannel> channel)
188 processor->Process(channel);
202 throw std::logic_error(
"Cannot access builtin computer. No endpoints was created. You have to configure endpoints.");
207 params.
SecurePolicy =
"http://opcfoundation.org/UA/SecurityPolicy#None";
244 std::vector<OpcUa::ApplicationDescription> applicationDescriptions;
245 std::vector<OpcUa::EndpointDescription> endpointDescriptions;
249 applicationDescriptions.push_back(application.Application);
250 endpointDescriptions.insert(endpointDescriptions.end(), application.Endpoints.begin(), application.Endpoints.end());
257 LOG_ERROR(
Logger,
"cannot store endpoints information, endpoints service addon has not been registered");
261 endpointsAddon->AddEndpoints(endpointDescriptions);
262 endpointsAddon->AddApplications(applicationDescriptions);
267 Protocol->StartEndpoints(endpointDescriptions, internalServer->GetServer());
294 throw std::logic_error(
"unable to serve more then one binary connection");
virtual const Logger::SharedPtr & GetLogger() const
std::shared_ptr< BufferedInput > ServerInput
const char EndpointsRegistryAddonId[]
std::unique_ptr< Common::Thread > Thread
std::shared_ptr< OpcUa::IOChannel > ClientChannel
virtual std::shared_ptr< Addon > GetAddon(const AddonId &id) const =0
getting addon by id
virtual void Listen(const OpcUa::Server::TcpParameters ¶ms, std::shared_ptr< OpcUa::Server::IncomingConnectionProcessor > processor) override
#define LOG_ERROR(__logger__,...)
#define LOG_DEBUG(__logger__,...)
virtual void OnError(const std::exception &exc) override
Thread exited with error.
virtual void Initialize(Common::AddonsManager &addons, const Common::AddonParameters ¶ms) override
initialize addon.
const char ServicesRegistryAddonId[]
virtual void OnSuccess() override
thread exited with Success.
OpcUa::Server::OpcUaProtocol::SharedPtr Protocol
std::shared_ptr< OpcUa::IOChannel > ServerChannel
#define LOG_INFO(__logger__,...)
virtual void Stop() override
Stopping addon work. After calling this method addon should throw exception on any calls...
Services::SharedPtr CreateBinaryClient(IOChannel::SharedPtr channel, const SecureConnectionParams ¶ms, const Common::Logger::SharedPtr &logger=nullptr)
Create server based on opc ua binary protocol.
OpcUa::Services::SharedPtr GetServices() const override
std::vector< Server::ApplicationData > ParseEndpointsParameters(const std::vector< Common::ParametersGroup > &rootGroup, const Common::Logger::SharedPtr &logger)
std::vector< ParametersGroup > Groups
virtual void StopListen(const OpcUa::Server::TcpParameters ¶ms) override
TcpServer::UniquePtr CreateTcpServer(const Common::Logger::SharedPtr &logger)
std::shared_ptr< BufferedInput > ClientInput
OpcUaProtocol::UniquePtr CreateOpcUaProtocol(TcpServer &tcpServer, const Common::Logger::SharedPtr &logger)
BuiltinServerAddon(const Common::Logger::SharedPtr &logger=nullptr)
~BuiltinServerAddon() override
Common::Logger::SharedPtr Logger
std::vector< Parameter > Parameters