It is currently April 27th, 2024, 10:54 am

Please help...Trying to access CPU Data

Get help with creating, editing & fixing problems with skins
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Please help...Trying to access CPU Data

Post by dberm22 »

I am trying to create a skin in which the CPU bar moves smoothly, but I am having trouble. I think it is in my using of #CPU# in my calc function, but I'm not sure. Please help me by letting me know what I am doing incorrectly.

Code: Select all

;===========  CPU ============
...
[CPU]
Measure=CPU
Update=1000

[CPU_SMOOTH]
Measure=Calc
Formula=(NUMBER>#CPU#) ? (NUMBER-.01) : (NUMBER+.01)
Update=100

[CPU_SMOOTH_SET]
Measure=Calc
Formula=CPU_SMOOTH
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable NUMBER [CPU_SMOOTH]

;---------------------------


[CPU_BAR]
MeasureName=CPU_SMOOTH
Meter=ROUNDLINE
...
Last edited by dberm22 on March 30th, 2011, 5:48 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help...Trying to access CPU Data

Post by jsmorley »

Aside from anything else, "Update=" is a setting which can only be set once, in the [Rainmeter] section of the skin. You can never change it, and you can never have a skin which does anything "faster" than what is set in Update= in [Rainmeter]. UpdateDivider / UpdateRate can be used to make a particular part of a skin (a given measure or meter) run "slower" than what is set in Update=, but never faster.
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Re: Please help...Trying to access CPU Data

Post by dberm22 »

Thanks for that. I changed that but your suggestion doesn't address the overall issue I am having. Is it even possible to do computations on something being measured?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help...Trying to access CPU Data

Post by jsmorley »

Yes you can, but your syntax needed some work. You can't reference a "variable" without putting it inside pound signs, and you can't use just .01 in a formula. It needs to be 0.01 or you get a syntax error.

[Rainmeter]
Update=1000

[Variables]
Number=5

[CPU]
Measure=CPU

[CPU_SMOOTH]
Measure=Calc
Formula=(#Number#>CPU) ? (#Number#-0.01) : (#Number#+0.01)
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Re: Please help...Trying to access CPU Data

Post by dberm22 »

Ahh..thanks alot. I'll try that in a little and I'll let you know how that works out for me.

Thanks.
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Re: Please help...Trying to access CPU Data

Post by dberm22 »

jsmorley wrote:Yes you can, but your syntax needed some work. You can't reference a "variable" without putting it inside pound signs, and you can't use just .01 in a formula. It needs to be 0.01 or you get a syntax error.
I've implemented what you've said, but now I'm having the problem that the code is not storing the new value of NUMBER. I've tried setting the MeasureName = CPU_SMOOTH and MeasureName = CPU_SMOOTH_SET, but neither of them are storing the new value...the meter is always centered around 30% and goes either to 31% or 29%. Here's my updated code:

Code: Select all

[Rainmeter]
Update=100

[Variables]
NUMBER=0.3
...
;===========  CPU ============

[CPU]
Measure=CPU

[CPU_SMOOTH]
Measure=Calc
Formula=(#NUMBER#>CPU) ? (#NUMBER#-0.01) : (#NUMBER#+0.01)

[CPU_SMOOTH_SET]
Measure=Calc
Formula=CPU_SMOOTH
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable NUMBER [CPU_SMOOTH]

;---------------------------


[CPU_BAR]
MeasureName=CPU_SMOOTH
Meter=ROUNDLINE
...
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help...Trying to access CPU Data

Post by jsmorley »

Two things to keep in mind.

1) If you are going to use the value of NUMBER in a dynamic way (which you are) you want to be sure your meter using it has DynamicVariables=1 set on it, or it will never see the altered value set by !RainmeterSetVariable. I can't tell if "..." includes this, but it is required.

2) An IfAction, like IfAboveValue, works in the following way. It will fire the action assigned to IfAboveAction when the condition in IfAboveValue becomes "true", but will not fire it again until it becomes "false" and then "true" again. This is to keep IfActions from just running amok and continuously firing actions when for instance the IfAboveValue is "1" and the detected value just keeps rising to 2, 3, 4 etc. If has to go "below" the IfAboveValue setting, then back to "above" (false / true) to again fire the action. I am not sure from your snippets if this is going to be an issue for your code, but keep it in mind.
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Re: Please help...Trying to access CPU Data

Post by dberm22 »

jsmorley wrote: 2) An IfAction, like IfAboveValue, works in the following way. It will fire the action assigned to IfAboveAction when the condition in IfAboveValue becomes "true", but will not fire it again until it becomes "false" and then "true" again. This is to keep IfActions from just running amok and continuously firing actions when for instance the IfAboveValue is "1" and the detected value just keeps rising to 2, 3, 4 etc. If has to go "below" the IfAboveValue setting, then back to "above" (false / true) to again fire the action..
Ahh! That is my problem! How do I make it so that it keeps firing until it becomes false?

Ive tried using Counter, as shown below, but that isn't working

Code: Select all

[CPU_SMOOTH]
Measure=Calc
Formula=(#NUMBER#>CPU)?(#NUMBER#-0.01):(#NUMBER#+0.01)
DynamicVariables=1

[CPU_SMOOTH_SET]
Measure=Calc
Formula=Counter % 2
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable NUMBER [CPU_SMOOTH]
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Please help...Trying to access CPU Data

Post by jsmorley »

dberm22 wrote: Ahh! That is my problem! How do I make it so that it keeps firing until it becomes false?
Not an easy thing to do with IfActions. They are hard wired to work the way they do. You might want to explore a different approach, where instead of setting a variable on IfAboveAction, you !RainmeterEnableMeasure and !RainmeterDisableMeasure one or more measures (Calc measures perhaps) that then contain the value you want to use in your meter later.

The format of the command(s) is:

!RainmeterEnableMeasure [Measure] (Config)

So something like:

IfAboveValue=0
IfAboveAction=!Execute [!RainmeterEnableMeasure MyMeasure #CURRENTCONFIG#]
IfBelowValue=0
IfBelowAction=!Execute [!RainmeterDisableMeasure MyMeasure #CURRENTCONFIG#]


If you "enable" a measure using !RainmeterEnableMeasure when IfAboveAction is true, it will keep updating. Then you "disable" it using an IfBelowAction on the same measure with the IfAboveAction. That way the measure will be enabled until turned off again by the IfBelowAction.

The only downside to this is that you need to be aware that every time you "kite / hand off" a value through a calc measure in order to "carry it along" like this, (or to do math on a value or convert a string to a number, some other reasons to do this) you get one "Update=" behind each time. So for a meter that directly gets a value that has been measured by something like Measure=CPU will display the "current" value, if you pass the value through one or two or three calc measures for whatever reason, each calc measure will in effect delay what is being shown by the meter by one Update each. Just something to keep in mind.

Make sense?
User avatar
dberm22
Posts: 8
Joined: March 29th, 2011, 11:05 pm

Re: Please help...Trying to access CPU Data

Post by dberm22 »

That make sense, but in my case, a .3 second delay is not a big deal. I am using counter to keep the thing firing, but I feel as if the CPU isn't being measured very often. The bar keeps jumping around (randomly?) but is increasing slightly over time. Not sure why this is. I have attached the skin in case you wanted to go above and beyond with helping me. It is a modification of this guy's work.

http://hunterludi.deviantart.com/art/DustMedia-Rainmeter-Win7-Theme-158396832

Attached are my modified files.
You do not have the required permissions to view the files attached to this post.