It is currently March 28th, 2024, 3:50 pm

Text color change using multiple measure input

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
Stillub
Posts: 17
Joined: December 30th, 2017, 2:38 pm

Text color change using multiple measure input

Post by Stillub »

I have been working on a skin that displays temperature values from a solar heat project (discussed in earlier threads)
which works quite well. I would however like to make a change so that the Text color will change based on the value of multiple measures. To that end I have modified one of my measure scripts to this:

Code: Select all

[MeasureTank_R1]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1
IfCondition=MeasureTank_R1 <0
IfTrueAction=[!SetOption MeterTank_R1 FontColor "255,0,0,128"][!Redraw]
IfCondition2=(MeasureTank_R1 >=24) && (> MeasureTank_R2)
IfTrueAction2=[!SetOption MeterTank_R1 FontColor "255,0,0"][!Redraw]
IfCondition3=MeasureTank_R1 >=1
IfTrueAction3=[!SetOption MeterTank_R1 FontColor "255,255,255,128"][!Redraw]
RegExpSubstitute=1
Substitute="\n":""
My question is whether or not I have the following line correct:

Code: Select all

IfCondition2=(MeasureTank_R1 >=24) && (> MeasureTank_R2)
In particular, do I the greater than sign in the correct place for this measure (> MeasureTank_R2) ?
I am confident it is correct for the first measure, just not sure about the second. I will also make changes to other parts of the measure, but my concern at the moment is what I have described above.

Thanks
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Text color change using multiple measure input

Post by jsmorley »

IfCondition2=(MeasureTank_R1 >= 24) && (MeasureTank+R1 > MeasureTank_R2)

The tests on either side of a logical && (AND) or || (OR) must be complete comparisons, and enclosed in (parentheses).


P.S. [!Redraw] in and of itself does nothing useful... What you want is [!UpdateMeter MeterTank_R1][!Redraw].

What !Redraw does is "redraw the skin with the current state of all meters". While you have used !SetOption to change the FontColor option of MeterTank_R1, the meter has not been "updated" to apply the change made to the option. So first update the meter, then redraw the skin...
User avatar
Stillub
Posts: 17
Joined: December 30th, 2017, 2:38 pm

Re: Text color change using multiple measure input

Post by Stillub »

Thanks!
I think I understood what you have written and have applied it to the Measure. I also adjusted the other two "conditions".

Code: Select all

[MeasureTank_R1]
Measure=Plugin
Plugin=WebParser
URL=[MeasureParent]
StringIndex=1
IfCondition=(MeasureTank_R1 >=1) && (MeasureTank_R1 <=35)
IfTrueAction=[!SetOption MeterTank_R1 FontColor "255, 252, 252"][!UpdateMeter MeterTank_R1][!Redraw]
IfCondition2=(MeasureTank_R1 >=36) && (MeasureTank_R1 >=MeasureTank_R2)
IfTrueAction2=[!SetOption MeterTank_R1 FontColor "255,0,0"][!UpdateMeter MeterTank_R1][!Redraw]
IfCondition3=MeasureTank_R1 <=0
IfTrueAction3=[!SetOption MeterTank_R1 FontColor "255, 255, 0"][!UpdateMeter MeterTank_R1][!Redraw]
RegExpSubstitute=1
Substitute="\n":""
Assuming I have that Measure correct, I have a dilemma with my third Measurer. In the third, I need to have 3 parameters and not two. The first two parameters relate to the third Measure itself but the third parameter relates to the second Measure. If you could give me a nudge in the right direction, I would appreciate it.

Third Measure:

Code: Select all

[MeasureRoof]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureParent]
StringIndex=3
IfCondition=(MeasureRoof >=1) && (MeasureRoof <=8) && (MeasureTank_R2 >=30)
IfTrueAction=[!SetOption MeterRoof FontColor "255,0,0"][!UpdateMeter MeterRoof][!Redraw]
IfCondition2=MeasureRoof >=9
IfTrueAction2=[!SetOption MeterRoof FontColor "255, 252, 252"][!UpdateMeter MeterRoof][!Redraw]
IfCondition3=MeasureRoof <=0
IfTrueAction3=[!SetOption MeterRoof FontColor "255, 255, 0"][!UpdateMeter MeterRoof][!Redraw]
RegExpSubstitute=1
Substitute="\n":""
Line in question:

Code: Select all

IfCondition=(MeasureRoof >=1) && (MeasureRoof <=8) && (MeasureTank_R2 >=30)
Brian
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Text color change using multiple measure input

Post by jsmorley »

IfCondition=(MeasureRoof >=1) && (MeasureRoof <=8) && (MeasureTank_R2 >=30)

That is a valid IfCondition. All three must be "true". I assume that is what you are going for.

It would need to be a bit different if an OR was in the mix.

IfCondition=((MeasureRoof >=1) && (MeasureRoof <=8)) || (MeasureTank_R2 >=30)

BTW, the best way to "test" these conditions is to comment out the WebParser bit and temporarily make one or more Calc measure(s) that you can just force to a value.

Code: Select all

[MeasureRoof]
Measure=Calc
Formula=7

[MeasureTank_R2]
Measure=Calc
Formula=32
IfCondition=(MeasureRoof >=1) && (MeasureRoof <=8) && (MeasureTank_R2 >=30)
IfTrueAction=[!Log "True"]
IfFalseAction=[!Log "False"]
1.png
Up to you, you can have it just do the actual action you intend (changing a FontColor) or just !Log it to test for a result.
User avatar
Stillub
Posts: 17
Joined: December 30th, 2017, 2:38 pm

Re: Text color change using multiple measure input

Post by Stillub »

Thanks again for your reply and especially for the additional "test & tune" tips. Much appreciated!
They will prove to be a big help I am sure, as I cannot run any tests directly as I did initially. The Arduino micro controller/server, is now installed in the field running on a local network, therefore I cannot access it from my location.
Any changes to the skin script have to be forwarded (emailed) and updated by someone else (my Father... which in of itself is proving to be a challenge ;)..)

Brian
Post Reply