Difference when adding StreamState programmatically vs using XML|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Difference when adding StreamState programmatically vs using XML
Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
1
07/13/2021 - 07:44
sp_Permalink sp_Print

Hi

In C#, when I add a stream state with the model compiler using:

<Object SymbolicName=”MNS:MyStream1″ TypeDefinition=”ADI:StreamType”>
</Object>

I do not get IsEnabled and IsForced in the configuration. However when I use the below code, I do. 

var stream = new StreamState(this);
stream.Create(context, null, new QualifiedName(“MyStream”), null, true);
this.AddChild(stream);

Why is this and how do I get my XML stream state to have the mentioned properties in the configuration?

Thanks for any help.

JC

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/13/2021 - 14:51
sp_Permalink sp_Print sp_EditHistory

DI:ParameterSet is optional so it does not appear unless explicitly declared in an instance.

The Server Object declaration has the same issue and deals with it by re-declaring instances as Mandatory:

You do not need to repeat information from the type since it will be automatically filled in.

In C# you have explicitly create optional children before calling Create.

Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
3
07/23/2021 - 06:22
sp_Permalink sp_Print

Thank you Randy

Two questions:

1) Can you show how to re-declare as mandatory please?

2) If doing the explicit creation in C#, how do you refer to the existing IsEnabled?

Cheers, 

JC

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
07/23/2021 - 10:57
sp_Permalink sp_Print

Search for the “Server” Object:

https://github.com/OPCFoundati…..dTypes.xml

In memory serves, the DI model does not follow the pattern that the C# code generator expects because of the un-typed folders with random properties and methods thrown into an instance. The lack of types means no named property accessors unless you add them in your own code.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 27
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4891