Given: Skin that pulls data from internet site every 15 min. Data pulled is static nights and weekends.
Question: Is there a method or code example where I can timebound the refresh to ONLY occur M-F 9am - 5pm?
Appreciate any tips/examples.
It is currently April 28th, 2024, 7:27 am
Time Bounding Skin Refresh from Interwebby
-
- Posts: 11
- Joined: November 13th, 2016, 7:33 pm
-
- Rainmeter Sage
- Posts: 16183
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Time Bounding Skin Refresh from Interwebby
What do you mean by this?
There definitely is, but how can be done depends on what exactly the measure is returning, how those expressions are looking. For instance the day of week is returned as a letter, an expression or what? Also the day of week and the time is returned as a single expression or from two different measures, one for day and the other for the time?PhantomRAM wrote: ↑November 23rd, 2023, 7:00 pm Question: Is there a method or code example where I can timebound the refresh to ONLY occur M-F 9am - 5pm?
So an example code would be nice, to let us know exactly how the expressions are looking.
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Time Bounding Skin Refresh from Interwebby
He means that the data he's retrieving from the internet does not change when it's night or in the weekend. Hence the desired interval for which he wants a "refresh" (well, most likely the related WebParser measures' updates actually) to happen. Basically, he wants the WebParsers to only retrieve data during the workdays period, when the site(s) update it as well.
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Time Bounding Skin Refresh from Interwebby
An idea would be to use two Time measures to check out the current hour and the current weekday, then use some IfConditions in each of those measures where you enable your internet data grabbing measures - WebParser ones, I suspect - if the hour or weekday correspond to workdays' period, and disable them if not (by the way, IfConditions only work with numbers, so you should get the current weekday as a number, not string):PhantomRAM wrote: ↑November 23rd, 2023, 7:00 pm Given: Skin that pulls data from internet site every 15 min. Data pulled is static nights and weekends.
Question: Is there a method or code example where I can timebound the refresh to ONLY occur M-F 9am - 5pm?
Appreciate any tips/examples.
https://docs.rainmeter.net/manual/measures/time/
https://docs.rainmeter.net/manual/measures/general-options/ifconditions/
https://docs.rainmeter.net/manual/bangs/#EnableDisableToggleMeasure
Depending on whether you need stuff to happen immediately, updating (or commanding to update) those data grabbing measures, updating the meters and redrawing the skin via bangs like !UpdateMeasure (!CommandMeasure "Update"), !UpdateMeter and !Redraw (see the last link above) might be needed. If you're happy with letting the specific Update / UpdateDivider / UpdateRate values in your skin and measures handle that, then the last part is not needed.
As for an example, something along these lines should do:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[Hour]
Measure=Time
Format=%H
[Weekday]
Measure=Time
Format=%w
[Toggle]
Measure=Calc
IfCondition=(Hour>8)&&(Hour<17)&&(Weekday<6)
IfTrueAction=[!EnableMeasure WebParser][!UpdateMeasure WebParser][!CommandMeasure WebParser "Update"]
IfFalseAction=[!DisableMeasure WebParser][!UpdateMeasure WebParser]
[WebParser]
Measure=WebParser
URL=https://google.com
RegExp=(?siU)^(.{30}).*$
StringIndex=1
UpdateRate=600
FinishAction=[!Log "Data Retrieved"]
---Meters---
[WebParserValue]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=WebParser
Text="WebParser Value:#CRLF##CRLF#%1"
That being said, it's possible that you might not even need the above, since, according to the default values of options in a WebParser measure, such a measure "reads the resource only if it has been modified since last read" ... so if your data is (entirely, as in the whole webpage) static, then the cache would be used instead of acessing the resource again. Unless, of course, that refers only to downloading from the said webpage, cause the manual is not entirely clear in that regard.