It is currently March 29th, 2024, 8:09 am

Calculate Min,Max Value of a measure

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Calculate Min,Max Value of a measure

Post by pul53dr1v3r »

I'd like to get Min and Max value of a measure(sensor) to show on a skin. For instance, the values of Min/Max temperature, Min/Max Power draw etc. in a session.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calculate Min,Max Value of a measure

Post by jsmorley »

User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calculate Min,Max Value of a measure

Post by balala »

Sorry jsmorley, but I don't think this is the right answer to Pul53dr1v3r's question. At least from what I've understood...
Pul53dr1v3r wrote:I'd like to get Min and Max value of a measure(sensor) to show on a skin. For instance, the values of Min/Max temperature, Min/Max Power draw etc. in a session.
To get the largest value is simple. Eg in the following code, [MeasureCalc] returns a value between 1 and 100 and [MeasureMax] returns the largest value achieved so far:

Code: Select all

[MeasureCalc]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=1
HighBound=100

[MeasureMax]
Measure=Calc
Formula=( Max ( MeasureCalc, MeasureMax ))
Theoretically a similar approach should work to get the smallest value too, however, you'll need a trick. Eg take a look at the following code:

Code: Select all

[MeasureCalc]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=1
HighBound=100

[MeasureMin]
Measure=Calc
Formula=( Min ( MeasureCalc, MeasureMin ))
In this case, [MeasureMin] measure always return 0, because its initial value is 0 and after that, no matter what value does return the [MeasureCalc] measure, it won't be smaller then 0.
To make it to properly work, you have to use a trick. Replace the Formula option of the [MeasureMin] measure, with this one: Formula=( Min ( MeasureCalc, 100 )). This formula avoids the measure to always return 0, but it's not the correct one, so you have to replace it after the first update of the measure. So, add the following option to the [MeasureCalc] measure: OnChangeAction=[!SetOption MeasureMin Formula "(Min(MeasureCalc,MeasureMin))"]. After the first update of the [MeasureCalc] measure, this option will replace the Formula option of the [MeasureMin] measure, which will start to return the lowest value achieved so far.
If you couldn't follow everything I've described above, here is the whole code:

Code: Select all

[Rainmeter]
DynamicWindowSize=1
Update=1000

[Variables]


[MeasureCalc]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=1
HighBound=100
OnChangeAction=[!SetOption MeasureMin Formula "(Min(MeasureCalc,MeasureMin))"]

[MeasureMin]
Measure=Calc
Formula=( Min ( MeasureCalc, 100 ))
Group=MinMax

[MeasureMax]
Measure=Calc
Formula=( Max ( MeasureCalc, MeasureMax ))
Group=MinMax

[MeterMinMax]
Meter=STRING
MeasureName=MeasureCalc
MeasureName2=MeasureMin
MeasureName3=MeasureMax
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Val: %1#CRLF#Min: %2#CRLF#Max: %3
Obviously for your needs, you have to replace the [MeasureCalc] measure with the needed one, which measures the temperature or whatever.

Now which answer is what you wanted: what I've described, or jsmorley's one?
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Calculate Min,Max Value of a measure

Post by pul53dr1v3r »

besfore I do anything, just to say that I don't need a percentual value at all. Here is a formula I used to get the Max value with, but not sure how good it is as the same is used for net speed peak measure.

Code: Select all

[MeasureMaxPowerDraw]
Measure=Calc
Formula=Max(Max(PSUPowerUsage, PSUPowerUsage), #MaxPowerDraw#)
IfConditionMode=1
IfCondition=((MeasureMaxPowerDraw > #MaxPowerDraw#) && (MeasureMaxPowerDraw < 134217728))
IfTrueAction=[!SetVariable MaxPowerDraw ([MeasureMaxPowerDraw])]
DynamicVariables=1

Code: Select all

[Variables]
MaxPowerDraw=0
.
.
.
[PSUPowerUsage]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\FinalWire\AIDA64\SensorValues
RegValue=Value.PPSU
UpdateDivider=2

Image
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calculate Min,Max Value of a measure

Post by balala »

Pul53dr1v3r wrote:besfore I do anything, just to say that I don't need a percentual value at all. Here is a formula I used to get the Max value with, but not sure how good it is as the same is used for net speed peak measure.
In your code I see how the max value is returned (by the [MeasureMaxPowerDraw] measure), but what measure returns the Min value (which is 0, according to the image)?
Also note that the Max(PSUPowerUsage, PSUPowerUsage) part of the Formula of the [MeasureMaxPowerDraw] measure is perfectly useless. It always returns a value equal with [PSUPowerUsage], because the largest value between PSUPowerUsage and PSUPowerUsage is always PSUPowerUsage!
Also not sure who talked here about percentual values?

Although I don't have the needed software to can check, I think the following code should work:

EDIT: The following code is fixed. Previously the !SetOption bang of the OnChangeAction option of the [PSUPowerUsage] measure was mistaken. Sorry...

Code: Select all

[PSUPowerUsage]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\FinalWire\AIDA64\SensorValues
RegValue=Value.PPSU
UpdateDivider=2
OnChangeAction=[!SetOption MeasureMin Formula "(Min(PSUPowerUsage, MeasureMin))"]

[MeasureMin]
Measure=Calc
Formula=( Min ( PSUPowerUsage, 134217730 ))
Group=MinMax

[MeasureMax]
Measure=Calc
Formula=( Max ( PSUPowerUsage, MeasureMax ))
Group=MinMax
Here [MeasureMin] should return the smallest, not zero value achieved so far and [MeasureMax] the largest one.
Please check this code and let me know if they do.
Last edited by balala on November 13th, 2017, 8:02 pm, edited 2 times in total.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Calculate Min,Max Value of a measure

Post by pul53dr1v3r »

balala wrote: In your code I see how the max value is returned (by the [MeasureMaxPowerDraw] measure), but what measure returns the Min value (which is 0, according to the image)?
It just was my bad try.

As far as the new solution is concerned, I've removed "134217730" from the code and have made this:

Code: Select all

[PSUPowerUsage]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\FinalWire\AIDA64\SensorValues
RegValue=Value.PPSU
UpdateDivider=2
OnChangeAction=[!SetOption MeasureMinPowerDraw Formula "(Min(PSUPowerUsage,PSUPowerUsage))"]

[MeasureMaxPowerDraw]
Measure=Calc
Formula=( Max ( PSUPowerUsage, MeasureMaxPowerDraw))
Group=MinMax

[MeterMaxPowerDrawValaue]
Meter=String
MeasureName=MeasureMaxPowerDraw
MeterStyle=styleRightText
FontColor=255,255,255,50
FontSize=7
Text="Max: %1W"
X=195
Y=82
Autoscale=1
ToolTipText=Max Power Draw

;Min_Power

[MeasureMinPowerDraw]
Measure=Calc
Formula=( Min ( PSUPowerUsage, MeasureMinPowerDraw))
Group=MinMax

[MeterMinPowerDrawValaue]
Meter=String
MeasureName=MeasureMinPowerDraw
MeterStyle=styleRightText
FontColor=255,255,255,50
FontSize=7
Text="Min: %1W"
X=195
Y=99
Autoscale=1
ToolTipText=Min Power Draw
The Max works OK, but the Min shows current Power Usage...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calculate Min,Max Value of a measure

Post by balala »

Pul53dr1v3r wrote:The Max works OK, but the Min shows current Power Usage...
I don't think so. The Min should show always 0.
I think I explained above why. Just leave there the 134217730 value and give it a new try.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Calculate Min,Max Value of a measure

Post by pul53dr1v3r »

The same with the number. Just showing the current value.

Edit: The Min value can never be 0, neither close to 0 when the PC is Turned On. The lowest value (wattage) I've ever got was 29 W, in idle.
Last edited by pul53dr1v3r on November 13th, 2017, 8:30 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Calculate Min,Max Value of a measure

Post by balala »

Pul53dr1v3r wrote:The same with the number. Just showing the current value.
You're right, I just realized why. I edited my previous code.
And here is your code, fixed, too:

Code: Select all

[PSUPowerUsage]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\FinalWire\AIDA64\SensorValues
RegValue=Value.PPSU
UpdateDivider=2
OnChangeAction=[!SetOption MeasureMinPowerDraw Formula "(Min(PSUPowerUsage,MeasureMinPowerDraw))"]

[MeasureMaxPowerDraw]
Measure=Calc
Formula=( Max ( PSUPowerUsage, MeasureMaxPowerDraw ))
Group=MinMax

[MeterMaxPowerDrawValaue]
Meter=String
MeasureName=MeasureMaxPowerDraw
MeterStyle=styleRightText
FontColor=255,255,255,50
FontSize=7
Text="Max: %1W"
X=195
Y=82
Autoscale=1
ToolTipText=Max Power Draw

;Min_Power

[MeasureMinPowerDraw]
Measure=Calc
Formula=( Min ( PSUPowerUsage, 134217730 ))
Group=MinMax

[MeterMinPowerDrawValaue]
Meter=String
MeasureName=MeasureMinPowerDraw
MeterStyle=styleRightText
FontColor=255,255,255,50
FontSize=7
Text="Min: %1W"
X=195
Y=99
Autoscale=1
ToolTipText=Min Power Draw
I put back the numerical value in the Formula option of the [MeasureMinPowerDraw] measure and fixed the formula which is set by the !SetOption bang in the OnChangeAction option of the [PSUPowerUsage] measure.
Sorry for the inconveniences, I hope this time everything is ok. It was my fault.
Please check this code and let me know if it is.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Calculate Min,Max Value of a measure

Post by pul53dr1v3r »

balala wrote: Please check this code and let me know if it is.
Image

That's it. Works as it should. Thx once more!