private async Task <bool> Initialize(OPCUAParameters opcUAParameters, ThingCreationParameters thingCreation) { if (thingCreation == null) { thingCreation = new ThingCreationParameters(); } Dictionary <string, object> properties; if (opcUAParameters != null) { try { properties = TheCommonUtils.DeserializeJSONStringToObject <Dictionary <string, object> >(TheCommonUtils.SerializeObjectToJSONString(opcUAParameters)); } catch { return(false); } } else { properties = new Dictionary <string, object>(); } var tTaskForThing = TheThingRegistry.CreateOwnedThingAsync(new TheThingRegistry.MsgCreateThingRequestV1 { EngineName = TheOPCUAClientEngines.EngineName, DeviceType = eOPCUAClientDeviceTypes.RemoteServer, Address = ServerAddress, CreateIfNotExist = thingCreation.CreateIfNotExist, FriendlyName = thingCreation.FriendlyName, Hidden = thingCreation.Hidden, ReadOnly = thingCreation.ReadOnly, InstanceId = thingCreation.InstanceId, OwnerAddress = OwnerAddress, Properties = properties, }, new TheMessageAddress { Node = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID }, new TimeSpan(0, 0, 30)); var tThing = await tTaskForThing; if (tThing == null) { return(false); } OpcThingAddress = tThing; _opcThing = tThing; RegisterEvent(eOPCUAClientEvents.ConnectComplete, sinkConnected); RegisterEvent(eOPCUAClientEvents.ConnectFailed, sinkConnectFailure); RegisterEvent(eOPCUAClientEvents.DisconnectComplete, sinkDisconnected); return(true); }
public OPCUAParameters(OPCUAParameters p) { DisableSecurity = p.DisableSecurity; PreferredLocales = p.PreferredLocales; DisableDomainCheck = p.DisableDomainCheck; AutoConnect = p.AutoConnect; AcceptUntrustedCertificate = p.AcceptUntrustedCertificate; AcceptInvalidCertificate = p.AcceptInvalidCertificate; AppCertSubjectName = p.AppCertSubjectName; ReconnectPeriod = p.ReconnectPeriod; ReconnectCount = p.ReconnectCount; SessionTimeout = p.SessionTimeout; KeepAliveInterval = p.KeepAliveInterval; KeepAliveTimeout = p.KeepAliveTimeout; OperationTimeout = p.OperationTimeout; SendStatusCode = p.SendStatusCode; SendServerTimestamp = p.SendServerTimestamp; SendPicoSeconds = p.SendPicoSeconds; SendSequenceNumber = p.SendSequenceNumber; UseSequenceNumberForThingSequence = p.UseSequenceNumberForThingSequence; DoNotUsePropsOfProps = p.DoNotUsePropsOfProps; DoNotWriteArrayElementsAsProperties = p.DoNotWriteArrayElementsAsProperties; EnableOPCDataLogging = p.EnableOPCDataLogging; }
public static async Task <TheOPCUAClient> CreateAndInitAsync(TheMessageAddress owner, string serverAddress, OPCUAParameters opcUAParameters = null, OPCUAConnectParameters connectParameters = null, ThingCreationParameters thingCreationParameters = null) { var client = new TheOPCUAClient(owner, serverAddress, connectParameters); if (await client.Initialize(opcUAParameters, thingCreationParameters)) { return(client); } return(null); }