It is currently April 28th, 2024, 2:52 pm

Help with running count-esque display

Get help with creating, editing & fixing problems with skins
RedFogul
Posts: 5
Joined: June 17th, 2011, 9:14 am

Help with running count-esque display

Post by RedFogul »

Sorry about the ambiguous title, i'm not really sure how to word this so ill just explain.

I use ddwrt for my router and it has a nifty page for giving me interface statistics
the output is essentially thus: (note the nice lack of html garbage)

Code: Select all

Fri Jun 17 10:41:47 UTC 2011 vlan2:3474054396 10373483 0 0 0 0 0 0 310577720 4631854 0 0 0 0 0 0
The first two big numbers are the running total (NOT bits per second) bit count for the interface (in and out respectively)

what I want is a meter or bar or something to display bits per second for both.

What I have is this:

Code: Select all

;[BEGIN CONFIG FILE]==============================

[Variables]
URL="http://10.1.1.1/fetchif.cgi?vlan2"
FontColor=255, 255, 255, 255

[MeasureWebsite]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=100
Url=#URL#
RegExp="(?siU)vlan2:(.*) (.*) (.*)"
Debug=1

[MeasureIfIn]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=1

[MeasureIfOut]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=2

[MeterBackground]
Meter=IMAGE
X=1
Y=1
H=220
W=300
SolidColor=0,0,0,255

[MeterIfIn]
MeasureName=MeasureIfIn
Meter=STRING
X=2
Y=2
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
Antialias=1
Prefix="Bits In: "


[MeterIfOut]
MeasureName=MeasureIfOut
Meter=STRING
X=2
Y=20
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
Antialias=1
Prefix="Bits Out: "
This works, but it only shows me the interface totals, i want bits per second.

I have tried using dynamicVariables, setting global variables, using the calc function... But essentially I am baffled by the way rainmeter code functions (being an imperative language programmer). Any help would be greatly appreciated.

Thank you.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Help with running count-esque display

Post by Seahorse »

Assuming that MeasureIfIn & MeasureIfOut are getting numbers, then you appear to be missing the %1 as below, see String Meters
You can mix the results of measures and static text by using Text= combined with %1, %2 etc. to indicate the value of the measures used by the meter.

Code: Select all

[MeterIfIn]
MeasureName=MeasureIfIn
Meter=STRING
X=2
Y=2
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
Antialias=1
Prefix="Bits In: %1"


[MeterIfOut]
MeasureName=MeasureIfOut
Meter=STRING
X=2
Y=20
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
Antialias=1
Prefix="Bits Out: %1 "
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

RedFogul
Posts: 5
Joined: June 17th, 2011, 9:14 am

Re: Help with running count-esque display

Post by RedFogul »

Thx for the help, but that wasn't the problem.

The display for what I have works fine, but it's not what I want to do.

What I have is total bits, what I want is bits per second. ie: What I need is a way to store the value from the last update and subtract it from the current one. This would give me bits per second (as I have it update once per second). What I can't figure out is how to store a value that can be read by the next update, OR how to do the math...
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Help with running count-esque display

Post by Seahorse »

I get where you are heading, however I don't know how to achieve that with a Calc either, as I am certain it include an IF ELSE in there, but I'm sure one of the geniuses here will be along shortly with the appropriate formula... ;-)
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

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

Re: Help with running count-esque display

Post by jsmorley »

Something like this will work:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
OldInput=0
OldOutput=0

[MeasureRouter]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#Test.txt
RegExp="(?siU)vlan2:(.*) (.*)"
UpdateRate=1
ForceReload=1

[MeasureInput]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureRouter]
StringIndex=1

[MeasureInputCompare]
Measure=Calc
Formula=([MeasureInput] - #OldInput#)
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable OldInput [MeasureInput]
DynamicVariables=1

[MeterInput]
Meter=String
MeasureName=MeasureInputCompare
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Since the value of the variables OldInput and OldOutput are updated at the end of the process, when the comparison/subtraction is done in the calc measure the variables contain the values from the previous "update".

Firing WebParser once a second is going to use just a tad of CPU, so you might want to consider if you really need "real time" measuring or maybe once every 5 seconds or something, but that is up to you. Also not sure why you would directly hit your router with WebParser rather than just using NetIn/NetOut measures in Rainmeter, but to each his own. I guess one advantage is that you are getting total bytes through the router, which would include other computers on your network, while NetIn/NetOut measure your PC's NIC and would not detect other traffic on your network.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Help with running count-esque display

Post by Seahorse »

See, told you a genius would be along!

I was head scratching and got this far - though I don't think it's right, it is heading in the right direction (fingers crossed) to my way of thinking. Academic now I guess.

Code: Select all

[MeterIfInCalc]
Measure=Calc
Formula=(MeterIfIn > MeterIfInCalc) ? (MeterIfIn-MeterIfInCalc/60) : (MeterIfInCalc-MeterIfIn/60)
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

RedFogul
Posts: 5
Joined: June 17th, 2011, 9:14 am

Re: Help with running count-esque display

Post by RedFogul »

Thank you jsmorley but it doesn't appear to work, the value just keeps counting up until it gets waaaay beyond my bandwidth, I'm not sure where the number is coming from, but I have a feeling that the value set to oldValue isn't being updated, because it always starts at zero when I refresh the skin and then just counts up. The numbers do suggest that it is displaying total bits since refresh (based on a test download of a 100MBit file).

Also, CPU consumption is not an issue, i'm on a 2600K :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with running count-esque display

Post by jsmorley »

Try it this way:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
OldInput=0
OldOutput=0

[MeasureRouter]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#CURRENTPATH#Test.txt
RegExp="(?siU)vlan2:(.*) (.*)"
UpdateRate=1
ForceReload=1
FinishAction=!RainmeterEnableMeasure MeasureInputCompare #CURRENTCONFIG#

[MeasureInput]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasureRouter]
StringIndex=1

[MeasureInputCompare]
Measure=Calc
Formula=([MeasureInput] - #OldInput#)
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable OldInput [MeasureInput]
IfEqualValue=0
IfEqualAction=!RainmeterSetVariable OldInput [MeasureInput]
DynamicVariables=1
Disabled=1

[MeterInput]
Meter=String
MeasureName=MeasureInputCompare
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Text=%1 | #OldInput#
DynamicVariables=1
What I added was an IfEqualAction to be sure the OldInput variable is set even if the number is constantly rising. I had to disable the calc measure until the WebParser measure fires at least once or the calc measure is toasted by the fact that "MeasureInput" isn't zero or any other value, but just doesn't exist the first time the calc is run.

See if that works better. I can't really test this like I would prefer, as I don't have that capability with my router, so I am just editing a text file and changing the number. No matter how fast I am the difference is always zero for some of the updates and the skin works fine for me. I suspect what you are seeing is that when you are actively downloading something, the difference between now and one second ago is never zero, so the IfAboveValue action is only firing once. Obviously we need to set that variable every second...
RedFogul
Posts: 5
Joined: June 17th, 2011, 9:14 am

Re: Help with running count-esque display

Post by RedFogul »

Thanks, I will try it again tonight when I am back at the office. If it doesn't work ( and you don't mind experimenting some more ) i'll set it so that the page is viewable from the net and then PM you with my IP.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with running count-esque display

Post by jsmorley »

RedFogul wrote:Thanks, I will try it again tonight when I am back at the office. If it doesn't work ( and you don't mind experimenting some more ) i'll set it so that the page is viewable from the net and then PM you with my IP.
That would help, so I can test some ideas properly.