<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	    <channel>
        <title>Prosys Forum - Forum: Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</title>
        <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/</link>
        <description><![CDATA[Prosys OPC &#038; OPC UA related discussion]]></description>
        <generator>Simple:Press Version 6.11.11</generator>
        <atom:link href="https://forum.prosysopc.com/forum/opc-sdk-sentrol/rss/" rel="self" type="application/rss+xml"/>
		                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7502</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7502</guid>
					                        <description><![CDATA[<p>Well done. I managed to explain that, as well, while you already got it 🙂</p>
]]></description>
					                    <pubDate>Tue, 24 Mar 2026 18:20:29 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7501</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7501</guid>
					                        <description><![CDATA[<p>Update:</p>
<p>Ok, figured out how that is supposed to work. I found the VarStructureCreate function in UAVariants.</p>
<p>What you do is create a normal variant array and then add the type structure with VarStructureCreate(...) to each element of that array. So something like this (this example omits a couple steps but highlights the part of how to create the array of the structure type.</p>
<p>var<br />
  V: Variant<br />
  myStruct: IUaDynamicStructure;<br />
begin<br />
  MyTypeVar := MyNodeManager.CreateVar(‘test’);<br />
  MyTypeVar.DataType := MyStructType2;<br />
  MyTypeVar.DataTypeID := MyStructType2.NodeID;</p>
<p>  MyBuilder := UAServer.TypeDictionary.CreateDynamicStructureBuilder(myStructType2.NodeId);</p>
<p>  //fill normal elements<br />
  V := VarArrayCreate([0, 1], varVariant);<br />
  for i := 0 to 2 do<br />
  begin<br />
    myStruct := CreateStructure(..); //this creates the actual structure using the Builder Interface<br />
    V[i] := VarStructureCreate(MyStruct);<br />
  end;</p>
<p>  MyBuilder.SetFieldValue('Field2', TUaVariant.Create(V));</p>
<p>  MyTypeVar.Value := MyBuilder.Build;<br />
end;</p>
]]></description>
					                    <pubDate>Tue, 24 Mar 2026 18:06:29 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7500</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7500</guid>
					                        <description><![CDATA[<p>And this method would do the generic conversion:</p>
<p></p>
<div class='sfcode' id='sfcode1366'>
function TUaSampleServerForm.CreateStructureArray(Value: array of TUaVariant):<br />
  TUaVariant;<br />
var<br />
  High: Integer;<br />
  I: Integer;<br />
  V: Variant;<br />
begin<br />
  High := Length(Value)-1;<br />
  V := VarArrayCreate([0,High], varVariant);<br />
  for I := 0 to High do<br />
    // VarStructureCreate is in ProsysOPC.UaVariants<br />
    V[I] := VarStructureCreate(Value[I]);<br />
  Result := TUaVariant.Create(V);<br />
end;
</div>
]]></description>
					                    <pubDate>Tue, 24 Mar 2026 18:05:11 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7499</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7499</guid>
					                        <description><![CDATA[<p>Well, yeah, quite simple, if you know what you need to do. <img class="spSmiley" style="margin:0" src="https://forum.prosysopc.com/wp-content/sp-resources/forum-smileys/sf-wink.gif" title="Wink" alt="Wink" /></p>
<p>I didn't remember even myself by heart, but managed to create the sample. It's a bit too complicated to work together with TUaVariant and Variant and the arrays require Variants.</p>
<p>So, it goes like this:</p>
<p></p>
<div class='sfcode' id='sfcode3591'>
function TUaSampleServerForm.CreateMyStructureArrayValue: TUaVariant;<br />
var<br />
  V: Variant;<br />
begin<br />
  V := VarArrayCreate([0,1], varVariant);<br />
  // VarStructureCreate is in ProsysOPC.UaVariants<br />
  V[0] := VarStructureCreate(CreateMyStructureValue);<br />
  V[1] := VarStructureCreate(CreateMyStructureValue);<br />
  Result := TUaVariant.Create(V);<br />
end;
</div>
<p>where 'CreateMyStructureValue' returns a single 'IUaStructure' value, similar to what I wrote above (I will add the function definition in there, too).</p>
]]></description>
					                    <pubDate>Tue, 24 Mar 2026 17:45:39 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7498</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7498</guid>
					                        <description><![CDATA[<p>I stumbled over something else, which I guess is fairly simple I just don't see it right now.</p>
<p>How do I create an array of a complex type? For example my Structure looks like this:</p>
<p>MyStructureType<br />
-&#062; Field1: Integer<br />
-&#062; Field2: String<br />
-&#062; Field3: array of String</p>
<p>MyStructureType2<br />
-&#062; Field1: string<br />
-&#062; Field2: array of MyStructureType</p>
<p>Just to clarify I'm not talking about the declaration of the type this time, that works perfectly fine but the creation of the actual value for it using the </p>
<p>MyBuilder := UAServer.TypeDictionary.CreateDynamicStructureBuilder(MyStructureType2.NodeID);</p>
<p>the standard fields are clear, just call </p>
<p>MyBuilder.SetFieldValue('Field1', 'Test')</p>
<p>For an array of simple types I use something like this:<br />
var<br />
  v: Variant;</p>
<p>v := VarArrayCreate([0, 6], varString);<br />
TUaVariant.Create(v);</p>
<p>for a complex type I tried using this:<br />
var<br />
  A: Array of TUaVariant;<br />
  MyTypeVar: TUaVariable;<br />
begin<br />
  MyTypeVar := MyNodeManager.CreateVar('test');<br />
  MyTypeVar.DataType := MyStructType2;<br />
  MyTypeVar.DataTypeID := MyStructType2.NodeID;</p>
<p>  MyBuilder := UAServer.TypeDictionary.CreateDynamicStructureBuilder(myStructType2.NodeId);</p>
<p>  SetLength(A, 3);</p>
<p>  for i := 0 to 2 do<br />
  begin<br />
    p := CreateStructure(...); //this one creates a builder for the MyStructType and fills it with values, that works<br />
    A[0] := p;<br />
  end;</p>
<p>  MyBuilder.SetField('Field2', TUaVariant.Create(A));</p>
<p>  MyTypeVar.Value := MyBuilder.Build;<br />
end;</p>
<p>that compiles without problems but gives me a runtime error "Invalid class typecast" when I try to assign the actual build variable to the UAVariable, so last line there.</p>
<p>I tried a couple different approaches too but always ran in some kind of runtime error. I'm pretty sure I'm doing something wrong there but I'm not sure what...</p>
]]></description>
					                    <pubDate>Tue, 24 Mar 2026 15:53:07 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7497</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7497</guid>
					                        <description><![CDATA[<p>Yeah, it's good to find all the details. You seem to be ahead of everyone else, since these parts of the SDK hadn't been used before and not 100% verified for your case... </p>
<p>And it's always nice to work on things that people use for real. So, let us know if you bump into something else along the way.</p>
]]></description>
					                    <pubDate>Mon, 23 Mar 2026 13:57:59 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7494</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7494</guid>
					                        <description><![CDATA[<p>That does look very promising. A first quick test with the sample server project looked good.<br />
I added the browse name fix for the object type creation too, just in case.</p>
<p>Thank you for the help with this and if you found a couple bugs along the way that's a nice benefit for you too. Fewer bugs are always nice 😉</p>
]]></description>
					                    <pubDate>Mon, 23 Mar 2026 13:31:58 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7491</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7491</guid>
					                        <description><![CDATA[<p>Well, it wasn't that complicated, after all.:)  </p>
<p>A couple of hurdles (bugs) were just making it a bit harder...</p>
<p>This method defines a new structure type:</p>
<p></p>
<div class='sfcode' id='sfcode5413'>
procedure TUaSampleServerForm.CreateMyStructureType;<br />
var<br />
  Fields: TArray;<br />
  MyBinaryEncodeId: TUaNodeId;<br />
  MyBinaryEncoding: TUaObject;<br />
  MyStructureTypeId: TUaNodeId;<br />
  S: IUaStructureDefinition;<br />
begin<br />
  MyStructureTypeId := TUaNodeId.Create(MyNodeManager.Namespace, 10001);<br />
  MyBinaryEncodeId := TUaNodeId.Create(MyNodeManager.Namespace, 10002);</p>
<p>  // The new Type Node<br />
  MyStructureType := UaServer.AddressSpace.GetType(Id_Structure).<br />
    AddSubtype(MyStructureTypeId, 'MyStructureType') as TUaDataType;<br />
  // Seems to be a bug that this needs to be defined separately:<br />
  MyStructureType.BrowseName :=<br />
    TUaQualifiedName.Create(MyNodeManager.Namespace, 'MyStructureType');</p>
<p>  // Encoding Node for the new Type<br />
  MyBinaryEncoding := MyNodeManager.CreateObject('Default Binary', MyBinaryEncodeId);<br />
  MyBinaryEncoding.TypeDefinitionId := Id_DataTypeEncodingType;<br />
  MyStructureType.AddReference(MyBinaryEncoding, Id_HasEncoding);</p>
<p>  // The Structure Fields<br />
  SetLength(Fields, 2);</p>
<p>  Fields[0] := TUaStructureField.Builder.<br />
    Name('Field0').DataType(Id_String).ValueRank(vrScalar).IsOptional(False).<br />
    Build;<br />
  Fields[1] := TUaStructureField.Builder.<br />
    Name('Field1').DataType(Id_Double).ValueRank(vrScalar).IsOptional(False).<br />
    Build;</p>
<p>  // The Structure Definition<br />
  S := TUaStructureDefinition.Builder.<br />
    BaseDataType(Id_Structure).<br />
    DefaultEncodingId(MyBinaryEncodeId).<br />
    StructureType(stStructure).<br />
    Fields(Fields).<br />
    Build;</p>
<p>  MyStructureType.DataTypeDefinition := S;<br />
end;
</p>
</div>
<p>and then you can create the variable with:</p>
<p></p>
<div class='sfcode' id='sfcode4006'>
  MyStructure := MyNodeManager.CreateVariable('MyStructure');<br />
  MyStructure.DataType := MyStructureType; // Another bug in here, so you need to use also:<br />
  MyStructure.DataTypeId := MyStructureType.NodeId;
</div>
<p>and then you can create the value, with</p>
<p></p>
<div class='sfcode' id='sfcode7700'>
  MyStructure.Value := CreateMyStructureValue;
</div>
<p>where</p>
<p></p>
<div class='sfcode' id='sfcode2630'>
function TUaSampleServerForm.CreateMyStructureValue: IUaDynamicStructure;<br />
begin<br />
  Result := UaServer.TypeDictionary.CreateDynamicStructureBuilder(MyStructureType.NodeId).<br />
    SetFieldValue('Field0', 'a string').<br />
    SetFieldValue('Field1', 4.4).<br />
    Build;<br />
end;
</div>
<p>I will get the bugs fixed to the next release, and can provide you a beta as well.</p>
<p>But fix the BrowseName for your ObjectType as well. Prosys OPC UA Browser didn't seem to like it, if it was missing...</p>
]]></description>
					                    <pubDate>Fri, 20 Mar 2026 22:12:34 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7490</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7490</guid>
					                        <description><![CDATA[<p>Yes, this is not so simple, and I need to study a bit more, to see if it is even possible at the moment. The data types are typically defined with UaModeler and exported to Nodeset files, where they are loaded to the server types. </p>
<p>I tried to find the proper way to do it, but it may be that the SDK needs a bit of tweaks to enable what you need. I will keep you updated.</p>
]]></description>
					                    <pubDate>Fri, 20 Mar 2026 21:07:53 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7489</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7489</guid>
					                        <description><![CDATA[<p>I ran into another thing now. Is it possible to create datatypes for structures dynamically as well? The example in the server (CreateDynamicStructureValue) shows how to use a type that is defined in a nodeset.xml but again I'd like to skip the NodeSet.xml and do it manually / dynamically in code.</p>
<p>What I got so far is the following:</p>
<p>MyType2 := (MyNodeManager.GetType(Id_StructureType) as TUaDataType)<br />
    .AddSubtype(TUaNodeId.Create(MyNodeManager.Namespace, 9998), 'MyTestStruct') as TUaDataType;</p>
<p>pDef := TUaDataTypeDefinition.Create;</p>
<p>//define the actual datatype<br />
//?</p>
<p>MyType2.DataTypeDefinition := pDef;</p>
<p>The problem is I don't see a way to actually define the fields in the TypeDefinition, as it seems like it only allows to read fields, but not to actually define them. Using the Builder Interface (TUaDataTypeDefinition.Builder) doesn't seem to help either, as that again expects a definition to create the structure...</p>
]]></description>
					                    <pubDate>Fri, 20 Mar 2026 16:49:59 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7485</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7485</guid>
					                        <description><![CDATA[<p>Super. Just ask, if there are more details that you need to refine.</p>
]]></description>
					                    <pubDate>Fri, 20 Mar 2026 12:32:54 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7484</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7484</guid>
					                        <description><![CDATA[<p>Thanks for the help, seems like I got everything I need now and can build the actual logic for the server to support PackML and custom types.</p>
]]></description>
					                    <pubDate>Fri, 20 Mar 2026 12:29:52 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7483</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7483</guid>
					                        <description><![CDATA[<p>And for the subtypes, you need to have the HasSubtype reference in place. So, best to use the AddSubType method, which adds that, too.</p>
]]></description>
					                    <pubDate>Thu, 19 Mar 2026 20:38:49 +0200</pubDate>
                </item>
				                <item>
                    <title>Jouni Aro on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7482</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7482</guid>
					                        <description><![CDATA[<p>Good that you figured out the Variable creation. I don't even recall what was the exact difference here, but CreateVariable is the proper way to do it...</p>
<p>When you create your object instances, you should not place them in the PackMLNodeManager, but your own. So always use</p>
<p>MyNodeManager.CreateInstance and TUaNodeId.Create(MyNodeManager, ...)</p>
<p>for them. The PackMLNodeManager is hosting the types defined in that model and you should not extend it yourself.</p>
<p>Note that CreateInstance will also define a new NodeId based on the name, by default, if you omit the NodeId. But you can see which strategy works the best for you.</p>
<p>For the optional members, you need to define the names using the PackML Namespace. The default is the OPC UA Standard namespace, which works for those types only.  And again, modify your own NodeManager. So, try this:</p>
<p>MyNodeManager.NodeBuilderConfiguration :=<br />
TUaTypeDefinitionBasedNodeBuilderConfiguration.Builder<br />
.AddOptional(TUaQualifiedName.Create(PackMLNodeManager.Namespace, ‘Parameter’))<br />
.AddOptional(TUaQualifiedName.Create(PackMLNodeManager.Namespace, ‘Product’))<br />
.AddOptional(TUaQualifiedName.Create(PackMLNodeManager.Namespace, ‘MaterialInterlocked’))<br />
.Build;</p>
]]></description>
					                    <pubDate>Thu, 19 Mar 2026 20:36:26 +0200</pubDate>
                </item>
				                <item>
                    <title>Patrick on Custom Object Types</title>
                    <link>https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7481</link>
                    <category>Prosys Sentrol OPC UA &#038; Classic SDK for Delphi</category>
                    <guid isPermaLink="true">https://forum.prosysopc.com/forum/opc-sdk-sentrol/custom-object-types/#p7481</guid>
					                        <description><![CDATA[<p>Update:<br />
Seems like the trick to get the UaVariable added to the type definition is to use:</p>
<p>p := MyNodeManager.CreateVariable('Test');<br />
instead of<br />
p := TUaVariable.Create(MyNodeManager);</p>
]]></description>
					                    <pubDate>Thu, 19 Mar 2026 19:58:07 +0200</pubDate>
                </item>
				    </channel>
	</rss>
