private HistoryReadValuesTests <EndpointModel> GetTests() { var codec = new VariantEncoderFactory(); return(new HistoryReadValuesTests <EndpointModel>( () => new HistoricAccessAdapter <EndpointModel>(new AddressSpaceServices(_server.Client, codec, _server.Logger), codec), new EndpointModel { Url = $"opc.tcp://{Dns.GetHostName()}:{_server.Port}/UA/SampleServer", Certificate = _server.Certificate?.RawData?.ToThumbprint() })); }
private HistoryReadValuesTests <EndpointModel> GetTests() { var codec = new VariantEncoderFactory(); return(new HistoryReadValuesTests <EndpointModel>( () => new AddressSpaceServices(_server.Client, codec, _server.Logger), new EndpointModel { Url = $"opc.tcp://{_hostEntry?.HostName ?? "localhost"}:{_server.Port}/UA/SampleServer", AlternativeUrls = _hostEntry?.AddressList .Where(ip => ip.AddressFamily == AddressFamily.InterNetwork) .Select(ip => $"opc.tcp://{ip}:{_server.Port}/UA/SampleServer").ToHashSet(), Certificate = _server.Certificate?.RawData?.ToThumbprint() }, codec)); }
private HistoryReadValuesTests <string> GetTests() { var client = _factory.CreateClient(); // Call to create server var module = _factory.Resolve <ITestModule>(); module.Endpoint = Endpoint; var log = _factory.Resolve <ILogger>(); var serializer = _factory.Resolve <IJsonSerializer>(); var codec = new VariantEncoderFactory(); return(new HistoryReadValuesTests <string>(() => // Create an adapter over the api new HistoryRawAdapter( new TwinServiceClient(new HttpClient(_factory, log), new TestConfig(client.BaseAddress), serializer)), "fakeid", codec)); }
/// <summary> /// Read value /// </summary> /// <param name="client"></param> /// <param name="endpoint"></param> /// <param name="elevation"></param> /// <param name="readNode"></param> /// <returns></returns> public static Task <JToken> ReadValueAsync(this IEndpointServices client, EndpointModel endpoint, CredentialModel elevation, string readNode) { var codec = new VariantEncoderFactory(); return(client.ExecuteServiceAsync(endpoint, elevation, session => { var nodesToRead = new ReadValueIdCollection { new ReadValueId { NodeId = readNode.ToNodeId(session.MessageContext), AttributeId = Attributes.Value } }; var responseHeader = session.Read(null, 0, TimestampsToReturn.Both, nodesToRead, out var values, out var diagnosticInfos); var result = codec.Create(session.MessageContext) .Encode(values[0].WrappedValue, out var tmp); return Task.FromResult(result); }));