6:06, EEST
October 27, 2022
Hi
I seem to have hit a max array size as some of my arrays are not being created correctly on the server
this is the code i am using to define one of the arrays that doesnt work
gOPCHistLiveValid := MyNodeManager.CreateVariable(‘gHistLiveValid’);
gOPCHistLiveValid.DataTypeId := Id_Byte;
gOPCHistLiveValid.ArrayDimensions := [1,24, 0,33, 1,144, 1,2];
MyDevice.AddComponent(gOPCHistLiveValid);
gHistLiveValid := VarArrayCreate([1,24, 0,33, 1,144, 1,2], varByte);
vararraylock(gHistLiveValid);
gOPCHistLiveValid.Value := TUaVariant.Create(gHistLiveValid);
smaller ones using the same code are fine.
What is the default max array size and can this be increased and if so how?
thanks
wayne
14:46, EEST
December 21, 2011
16:22, EEST
October 27, 2022
4 dimensional arrays do work already if you define them as variant arrays
I have done further tests and it seems there is a limit of 65536 values in an array, go higher than this and the tag doesn’t seem to get created properly.
Is this a hard limit or is there a setting somewhere to increase it.
thanks
Wayne
14:03, EEST
December 21, 2011
Yes, you are right. It seems that the Stack defaults to 65535, although we are setting -1 by default. But, you can extend the limit with
ProsysOPC.UaStack,
…
begin
TUaStack.SerializerMaxArrayLength := MaxInt;
Add it to the beginning of the project file to be sure it’s set in time. These values are applied when the first TUaServer or TUaClient-component is created. So it applies to bothe server and client applications.
14:38, EEST
December 21, 2011
And you should actually initialise the ValueRank and Dimensions like this:
gOPCHistLiveValid.ArrayDimensions := [24, 34, 144, 2];
The values define the maximum number of elements in each dimensions.
If you don’t wish to define any maximums, you can use
gOPCHistLiveValid.ArrayDimensions := [0, 0, 0, 0];
If your array may also have a variable number of dimensions, you can use
gOPCHistLiveValid.ArrayDimensions := [];
And note that the arrays are delivered without the low index over OPC UA, so the client will not be able to distinguish if you define the the index range with 0,33 or 1,34. In OPC UA the array dimensions are always 0-based – and the client apps can actually access just some elements by defining the IndexRange parameter to Read calls.
But, if it helps you to define the data in the server with 1-based dimensions, just use them.
EDIT: The dimensions are maximums, not fixed sizes.
15:02, EEST
December 21, 2011
Here’s the reference to the specification:
https://reference.opcfoundation.org/v105/Core/docs/Part3/5.6.2/
5:40, EET
October 27, 2022
Unfortunately it doesn’t appear setting TUaStack.SerializerMaxArrayLength := MaxInt; does anything i tried going both ways larger and i still had the same issue.
So i set it to 20 which should have broken the other OPC arrays i was creating and they still worked.
I don’t have the source code version of your component so cant check the code but my guess is the stack is being set to -1 after i try to set it to the value i require.
I put the TUaStack.SerializerMaxArrayLength as the first line of code in formcreate.
10:37, EET
December 21, 2011
FormCreate is too late. The values are applied when the components are loaded and FormCreate happens after that.
That’s why you have to put it in the program source. Or you can add it to the form unit’s ‘initialization’ phase, if you don’t have other units that have UA components.
Eventually, you should, preferably use a smaller limit than MaxInt, to avoid potential side effects from malicious clients. since the limits are applied to all arrays in the stack layer.
Most Users Ever Online: 1919
Currently Online:
12 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 726
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1