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 Tue Feb 18, 2020 8:24 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Wed Dec 04, 2019 9:02 pm 
Offline
Frequent User
Frequent User

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 107
Hi,

I know that if I use variables inside a visu I can do some logic. For exemple if I declare 2 DWORD (word1 and word2) I can do a logical 'OR' for the 'Fill color' property of a rectangle. Like this:

At runtime, if I set word1 to 16#FFFF0000 and word2 to 16#FF00FF00, the rectangle becomes yellow. This means I can do some logic inside the VISU.

Now, my question is: How can I make more complex logic like IF THEN ELSE? What would be the syntax? Where can I find it in the help?

Thank you.


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


Top
   
PostPosted: Wed Dec 04, 2019 9:37 pm 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 288
Hi.

You can use code when a button is pressed.

But when I need that the code runs every cycle, I create a method wich returns 0, and I put the method in absolute_movement or relative_movement in x or y.

I don't know if it is possible to call code ciclicaly in other form.

Sent from my Moto G (5S) Plus using Tapatalk


Top
   
PostPosted: Thu Dec 05, 2019 2:58 pm 
Offline
Frequent User
Frequent User

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 107
It looks like it is called cyclically because as soon as I update one of the variable (word1 or word2) the rectangle filled color changes.

I was wondering if I could do some more complex logic right inside the visu.


Top
   
PostPosted: Thu Dec 05, 2019 4:05 pm 
Offline
Frequent User
Frequent User

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

you can only do the things you can do in a normal assignment.
But you can call a function and do more complex logic in there and depending on that return different colors.

Best regards,
Marcel


Top
   
PostPosted: Thu Dec 05, 2019 5:15 pm 
Offline
Frequent User
Frequent User

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 107
Thanks for the advice.

I created a function that returns a color. I call this function right from the visu and it works great. Even for setting colors of each cells in a table!

You need to have a target or web visu for it to work. (In TwinCAT. I did not try with Codesys).

Thank you!


Top
   
PostPosted: Thu Dec 05, 2019 5:39 pm 
Offline
Frequent User
Frequent User

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 107
I tried to do the same thing but for text and I cannot make it work.

I am not able to call the Function from the text property. It kind of makes sense. It just prints whatever I put in there instead of calling the function.
Is there a way to call the function from the text property?


Top
   
PostPosted: Fri Dec 06, 2019 8:36 am 
Offline
Frequent User
Frequent User

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

You need to put the function call inside the text variable (requires %s inside Texts)
See attached screenshots

Best regards,
Marcel


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


Top
   
PostPosted: Fri Dec 06, 2019 12:42 pm 
Offline
Frequent User
Frequent User

Joined: Mon Apr 28, 2014 7:05 pm
Posts: 107
It works with a simple rectangle but it does not work inside of a table.
Calling a function inside a table to update color works. But text does not work. Could it be a bug?


Top
   
PostPosted: Fri Dec 06, 2019 5:10 pm 
Offline
Frequent User
Frequent User

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 126
Could you just add a rectangle element to the visu to call one function for the entire visu page you are working on. Then use that one function to update all the elements (tables, buttons, text, etc) colors or other logic you need on the page.


Top
   
PostPosted: Tue Dec 10, 2019 10:02 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 189
yannickasselin1 wrote:
It works with a simple rectangle but it does not work inside of a table.
Calling a function inside a table to update color works. But text does not work. Could it be a bug?


Why not update the data for the table instead of converting the displayed value each cycle?

Best regards,
Marcel


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 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