It is currently April 25th, 2024, 9:21 am

IfCondition= not working for Ram but is for CPU

Get help with creating, editing & fixing problems with skins
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

IfCondition= not working for Ram but is for CPU

Post by DigitalEssence »

Hi,

Looking for some more help please. This one has me puzzled.

I have an IfCondition which is checking if the Ram is over 40 and if so changing the colour of the line to red. When I reload the skin, it changes to red and stays red even when the Ram is below 40.

I have exactly the same condition for my CPU and that works fine, changing colours when it reaches above or below the number set.

Here is my code for the Ram which changes to red and stays red. I am truly confuzzled...

Code: Select all

[measureRAM]
Measure=PhysicalMemory
Processor=0
IfCondition=measureRAM > 40
IfTrueAction=[!SetOption MeterUsedRAM LineColor 255,0,0,255]
IfCondition2=measureRAM < 40
IfTrueAction2=[!SetOption MeterUsedRAM LineColor #UsedColour#]
OnUpdateAction=[!UpdateMeter MeterUsedRAM][!Redraw]

[MeterUsedRAM]
Meter=Roundline
MeasureName=measureRAM
X=210
Y=0
W=120
H=120
StartAngle=#StartAngle#
RotationAngle=#RotationAngle#
LineStart=#LineStart#
LineLength=#LineLength#
;LineColor=#UsedColour#
Solid=1

and here is the code I use for the CPU which works as expected.

Code: Select all

[measureCPU]
Measure=CPU
Processor=0
IfCondition=measureCPU > 20
IfTrueAction=[!SetOption MeterUsedCPU LineColor 255,0,0,255]
IfCondition2=measureCPU < 20
IfTrueAction2=[!SetOption MeterUsedCPU LineColor #UsedColour#]
OnUpdateAction=[!UpdateMeter MeterUsedCPU][!Redraw]

[MeterUsedCPU]
Meter=Roundline
MeasureName=measureCPU
X=10
Y=0
W=120
H=120
StartAngle=#StartAngle#
RotationAngle=#RotationAngle#
LineStart=#LineStart#
LineLength=#LineLength#
LineColor=#UsedColour#
Solid=1

Here is my complete ini file.

Code: Select all

[Rainmeter]
Update=500
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=System measures
Author=Heds
Information=Roundline meter
License=Creative Commons
Version=1.0


;================================================================
;------------------------  STYLES  ------------------------------
;================================================================

[styleTitle]
StringCase=UPPER
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontColor=255,255,255,120
FontSize=9
AntiAlias=1
StringAlign=Left
FontFace=Product Sans



;================================================================
;-----------------------  VARIABLES  ----------------------------
;================================================================

[Variables]

;--------------
; Circle Meters
;--------------



UsedColour=113,175,216,170
CircleColour=255,255,255,30
CircleLineColour=255,255,255,100
CircleLineInner=25,25,19
CircleLineOuter=24,25,30
CircleStrokeWidth=12
TransColor=255,255,255,0
LineLength=30
LineStart=19
RotationAngle=6.283
;StartAngle=4.712
StartAngle=6.295

;================================================================
;------------------------  MEASURES  ----------------------------
;================================================================


;=====================
;-----  CPU  ---------
;=====================

[measureCPU]
Measure=CPU
Processor=0
IfCondition=measureCPU > 20
IfTrueAction=[!SetOption MeterUsedCPU LineColor 255,0,0,255]
IfCondition2=measureCPU < 20
IfTrueAction2=[!SetOption MeterUsedCPU LineColor #UsedColour#]
OnUpdateAction=[!UpdateMeter MeterUsedCPU][!Redraw]

[MeterUsedCPU]
Meter=Roundline
MeasureName=measureCPU
X=10
Y=0
W=120
H=120
StartAngle=#StartAngle#
RotationAngle=#RotationAngle#
LineStart=#LineStart#
LineLength=#LineLength#
;LineColor=#UsedColour#
Solid=1

[MeterCPUCircle]
Meter=Shape
X=45
Y=35
Shape=Rectangle 0,0,50,50,50 | Extend MyModifiers1
MyModifiers1=Fill Color #TransColor# | StrokeWidth #CircleStrokeWidth# | Stroke Color #CircleColour#

[MeterCPUInnerLine]
Meter=Shape
X=45
Y=35
Shape=Ellipse #CircleLineInner# | Extend MyModifiers1
MyModifiers1=Fill Color 191,237,239,0 | StrokeWidth 1 | Stroke Color #CircleLineColour#

[MeterCPUOuterLine]
Meter=Shape
X=45
Y=35
Shape=Ellipse #CircleLineOuter#  | Extend MyModifiers1
MyModifiers1=Fill Color 191,237,239,0 | StrokeWidth 1 | Stroke Color #CircleLineColour#

[meterValueCPU]
Meter=STRING
MeterStyle=styleTitle
MeasureName=measureCPU
X=5R
Y=44
W=290
H=14
Text=CPU %1%

[meterCPULine]
Meter=Line
x=100
Y=61
w=100
LineColor=#CircleLineColour#

;=====================
;-----  RAM  ---------
;=====================

[measureRAM]
Measure=PhysicalMemory
Processor=0
IfCondition=measureRAM > 40
IfTrueAction=[!SetOption MeterUsedRAM LineColor 255,0,0,255]
IfCondition2=measureRAM < 40
IfTrueAction2=[!SetOption MeterUsedRAM LineColor #UsedColour#]
OnUpdateAction=[!UpdateMeter MeterUsedRAM][!Redraw]

[MeterUsedRAM]
Meter=Roundline
MeasureName=measureRAM
X=210
Y=0
W=120
H=120
StartAngle=#StartAngle#
RotationAngle=#RotationAngle#
LineStart=#LineStart#
LineLength=#LineLength#
;LineColor=#UsedColour#
Solid=1
;AntiAlias=1

[MeterRAMCircle]
Meter=Shape
X=245
Y=35
Shape=Rectangle 0,0,50,50,50 | Extend MyModifiers1
MyModifiers1=Fill Color #TransColor# | StrokeWidth #CircleStrokeWidth# | Stroke Color #CircleColour#

[MeterRAMInnerLine]
Meter=Shape
X=245
Y=35
Shape=Ellipse #CircleLineInner# | Extend MyModifiers1
MyModifiers1=Fill Color 191,237,239,0 | StrokeWidth 1 | Stroke Color #CircleLineColour#

[MeterRAMOuterLine]
Meter=Shape
X=245
Y=35
Shape=Ellipse #CircleLineOuter# | Extend MyModifiers1
MyModifiers1=Fill Color 191,237,239,0 | StrokeWidth 1 | Stroke Color #CircleLineColour#

[meterValueRAM]
Meter=STRING
MeterStyle=styleTitle
MeasureName=measureRAM
X=5R
Y=44
W=290
H=14
Text=RAM %1%
Percentual=1

[meterRAMLine]
Meter=Line
x=300
Y=61
w=100
LineColor=#CircleLineColour#
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition= not working for Ram but is for CPU

Post by jsmorley »

DigitalEssence wrote:Hi,

Looking for some more help please. This one has me puzzled.

I have an IfCondition which is checking if the Ram is over 40 and if so changing the colour of the line to red. When I reload the skin, it changes to red and stays red even when the Ram is below 40.

I have exactly the same condition for my CPU and that works fine, changing colours when it reaches above or below the number set.

The various Memory measures return a value in Bytes. I suspect you always have more than 40 Bytes of memory available.

https://docs.rainmeter.net/manual/measures/memory/

They have a MaxValue automatically set to the total amount of memory present in the selected category, so they can be used as a "percentage" for things like a Bar meter or Roundline meter, but their actual value is in Bytes. Any IfCondition that you do in the measure itself needs to be based on that, and not the percentage.

You can see what a measure is returning by using About / Skins and selecting the skin in question. The current values for measures and variables will be listed.

https://docs.rainmeter.net/manual/user-interface/about/#SkinsTab
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Re: IfCondition= not working for Ram but is for CPU

Post by DigitalEssence »

Thank you so much.

That resolved the issue.

My mistake was expecting the IfCondition to work on the same % value it was displaying in my meter. Instead I've had to change it to:

IfCondition=measureRAM > 3500000000

to get it to trigger at 40%.

Will look into why the meters return a % but the IfCondition works on true Ram amounts.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition= not working for Ram but is for CPU

Post by jsmorley »

If you want to use a percentage to do your "comparison", and it makes sense to do so, you might:

Code: Select all

[measureRAM]
Measure=PhysicalMemory
IfCondition=(([measureRAM]/[measureRAM:MaxValue]) * 100) > 40
IfTrueAction=[!SetOption MeterUsedRAM LineColor 255,0,0,255]
IfFalseAction=[!SetOption MeterUsedRAM LineColor #UsedColour#]
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition= not working for Ram but is for CPU

Post by jsmorley »

DigitalEssence wrote:Thank you so much.

That resolved the issue.

My mistake was expecting the IfCondition to work on the same % value it was displaying in my meter. Instead I've had to change it to:

IfCondition=measureRAM > 3500000000

to get it to trigger at 40%.

Will look into why the meters return a % but the IfCondition works on true Ram amounts.
Meters that display things as a percentage work by taking the actual value of the measure in question, and figuring out themselves what percentage that value is of the MaxValue of the measure. It's not that the value of the measure is a percentage in most cases (it is in CPU, the percentage IS the value, but others like Memory or FreeDiskSpace or Network are actual raw numbers of Bytes), but that the POINT of the meter is to do the work of figuring out what percentage of the total that raw value is.
DigitalEssence
Posts: 27
Joined: January 29th, 2016, 6:43 pm

Re: IfCondition= not working for Ram but is for CPU

Post by DigitalEssence »

jsmorley wrote:If you want to use a percentage to do your "comparison", and it makes sense to do so, you might:

Code: Select all

[measureRAM]
Measure=PhysicalMemory
IfCondition=(([measureRAM]/[measureRAM:MaxValue]) * 100) > 40
IfTrueAction=[!SetOption MeterUsedRAM LineColor 255,0,0,255]
IfFalseAction=[!SetOption MeterUsedRAM LineColor #UsedColour#]
DynamicVariables=1
Wow. Wish all forums were as friendly and helpful as this one. Not only does your example code resolve my issue but is also neater with True/False rather than my clunky Condition 1 and 2 example.

Thank you.

I quite pleased with my evenings work... https://www.screencast.com/t/YGB1QpI6YsRu
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition= not working for Ram but is for CPU

Post by jsmorley »

Don't forget that the raw number values are of interest as well...

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[measureRAMTotal]
Measure=PhysicalMemory
Total=1

[measureRAMFree]
Measure=PhysicalMemory
InvertMeasure=1

[measureRAMUsed]
Measure=PhysicalMemory

[measureTest]
Measure=Calc
Formula=1
IfCondition=(([measureRAMUsed]/[measureRAMUsed:MaxValue]) * 100) > 40
IfTrueAction=[!SetOption MeterRAMBar BarColor "255,0,0,255"]
IfFalseAction=[!SetOption MeterRAMBar BarColor "76,217,99,255"]
DynamicVariables=1

[MeterRAM]
Meter=String
MeasureName=measureRAMUsed
MeasureName2=measureRAMFree
MeasureName3=measureRAMTotal
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AutoScale=1
NumOfDecimals=2
AntiAlias=1
Text=%1B used of %3B total : %2B free

[MeterRAMBar]
Meter=Bar
MeasureName=MeasureRAMUsed
Y=5R
W=300
H=20
BarColor=76,217,99,255
SolidColor=47,47,47,255
BarOrientation=Horizontal
1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition= not working for Ram but is for CPU

Post by jsmorley »

DigitalEssence wrote:Wow. Wish all forums were as friendly and helpful as this one. Not only does your example code resolve my issue but is also neater with True/False rather than my clunky Condition 1 and 2 example.

Thank you.

I quite pleased with my evenings work... https://www.screencast.com/t/YGB1QpI6YsRu
Glad to help. That's some nice looking work there...