53 , OutputStream(*outputChannel)
73 catch (
const std::exception & exc)
75 LOG_ERROR(
Logger,
"opc_tcp_processor | stopping OpcTcpMessages failed: {}", exc.what());
120 LOG_ERROR(
Logger,
"opc_tcp_processor | received acknowledge from client: this should not have happend...");
122 throw std::logic_error(
"Thank to client about acknowledge.");
129 throw std::logic_error(
"It is very nice get to know server about error in the client.");
134 LOG_ERROR(
Logger,
"opc_tcp_processor | unknown message type '{}' received", msgType);
136 throw std::logic_error(
"unknown message type received.");
147 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending PublishResult to client");
151 OpcUa::OutputChannel::SharedPtr outputChannel =
OutputChannel.lock();
153 if (!outputChannel) {
154 LOG_WARN(
Logger,
"opc_tcp_processor | parent instance already deleted");
160 LOG_WARN(
Logger,
"error trying to send publish response while we do not have data from a PublishRequest");
204 ostream << ackHeader << ack <<
flush;
209 uint32_t channelId = 0;
210 istream >> channelId;
212 istream >> algorithmHeader;
214 if (algorithmHeader.SecurityPolicyUri !=
"http://opcfoundation.org/UA/SecurityPolicy#None")
216 throw std::logic_error(
std::string(
"Client want to create secure channel with unsupported policy '") + algorithmHeader.SecurityPolicyUri +
std::string(
"'"));
227 throw std::logic_error(
"Unsupported security mode.");
249 ostream << responseHeader << algorithmHeader << sequence << response <<
flush;
254 uint32_t channelId = 0;
255 istream >> channelId;
258 istream >> algorithmHeader;
269 uint32_t channelId = 0;
270 istream >> channelId;
273 istream >> algorithmHeader;
282 istream >> requestHeader;
299 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Get Endpoints' request");
312 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
318 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Find Servers' request");
331 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
351 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
362 Logger->debug(
"opc_tcp_processor | processing 'Read' request for Node:");
371 Logger->debug(
"opc_tcp_processor | {} ({})",
id.
NodeId, name);
377 std::vector<DataValue> values;
379 if (std::shared_ptr<OpcUa::AttributeServices> service =
Server->Attributes())
381 values = service->Read(params);
386 for (
auto attribId : params.AttributesToRead)
391 values.push_back(value);
401 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
415 std::vector<DataValue> values;
417 if (std::shared_ptr<OpcUa::AttributeServices> service =
Server->Attributes())
419 response.
Results = service->Write(params.NodesToWrite);
428 secureHeader.AddSize(
RawSize(algorithmHeader));
429 secureHeader.AddSize(
RawSize(sequence));
430 secureHeader.AddSize(
RawSize(response));
431 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
438 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Translate Browse Paths To Node Ids' request");
447 std::stringstream result;
454 Logger->debug(
"opc_tcp_processor | requested path is: {}", result.str());
458 std::vector<BrowsePathResult> result =
Server->Views()->TranslateBrowsePathsToNodeIds(params);
467 target << path.
Node ;
469 Logger->debug(
"opc_tcp_processor | result of browsePath is: {}, target is: {}", (uint32_t)res.Status, target.str());
481 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Translate Browse Paths To Node Ids' request");
483 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
490 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Create Session' request");
510 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
517 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Activate Session' request");
529 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
535 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Close Session' request");
537 bool deleteSubscriptions =
false;
538 istream >> deleteSubscriptions;
540 if (deleteSubscriptions)
552 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
561 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Create Subscription' request");
565 request.
Header = requestHeader;
570 SharedPtr
self = shared_from_this();
575 self->ForwardPublishResponse(i);
578 catch (std::exception & ex)
581 LOG_WARN(self->Logger,
"error forwarding PublishResult to client: {}", ex.what());
591 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
597 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Modify Subscription' request");
601 request.
Header = requestHeader;
611 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Modify Subscription' request");
613 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
619 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Delete Subscription' request");
621 std::vector<uint32_t> ids;
629 response.
Results =
Server->Subscriptions()->DeleteSubscriptions(ids);
636 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Delete Subscription' request");
638 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
644 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Create Monitored Items' request");
651 response.
Results =
Server->Subscriptions()->CreateMonitoredItems(params);
659 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Create Monitored Items' request");
661 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
667 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Delete Monitored Items' request");
674 response.
Results =
Server->Subscriptions()->DeleteMonitoredItems(params);
682 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Delete Monitored Items' request");
684 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
693 request.
Header = requestHeader;
701 Server->Subscriptions()->Publish(request);
710 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Set Publishing Mode' request");
725 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Set Publishing Mode' request");
727 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
733 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Add Nodes' request");
738 std::vector<AddNodesResult> results =
Server->NodeManagement()->AddNodes(params.NodesToAdd);
749 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Add Nodes' request");
751 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
757 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Add References' request");
762 std::vector<StatusCode> results =
Server->NodeManagement()->AddReferences(params.ReferencesToAdd);
773 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Add References' request");
775 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
781 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Republish' request");
796 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Republish' request");
798 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
812 if (std::shared_ptr<OpcUa::MethodServices> service =
Server->Method())
814 response.
Results = service->Call(params.MethodsToCall);
819 for (
auto callMethodRequest : params.MethodsToCall)
823 response.
Results.push_back(result);
831 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
838 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Register Nodes' request");
854 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Register Nodes' request");
856 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
862 LOG_DEBUG(
Logger,
"opc_tcp_processor | processing 'Unregister Nodes' request");
878 LOG_DEBUG(
Logger,
"opc_tcp_processor | sending response to 'Unregister Nodes' request");
880 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
895 LOG_WARN(
Logger,
"opc_tcp_processor | sending 'ServiceFaultResponse' to unsupported request of id: {}", message);
897 ostream << secureHeader << algorithmHeader << sequence << response <<
flush;
912 std::vector<uint32_t> subs;
916 subs.push_back(subid);
919 Server->Subscriptions()->DeleteSubscriptions(subs);
920 Subscriptions.clear();
std::vector< ApplicationDescription > Descriptions
OpcUa::ResponseHeader Header
std::vector< OpcUa::NodeId > NodesToRegister
#define LOG_WARN(__logger__,...)
QualifiedName GetBrowseName() const
OpcUa::ResponseHeader Header
OpcUa::CreateSubscriptionParameters Parameters
std::vector< AddNodesResult > results
std::vector< OpcUa::EndpointDescription > ServerEndpoints
std::vector< OpcUa::NotificationData > NotificationData
const uint8_t DATA_VALUE_STATUS_CODE
std::vector< OpcUa::StatusCode > Results
OpcUa::ResponseHeader Header
TranslateBrowsePathsResult Result
#define LOG_ERROR(__logger__,...)
#define LOG_DEBUG(__logger__,...)
std::vector< StatusCode > Results
void CloseChannel(Binary::IStreamBinary &istream)
OpcUa::NodeId AuthenticationToken
OpcUa::ResponseHeader Header
uint32_t MaxRequestMessageSize
std::vector< OpcUa::StatusCode > Results
OpcUa::CreateSessionResult Parameters
OStream< ChannelType > & flush(OStream< ChannelType > &os)
OpcUa::ResponseHeader Header
bool ProcessMessage(Binary::MessageType msgType, Binary::IStreamBinary &iStream)
void FillResponseHeader(const RequestHeader &requestHeader, ResponseHeader &responseHeader)
OpcUa::Binary::OStreamBinary OutputStream
OpcUa::ResponseHeader Header
std::vector< BrowseResult > Results
Binary::SequenceHeader sequence
OpcUa::ResponseHeader Header
Common::Logger::SharedPtr Logger
std::vector< OpcUa::DataValue > Results
#define LOG_INFO(__logger__,...)
OpcUa::RequestHeader Header
OpcUa::ResponseHeader Header
std::vector< OpcUa::MonitoredItemCreateResult > Results
std::vector< RelativePathElement > Elements
RequestHeader requestHeader
std::vector< BrowsePathResult > Paths
OpcUa::Services::SharedPtr Server
OpcUa::ResponseHeader Header
SecurityToken ChannelSecurityToken
OPC UA Address space part. GNU LGPL.
OpcUa::PublishResult Parameters
OpcUa::ResponseHeader Header
OpcUa::ResponseHeader Header
std::vector< OpcUa::StatusCode > Results
void ForwardPublishResponse(const PublishResult response)
Binary::SymmetricAlgorithmHeader algorithmHeader
OpcUa::PublishingModeResult Result
OpcUa::ResponseHeader Header
A Node object represent an OPC-UA node. It is high level object intended for developper who want to e...
OpcUa::ResponseHeader Header
OpcUa::SubscriptionData Data
void OpenChannel(Binary::IStreamBinary &istream, Binary::OStreamBinary &ostream)
OpcUa::RequestHeader Header
double RevisedSessionTimeout
static DateTime Current()
std::queue< PublishRequestElement > PublishRequestQueue
std::vector< OpcUa::NodeId > NodesToUnregister
OpcUa::ModifySubscriptionParameters Parameters
OpcTcpMessages(OpcUa::Services::SharedPtr server, OpcUa::OutputChannel::SharedPtr outputChannel, const Common::Logger::SharedPtr &logger)
std::vector< OpcUa::CallMethodResult > Results
uint32_t ReceiveBufferSize
void DeleteAllSubscriptions()
OpcUa::NotificationMessage NotificationMessage
std::vector< OpcUa::NodeId > Result
void DeleteSubscriptions(const std::vector< uint32_t > &ids)
ExpandedNodeId GenerateSessionId()
OpcUa::ResponseHeader Header
std::vector< OpcUa::SubscriptionAcknowledgement > SubscriptionAcknowledgements
OpcUa::ResponseHeader Header
std::list< uint32_t > Subscriptions
void ProcessRequest(Binary::IStreamBinary &istream, Binary::OStreamBinary &ostream)
OpcUa::ResponseHeader Header
OpcUa::RequestHeader Header
MessageId GetMessageId(const NodeId &id)
void HelloClient(Binary::IStreamBinary &istream, Binary::OStreamBinary &ostream)
std::vector< OpcUa::EndpointDescription > Endpoints
std::size_t RawSize(const T &obj)
std::vector< OpcUa::StatusCode > Results