It is currently May 5th, 2024, 5:37 am

Download page source and implement issues

Get help with creating, editing & fixing problems with skins
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

Code: Select all

[Variables]
MaximumBarValue


[MeasureAchievementsEarnedMax]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureSoldierStats]
StringIndex=1
RegExpSubstitute=1
Substitute="\d{1,3}\s\w{2}\s(\d{1,3}).+":"\1"
FinishAction=!Execute [!Update][!WriteKeyValue Variables "MaximumBarValue" "[MeasureAchievementsEarnedMax]"][!Refresh]

[MeasureAchievementsEarnedValue]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureSoldierStats]
StringIndex=1
RegExpSubstitute=1
Substitute="\s.+":""
MaxValue=MaximumBarValue
MinValue=0
When I open the logger and look at the measures, it's still not updating the maximum, any ideas?
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Download page source and implement issues

Post by Kaelri »

FatalityUK wrote:When I open the logger and look at the measures, it's still not updating the maximum, any ideas?
Ok, there are a few problems here:

Code: Select all

FinishAction=!Execute [!Update][!WriteKeyValue Variables "MaximumBarValue" "[MeasureAchievementsEarnedMax]"][!Refresh]
- The FinishAction needs to be set on the parent WebParser measure, which in this case is [MeasureSoldierStats].

- WebParser measures can't use dynamic variables, which is the whole reason you're doing this in the first place. So [!WriteKeyValue Variables "MaximumBarValue" "[MeasureAchievementsEarnedMax]"] is not going to work when you send it directly from the FinishAction. You'll need to create a separate measure - we usually use a Calc measure - and use the FinishAction to activate that measure, which will then perform the !WriteKeyValue and !Refresh actions.

- There's no reason to send [!Update], since you're just going to refresh the skin anyway.

- Unless you disable the original WebParser measure somehow, it's just going to create an infinite loop in which the skin keeps refreshing itself. See this post for some ideas on how to limit the refreshing action without disabling the WebParser measure entirely.

Code: Select all

MaxValue=MaximumBarValue
- Variables are indicated with ## containers, as in #MaximumBarValue#.
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

OK thanks :).

I'll try work something out
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

So if I do like you suggested in that other thread, will the parser only get the information once and then be disabled forever? I'm wondering because if I have a variable at the top of the config set to 1, then surely if the skin is refreshed will it not load the config and the variable will be set back to 1 again which would cause the parser to be enabled again.

I need the parser to continue to operate for my skin but need it limited to say once every 30 minutes/an hour. Would I have to use some kind of counter to achieve this?
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Download page source and implement issues

Post by Kaelri »

FatalityUK wrote:So if I do like you suggested in that other thread, will the parser only get the information once and then be disabled forever? I'm wondering because if I have a variable at the top of the config set to 1, then surely if the skin is refreshed will it not load the config and the variable will be set back to 1 again which would cause the parser to be enabled again.
That's what this part is for:

Code: Select all

[MeasureWriteKeyValue]
Measure=Calc
Disabled=1
DynamicVariables=1
Formula=#WriteNewVariable#
IfEqualValue=1
IfEqualAction=!Execute [!WriteKeyValue Variables WriteNewVariable 0][!WriteKeyValue URL "[MeasureItem1]"][!Refresh]
Instead of disabling the WebParser measure, you can just change the value of "WriteNewVariable" to 0, so it won't keep rewriting and refreshing the skin. You will need a separate button or counter to send [!SetVariable WriteNewVariable 1] in order to reset the skin.
FatalityUK wrote:I need the parser to continue to operate for my skin but need it limited to say once every 30 minutes/an hour. Would I have to use some kind of counter to achieve this?
You can set an UpdateRate on the main WebParser measure, as in:

Code: Select all

UpdateDivider=3600
When Update=1000 (default), UpdateDivider is expressed in seconds, so 3600 would give you an hour, 1800 would be half an hour, etc.
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

Thanks :).

I have another random issue which you may be able to help me with.

Basically the skin I'm designing as several UI elements with their own .ini files and they use the webparser to display data. The thing is, they all use data taken from the webpage so I was thinking it would be best to only have one download the page, then the others can use the page locally. The issue is that, which one should I make download the page? What if the user doesn't want that displayed, but wants the others displayed, they won't be able to show values because there is no local files.

how could I go about solving this?
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Download page source and implement issues

Post by Kaelri »

You could have your download measure run in a "background" skin, which is a skin that technically exists on the desktop, but has no visible or clickable meters. Rainmeter requires every skin to have at least one meter, but you can trick it by adding a meter which displays absolutely nothing, such as this:

Code: Select all

[Meter]
Meter=STRING

Then, have each of the dependent skins activate the download skin with an OnRefreshAction. This will automatically ensure that the download skin is always running, no matter which skins you chooses to run. The user never has to know that the download skin is there.

To be courteous to your users, you should also add a system whereby the download skin checks to see if at least one of the dependent skins is running, and if there is none, it deactivates itself. I'll have to think about the best way to do this, but here's an idea off the top of my head:

In each of your dependent skins, create a measure which sends an "I'm not dead" bang to the download skin every 10 seconds or so.

Code: Select all

[Skin1IsAlive]
Measure=Calc
Formula=Counter%10
IfEqualValue=0
IfEqualAction=!SetVariable Skin1Ping 0 "SuiteName\DownloadSkin"
In the download skin, create a corresponding measure which records how long it's been since the dependent skin has reported. (When it receives the !SetVariable bang from the skin, it resets and starts over.)

Code: Select all

[Skin1Time]
Measure=Calc
DynamicVariables=1
Formula=(Skin1Time+1)*#Skin1Ping#
IfEqualValue=0
IfEqualAction=!SetVariable Skin1Ping 1
Finally, also in the download skin, create a "self-destruct" measure which deactivates the download skin if no other skins have reported in for more than, say, 60 seconds.

Code: Select all

[SelfDestruct]
Measure=Calc
Formula=(SelfDestruct+1)*(Skin1Time > 60)*(Skin2Time > 60)*(Skin3Time > 60)
IfAboveValue=15
IfAboveAction=!DeactivateConfig
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

Kaelri wrote:You could have your download measure run in a "background" skin, which is a skin that technically exists on the desktop, but has no visible or clickable meters. Rainmeter requires every skin to have at least one meter, but you can trick it by adding a meter which displays absolutely nothing, such as this:

Code: Select all

[Meter]
Meter=STRING

Then, have each of the dependent skins activate the download skin with an OnRefreshAction. This will automatically ensure that the download skin is always running, no matter which skins you chooses to run. The user never has to know that the download skin is there.

To be courteous to your users, you should also add a system whereby the download skin checks to see if at least one of the dependent skins is running, and if there is none, it deactivates itself. I'll have to think about the best way to do this, but here's an idea off the top of my head:

In each of your dependent skins, create a measure which sends an "I'm not dead" bang to the download skin every 10 seconds or so.

Code: Select all

[Skin1IsAlive]
Measure=Calc
Formula=Counter%10
IfEqualValue=0
IfEqualAction=!SetVariable Skin1Ping 0 "SuiteName\DownloadSkin"
In the download skin, create a corresponding measure which records how long it's been since the dependent skin has reported. (When it receives the !SetVariable bang from the skin, it resets and starts over.)

Code: Select all

[Skin1Time]
Measure=Calc
DynamicVariables=1
Formula=(Skin1Time+1)*#Skin1Ping#
IfEqualValue=0
IfEqualAction=!SetVariable Skin1Ping 1
Finally, also in the download skin, create a "self-destruct" measure which deactivates the download skin if no other skins have reported in for more than, say, 60 seconds.

Code: Select all

[SelfDestruct]
Measure=Calc
Formula=(SelfDestruct+1)*(Skin1Time > 60)*(Skin2Time > 60)*(Skin3Time > 60)
IfAboveValue=15
IfAboveAction=!DeactivateConfig
Thanks so much! Sounds like an ideal solution :). I'll try it out and let you know how it all works out :).
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

I have another slight issue.

Everything you suggested is working fine, but if I load one of the skins which displays stats, it will show an error in the log because the files from which it has to parse its data have not been created yet (it has called the hidden downloader skin but it obviously has to create the files to read from first). Is there a way of delaying the web parser for a short while on the initial loading of the skin? A way around this would be to supply some files to begin with I guess, and just fill in ?? or something.

Another thing I was wondering is that after the hidden downloader skin has got the files from which the other skins can get their data, I want it to refresh all the on screen skins so their data updates. I'm a little confused with using the correct bang, I was trying to use !Refresh but it keeps saying the config doesn't exist. I'm a little confused as to what exactly a "config" is. Is there anyway I can simply use a path to the .ini file to be refreshed?
FatalityUK
Posts: 18
Joined: September 9th, 2011, 6:34 pm

Re: Download page source and implement issues

Post by FatalityUK »

Okay, making progress but the skin seems to be constantly refreshing itself and I'm trying to locate the cause.

If I have the following:

Code: Select all

WriteVariable=1
MaxAchievementCount=0

[MeasureSoldierStats]
Measure=Plugin
Plugin=WebParser.dll
UpdateRate=3600
*info cut blah blah*
FinishAction=!Execute [!EnableMeasure MeasureWriteMaxAchievementCount]

[MeasureWriteMaxAchievementCount]
Measure=Calc
Disabled=1
DynamicVariables=1
Formula=#WriteVariable#
IfEqualValue=1
IfEqualAction=!Execute [!WriteKeyValue Variables "WriteVariable" "0"][!WriteKeyValue Variables "MaxAchievementCount" "[MeasureAchievementsEarnedMax]"][!Refresh]

[MeasureActivateWriteVariable]
Measure=Calc
Formula=Counter%3605
IfEqualValue=0
IfEqualAction=!WriteKeyValue Variables "WriteVariable" "1"
I think the problem is with the measure which sets write variable back to 1 again. The counter will equal 0 every time the skin is refreshed won't it? Cos it will start again from 0 thus firing the if equal action and setting the write variable to 1, causing the skin to refresh which starts the whole process again thus creating the loop. I think it's the case but I'd like a second opinion. Would using a counter like:

Code: Select all

[MeasureActivateWriteVariable]
Measure=Calc
Formula=(MeasureActivateWriteVariable+1)
IfEqualValue=3605
IfEqualAction=!WriteKeyValue Variables "WriteVariable" "1"
Do the trick because it won't fire immediately? You see I'm not sure about how exactly variables work with this program, are they kept in memory when the skin refreshes, or lost? Are the counters set back to the start or will the one I posted above just give counting up and up no matter how many times the skin is refreshed?