本文整理汇总了C#中ConfiguredEndpoint.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ConfiguredEndpoint.Update方法的具体用法?C# ConfiguredEndpoint.Update怎么用?C# ConfiguredEndpoint.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfiguredEndpoint
的用法示例。
在下文中一共展示了ConfiguredEndpoint.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConsoleSampleClient
public static async Task ConsoleSampleClient(string endpointURL)
{
Console.WriteLine("1 - Create an Application Configuration.");
var config = new ApplicationConfiguration()
{
ApplicationName = "UA Core Sample Client",
ApplicationType = ApplicationType.Client,
ApplicationUri = "urn:"+Utils.GetHostName()+":OPCFoundation:CoreSampleClient",
SecurityConfiguration = new SecurityConfiguration
{
ApplicationCertificate = new CertificateIdentifier
{
StoreType = "Directory",
StorePath = "OPC Foundation/CertificateStores/MachineDefault",
SubjectName = "UA Core Sample Client"
},
TrustedPeerCertificates = new CertificateTrustList
{
StoreType = "Directory",
StorePath = "OPC Foundation/CertificateStores/UA Applications",
},
TrustedIssuerCertificates = new CertificateTrustList
{
StoreType = "Directory",
StorePath = "OPC Foundation/CertificateStores/UA Certificate Authorities",
},
RejectedCertificateStore = new CertificateTrustList
{
StoreType = "Directory",
StorePath = "OPC Foundation/CertificateStores/RejectedCertificates",
},
NonceLength = 32,
AutoAcceptUntrustedCertificates = true
},
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 15000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }
};
await config.Validate(ApplicationType.Client);
bool haveAppCertificate = config.SecurityConfiguration.ApplicationCertificate.Certificate != null;
if (!haveAppCertificate)
{
Console.WriteLine(" INFO: Creating new application certificate: {0}", config.ApplicationName);
X509Certificate2 certificate = CertificateFactory.CreateCertificate(
config.SecurityConfiguration.ApplicationCertificate.StoreType,
config.SecurityConfiguration.ApplicationCertificate.StorePath,
config.ApplicationUri,
config.ApplicationName
);
config.SecurityConfiguration.ApplicationCertificate.Certificate = certificate;
}
haveAppCertificate = config.SecurityConfiguration.ApplicationCertificate.Certificate != null;
if (haveAppCertificate)
{
config.ApplicationUri = Utils.GetApplicationUriFromCertificate(config.SecurityConfiguration.ApplicationCertificate.Certificate);
if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates)
{
config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
}
}
else
{
Console.WriteLine(" WARN: missing application certificate, using unsecure connection.");
}
Console.WriteLine("2 - Discover endpoints of {0}.", endpointURL);
Uri endpointURI = new Uri(endpointURL);
var endpointCollection = DiscoverEndpoints(config, endpointURI, 10);
var selectedEndpoint = SelectUaTcpEndpoint(endpointCollection, haveAppCertificate);
Console.WriteLine(" Selected endpoint uses: {0}",
selectedEndpoint.SecurityPolicyUri.Substring(selectedEndpoint.SecurityPolicyUri.LastIndexOf('#') + 1));
Console.WriteLine("3 - Create a session with OPC UA server.");
var endpointConfiguration = EndpointConfiguration.Create(config);
var endpoint = new ConfiguredEndpoint(selectedEndpoint.Server, endpointConfiguration);
endpoint.Update(selectedEndpoint);
var session = await Session.Create(config, endpoint, true, ".Net Core OPC UA Console Client", 60000, null, null);
Console.WriteLine("4 - Browse the OPC UA server namespace.");
ReferenceDescriptionCollection references;
Byte[] continuationPoint;
references = session.FetchReferences(ObjectIds.ObjectsFolder);
session.Browse(
null,
null,
ObjectIds.ObjectsFolder,
0u,
BrowseDirection.Forward,
ReferenceTypeIds.HierarchicalReferences,
//.........这里部分代码省略.........