17 using namespace OpcUa;
23 : Applications(GetApplications(url))
33 virtual std::vector<EndpointDescription> GetEndpoints(
const EndpointsFilter & filter)
const 40 throw std::logic_error(
"not implemented.");
44 std::vector<ApplicationDescription> GetApplications(
const std::string &
url)
const 49 app.ProductURI =
"ProductURI";
50 app.Name.Text =
"Name";
51 app.GatewayServerURI =
"GatewayServerURI";
52 app.DiscoveryProfileURI =
"DiscoveryProfileURI";
53 app.DiscoveryURLs.push_back(url);
54 return std::vector<ApplicationDescription>(1, app);
57 std::vector<EndpointDescription> GetEndpoints(
const std::string & url)
const 65 endpoint.
Server = GetApplications(url).front();
68 return std::vector<EndpointDescription>(1, endpoint);
71 std::vector<OpcUa::UserTokenPolicy> GetUserTokens()
const 79 return std::vector<OpcUa::UserTokenPolicy>(1, policy);
83 std::vector<ApplicationDescription> Applications;
84 std::vector<EndpointDescription>
Endpoints;
87 void Assert(
bool isTrue,
const char * msg)
91 throw std::logic_error(msg);
101 Assert(params.TimestampsType == TimestampsToReturn::BOTH,
"Invalid value of TimestampsToReturn.");
106 Assert(
id.DataEncoding.NamespaceIndex == 3,
"Invalid namespace index in DataEncoding.");
107 Assert(
id.DataEncoding.Name ==
"binary",
"Invalid name in DataEncoding.");
108 Assert(
id.IndexRange ==
"1:2",
"Invalid value of IndexRange.");
109 Assert(
id.
Node.IsInteger(),
"Node id is not integer.");
110 Assert(
id.
Node.GetIntegerIdentifier() == 2,
"Node id is not equal to 2.");
111 Assert(
id.
Node.GetNamespaceIndex() == 1,
"NodeId's namespace index is not equal to 1.");
121 data.ServerPicoseconds = 1;
122 data.ServerTimestamp.Value = 2;
123 data.SourcePicoseconds = 3;
124 data.SourceTimestamp.Value = 4;
128 return std::vector<DataValue>(1, data);
131 virtual std::vector<StatusCode>
Write(
const std::vector<OpcUa::WriteValue> & data)
133 Assert(data.size() == 1,
"Invalid number od data for write.");
137 Assert(value.Node.StringData.NamespaceIndex == 1,
"Invalid namespace of node.");
138 Assert(value.Node.StringData.Identifier ==
"node",
"Invalid identifier of node.");
139 Assert(value.NumericRange ==
"1:2",
"Invalid numeric range.");
140 Assert(value.Data.ServerPicoseconds == 1,
"Invalid ServerPicoseconds.");
141 Assert(value.Data.ServerTimestamp.Value == 2,
"Invalid ServerTimeStamp.");
142 Assert(value.Data.SourcePicoseconds == 3,
"Invalid SourcePicoseconds.");
143 Assert(value.Data.SourceTimestamp.Value == 4,
"Invalid SourceTimeStamp.");
146 Assert(value.Data.Value.As<
std::string>().size() == 1,
"Invalid number of strings in variant.");
147 Assert(value.Data.Value == std::vector<std::string>(1,
"value"),
"Invalid data value.");
149 const uint8_t encoding =
157 Assert(value.Data.Encoding == encoding,
"Invalid encoding mask.");
183 return std::vector<ReferenceDescription>(1, ref);
186 virtual std::vector<ReferenceDescription> BrowseNext()
const 188 return std::vector<ReferenceDescription>();
193 throw std::logic_error(
"not implemented.");
197 class TestComputer :
public Services 201 : EndpointsImpl(new TestEndpoints(url))
202 , ViewsImpl(new TestViewServices())
203 , AttributesImpl(new TestAttributes)
209 throw std::logic_error(
"not implemented.");
214 throw std::logic_error(
"not implemented.");
219 throw std::logic_error(
"not implemented.");
222 virtual std::shared_ptr<EndpointServices>
Endpoints()
224 return EndpointsImpl;
227 virtual std::shared_ptr<ViewServices>
Views()
232 virtual std::shared_ptr<AttributeServices> Attributes()
234 return AttributesImpl;
237 virtual std::shared_ptr<SubscriptionServices> Subscriptions()
239 throw std::logic_error(
"not implemented.");
242 virtual std::shared_ptr<NodeManagementServices> NodeManagement()
244 throw std::logic_error(
"not implemented.");
248 EndpointServices::SharedPtr EndpointsImpl;
249 ViewServices::SharedPtr ViewsImpl;
250 AttributeServices::SharedPtr AttributesImpl;
260 return std::unique_ptr<Services>(
new TestComputer(url));
std::vector< OpcUa::ReadValueId > AttributesToRead
struct OpcUa::NodeId::NumericDataType NumericData
std::vector< OpcUa::UserTokenPolicy > UserIdentityTokens
std::string SecurityPolicyUri
void CloseSession(OpcUa::Binary::IOStream &stream, const OpcUa::Binary::CreateSessionResponse &session)
const uint8_t DATA_VALUE_STATUS_CODE
std::string SecurityPolicyUri
std::string IssuedTokenType
std::vector< T > Browse(const NodeId &node, NodeClass nodeClassMask, Services::SharedPtr services)
LocalizedText DisplayName
const uint8_t DATA_VALUE_Server_TIMESTAMP
OpcUa::ApplicationDescription Server
std::string TransportProfileUri
OpcUa::Binary::CreateSessionResponse CreateSession(OpcUa::Binary::IOStream &stream)
const uint8_t DATA_VALUE_SOURCE_PICOSECONDS
struct OpcUa::NodeId::FourByteDataType FourByteData
NodeClass TargetNodeClass
const uint8_t DATA_VALUE_SOURCE_TIMESTAMP
OpcUa::MessageSecurityMode SecurityMode
OPC UA Address space part. GNU LGPL.
const uint8_t DATA_VALUE_Server_PICOSECONDS
void ActivateSession(OpcUa::Binary::IOStream &stream, const OpcUa::Binary::CreateSessionResponse &session)
NodeId TargetNodeTypeDefinition
struct OpcUa::NodeId::StringDataType StringData
OpcUa::ByteString ServerCertificate
A Node object represent an OPC-UA node. It is high level object intended for developper who want to e...
void Assert(bool condition, const char *file, int line)
OpcUa::UserTokenType TokenType
std::string IssuerEndpointUrl
std::unique_ptr< RemoteConnection > Connect(const std::string &host, unsigned port, const Common::Logger::SharedPtr &logger)