It is currently March 29th, 2024, 9:54 am

Deduct Minutes from a time

General topics related to Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Deduct Minutes from a time

Post by balala »

dvo wrote:for me it's not import .... just tested both doesn't seem to work 4 me :P
Please dvo, do a complet restart of Rainmeter. The skin uses the WebParser plugin and with the skins using it, many times a restart of Rainmeter can help.
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

You are trying to download a satellite image from the future 2017-05-31 00:00. That can't work :p

And yes, I believe that is the DST problem. Try the attached package and set the DST=1.

I have created another package and in the variables you can set the DST=1 if you have daylight savings time. That will deduct an additional hour from the actual time.
HKG Satellite_1.1.rmskin
You do not have the required permissions to view the files attached to this post.
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

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

Re: Deduct Minutes from a time

Post by jsmorley »

Matth wrote:You are trying to download a satellite image from the future 2017-05-31 00:00. That can't work :p

And yes, I believe that is the DST problem. Try the attached package and set the DST=1.

I have created another package and in the variables you can set the DST=1 if you have daylight savings time. That will deduct an additional hour from the actual time.

HKG Satellite_1.1.rmskin
Just FYI, there is a way to get the state of DST automatically...

Code: Select all

[MeasureDSTActive]
Measure=Plugin
Plugin=SysInfo
SysInfoType=TIMEZONE_ISDST
https://docs.rainmeter.net/manual-beta/plugins/sysinfo/#TimeZoneValues
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

Thanks. The next version will have that included. I already adjusted it here, but I plan some more changes...
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

Just figured out myself what I was asking. Not relevant...
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

While the code now works nicely (at least on my PC) I am still puzzled about one feature that just doesn't seem right.

The measure to retrieve the image should actually only be triggered once every ten minutes, when the time changes to the next rounded 10 minutes.

Code: Select all

[MeasureNTUTC]
Measure=String
String=[MeasureDateUTC][MeasureHourUTC][MeasureMinUTC]
DynamicVariables=1
;If the time changes (next 10 minutes) update the URL and trigger the download for a new file
IfConditionMode=1
IfCondition=([MeasureNTUTC] <> #pBSUTC#)
IfTrueAction=[!SetVariable pBSUTC "[MeasureNTUTC]"][!SetVariable rURL "http://www.weather.gov.hk/wxinfo/intersat/satellite/image/e_infrared/[&MeasureNTHKG]+[&MeasureNTUTC]H08.nb_x8M--L1B.H08_IR1_coast.png"][!CommandMeasure "RadarMeasure" "Update"]
Here I combine the UTC time and compare it in the IfCondition with a variable that was set the previous 10 minutes. If the current time [MeasureNTUTC] is not equal to the variable #pBSUTC# then the IfTrueAction should trigger. Here I set the variables #pBSUTC# and rURL. After that I trigger a CommandMeasure to update the [RadarMeasure].

Code: Select all

[RadarMeasure]
;Downloads the image every 10 minutes
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#rURL#
Download=1
UpdateDivider=-1
DynamicVariables=1
DownloadFile="infrared\radar[MeasureHour][MeasureMin].png"
;Start displaying the images
FinishAction=[!EnableMeasureGroup "Images"][!UpdateMeasureGroup "Images"][!EnableMeasure "MeasureTimer"][!ShowMeterGroup "ImgDat"][!CommandMeasure "MeaFolder" "Update"]
No this measure downloads the variable #rURL# set in the previous measure and then starts the animation. There is no other CommandMeasure calling this measure and yet, it is triggered more or less exactly every 2:30 minutes. I can understand the 2:30 minutes as it comes from the default 600 milliseconds from the WebParser plugin and the Update=250 of the skin. But then I thought the UpdateDivider=-1 would prevent any automatic update and only fetch the URL if it is loaded or refreshed (or called with the CommandMeasure I would believe). What do I need to add to ONLY get it once every 10 minutes?
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

Ok, so it seems if UpdateDivider=-1 is set, then even the CommandMeasure does not trigger a new download.

I now added UpdateRate=2400 and it seems to work as it should. It now downloads the image only every 10 minutes.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Deduct Minutes from a time

Post by balala »

Now if you've figured out what's happening, I'd have one more recommendation: you should replace the [MeasureNTUTC] string measure, with a Calc measure. You should do this because the IfCondition is working with numeric values, but even if the value of the [MeasureNTUTC] measure is composed by digits, it being a string measure, its value in fact is a string. It's true you're converting it to number (using the brackets), but a much more elegant solution would be to use a Calc measure:

Code: Select all

[MeasureNTUTC]
Measure=Calc
Formula=( 10000 * [MeasureDateUTC] + 100 * [MeasureHourUTC] + [MeasureMinUTC] )
DynamicVariables=1
;If the time changes (next 10 minutes) update the URL and trigger the download for a new file
IfConditionMode=1
IfCondition=(MeasureNTUTC <> #pBSUTC#)
IfTrueAction=[!SetVariable pBSUTC "[MeasureNTUTC]"][!SetVariable rURL "http://www.weather.gov.hk/wxinfo/intersat/satellite/image/e_infrared/[&MeasureNTHKG]+[&MeasureNTUTC]H08.nb_x8M--L1B.H08_IR1_coast.png"][!CommandMeasure "RadarMeasure" "Update"]
You should do the same with the [MeasureNTHKG] and [MeasureBaseTime] string measures.
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Deduct Minutes from a time

Post by Matth »

It might be more elegant but it strips off the leading zero on the date. This is required and if I change it it'll fail to download the images.