It is currently June 24th, 2021, 4:12 pm

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

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

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

Post by goeway »

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: 21787
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post by jsmorley »

!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.
User avatar
goeway
Posts: 21
Joined: March 20th, 2019, 8:50 pm

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

Post by goeway »

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

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

Post by jsmorley »

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/
User avatar
Markster
Posts: 10
Joined: March 26th, 2020, 11:07 pm

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

Post by Markster »

Apologies if this is the wrong thread to post this question. I did a search and could not find the answer I was looking for. I have written my own python scripts to update various content on my Rainmeter skins for my SmartMirror. I posted another topic on the SmartMirror awhile ago. I use the scripts to gather various information (like FitBit info for my Bio update Rainmeter skin) and then I use command line arguments to trigger various measure and meter updates, including redraw when needed. Very efficient and all works great.

However, my issue is with the WebParser and trying to get it to parse a local file ONLY when I want it to read it. I can't seem to get the WebParser to read the file. If I refresh the skin it reads it fine, but it won't do it when I try to use a command line argument.

The command line argument does an UpdateMeasure on the skin, and it works as I see the "In MyRefresh1" log entry in the log. Here is the measure that I call from the command line.

Code: Select all

[MyRefresh1]
Measure=Calc
Formula=1
OnUpdateAction=[!Log "In MyRefresh1"][!CommandMeasure InfoIndex1 "Update"]

The InfoIndex1 webparser never gets triggered though?
Here is the webparser measure code:

[InfoIndex1]
Measure=WebParser
URL=file://s:\Python\stocks_1.json
RegExp=(?siU) .*"name": "(.*)",.*"val": "(.*)",.*"chg": "(.*)",.*"perchg": "(.*)" }
StringIndex=1
UpdateRate=1
ForceReload=1
FinishAction=[!CommandMeasure MyActionTimer1 "Execute 1"]

The FinishAction does not appear to get triggered? If it did get triggered, it would cause another log entry and update the Measure and Meters associated with that particular group. This is the code it should trigger:

Code: Select all

[MyActionTimer1]
Measure=Plugin
Plugin=ActionTimer
ActionList1=ForceUpdate
ForceUpdate=[!Log "Update Index 1"][!UpdateMeasureGroup Index1Grp][!UpdateMeterGroup Index1Grp]

Any help in what I am doing wrong here. I can't figure out why the WebParser is not getting activated.
Last edited by balala on February 10th, 2021, 1:40 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting code snippets. It's the </> button.
User avatar
Markster
Posts: 10
Joined: March 26th, 2020, 11:07 pm

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

Post by Markster »

I should also state that I turned on DEBUG and I do not see the debug file created when I use the [!CommandMeasure "InfoIndex1" "Update"]. I do see the debug file initially when the skin first loads, but I can not get it to work via the CommandMeasure bang. If I refresh the skin, the debug file is written. So I know the WebParser works.
User avatar
Markster
Posts: 10
Joined: March 26th, 2020, 11:07 pm

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

Post by Markster »

As an update to this issue, I appear to have solved my problem by changing the [!CommandMeasure InfoIndex1 "Update"] to [!UpdateMeasure InfoIndex1]. From what I had read this is not supposed to work but it does?
User avatar
goeway
Posts: 21
Joined: March 20th, 2019, 8:50 pm

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

Post by goeway »

Markster wrote: February 10th, 2021, 2:01 am Apologies if this is the wrong thread to post this question. I did a search and could not find the answer I was looking for. I have written my own python scripts to update various content on my Rainmeter skins for my SmartMirror. I posted another topic on the SmartMirror awhile ago. I use the scripts to gather various information (like FitBit info for my Bio update Rainmeter skin) and then I use command line arguments to trigger various measure and meter updates, including redraw when needed. Very efficient and all works great.

However, my issue is with the WebParser and trying to get it to parse a local file ONLY when I want it to read it. I can't seem to get the WebParser to read the file. If I refresh the skin it reads it fine, but it won't do it when I try to use a command line argument.

The command line argument does an UpdateMeasure on the skin, and it works as I see the "In MyRefresh1" log entry in the log. Here is the measure that I call from the command line.

Code: Select all

[MyRefresh1]
Measure=Calc
Formula=1
OnUpdateAction=[!Log "In MyRefresh1"][!CommandMeasure InfoIndex1 "Update"]

The InfoIndex1 webparser never gets triggered though?
Here is the webparser measure code:

[InfoIndex1]
Measure=WebParser
URL=file://s:\Python\stocks_1.json
RegExp=(?siU) .*"name": "(.*)",.*"val": "(.*)",.*"chg": "(.*)",.*"perchg": "(.*)" }
StringIndex=1
UpdateRate=1
ForceReload=1
FinishAction=[!CommandMeasure MyActionTimer1 "Execute 1"]

The FinishAction does not appear to get triggered? If it did get triggered, it would cause another log entry and update the Measure and Meters associated with that particular group. This is the code it should trigger:

Code: Select all

[MyActionTimer1]
Measure=Plugin
Plugin=ActionTimer
ActionList1=ForceUpdate
ForceUpdate=[!Log "Update Index 1"][!UpdateMeasureGroup Index1Grp][!UpdateMeterGroup Index1Grp]

Any help in what I am doing wrong here. I can't figure out why the WebParser is not getting activated.
I created a new simple skin to test it, without adding any extra actions, and it works fine. It updates in real time when I change the content of the file I need to read. So, not sure why you have to make it so complicated。

skin:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]

[InfoIndex1]
Measure=WebParser
URL=file://E:\desktop\test.txt
RegExp=(?siU)test (.*) if test>=10000 then....
StringIndex=1
UpdateRate=1
ForceReload=1

[test]
Meter=String
X=0
Y=0
W=160
H=18
FontSize=9
FontColor=0,0,0,255
Text=[InfoIndex1]
SolidColor=200,200,0,100
AntiAlias=1
DynamicVariables=1
test.txt:

Code: Select all

test 12354545 if test>=10000 then....
Last edited by goeway on February 11th, 2021, 2:24 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 21787
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post by jsmorley »

We would prefer that posts be done in English. While no language is any better than any other, we are hoping not to have silos of conversations that are limited to people who speak a particular language.

What is the world's lingua franca?