Calculate Min,Max Value of a measure

Help with creating, editing & fixing problems with skins

Re: Calculate Min,Max Value of a measure

November 13th, 2017, 8:24 pm
Pul53dr1v3r
   [77 posts]

just thinking about calculating average value... :???:
User avatar

Re: Calculate Min,Max Value of a measure

November 13th, 2017, 8:25 pm
balala
Rainmeter Sage   [4982 posts]

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

You're welcome and sorry again for that mistake. It was my fault...

Re: Calculate Min,Max Value of a measure

November 13th, 2017, 8:54 pm
Pul53dr1v3r
   [77 posts]

your apology shouldn't be here at all.
User avatar

Re: Calculate Min,Max Value of a measure

November 13th, 2017, 9:01 pm
balala
Rainmeter Sage   [4982 posts]

Pul53dr1v3r wrote:your apology shouldn't be here at all.

I'm glad if you think so. Finally I messed up that code...

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 11:18 am
Pul53dr1v3r
   [77 posts]

I've two more questions about the measures:
1) How to avoid "0" of the "Min" after we restart a PC or AIDA64 (tried sth with IfCondintionMode, but seems I'm not smart enough),
2) How to get the Average value in this case? - (tried with sth like (Min+Current+Max)/3 but doesn't give the accurate value at all).

Don't even think the Min and the Max should be used in this case.
User avatar

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 3:07 pm
balala
Rainmeter Sage   [4982 posts]

Pul53dr1v3r wrote:1) How to avoid "0" of the "Min" after we restart a PC or AIDA64 (tried sth with IfCondintionMode, but seems I'm not smart enough),

After you restart the computer, min should not return 0. This is avoided by the Formula option of the [MeasureMinPowerDraw] measure (Formula=( Min ( PSUPowerUsage, 134217730 ))). I found this formula and its change by the OnChangeAction option of the [PSUPowerUsage] measure,exactly to avoid the measure to return 0 in the very first moment after a refresh / restart / load of the skin or of whole Rainmeter.
Restarting AIDA64 is another question. When you exit the software, the skin remains loaded, but because the softwer is closed, the [PSUPowerUsage] measure returns probably 0. When AIDA64 is restarted, the smallest value remains 0, because although now the measure returns larger values, the smallest one is still 0, returned while AIDA64 was closed.
A possible solution for this would be maybe to pause / disable the [PSUPowerUsage] measure and pause [MeasureMaxPowerDraw] and [MeasureMinPowerDraw], while AIDA64 is unloaded. This can be achieved by a this kind of measure (add it to your code):

Code: Select all

[MeasureProcessAIDA64]
Measure=Plugin
Plugin=PerfMon
PerfMonObject=Process
PerfMonCounter=ID Process
PerfMonInstance=ADD-HERE-THE-NAME-Of-THE-PROCESS-OF-AIDA64
PerfMonDifference=0
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!EnableMeasure "PSUPowerUsage"][!UnpauseMeasure "MeasureMaxPowerDraw"][!UnpauseMeasure "MeasureMinPowerDraw"]
IfFalseAction=[!DisableMeasure "PSUPowerUsage"][!PauseMeasure "MeasureMaxPowerDraw"][!PauseMeasure "MeasureMinPowerDraw"]

Take care to add the name of the process of AIDA64 software (which I don't know), to the PerfMonInstance option.
This measure returns 0 when the appropriate process isn't loaded and a larger value, when it is. The IfTrueAction / IfFalseAction options disables / enables the [PSUPowerUsage] measure and pause / unpause the [MeasureMaxPowerDraw] / [MeasureMinPowerDraw] measures.
Maybe this measure will avoid the described issue, however I'm not very sure, because I don't have AIDA64 installed, so I can't check. Please check and let me know if it does.
Pul53dr1v3r wrote:2) How to get the Average value in this case? - (tried with sth like (Min+Current+Max)/3 but doesn't give the accurate value at all).

I'm not sure I understood what average would you like to get. Could you please explain what you need it for? (Min+Current+Max)/3 does return the average of these three values, but if it's not accurate enough, I don't know what you need.

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 4:59 pm
Pul53dr1v3r
   [77 posts]

At first, the Min value was getting "0.0" after AIDA is closed, and when I reopen AIDA, it doesn't change from 0.0 until MANUAL skin reset. The same happens on the system restart, since Rainmeter is loaded quicker than AIDA.

With this code, the only change is that, when AIDA is closed, it keeps the old value (doesn't reset to 0.0 as without your code) UNTIL I start AIDA again. Immediately after click on AIDA (to get started), it returns the value to 0.0 and keeps all the time until a manual reset.
Manual skin reset always returns the correct values from zeroes(with loaded AIDA64).

A line-two about AIDA: After starting AIDA, it takes some time (5-10s) to start writing values to the registry-its sensors haven't been activated at the same moment after it's loaded, or even better, after it is shown in the processes.
User avatar

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 5:21 pm
balala
Rainmeter Sage   [4982 posts]

Pul53dr1v3r wrote:A line-two about AIDA: After starting AIDA, it takes some time (5-10s) to start writing values to the registry-its sensors haven't been activated at the same moment after it's loaded, or even better, after it is shown in the processes.

There is certain registry key where AIDA writes its values and you can read it? Which one is that?

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 5:32 pm
Pul53dr1v3r
   [77 posts]

Image

Value.PPSU is the reg key in charge of getting the Power Usage.
Last edited by Pul53dr1v3r on November 14th, 2017, 9:30 pm, edited 1 time in total.
User avatar

Re: Calculate Min,Max Value of a measure

November 14th, 2017, 6:19 pm
balala
Rainmeter Sage   [4982 posts]

In this case, I'd try to modify the above measure as it follows. Before you start, take care to have a backup of the old .ini file, just in case.
First add the following two variables to the [Variables] section of your code:

Code: Select all

[Variables]
...
Aida64Proc=0
Aida64Reg=0

We'll use these variables immediately.
Now modify the IfTrueAction and IfFalseAction options of the [MeasureProcessAIDA64] measure this way:

Code: Select all

[MeasureProcessAIDA64]
...
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!SetVariable Aida64Proc "1"]
IfFalseAction=[!SetVariable Aida64Proc "0"][!SetVariable Aida64Reg "0"]

The value of Aida64Proc variable will be 1 while AIDA is running and 0 if it doesn't. When AIDA closes, both variable will be set to 0, by the two !SetVariable bangs of the IfFalseAction option.
Another measure you'll need is the following one:

Code: Select all

[MeasureAIDAWriting]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\FinalWire\AIDA64\SensorValues
RegValue=Value.PPSU
OnChangeAction=[!SetVariable Aida64Reg "1"]

As you've posted just an image with the needed registry key, please check if I wrote it correctly above.
The OnChangeAction option of this measure sets the Aida64Reg variable to 1 when the software starts to write (change) the value of the registry key
And finally you'll need the following Calc measure:

Code: Select all

[MeasureAIDA64]
Measure=Calc
Formula=( #Aida64Proc# + #Aida64Reg# )
IfCondition=(#CURRENTSECTION#=2)
IfTrueAction=[!EnableMeasure "PSUPowerUsage"][!UnpauseMeasure "MeasureMaxPowerDraw"][!UnpauseMeasure "MeasureMinPowerDraw"]
IfFalseAction=[!DisableMeasure "PSUPowerUsage"][!PauseMeasure "MeasureMaxPowerDraw"][!PauseMeasure "MeasureMinPowerDraw"]
DynamicVariables=1

You need this measure because you have to enable the [PSUPowerUsage] measure and unpause [MeasureMaxPowerDraw] and [MeasureMinPowerDraw] when both variables are set to 1, so their sum is equal to 2. Otherwise, if any of them is 0 (so their sum is less then 2), [PSUPowerUsage] must be disabled and [MeasureMaxPowerDraw] and [MeasureMinPowerDraw] must be paused.

Again I don't have AIDA installed, so I can't check the above code. I hope it works well, but I'm not sure.
Please let me know if it does.

Return to “Help: Rainmeter Skins”



Who is online

Users browsing this forum: No registered users and 8 guests