It is currently February 29th, 2020, 4:16 am

Trying to save maximum cpu temp & time

Help with creating, editing & fixing problems with skins
Mike-G
Posts: 2
Joined: February 10th, 2020, 1:00 pm

Trying to save maximum cpu temp & time

Post by Mike-G »

I'm trying to add a way to report the highest CPU temperature, and the time it was recorded, until I reset it. The longer-term plan is to include a mouse-able item on the skin to reset the values.

My idea was to have a couple measures to persist the max temp value and associated time, update those values in a separate measure each iteration, and use those values in a couple meters. I thought to use separate measures for the persisted values because I'm already using the measures that update each iteration as inputs to other meters that I want updated each iteration.

My "About Rainmeter" Log tab isn't showing any errors, but the Skins tab isn't showing the max values ever getting updated. I'm a bit new at this, so I may be doing something very stupid, or my approach might be fundamentally wrong.

This is what I've got (The [Measure_CPU_Temp] Measure is a HWInfo Plugin and is working correctly):

Code: Select all

[Measure_Short_Time]
Measure=Time
Format=%m/%d/%y  %#I:%M %p

[Max_CPU_Temp_Value]
UpdateDivider=-1
Dynamic_Variables=1
Measure=Calc
Formula=0

[Max_CPU_Temp_Time]
UpdateDivider=-1
Dynamic_Variables=1
Measure=String
String=None

[Calc_CPU_Temp_Graph_Value] ; Min/Max Values for proper drawing in graph
DynamicVariables=1
Measure=Calc
Formula=Measure_CPU_Temp
MinValue=0
MaxValue=100
IfCondition=Max_CPU_Temp_Value < Measure_CPU_Temp
IfTrueAction=[!SetOption Max_CPU_Temp_Value Formula [Measure_CPU_Temp]]
IfTrueAction2=[!SetOption Max_CPU_Temp_Time String [Measure_Short_Time]]
My plan (once this is working) is to include something similar to the [!SetOption]'s in [Calc_CPU_Temp_Graph_Value] to reset the persisted Max values to 0 so they are updated on the next iteration.

Any pointers in the right direction would be appreciated.
Yincognito
Posts: 837
Joined: February 27th, 2015, 2:38 pm

Re: Trying to save maximum cpu temp & time

Post by Yincognito »

Mike-G wrote:
February 10th, 2020, 1:29 pm
This is what I've got (The [Measure_CPU_Temp] Measure is a HWInfo Plugin and is working correctly). Any pointers in the right direction would be appreciated.
Well, first of all, from the top of my head, you have 2 things missing in your code:

1. The IfConditionMode=1 added to the [Calc_CPU_Temp_Graph_Value] measure, in order to evaluate the conditions each time the measure is updated. In this format, as far as I can tell, the conditions are evaluated only once, when the skin is refreshed (i.e. at the first update of [Calc_CPU_Temp_Graph_Value])

2. I believe the IfTrueAction you have there should also include an [!UpdateMeasure "Max_CPU_Temp_Value"], same for IfTrueAction2, which should include an [!UpdateMeasure "Max_CPU_Temp_Time"]. These bangs should be added after the !SetOption bangs, so that not only the said measures are assigned the values, but also they are updated to reflect the new values. Since we're at it, there's no need to have two IfTrueActions, the code from the second should be able to be added to the first without causing problems in the expected results. Just make sure each measure update takes place after setting an option on it.

Hopefully these are the only things preventing you from getting the desired results. If not, let me know.
Mike-G
Posts: 2
Joined: February 10th, 2020, 1:00 pm

Re: Trying to save maximum cpu temp & time

Post by Mike-G »

@Yincognito -- I made the changes you suggested and the Max values are now being updated and persisted as I was hoping.

Thanks, very much, for your help!
Yincognito
Posts: 837
Joined: February 27th, 2015, 2:38 pm

Re: Trying to save maximum cpu temp & time

Post by Yincognito »

Mike-G wrote:
February 10th, 2020, 2:47 pm
@Yincognito -- I made the changes you suggested and the Max values are now being updated and persisted as I was hoping.

Thanks, very much, for your help!
You're welcome.
User avatar
balala
Rainmeter Sage
Posts: 9799
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to save maximum cpu temp & time

Post by balala »

Yincognito wrote:
February 10th, 2020, 2:05 pm
2. I believe the IfTrueAction you have there should also include an [!UpdateMeasure "Max_CPU_Temp_Value"], same for IfTrueAction2, which should include an [!UpdateMeasure "Max_CPU_Temp_Time"].
In fact in this case IfTrueAction2 doesn't even make sense, because there is no IfCondition2. IfTrueAction2 should be executed when IfCondition2 becomes true. What if there is no IfCondition2? When is IfTrueAction2 executed?
User avatar
balala
Rainmeter Sage
Posts: 9799
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to save maximum cpu temp & time

Post by balala »

Mike-G wrote:
February 10th, 2020, 1:29 pm
I'm trying to add a way to report the highest CPU temperature, and the time it was recorded, until I reset it.
Beside Yincognito's solution (seeming he offered a solution), just to make sure I didn't misunderstood you, let's see if I am correct: would you like to get the largest temperature ever achieved? IIs this correct? Because if it is, here is an alternative solution. You need just one single extra measure, beside [Measure_CPU_Temp]:

Code: Select all

[Measure_CPU_Temp_Max]
Measure=Calc
Formula=( Max ( Measure_CPU_Temp, Measure_CPU_Temp_Max ))
As said, this measure returns the largest temperature ever achieved by the [Measure_CPU_Temp] measure.
Now resetting it is quite easy. You just have to disable, update, then reenable it, for instance using the following bangs: [!DisableMeasure "Measure_CPU_Temp_Max"][!UpdateMeasure "Measure_CPU_Temp_Max"][!EnableMeasure "Measure_CPU_Temp_Max"].
[Measure_Short_Time] should be paused (you should in fact add an UpdateDivider=-1 option) and should be updated whenever [Measure_CPU_Temp_Max] is changing. The Time measure is updated only when maximum is changing, so it always returns the time of the last maximum.
All in one, here is my code proposal:

Code: Select all

[Measure_Short_Time]
Measure=Time
Format=%m/%d/%y  %#I:%M %p
UpdateDivider=-1

[Measure_CPU_Temp]
...

[Measure_CPU_Temp_Max]
Measure=Calc
Formula=( Max ( Measure_CPU_Temp, Measure_CPU_Temp_Max ))
OnChangeAction=[!UpdateMeasure "Measure_Short_Time"]
No need for IfConditions. [Measure_CPU_Temp_Max] is returning the largest achieved temperature, while [Measure_Short_Time], the time when this largest value has been achieved.

Additional note: never, but never put a comment into a line used for anything else ([Calc_CPU_Temp_Graph_Value] ; Min/Max Values for proper drawing in graph). In Rianmeter, unlike in a programming language (what Rainmeter isn't!), comments should go onto new lines. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=27443&p=142422#p142422
Yincognito
Posts: 837
Joined: February 27th, 2015, 2:38 pm

Re: Trying to save maximum cpu temp & time

Post by Yincognito »

balala wrote:
February 10th, 2020, 4:25 pm
In fact in this case IfTrueAction2 doesn't even make sense, because there is no IfCondition2. IfTrueAction2 should be executed when IfCondition2 becomes true. What if there is no IfCondition2? When is IfTrueAction2 executed?
You're absolutely correct - didn't notice that one. But then, this is the kind of mistakes we all make when we begin to learn something new.
balala wrote:
February 10th, 2020, 4:56 pm
Beside Yincognito's solution (seeming he offered a solution), just to make sure I didn't misunderstood you, let's see if I am correct: would you like to get the largest temperature ever achieved? [...] All in one, here is my code proposal [...]
Again, you're probably right, it's simpler your way. I thought that it was better to work with the "client setup" this time though, since as a beginner it's best to understand something fully (even if it can be done better) before you move on and try to seek more efficient alternatives (like yours). Hopefully, he will try your way too, as it will only improve his knowledge and abilities in Rainmeter. :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 9799
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to save maximum cpu temp & time

Post by balala »

Yincognito wrote:
February 10th, 2020, 6:22 pm
You're absolutely correct - didn't notice that one. But then, this is the kind of mistakes we all make when we begin to learn something new.
Agree. And doesn't even matter. Just saw this inconsistence and had to said it.
Yincognito wrote:
February 10th, 2020, 6:22 pm
Again, you're probably right, it's simpler your way. I thought that it was better to work with the "client setup" this time though, since as a beginner it's best to understand something fully (even if it can be done better) before you move on and try to seek more efficient alternatives (like yours). Hopefully, he will try your way too, as it will only improve his knowledge and abilities in Rainmeter. :thumbup:
Well, right this one as well. But when I saw that request this was my first thought and posted it immediately. Probably indeed the simplest solution is not always the best one. :lol:
Yincognito
Posts: 837
Joined: February 27th, 2015, 2:38 pm

Re: Trying to save maximum cpu temp & time

Post by Yincognito »

balala wrote:
February 10th, 2020, 6:36 pm
Probably indeed the simplest solution is not always the best one. :lol:
Often, it's not only about the quality of the solution, but also about timing the response to circumstances. In my experience, when folks just start things up, many of them will be "afraid" to do stuff in a different way because they believe it will "break things", not to mention the amount of information they have to absorb. So the best thing for them in that phase is to take things easy, one at a time. Only jump to the next once you grasped the meaning of the current one.

Once they become accustomed to the environment, they will speed up the process and be bolder.
User avatar
balala
Rainmeter Sage
Posts: 9799
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to save maximum cpu temp & time

Post by balala »

Yincognito wrote:
February 10th, 2020, 7:15 pm
Often, it's not only about the quality of the solution, but also about timing the response to circumstances. In my experience, when folks just start things up, many of them will be "afraid" to do stuff in a different way because they believe it will "break things", not to mention the amount of information they have to absorb. So the best thing for them in that phase is to take things easy, one at a time. Only jump to the next once you grasped the meaning of the current one.

Once they become accustomed to the environment, they will speed up the process and be bolder.
Yep, probably you're right. :thumbup: