Skip to content

Commit fe0aec4

Browse files
opcfoundation-orgrandy-armstrongmregen
authored
1.05.04 final release fixes (#2893)
* Add missing constants for JSON encoding. * Update generated files to 1.05.04. * Update NuGets * Fix compile errors due to abstract types. * Update nodesets. * Update JSON Encoder/Decoder. * Update with JSON encoder. * Change prefix char. * Change prefix to uppercase. * Fix JsonEncoder * Fix null pointer. * Update encoders to suppress artifacts. * JSON encoding fixes. * Fix JSON RawEncoding * Update JSON encoders. * Revert changes for Matrix in Variant. * Update NodeSet. * Resolve name conflict with new Opc.Ua types. * Fix failing Tests * Fix unit tests after change to Verbose/Compact encoding. * Add final 1.05.04 generated classes and unit test fixes. * Fix more unit tests. * Update NodeSet to released version. * Remove unintended changes to UANodeSet.xsd * Update Schema/UANodeSet.xsd * Merge breaking changes to JsonEncoder.cs from develop/main374 * Allow JObject in ExtensionObjects. * fix version json * Update generated files to UA-1.05.04-2025-01-08 * Some cleanup of the new APIs and Union implementation. (#2927) * Some cleanup of the new APIs and Union implementation. * fix build * Handle status code Uncertain according to the specification (#2898) * #2896: Write output arguments for good and uncertain status code When a method state's call method is invoked the output arguments should be written in case the status code is good or uncertain. This behavior would be conform with the current specification. * #2896: The service result corresponds the method call result The result of the Call method in the CustomNodeManager2 class represents the status of the CallMethodResult. It does not correspond to the ServiceResult of the CallResponse, thus returning Good as a general response is incorrect behavior. * Add SetHiResClockDisabled & fix Rejected Store Creation in ApplicationConfigurationBuilder (#2909) Add the method SetHiResClockDisabled to IApplicationConfigurationBuilder Fix the type of RejectedStore Created by the Builder to: CertificateStoreIdentifier * revert based on feedback * move some logic from class code to encoder/decoder * Fix race condition on Nuget build (#2930) - nodeset xmlzip is created in obj folders if multiple targets are built in parallel * update common comments * Update NodeSet files. * Fix ReadSwitchField Implementation. * Make UserIdentity.DisplayName writeable. * Fix merge failures. * Fix XmlElement encoding and bad NamespaceIndex fallback logic. * Fix 2D array raw encoding. * Add support for DesignToolOnly. --------- Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com> Co-authored-by: Martin Regen <mregen@microsoft.com> Co-authored-by: Martin Regen <7962757+mregen@users.noreply.github.com>
1 parent ef9387b commit fe0aec4

File tree

65 files changed

+71382
-46276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+71382
-46276
lines changed

Applications/ConsoleReferenceSubscriber/Program.cs

+11-19
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
using Opc.Ua;
3535
using Opc.Ua.PubSub;
3636
using Opc.Ua.PubSub.Configuration;
37-
using Opc.Ua.PubSub.Encoding;
37+
using Encoding = Opc.Ua.PubSub.Encoding;
3838
using Opc.Ua.PubSub.PublishedData;
3939
using Opc.Ua.PubSub.Transport;
4040

@@ -212,15 +212,15 @@ private static void UaPubSubApplication_DataReceived(object sender, SubscribedDa
212212
{
213213
Console.WriteLine("DataReceived event:");
214214

215-
if (e.NetworkMessage is UadpNetworkMessage)
215+
if (e.NetworkMessage is Encoding.UadpNetworkMessage)
216216
{
217217
Console.WriteLine("UADP Network DataSetMessage ({0} DataSets): Source={1}, SequenceNumber={2}",
218-
e.NetworkMessage.DataSetMessages.Count, e.Source, ((UadpNetworkMessage)e.NetworkMessage).SequenceNumber);
218+
e.NetworkMessage.DataSetMessages.Count, e.Source, ((Encoding.UadpNetworkMessage)e.NetworkMessage).SequenceNumber);
219219
}
220-
else if (e.NetworkMessage is JsonNetworkMessage)
220+
else if (e.NetworkMessage is Encoding.JsonNetworkMessage)
221221
{
222222
Console.WriteLine("JSON Network DataSetMessage ({0} DataSets): Source={1}, MessageId={2}",
223-
e.NetworkMessage.DataSetMessages.Count, e.Source, ((JsonNetworkMessage)e.NetworkMessage).MessageId);
223+
e.NetworkMessage.DataSetMessages.Count, e.Source, ((Encoding.JsonNetworkMessage)e.NetworkMessage).MessageId);
224224
}
225225

226226
foreach (UaDataSetMessage dataSetMessage in e.NetworkMessage.DataSetMessages)
@@ -248,20 +248,20 @@ private static void UaPubSubApplication_MetaDataDataReceived(object sender, Subs
248248
lock (m_lock)
249249
{
250250
Console.WriteLine("MetaDataDataReceived event:");
251-
if (e.NetworkMessage is JsonNetworkMessage)
251+
if (e.NetworkMessage is Encoding.JsonNetworkMessage)
252252
{
253253
Console.WriteLine("JSON Network MetaData Message: Source={0}, PublisherId={1}, DataSetWriterId={2} Fields count={3}\n",
254254
e.Source,
255-
((JsonNetworkMessage)e.NetworkMessage).PublisherId,
256-
((JsonNetworkMessage)e.NetworkMessage).DataSetWriterId,
255+
((Encoding.JsonNetworkMessage)e.NetworkMessage).PublisherId,
256+
((Encoding.JsonNetworkMessage)e.NetworkMessage).DataSetWriterId,
257257
e.NetworkMessage.DataSetMetaData.Fields.Count);
258258
}
259-
if (e.NetworkMessage is UadpNetworkMessage)
259+
if (e.NetworkMessage is Encoding.UadpNetworkMessage)
260260
{
261261
Console.WriteLine("UADP Network MetaData Message: Source={0}, PublisherId={1}, DataSetWriterId={2} Fields count={3}\n",
262262
e.Source,
263-
((UadpNetworkMessage)e.NetworkMessage).PublisherId,
264-
((UadpNetworkMessage)e.NetworkMessage).DataSetWriterId,
263+
((Encoding.UadpNetworkMessage)e.NetworkMessage).PublisherId,
264+
((Encoding.UadpNetworkMessage)e.NetworkMessage).DataSetWriterId,
265265
e.NetworkMessage.DataSetMetaData.Fields.Count);
266266
}
267267

@@ -326,8 +326,6 @@ private static PubSubConfigurationDataType CreateSubscriberConfiguration_UdpUadp
326326
readerGroup1.Name = "ReaderGroup 1";
327327
readerGroup1.Enabled = true;
328328
readerGroup1.MaxNetworkMessageSize = 1500;
329-
readerGroup1.MessageSettings = new ExtensionObject(new ReaderGroupMessageDataType());
330-
readerGroup1.TransportSettings = new ExtensionObject(new ReaderGroupTransportDataType());
331329

332330
#region Define DataSetReader 'Simple' for PublisherId = (UInt16)1, DataSetWriterId = 1
333331
DataSetReaderDataType dataSetReaderSimple = new DataSetReaderDataType();
@@ -338,7 +336,6 @@ private static PubSubConfigurationDataType CreateSubscriberConfiguration_UdpUadp
338336
dataSetReaderSimple.Enabled = true;
339337
dataSetReaderSimple.DataSetFieldContentMask = (uint)DataSetFieldContentMask.RawData;
340338
dataSetReaderSimple.KeyFrameCount = 1;
341-
dataSetReaderSimple.TransportSettings = new ExtensionObject(new DataSetReaderTransportDataType());
342339

343340
UadpDataSetReaderMessageDataType uadpDataSetReaderMessage = new UadpDataSetReaderMessageDataType() {
344341
GroupVersion = 0,
@@ -385,7 +382,6 @@ private static PubSubConfigurationDataType CreateSubscriberConfiguration_UdpUadp
385382
dataSetReaderAllTypes.Enabled = true;
386383
dataSetReaderAllTypes.DataSetFieldContentMask = (uint)DataSetFieldContentMask.RawData;
387384
dataSetReaderAllTypes.KeyFrameCount = 1;
388-
dataSetReaderAllTypes.TransportSettings = new ExtensionObject(new DataSetReaderTransportDataType());
389385

390386
uadpDataSetReaderMessage = new UadpDataSetReaderMessageDataType() {
391387
GroupVersion = 0,
@@ -468,8 +464,6 @@ private static PubSubConfigurationDataType CreateSubscriberConfiguration_MqttJso
468464
readerGroup1.Name = "ReaderGroup 1";
469465
readerGroup1.Enabled = true;
470466
readerGroup1.MaxNetworkMessageSize = 1500;
471-
readerGroup1.MessageSettings = new ExtensionObject(new ReaderGroupMessageDataType());
472-
readerGroup1.TransportSettings = new ExtensionObject(new ReaderGroupTransportDataType());
473467

474468
#region Define DataSetReader1 'Simple' for PublisherId = (UInt16)2, DataSetWriterId = 1
475469

@@ -625,8 +619,6 @@ private static PubSubConfigurationDataType CreateSubscriberConfiguration_MqttUad
625619
readerGroup1.Name = "ReaderGroup 1";
626620
readerGroup1.Enabled = true;
627621
readerGroup1.MaxNetworkMessageSize = 1500;
628-
readerGroup1.MessageSettings = new ExtensionObject(new ReaderGroupMessageDataType());
629-
readerGroup1.TransportSettings = new ExtensionObject(new ReaderGroupTransportDataType());
630622

631623
#region Define DataSetReader 'Simple' for PublisherId = (UInt16)1, DataSetWriterId = 1
632624
DataSetReaderDataType dataSetReaderSimple = new DataSetReaderDataType();

Applications/Quickstarts.Servers/Alarms/AlarmNodeManager.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
using System;
3131
using System.Collections.Generic;
32+
using System.Globalization;
3233
using System.Threading;
3334
using Opc.Ua;
3435
using Opc.Ua.Server;
@@ -143,7 +144,7 @@ public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> e
143144

144145
Type alarmControllerType = Type.GetType("Alarms.AlarmController");
145146
int interval = 1000;
146-
string intervalString = interval.ToString();
147+
string intervalString = interval.ToString(CultureInfo.InvariantCulture);
147148

148149
int conditionTypeIndex = 0;
149150
#endregion

Applications/Quickstarts.Servers/ReferenceServer/ReferenceNodeManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> e
669669
string referenceString = "Has3ForwardReferences";
670670
if (i > 1)
671671
{
672-
referenceString += i.ToString();
672+
referenceString += i.ToString(CultureInfo.InvariantCulture);
673673
}
674674
BaseDataVariableState has3ForwardReferences = CreateMeshVariable(referencesFolder, referencesPrefix + referenceString, referenceString);
675675
has3ForwardReferences.AddReference(ReferenceTypes.HasCause, false, variables[0].NodeId);

Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ private async Task<NodeId> GetBuiltInSuperTypeAsync(NodeId dataType, bool allowS
11581158
{
11591159
// enumerations of namespace 0 in a structure
11601160
// which are not in the type system are encoded as UInt32
1161-
return new NodeId((uint)BuiltInType.UInt32);
1161+
return DataTypeIds.UInt32;
11621162
}
11631163
if (superType == DataTypeIds.Enumeration)
11641164
{

Libraries/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ public override void Encode(IEncoder encoder)
9393
{
9494
encoder.PushNamespace(XmlNamespace);
9595

96-
if (encoder.UseReversibleEncoding)
97-
{
98-
encoder.WriteUInt32("EncodingMask", m_encodingMask);
99-
}
96+
encoder.WriteEncodingMask(m_encodingMask);
10097

10198
foreach (var property in GetPropertyEnumerator())
10299
{
@@ -118,7 +115,22 @@ public override void Decode(IDecoder decoder)
118115
{
119116
decoder.PushNamespace(XmlNamespace);
120117

121-
m_encodingMask = decoder.ReadUInt32("EncodingMask");
118+
m_encodingMask = decoder.ReadEncodingMask(null);
119+
120+
// try again if the mask is implicitly defined by the JSON keys
121+
if (m_encodingMask == 0 && decoder is IJsonDecoder)
122+
{
123+
var masks = new StringCollection();
124+
foreach (var property in GetPropertyEnumerator())
125+
{
126+
if (property.IsOptional)
127+
{
128+
masks.Add(property.Name);
129+
}
130+
}
131+
132+
m_encodingMask = decoder.ReadEncodingMask(masks);
133+
}
122134

123135
foreach (var property in GetPropertyEnumerator())
124136
{
@@ -132,6 +144,7 @@ public override void Decode(IDecoder decoder)
132144

133145
DecodeProperty(decoder, property);
134146
}
147+
135148
decoder.PopNamespace();
136149
}
137150

Libraries/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs

+44-10
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,9 @@ public override void Encode(IEncoder encoder)
9494
{
9595
encoder.PushNamespace(XmlNamespace);
9696

97-
string fieldName = null;
98-
if (encoder.UseReversibleEncoding)
99-
{
100-
encoder.WriteUInt32("SwitchField", m_switchField);
101-
fieldName = "Value";
102-
}
97+
// the encoder may return an override for the field name
98+
// e.g. to support reversible JSON encoding
99+
encoder.WriteSwitchField(m_switchField, out string fieldName);
103100

104101
if (m_switchField != 0)
105102
{
@@ -114,11 +111,17 @@ public override void Encode(IEncoder encoder)
114111
}
115112
unionSelector++;
116113
}
114+
115+
if (encoder.UseReversibleEncoding)
116+
{
117+
fieldName = fieldName ?? unionProperty.Name;
118+
}
119+
117120
EncodeProperty(encoder, fieldName, unionProperty);
118121
}
119122
else if (!encoder.UseReversibleEncoding)
120123
{
121-
encoder.WriteString(null, "null");
124+
encoder.WriteString(null, null);
122125
}
123126

124127
encoder.PopNamespace();
@@ -129,20 +132,51 @@ public override void Decode(IDecoder decoder)
129132
{
130133
decoder.PushNamespace(XmlNamespace);
131134

132-
m_switchField = decoder.ReadUInt32("SwitchField");
135+
string fieldName = "Value";
136+
UInt32 unionSelector = 0;
137+
138+
unionSelector = decoder.ReadSwitchField(null, out var newFieldName);
139+
140+
// maybe the switch field is implicitly defined by the JSON keys
141+
bool isJsonDecoder = decoder.EncodingType == EncodingType.Json;
142+
if (unionSelector == 0 && isJsonDecoder)
143+
{
144+
var fields = new StringCollection();
145+
foreach (var property in GetPropertyEnumerator())
146+
{
147+
if (property.IsOptional)
148+
{
149+
fields.Add(property.Name);
150+
}
151+
}
152+
153+
unionSelector = decoder.ReadSwitchField(fields, out var newFeildName);
154+
}
133155

134-
UInt32 unionSelector = m_switchField;
156+
m_switchField = unionSelector;
135157
if (unionSelector > 0)
136158
{
137159
foreach (var property in GetPropertyEnumerator())
138160
{
139161
if (--unionSelector == 0)
140162
{
141-
DecodeProperty(decoder, "Value", property);
163+
fieldName = property.Name;
164+
165+
if (isJsonDecoder &&
166+
decoder is IJsonDecoder jsonDecoder &&
167+
jsonDecoder.ReadField("Value", out _))
168+
{
169+
DecodeProperty(jsonDecoder, "Value", property);
170+
}
171+
else
172+
{
173+
DecodeProperty(decoder, fieldName, property);
174+
}
142175
break;
143176
}
144177
}
145178
}
179+
146180
decoder.PopNamespace();
147181
}
148182

Libraries/Opc.Ua.Gds.Server.Common/ApplicationsDatabase/ApplicationsDatabaseBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ApplicationRecordDataType application
121121
}
122122
}
123123

124-
NodeId nodeId = new NodeId();
124+
NodeId nodeId = NodeId.Null;
125125
if (!NodeId.IsNull(application.ApplicationId))
126126
{
127127
// verify node integrity

0 commit comments

Comments
 (0)