Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Change of color in a Linear meter display based on bit value
PostPosted: Fri Nov 08, 2013 9:33 am 

Joined: Wed Jul 31, 2013 10:23 am
Posts: 13

Offline
Hello all,

Another small scripting issue as an iX developer beginner.
using Information designer it was really easy to change the color of the bar-graph in a Linear Meter element.
Now I want to use a similar function in the iX developer and it does not work quite I want to.

I created a Variable that based on value (0,1,2) should change colors from green, yellow to red depending on some error bits in my PLC code.
I do have the error bits and depending on the state of them I would like to set the color of my display

I was trying to use the code for Value change of my Level variable to initiate the check for the bits.
The code seem to be OK and translates without errors.
If I change the value of my "AlarmColorID_A" tag manually it will change the colors so this part is working. (just a NOTE)

But the function does not work :-(
Attached the code:

void _0__Level_A_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
if ( (Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 0))
Globals.Tags.AlarmColorID_A.Value = 0;

{
if ((Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
Globals.Tags.AlarmColorID_A.Value = 1;

{
if ((Globals.Tags._0_A_Level_Error.Value == 1) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
Globals.Tags.AlarmColorID_A.Value = 2;
}
}
}

I used if "expressions" before so ????... where is the bug ?
Am I blinded by something?


 Profile  
 
 Post subject: Re: Change of color in a Linear meter display based on bit v
PostPosted: Mon Apr 02, 2018 3:00 pm 

Joined: Mon Nov 20, 2017 5:29 pm
Posts: 43

Offline
JMkowol,

There are a few hitches i can see in your code. The brackets look a bit misplaced for me.

You can either do away with them like this:

void _0__Level_A_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
if ( (Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 0))
Globals.Tags.AlarmColorID_A.Value = 0;


if ((Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
Globals.Tags.AlarmColorID_A.Value = 1;


if ((Globals.Tags._0_A_Level_Error.Value == 1) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
Globals.Tags.AlarmColorID_A.Value = 2;
}

Or keep them like this:

void _0__Level_A_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
if ( (Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 0))
{
Globals.Tags.AlarmColorID_A.Value = 0;
}

if ((Globals.Tags._0_A_Level_Error.Value == 0) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
{
Globals.Tags.AlarmColorID_A.Value = 1;
}

if ((Globals.Tags._0_A_Level_Error.Value == 1) && (Globals.Tags._0_A_Level_low_Error.Value == 1))
{
Globals.Tags.AlarmColorID_A.Value = 2;
}

}

This should help.

_________________
Thanks,

Chris
Beijer Support
(801)708-6690


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours [ DST ]


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