CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

Dimensional array table
https://forum.codesys.com/viewtopic.php?f=11&t=10150
Page 1 of 1

Author:  LooijmansR [ Fri Nov 15, 2019 10:29 am ]
Post subject:  Dimensional array table

Hi,

I need to show some user-specific data which is stored into a 3-dimensional array, like:

userData : ARRAY[0..9,1..10,1..5] OF STRING;

The data is stored this way, because it is SQL data which needs to be visualized for the user. The visualization table works fine with a 2-dimensional array, but refuses to work with a 3-dimensional array, even when in the data-field (in the visu) a 2-dimensional array is stored.

Example:

Variable:
testData: ARRAY[1..10,1..5] OF STRING;

Data-field:
testData

Works fine, but when the following is entered, it's not working as I intended it to work.

Variable:
userData : ARRAY[0..9,1..10,1..5] OF STRING;

Data-field:
userData[CURRENTCLIENTID]

userData[CURRENTCLIENTID] really is a 2-dimensional array. So I have no idea why it would not work.

I hope someone could tell me what I am doing wrong or what I should do different.

Kind regards,
Reno

Author:  m.prestel [ Fri Nov 15, 2019 10:44 am ]
Post subject:  Re: Dimensional array table

Hello Reno,

could you provide a small example?

Thx!

Best regards,
Marcel

Author:  LooijmansR [ Fri Nov 15, 2019 11:18 am ]
Post subject:  Re: Dimensional array table

Hi Marcel,

Of course. See images attached ;-)

Thanks in advance.

Kind regards,
Reno

Author:  m.prestel [ Fri Nov 15, 2019 12:16 pm ]
Post subject:  Re: Dimensional array table

Hello,

that is not how the access to the array works, you need to specify the index of each dimension.

You cannot do stuff like this:
strMachineHistory := strMachineTest[0];

What you really wanna do, is defining an array of array!

Just keep in mind -1 is a valid ID for CURRENTCLIENTID (Better use the constants VISU_MIN_NUMBER_OF_CLIENTS and VISU_MAX_NUMBER_OF_CLIENTS)

Best regards,
Marcel

Author:  LooijmansR [ Fri Nov 15, 2019 1:36 pm ]
Post subject:  Re: Dimensional array table

Hi Marcel,

Thanks for the tip on VISU_MIN_NUMBER_OF_CLIENTS and VISU_MAX_NUMBER_OF_CLIENTS, I'm gonna edit that right away.

Though, I'm not entirely sure what you're advising. If you're implying what I think you are, then that is not working either. See image attached.

In any case, how would I best render a table with SQL data based on the visu user? I really thought a 3D array would be a good solution if I provided the client ID as the first index in the table data array.

Author:  m.prestel [ Mon Nov 18, 2019 8:25 am ]
Post subject:  Re: Dimensional array table

Hello,

to make the configuration work you need to define strMachineTest like this

strMachineTest : ARRAY[VISU_MIN_NUMBER_OF_CLIENTS ..VISU_MAX_NUMBER_OF_CLIENTS] OF ARRAY[0..5,1..10] OF STRING;

If that is not what you are trying to do, then please describe your data a bit more and why/if it has really 3 dimensions.

Best regards,
Marcel

Author:  LooijmansR [ Fri Nov 22, 2019 11:03 am ]
Post subject:  Re: Dimensional array table

Hi Marcel,

Thanks for your reply! That seems like it is the solution. Could you elaborate what the difference is between defining the dimensional variable like your proposed method and the definition below?

strMachineTest := [0..1,0..5,1..10] OF STRING;

Kind regards,
Reno

Author:  m.prestel [ Fri Nov 22, 2019 11:34 am ]
Post subject:  Re: Dimensional array table

Hello Reno,

please take a look at the online help.

https://help.codesys.com/webapp/_cds_da ... n=3.5.15.0

Especially the attached screenshot shows the difference between the two ways of defining an array really good.

Best regards,
Marcel

Author:  LooijmansR [ Fri Nov 22, 2019 12:57 pm ]
Post subject:  Re: Dimensional array table

Hi Marcel,

Perfect! Seems like I've been doing this the wrong way the majority of my time.. I will change the way of defining arrays to your suggestion. That seems way more appropriate. I was not aware this was possible.

I should have read the docs better.. My bad.

Thanks for your time!!

Kind regards,
Reno

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/