It is currently May 27th, 2020, 4:23 am

Round 4 Core CPU Meter

Post your work-in-progress and completed skins to share and discuss.
User avatar
DavidRGreen
Posts: 12
Joined: May 5th, 2020, 10:19 am

Round 4 Core CPU Meter

Post by DavidRGreen »

This Widget, designed to sit discretely in a corner of the desktop reflects the CPU core usage as an arc per core, outer being #1 through to inner being #4. The line colour will change depending on the CPU core usage; length of arc, starting at a green colour though to red (for "red lining").

The percentile value at the bottom reflects the whole CPU average.

Image

As this was my first (significant) widget developed, I had a little help from balala in sorting out some of the code. (Thanks!)
Round CPU Meter_1.0.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 10605
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round 4 Core CPU Meter

Post by balala »

Looking good, congratulations. However there is a small improvement, which you could easily do and me personally at least, definitely recommend it.
Since not all processors have four cores, you should achieve the skin to show the appropriate number of Roundline meters, depending on the number of cores. You should choose a number of cores up to which the skin should show the correct number of meters. Not to modify too much the code, starting from the size of the existing meters, this number should be 8. If you want more, you have to increase the diameter of the Roundline meters.
Interested? If you are and you don't know how to achieve it, please let me know, for assistance.
User avatar
DavidRGreen
Posts: 12
Joined: May 5th, 2020, 10:19 am

Re: Round 4 Core CPU Meter

Post by DavidRGreen »

Thanks balala,

Actually, your suggestion is not totally unexpected. And I already have an idea on an implementation solution that will not impact its dimensions.
Ironically, when I first built this widget, many years ago, I only had a dual-core computer, but built it for a quad, and it was still 'good to go' when I upgraded to a quad-core machine.

Of course, Octo-core is all very well, but after that? Visualisation after that may become an overkill… Maybe…

Stay tuned for Updates :)
User avatar
balala
Rainmeter Sage
Posts: 10605
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round 4 Core CPU Meter

Post by balala »

DavidRGreen wrote:
May 24th, 2020, 3:20 am
Of course, Octo-core is all very well, but after that? Visualisation after that may become an overkill… Maybe…
Yep, but you could increase the diameter of the skin or whatever. It's up to you, you being the author.
DavidRGreen wrote:
May 24th, 2020, 3:20 am
Stay tuned for Updates :)
Alright.
User avatar
DavidRGreen
Posts: 12
Joined: May 5th, 2020, 10:19 am

Round 4, 6 & 8 Core CPU Meter

Post by DavidRGreen »

Okay, now we have 4, 6 & 8 Core CPU meters.

Image

I don't actually have an 8 core CPU on my computer, so my first thought was, "What are those extra lines doing there?"
I did check my system specs, and yes, I only have four, so them I checked the log, and all was revealed… Instead on yielding a return value of zero for non-existant cores (like it used to under XWidget), Rainmeter is populating the empty core values with the average (ie. Core 0).

I'd prefer a zero (or -1) for a null core, a -1 value would be detectable and actioned accordingly, but anyway…
Round CPU Meter_2.0.rmskin
So there it is, up to 8 cores, and still the same size, discrete and unimposing on desktop acreage.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 10605
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Round 4, 6 & 8 Core CPU Meter

Post by balala »

DavidRGreen wrote:
Yesterday, 2:33 am
I don't actually have an 8 core CPU on my computer,
Doesn't matter, if you're publishing your skin either here on the forum, or on DA, it is much better to have a skin which could be properly usable by as much users as possible.
DavidRGreen wrote:
Yesterday, 2:33 am
so my first thought was, "What are those extra lines doing there?"
I did check my system specs, and yes, I only have four, so them I checked the log, and all was revealed… Instead on yielding a return value of zero for non-existant cores (like it used to under XWidget), Rainmeter is populating the empty core values with the average (ie. Core 0).
Exactly, that's how the Rainmeter's CPU measures are working.
DavidRGreen wrote:
Yesterday, 2:33 am
I'd prefer a zero (or -1) for a null core, a -1 value would be detectable and actioned accordingly, but anyway…
Yep, but it anyway is detectable and the appropriate number of meters should be shown.
For instance, add the following measure to your code:

Code: Select all

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=WMIC CPU Get NumberOfLogicalProcessors
State=Hide
OutputType=ANSI
RegExpSubstitute=1
Substitute="\n":"","\s":"",".*(\d{1,2})":"\1"
IfCondition=([#CURRENTSECTION#]=1)
IfTrueAction=[!ShowMeter "DisplayCPU1"][!HideMeter "DisplayCPU2"][!HideMeter "DisplayCPU3"][!HideMeter "DisplayCPU4"][!HideMeter "DisplayCPU5"][!HideMeter "DisplayCPU6"][!HideMeter "DisplayCPU7"][!HideMeter "DisplayCPU8"]
IfCondition2=([#CURRENTSECTION#]=2)
IfTrueAction2=[!ShowMeter "DisplayCPU1"][!ShowMeter "DisplayCPU2"][!HideMeter "DisplayCPU3"][!HideMeter "DisplayCPU4"][!HideMeter "DisplayCPU5"][!HideMeter "DisplayCPU6"][!HideMeter "DisplayCPU7"][!HideMeter "DisplayCPU8"]
IfCondition3=([#CURRENTSECTION#]=4)
IfTrueAction3=[!ShowMeter "DisplayCPU1"][!ShowMeter "DisplayCPU2"][!ShowMeter "DisplayCPU3"][!ShowMeter "DisplayCPU4"][!HideMeter "DisplayCPU5"][!HideMeter "DisplayCPU6"][!HideMeter "DisplayCPU7"][!HideMeter "DisplayCPU8"]
IfCondition4=([#CURRENTSECTION#]=6)
IfTrueAction4=[!ShowMeter "DisplayCPU1"][!ShowMeter "DisplayCPU2"][!ShowMeter "DisplayCPU3"][!ShowMeter "DisplayCPU4"][!ShowMeter "DisplayCPU5"][!ShowMeter "DisplayCPU6"][!HideMeter "DisplayCPU7"][!HideMeter "DisplayCPU8"]
IfCondition5=([#CURRENTSECTION#]=8)
IfTrueAction5=[!ShowMeter "DisplayCPU1"][!ShowMeter "DisplayCPU2"][!ShowMeter "DisplayCPU3"][!ShowMeter "DisplayCPU4"][!ShowMeter "DisplayCPU5"][!ShowMeter "DisplayCPU6"][!ShowMeter "DisplayCPU7"][!ShowMeter "DisplayCPU8"]
DynamicVariables=1
When you refresh / load the skin, this measure has to be run, so add the following option to the [Rainmeter] section: OnRefreshAction=[!CommandMeasure "MeasureRun" "Run"].
A few other possible improvements I'd do on your code:
  • Additionally I'd add a Hidden=1 option to all Roundline meters ([DisplayCPU1] - [DisplayCPU8]). The appropriate number of meters are revealed when the RunCommand plugin measure is run.
  • I'd create a style section and would gather all commonly used options into such a style section. For instance a [RoundlineStyle] section should be created and the common Solid=1, AntiAlias=1, W=100 and H=100 options should be removed from all Roundline meters and moved there. Finally a MeterStyle=RoundlineStyle option should be added to all those Roundline meters, to let them get and use the options of the style section.
  • Whenever are you working with a skin which has no background, it is a good idea to add to the [Rainmeter] section, beside the existing options, the following ones as well:

    Code: Select all

    [Rainmeter]
    ...
    BackgroundMode=2
    SolidColor=0,0,0,1
    These options are creating a completely transparent background, but which reacts to mouse clicks and right-clicks.
User avatar
DavidRGreen
Posts: 12
Joined: May 5th, 2020, 10:19 am

Re: Round 4 Core CPU Meter

Post by DavidRGreen »

balala wrote:
Yesterday, 10:06 am
it is much better to have a skin which could be properly usable by as much users as possible
Well, I can't argue with that, although you'd have to admit that the creation of a widget would involve a degree of self-interest, which would then expand to a wider audience, if so inclined. I've still got training wheels deployed here, and still trying to get my head around the 'Rainmeter way'.
balala wrote:
Yesterday, 10:06 am
that's how the Rainmeter's CPU measures are working
… I'm still encumbered with expectations based on prior widget engine experience :)

Your code suggestion looks interesting.
I'm guessing that OnRefreshAction= limits the section's execution to load time only. It doesn't look like the sort of thing that you would want running at every update cycle. And it's a lot of Bags there.
Technically, hiding and showing CPU #1 is a little redundant. You'll need a least 1 CPU core to actually do anything, for without at least 1 CPU, your computer will be an inert circuit board…

"Styles" look interesting. I just haven't read all the documentation yet. I'll get there eventually.

And BTW, SolidColor=0,0,0,1 is not "completely transparent", it is ¹/₂₅₅ opaque! :)

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

Re: Round 4 Core CPU Meter

Post by balala »

DavidRGreen wrote:
Yesterday, 1:31 pm
I'm guessing that OnRefreshAction= limits the section's execution to load time only. It doesn't look like the sort of thing that you would want running at every update cycle. And it's a lot of Bags there.
Well, usually the number of cores doesn't change while you're running the skin, so... 8-)
DavidRGreen wrote:
Yesterday, 1:31 pm
Technically, hiding and showing CPU #1 is a little redundant. You'll need a least 1 CPU core to actually do anything, for without at least 1 CPU, your computer will be an inert circuit board…
Agree. However the conditions have to cover this case as well. My opinion...
DavidRGreen wrote:
Yesterday, 1:31 pm
"Styles" look interesting. I just haven't read all the documentation yet. I'll get there eventually.
It can shorten the code. In some cases extremely much...
DavidRGreen wrote:
Yesterday, 1:31 pm
And BTW, SolidColor=0,0,0,1 is not "completely transparent", it is ¹/₂₅₅ opaque! :)
Technically it is not, indeed, however you won't see such a background with naked eyes, but it'll react to mouse clicks.