It is currently May 25th, 2019, 2:21 pm

What is the difference between "!CommandMeasure" and "!UpdateMeasureGroup"?

General topics related to Rainmeter.
goeway
Posts: 3
Joined: March 20th, 2019, 8:50 pm

What is the difference between "!CommandMeasure" and "!UpdateMeasureGroup"?

goeway » March 29th, 2019, 4:26 am

SkinA.ini:

Code: Select all

[MeasureCheckNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
OnChangeAction=[!CommandMeasure MeasureA1 "Update"][!CommandMeasure MeasureA2 "Update"]

[MeasureA1]
Measure=Plugin
Plugin=WebParser
UpdateRate=120
URL=UrlA1
RegExp=(?siU).....

[MeasureA2]
Measure=Plugin
Plugin=WebParser
UpdateRate=120
URL=UrlA2
RegExp=(?siU).....
SkinB.ini:

Code: Select all

[MeasureCheckNetwork]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
OnChangeAction=[!UpdateMeasureGroup Test]

[MeasureA1]
Measure=Plugin
Plugin=WebParser
UpdateRate=120
URL=UrlA1
RegExp=(?siU).....
Group=Test

[MeasureA2]
Measure=Plugin
Plugin=WebParser
UpdateRate=120
URL=UrlA2
RegExp=(?siU).....
Group=Test
Last edited by balala on March 29th, 2019, 2:29 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: What is the difference between "!CommandMeasure" and "!UpdateMeasureGroup"?

jsmorley » March 29th, 2019, 11:52 am

!UpdateMeasure and !CommandMeasure are two very different things.

!UpdateMeasure is used to cause a measure to be updated, to measure the value it is designed to measure. It's just a way to shortcut the "loop" that a skin is in, and tells the measure to update "now", rather than waiting for the next time it would normally be updated by the normal course of the loop driven by the skin Update, and any UpdateDivider on the measure.

!CommandMeasure is used to tell a measure, one that is specifically designed to do so, to take some "specific" action. It is used in a sense to allow measures that support it to have a way to tell the measure "Do A" or "Do B" on demand. In some cases, like ActionTimer and RunCommand measures, it is the way you "trigger" the measure to take action, when it designed not to act independently. Not all measures support, nor do they need to, the use of !CommandMeasure.

WebParser is a special case. It is the only one that supports a !CommandMeasure action of "Update", which while the name of that action might be a bit regrettable, due to the possible confusion with the normal measure "update", is indeed a specific command, specifically supported by WebParser, to allow you to shortcut the behavior of UpdateRate in WebParser.

WebParser measures are controlled entirely by the skin Update times the measure UpdateRate. That is why when the skin Update is the default 1000, and the measure UpdateRate is the default 600, you get 1000ms X 600 equals 600 seconds, which equals 10 minutes.

Don't use !UpdateMeasure on WebParser measures.

WebParser works by using UpdateRate, an internal counter that tells WebParser how often to go out to the remote resource and get the data. The counter is incremented by one each time the parent measure is updated, until it reached the value set for UpdateRate, when it resets to zero and goes out for the data.

When the values are retrieved, the parent measure automatically sets the values for all its child measures. There is no possible utility in using UpdateDivider, UpdateRate, !UpdateMeasure, or !CommandMeasure on a WebParser child measure. The child measures with WebParser take no actions independent of the parent, and in fact don't "retrieve" any data at all, but are "handed" it by the parent.

So you see, if you have an UpdateRate of say 600 (the default), that internal counter is at zero when the skin is loaded or refreshed, and so the plugin goes out and gets the remote resource. Then on each subsequent update of the measure it adds one to that internal counter, and will do so until it reaches 600, when it will reset to zero, go get the remote resource, and begin the cycle again. So if you force an update of the measure, you simply increment that internal counter by one, say from 458 to 459, and are only one measure update closer to your goal. You sill have 141 measure updates to go before anything happens.

You can use !CommandMeasure to override UpdateRate and force WebParser to go out to the remote resource on demand.
https://docs.rainmeter.net/manual/measures/webparser/#CommandMeasureUpdate

What !CommandMeasure with an action of "Update" does with WebParser is simple. It sets that internal counter in WebParser to zero immediately...
Again, do NOT use !UpdateMeasure on WebParser measures. all that will do is increment the UpdateRate counter by one.


Using UpdateDivider on WebParser parent or child measures is generally not (and by generally, I really mean never) the way to go. All that is done on the update of a WebParser parent measure is that the UpdateRate counter is incremented by one. Leave UpdateDivider on all WebParser measure set to the default value of 1, and don't use !UpdateMeasure.
goeway
Posts: 3
Joined: March 20th, 2019, 8:50 pm

Re: What is the difference between "!CommandMeasure" and "!UpdateMeasureGroup"?

goeway » March 30th, 2019, 12:01 pm

:rosegift: jsmorley
User avatar
jsmorley
Developer
Posts: 19245
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: What is the difference between "!CommandMeasure" and "!UpdateMeasureGroup"?

jsmorley » March 30th, 2019, 3:30 pm

I think the issue of how UpdateRate works with WebParser is of enough general interest to warrant a "Tips & Tricks" entry...

https://docs.rainmeter.net/tips/
https://docs.rainmeter.net/tips/webparser-updaterate/