CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Dec 07, 2019 5:50 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Dimensional array table
PostPosted: Fri Nov 15, 2019 10:29 am 
Offline

Joined: Tue Jun 18, 2019 1:34 pm
Posts: 15
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


Top
   
PostPosted: Fri Nov 15, 2019 10:44 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 158
Hello Reno,

could you provide a small example?

Thx!

Best regards,
Marcel


Top
   
PostPosted: Fri Nov 15, 2019 11:18 am 
Offline

Joined: Tue Jun 18, 2019 1:34 pm
Posts: 15
Hi Marcel,

Of course. See images attached ;-)

Thanks in advance.

Kind regards,
Reno


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Nov 15, 2019 12:16 pm 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 158
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


Top
   
PostPosted: Fri Nov 15, 2019 1:36 pm 
Offline

Joined: Tue Jun 18, 2019 1:34 pm
Posts: 15
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.


Top
   
PostPosted: Mon Nov 18, 2019 8:25 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 158
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


Top
   
PostPosted: Fri Nov 22, 2019 11:03 am 
Offline

Joined: Tue Jun 18, 2019 1:34 pm
Posts: 15
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


Top
   
PostPosted: Fri Nov 22, 2019 11:34 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 158
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


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Nov 22, 2019 12:57 pm 
Offline

Joined: Tue Jun 18, 2019 1:34 pm
Posts: 15
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited