It is currently March 28th, 2024, 3:19 pm

(SOLVED) Counter variable for async meter text update?

Get help with creating, editing & fixing problems with skins
Post Reply
themohawkninja
Posts: 3
Joined: July 17th, 2017, 9:46 pm

(SOLVED) Counter variable for async meter text update?

Post by themohawkninja »

UPDATE: Just found the "UpdateDivider" general option, which is exactly what I needed.

Hello,

I am trying to setup an asynchronous update between the network upload and download speed string meters and their corresponding line meters such that while the line meter updates ever 100ms, the string value only updates every 1000ms.

I saw that the actionTimer doesn't support infinite loops due to performance concerns, so I figured I'd just use a variable that counts to 10, then updates the upload and download speed text and then resets to a value of 0, effectively making the update period 10 times that of the global update period.

The problem is, is that it doesn't work. At them moment, it still updates at a 100ms cycle.

The full Network.ini is in the spoiler tag below, but here's the excerpt that I believe is the important bits:

Code: Select all

[Variables]
ctr=0
upValue=0

[measureNetIn]
Measure=NetIn
NetInSpeed=#maxDownload#
IfCondition=#ctr#=10
IfTrueAction=[!SetOption meterUploadValue Text #upValue#][!SetVariable ctr 0]
IfFalseAction=[!SetVariable ctr (#ctr#+1)]
OnUpdateAction=[!UpdateMeter meterUploadValue][!Redraw]
DynamicVariables=1

[meterUploadValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureNetOut
X=200
Y=0r
W=190
H=14
upValue=%1B/s
; Text=%1B/s
NumOfDecimals=2
AutoScale=1
DynamicVariables=1
As as aside, I am assuming that one of my "DynamicVariables=1" lines is redundant, but I'm not sure which since I read that all meters and measures using changing variables need that line, so I figured I should just put it in both the meter and the measure.

Full Network.ini
; Lines starting ; (semicolons) are commented out.
; That is, they do not affect the code and are here for demonstration purposes only.
; ----------------------------------

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Update=100
Background=#@#Background.png
; #@# is equal to Rainmeter\Skins\illustro\@Resources
BackgroundMode=3
BackgroundMargins=0,34,0,14

[Metadata]
; Contains basic information of the skin.
Name=Network
Author=poiru
Information=Shows your IP address and network activity.
License=Creative Commons BY-NC-SA 3.0
Version=1.0.0

[Variables]
; Variables declared here can be used later on between two # characters (e.g. #MyVariable#).
fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
maxDownload=10485760
MaxUpload=10485760
IPSite=www.tell-my-ip.com
ctr=0
upValue=0

; Set maxDownload and maxUpload to your maximum download and upload speed in bits.
; To convert kilobits, megabits, kilobytes, and megabytes into bits, go to http://www.google.com
; and search for something like "10 megabytes in bits".

; ----------------------------------
; MEASURES return some kind of value
; ----------------------------------

[measureIP]
; This measure returns your IP. WebParser measures are relatively complicated. If you're a beginner with
; Rainmeter, take a look at some of the other illustro skins before modifying this one.
Measure=Plugin
Plugin=WebParser
UpdateRate=14400
URL=http://#IPSite#
RegExp=(?siU)<td.*>Your IP Address:</td><td>(.*)</td>.*<td>Country:</td>.*<img src="(.*)">
StringIndex=1
Substitute="":"N/A"
Debug=2
; Substitute works as follows: "A":"B" where A is a string to substitute and B is a string
; to substitute with. In this case, it substutes "" (i.e. empty) to N/A

[measureNetIn]
Measure=NetIn
NetInSpeed=#maxDownload#
IfCondition=#ctr#=10
IfTrueAction=[!SetOption meterUploadValue Text #upValue#][!SetVariable ctr 0]
IfFalseAction=[!SetVariable ctr (#ctr#+1)]
OnUpdateAction=[!UpdateMeter meterUploadValue][!Redraw]
DynamicVariables=1

[measureNetOut]
Measure=NetOut
NetOutSpeed=#maxUpload#

; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------

[styleTitle]
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
; Meters using styleLeftText will be left-aligned.
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleBar]
BarColor=#colorBar#
BarOrientation=HORIZONTAL
SolidColor=255,255,255,15

[styleSeperator]
SolidColor=255,255,255,15

; ----------------------------------
; METERS display images, text, bars, etc.
; ----------------------------------

[meterTitle]
Meter=String
MeterStyle=styleTitle
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=100
Y=12
W=190
H=18
Text=Network
; Even though the text is set to Network, Rainmeter will display
; it as NETWORK, because styleTitle contains StringCase=Upper.

[meterIPLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=40
W=190
H=14
Text=IP Address

[meterIPValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureIP
X=200
Y=0r
; r stands for relative. In this case, the Y postition of meterValueCPU is 0 pixels
; below the Y value of the previous meter (i.e it's the same as in meterLabelCPU).
W=190
H=14
Text=%1
; %1 stands for the value of MeasureName (measureIP in this case).

[IPURL]
Meter=String
MeterStyle=styleRightText
X=200
Y=14r
W=190
H=14
Text=(#IPSite#)

[meterSeperator]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=68
W=190
H=1

[meterUploadLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=74
W=190
H=14
Text=Upload

[meterUploadValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureNetOut
X=200
Y=0r
W=190
H=14
upValue=%1B/s
; Text=%1B/s
NumOfDecimals=2
AutoScale=1
DynamicVariables=1

[meterUploadBar]
Meter=Line
MeasureName=measureNetOut
X=10
Y=88
W=190
H=20
LineCount=1
LineColor=255,0,0,255
SolidColor=255,0,0,100
AutoScale=1
AntiAlias=1

[meterDownloadLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=114
W=190
H=14
Text=Download

[meterDownloadValue]
Meter=String
MeterStyle=styleRightText
MeasureName=measureNetIn
X=200
Y=0r
W=190
H=14
; Text=%1B/s
NumOfDecimals=2
AutoScale=1

[meterDownloadBar]
Meter=Line
MeasureName=measureNetIn
X=10
Y=128
W=190
H=20
LineCount=1
LineColor=0,255,0,255
SolidColor=0,255,0,100
AutoScale=1
AntiAlias=1
Post Reply