It is currently April 19th, 2024, 2:18 am

How to update a Ping measure?

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

How to update a Ping measure?

Post by Yincognito »

I have this Ping measure:

Code: Select all

[MS_Ping_Latency]
Measure=Plugin
Plugin=PingPlugin
DestAddress=www.google.com
UpdateRate=300
MinValue=0
MaxValue=30000
and then this corresponding meter:

Code: Select all

[MT_Ping_Latency_Value]
Meter=STRING
MeterStyle=SSectionRightValue
MeasureName=MS_Ping_Latency
Text="%1 ms"
LeftMouseUpAction=[!UpdateMeasure "MS_Ping_Latency"][!Redraw]
which tries to update the above measure when left-clicked on the meter. But it doesn't work.

I've tried to update with [!CommandMeasure MS_Ping_Latency Update] too, with no success. It doesn't even show any activity on the Log when I left-click the mouse.

So, is there any way of updating a Ping measure without refreshing the whole skin? I have other CPU intensive elements on the skin and I wouldn't want to trigger those every time I want to update just the Ping measure/meter...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to update a Ping measure?

Post by jsmorley »

The Ping plugin is driven by an UpdateRate internal counter, much like WebParser is. This counter is an internal loop from 0 to the value of UpdateRate on the measure, incremented by 1 on each update of the measure. It will execute the ping when the counter it is tracking is 0, which it is on the first update, and on the next update each time it reaches the value of UpdateRate, which has a default of 32. So by default, it will ping on load/refresh and then each 32 skin "updates", which with Update=1000 is every 32 seconds.

To override this with ping, you need to use !SetOption to temporarily set the value of UpdateRate to "0", so on the very next update of the measure the ping is fired again. Don't forget to set it back to it's original value right after, or it will send the ping on every skin update, which you never want.

Code: Select all

[MeasurePing]
Measure=Plugin
Plugin=PingPlugin
DestAddress=www.google.com
UpdateRate=32

[MeterPing]
Meter=String
MeasureName=MeasurePing
X=5
Y=5
W=200
H=20
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=google.com: %1ms
LeftMouseUpAction=[!SetOption MeasurePing UpdateRate 0][!UpdateMeasure MeasurePing][!SetOption MeasurePing UpdateRate 32]
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to update a Ping measure?

Post by Yincognito »

Now that was really interesting, jsmorley. I like the fact that you also explain the technical (inner working) side of things - this helps to deal with future situations.
That is why the ping tool in Windows by default does 4 one after the other, and averages the result.
But would this be a reliable solution in Rainmeter? I mean...it would take ages to "show" the computed latency (32s x 4 = 2 minutes?)...

Code: Select all

LeftMouseUpAction=[!SetOption MeasurePing UpdateRate 0][!UpdateMeasure MeasurePing][!SetOption MeasurePing UpdateRate 32]
Does this mean I'm bound to use the UpdateRate of 32 instead of 300 (if I understand correctly this would mean non-stop pinging the host - of course, having the timeout of 30s between "pings")?

How would this be any different than simply setting the UpdateRate to 32 and let the measure update on its own, without requiring mouse clicks? I mean the measure would update after 32 seconds anyway, right? Why setting UpdateRate to 0 if the measure updates when reaching the 32 seconds counter in any case?

A lot of questions, but I'm not sure what you're trying to say. Probably the fact that I shouldn't even use the Ping measure altogether, correct?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to update a Ping measure?

Post by jsmorley »

I guess all I was saying is that a single, mouse-driven ping doesn't really tell you much about the latency of the connection to the remote host. Yes, I'm not sure the ping plugin in Rainmeter is really of much value for that to be honest. It's fine for seeing if a host is "alive", but not much use in my view for measuring "performance" based on ping latency. My problem with a single ping is that a large value, like 400 or something, doesn't mean the connection has that latency, it means that ping had that latency. Any given ping can get hung up in the cloud somewhere.

There isn't any easy way I can think of to have it do what would make more sense to me, which would be to have it ping the site some number of times, like 4 or 6 or something very quickly, one right after the other, and then average the results. Then wait some period of time, 30 seconds or one minute or whatever, and repeat. The way the ping tool in Windows works is more to my liking, but hard to replicate with the ping plugin.

It just sorta is what it is. If you put AverageSize=4 on the measure, at least over time you will get an average of the last 4 pings. Pretty spread out, which isn't ideal, but might be better than just a single ping "on demand" or even a single ping every 32 seconds. However, you are right that the "average' is going to take some time to become a correct average, as for the first couple of minutes it's going to be based on an incomplete set of 4. When you first load or refresh, it will be the average of 4 based on only 1, then the average of 4 based on only 2 and so on. I believe it will take more than 4 times through to get all the way there, as for some time, even after 4 pings, the average will be based on the earlier average of parts of the set. So it will move toward correct, but will take some time.

Really, at the end of the day, what value is any of it? Ping latency is probably only of interest in the context of an online game anyway. What ping you are getting to Google.com is going to have little or nothing to do with how fast Google is in your browser. Outside of an online game, or maybe some connection to a business server you are networked with, showing ping latency is just showing a number because you can... As I said, ping is a great way to test if a host is "alive". I'm skeptical about other uses.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to update a Ping measure?

Post by jsmorley »

How would this be any different than simply setting the UpdateRate to 32 and let the measure update on its own, without requiring mouse clicks? I mean the measure would update after 32 seconds anyway, right? Why setting UpdateRate to 0 if the measure updates when reaching the 32 seconds counter in any case?
This won't help at all with the original request to have it fire "on demand" though. Now I'm lost, as certainly if you set UpdateRate=32 (which is the default anyway) it will ping every 32 seconds. I thought based on your original post that you wanted to be able to override that and do a ping "now" based on a mouse click.

To be clear, it's not counting "UpdateRate" in the plugin, but an entirely invisible to you "counter" in the plugin that is incremented by 1 on each update. What it does is fire the ping when that "counter" is at 0. It is at 0 when the skin is first loaded/refreshed, and again on the next update after "counter" is greater than or equal to "UpdateRate". There are simple statements in the update routine of the plugin that say:

If Counter = 0 then start a thread to do the ping.
If Counter >= UpdateRate, then Counter = 0, else Counter = Counter + 1

If UpdateRate is 32 then the counter will count from 0 to 32 and then back to 0. The ping is fired each time the counter is 0.

There is no way for you to "reset" that counter, other than dynamically changing UpdateRate to 0, so the counter resets itself on the next update.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to update a Ping measure?

Post by Yincognito »

This won't help at all with the original request to have it fire "on demand" though.
True, but the only reason I though of implementing a fire "on demand" was the "big" 300s UpdateRate. Sometimes one would want to see the "latency" as of "right now", instead of waiting 5 minutes for it to update. But I want to keep that 300s UpdateRate though!

On the other hand, having the UpdateRate set to 32s would make fire "on demand" quite irrelevant (therefore not going to be implemented), as the measure would update every 32s (a "small" interval) anyway.

The way I want to make this work is:
- a "big" "default" update of the measure (e.g. 300s)
- a possibility to "trigger" a "right now" update of the measure anytime.
Basically I want rare default pings, but with the ability of a "right now" manual mode (whether it's mouse click, mouse hover, etc.)
To be clear, it's not counting "UpdateRate" in the plugin, but an entirely invisible to you "counter" in the plugin that is incremented by 1 on each update.
I think I understand it now. The "counter" basically increments each second, right? And that "reset" can be implemented on each "update of the counter" (not the measure) - so actually the "reset" to 0 is possible each second (?).

You see, using the same word : "update" for both the measure and the "counter" - that's what created the confusion. But I guess it's settled now. As I said before, "resetting" the "counter" to 0 is useless given the fact that the measure updates every 32s anyway.

What triggered my questions in the first place was why setting the UpdateRate to 32? Wouldn't the "reset" be possible using a code like this?

Code: Select all

[MeasurePing]
Measure=Plugin
Plugin=PingPlugin
DestAddress=www.google.com
UpdateRate=300

[MeterPing]
Meter=String
MeasureName=MeasurePing
X=5
Y=5
W=200
H=20
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=google.com: %1ms
LeftMouseUpAction=[!SetOption MeasurePing UpdateRate 0][!UpdateMeasure MeasurePing][!SetOption MeasurePing UpdateRate 300]
I hope I'm not such a pain in the a$$ with this, but I feel I'm missing something, and I really want to understand how this can be done.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to update a Ping measure?

Post by jsmorley »

So you are all set. Just set (and set back after) UpdateRate to whatever you want for the regular update interval, and use my original !SetOption solution to do the "now" based on mouse click. 32 is just the default and what I used as an example. It can be whatever you want.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to update a Ping measure?

Post by Yincognito »

32 is just the default and what I used as an example. It can be whatever you want.
Why didn't you say that in the first place, LOL? I was trying (really hard :? ) to understand why should I set the measure update at 32 only to reset the "counter" a few seconds later. Phew...

Glad it's finally sorted out - I was beggining to believe I'm just too dumb to get it...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth