Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 3:32 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Bit out of tag
PostPosted: Sun Apr 10, 2011 7:24 am 
Offline

Joined: Sun Apr 10, 2011 7:16 am
Posts: 3
Hi

I don't understand how the expressions work. I'm trying to read a bit in an integer tag and change color if specific bit is on.

There could be little more text in the help site about the expression function...

Mika


Top
 Profile  
 
 Post subject: Re: Bit out of tag
PostPosted: Mon Apr 11, 2011 8:55 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
I don't know of a way to do exactly what you're asking for without a little bit a script. Here's one way, I'm researching if there's an easier way to do this.

Create a tag, in my example I'll call it "ColorTag". Select the object who's color you want to change. Click on the "Dynamic" tab. Click on "Fill" and set up some different colors mapped to the "ColorTag".

Attachment:
fill_dynamic.JPG
fill_dynamic.JPG [ 22.92 KiB | Viewed 2823 times ]


Next, select "Tags" on the left. Select the "Tags" tab, click on "Script". Double click on "ValueChange" in the tree to create an event in code. Add some code similar to this (see attached screenshot).
Code:
   int n = Globals.Tags.Tag1.Value.Int;
         if ((n & 0x01) != 0) {
            Globals.Tags.ColorTag.Value = 0;
         }
         else {
            Globals.Tags.ColorTag.Value = 1;
         }
         if ((n & 0x02) != 0) {
            Globals.Tags.ColorTag.Value = 0;
         }
         else {
            Globals.Tags.ColorTag.Value = 2;
         }         


Attachment:
script_example.JPG
script_example.JPG [ 169.25 KiB | Viewed 2833 times ]

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
 Post subject: Re: Bit out of tag
PostPosted: Fri Apr 15, 2011 12:18 am 
Offline

Joined: Sun Apr 10, 2011 7:16 am
Posts: 3
That could work but then I have to do new tag for each object.

The idea of this is that I bring input bytes from controller and the user can see and test if sensors or buttons don't word correctly, and changing a color is quite visual and easy to understand. So one object has only two colors indicating false/true.

In the manual, there is written in expressions that you could do this by writing code there were you select the tag for color change. In previous post, image "fill_dynamic", the button with "..." after tag selection box. There you can do the code, and there is a library where is the needed code, but i can't make it work..

So I hope you find the easier way.. The expressions could be the answer, if you only figure out how the code works.

Mika


Top
 Profile  
 
 Post subject: Re: Bit out of tag
PostPosted: Mon Apr 18, 2011 12:09 am 
Offline

Joined: Sun Apr 10, 2011 7:16 am
Posts: 3
I found a way to do what I needed..

Instead of changin the color, I control the "true"-indicators visibility. The "'false"-indicator is allways visible, and when the bit I'm watching is 1, the "true"-indicator comes visible on top of the "false"-indicator.

I used the expressions code function.

In future IX Dev programs, there should be an easyer way to do this...

Mika


Attachments:
File comment: The code. Found the code under the Library Expressions-> Load
kuva3.JPG
kuva3.JPG [ 28.53 KiB | Viewed 2807 times ]
File comment: TULOT = Inputs, OK1=electrical cabinet 1, A = card A, 015 = from bit 0 to bit 15
kuva2.JPG
kuva2.JPG [ 15.39 KiB | Viewed 2807 times ]
File comment: True and false indicators
kuva1.JPG
kuva1.JPG [ 7.5 KiB | Viewed 2804 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


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:  
cron
Powered by phpBB® Forum Software © phpBB Group