It is currently April 20th, 2024, 12:54 am

Rainmeter 2.3 fix for "delay" issue

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Rainmeter 2.3 fix for "delay" issue

Post by jsmorley »

In versions of Rainmeter prior to 2.3, a Measure=Calc using the value of another measure in the Formula= would cause a delay of one "Update" between the value returned by the source measure and the value of the calc measure. This caused some annoying issues that were challenging to resolve without adding a lot of of calc measures to "sync" things up. (and the only good solution was to make "everything" one Update behind using calc measures.)

This delay has been eliminated in Rainmeter 2.3, and a calc measure that uses another measure as the source will have the same value as the source measure on the same Update.

However, this "undocumented feature" was being used by some folks on purpose to resolve a situation where an IfxxxxAction on the source measure was being used to !SetVariable something like a color or image or text. Since the !SetVariable happens on the current update but is not used by the meter(s) in question until the next, this can also cause an "out of sync" effect. So some authors would "pass the value through a calc measure" to delay the raw output (say a string meter) of the source measure, thus allowing the text display and the color or image to be in sync, while again one update behind from reality.

While for most folks most of the time, the change to eliminate the delay with calc measures is a good thing, there may be cases as above where it is in fact desirable. The way this is handled is that:

- If a calc measure comes "after" the source measure referenced in the formula in the skin, there will be no delay. The value of the source measure and the calc will be the same on the same update.

- If a calc measure comes "before" the source measure referenced in the formula in the skin, the one update difference between the two will still be there. So simply changing where in the skin you put the calc measure can be used to determine if you want the delay or not.

Here is a little skin that demonstrates this functionality:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureCalcBefore]
Measure=Calc
Formula=MeasureCPU
MinValue=0
MaxValue=100

[MeasureCPU]
Measure=CPU
MinValue=0
MaxValue=100

[MeasureCalcAfter]
Measure=Calc
Formula=MeasureCPU
MinValue=0
MaxValue=100

[MeterBefore]
Meter=String
MeasureName=MeasureCalcBefore
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Text=Before: %1

[MeterBarBefore]
Meter=BAR
MeasureName=MeasureCalcBefore
BarColor=214,255,223
BarOrientation=Horizontal
DynamicVariables=1
Y=2R
W=800
H=6

[MeterActual]
Meter=String
MeasureName=MeasureCPU
Y=2R
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Text=Actual: %1

[MeterBarActual]
Meter=BAR
MeasureName=MeasureCPU
BarColor=214,255,223
BarOrientation=Horizontal
DynamicVariables=1
Y=2R
W=800
H=6

[MeterAfter]
Meter=String
MeasureName=MeasureCalcAfter
Y=2R
FontSize=13
FontColor=255,255,255,255
AntiAlias=1
Text=After: %1

[MeterBarAfter]
Meter=BAR
MeasureName=MeasureCalcAfter
BarColor=214,255,223
BarOrientation=Horizontal
DynamicVariables=1
Y=2R
W=800
H=6
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: Rainmeter 2.3 fix for "delay" issue

Post by MerlinTheRed »

At first I was like:
"Waah! There will be infinite loops everywhere!"

But then I was like:
"Hmm, doing it only based on position in the skin file seems like a good solution." ;)
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
burnwell88
Posts: 90
Joined: August 13th, 2009, 8:37 am

Re: Rainmeter 2.3 fix for "delay" issue

Post by burnwell88 »

this is great news that you fixed the delay ... thank you very much :)
NewWave
Posts: 23
Joined: April 15th, 2012, 5:39 am

Re: Rainmeter 2.3 fix for "delay" issue

Post by NewWave »

I found this topic from a google search. I was trying to find what method others used to sync everything up. Off to download v2.3. Thanks for fixing this.
User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Rainmeter 2.3 fix for "delay" issue

Post by wiedzmawiedzma »

I ran your code on the desktop and I understand After action but I can not get this to work in my skin please hint me where to apply it. According to your explanation, I understand that the [MeasureProcess1] and [MeasureProcess1Name] :oops:

Code: Select all

[Rainmeter]
Update=2000
DynamicWindowSize=1


[Variables]
font.color.Process1=[MeasureColor1]

[CPUUsageCalc]
Measure=Calc
Formula=MeasureProcess1/200000
MinValue=0
MaxValue=100



[MeasureColor1]
Measure=Calc
Formula=(CPUUsageCalc < 50 ? -1 : (CPUUsageCalc < 70 ? -2 : -3))
Substitute="-1":"7b7b7b", "-2":"979e2d", "-3":"9e2d2d"

[TextStyle]
FontFace=Segoe UI
fontColor=7b7b7b
StringStyle=BOLD
FontSize=7
AntiAlias=1

[TextStyle2]
FontFace=Segoe UI
fontColor=0,0,0,255
StringEffect=Border
StringStyle=BOLD
FontEffectColor=0,0,0,200
FontSize=7
AntiAlias=1

[MeterBackground]
Meter=Image
ImageName=backTopProcessor.png
X=0
Y=2

[Title]
Meter=STRING
X=29
Y=5
fontColor=0,0,0,255
FontSize=8
FontFace=Segoe UI
StringEffect=Border
StringStyle=BOLD
FontEffectColor=0,0,0,200
AntiAlias=1
Text="Top Procesy Procesora"

[Title2]
Meter=STRING
X=29
Y=4
fontColor=7b7b7b
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
AntiAlias=1
Text="Top Procesy Procesora"

[MeasureProcesses]
Measure=Plugin
Plugin=Perfmon
PerfMonObject="System"
PerfMonCounter="Processes"
PerfMonInstance=""
PerfMonDifference=0


[MeterProcessesShadow]
Meter=STRING
MeterStyle=TextStyle2
MeasureName=MeasureProcesses
X=29
Y=16
Text="Uruchomione Procesy:"

[MeterProcesses]
Meter=STRING
MeterStyle=TextStyle
MeasureName=MeasureProcesses
X=29
Y=15
Text="Uruchomione Procesy:"

[Nr.ProcessesShadow]
MeasureName=MeasureProcesses
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle2
X=160
Y=16

[Nr.Processes]
MeasureName=MeasureProcesses
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle
X=160
Y=15

;Process1---------------------------------

[MeasureProcess1]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=1
CPUExclude=Idle


[MeasureProcess1Name]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=2
CPUExclude=Idle


[MeterProcess1Shadow]
Meter=STRING
MeterStyle=TextStyle2
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=5
Y=30
Text="- %2"
NumOfDecimals=1
Scale=200000

[MeterProcess1]
Meter=STRING
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=5
Y=29
Text="- %2"
NumOfDecimals=1
DynamicVariables=1
Scale=200000
 
[MeterProcess1%Shadow]
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle2
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=160
Y=30
Text="%1%"
NumOfDecimals=1
Scale=200000 


[MeterProcess1%]
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1
MeasureName2=MeasureProcess1Name
X=160
Y=29
Text="%1%"
NumOfDecimals=1
Scale=200000 
DynamicVariables=1
User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Rainmeter 2.3 fix for "delay" issue

Post by wiedzmawiedzma »

I managed! :thumbup: I guess I'm too impatient and I bow to no poor knowledge of English. For the impatient I give my solution :

Code: Select all

[Rainmeter]
Update=2000
DynamicWindowSize=1


[Variables]
font.color.Process1=[MeasureColor1]

[CPUUsageCalc]
Measure=Calc
Formula=MeasureProcess1/200000
MinValue=0
MaxValue=100



[MeasureColor1]
Measure=Calc
Formula=(CPUUsageCalc < 50 ? -1 : (CPUUsageCalc < 70 ? -2 : -3))
Substitute="-1":"7b7b7b", "-2":"979e2d", "-3":"9e2d2d"

[TextStyle]
FontFace=Segoe UI
fontColor=7b7b7b
StringStyle=BOLD
FontSize=7
AntiAlias=1

[TextStyle2]
FontFace=Segoe UI
fontColor=0,0,0,255
StringEffect=Border
StringStyle=BOLD
FontEffectColor=0,0,0,200
FontSize=7
AntiAlias=1

[MeterBackground]
Meter=Image
ImageName=backTopProcessor.png
X=0
Y=2

[Title]
Meter=STRING
X=29
Y=5
fontColor=0,0,0,255
FontSize=8
FontFace=Segoe UI
StringEffect=Border
StringStyle=BOLD
FontEffectColor=0,0,0,200
AntiAlias=1
Text="Top Procesy Procesora"

[Title2]
Meter=STRING
X=29
Y=4
fontColor=7b7b7b
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
AntiAlias=1
Text="Top Procesy Procesora"

[MeasureProcesses]
Measure=Plugin
Plugin=Perfmon
PerfMonObject="System"
PerfMonCounter="Processes"
PerfMonInstance=""
PerfMonDifference=0


[MeterProcessesShadow]
Meter=STRING
MeterStyle=TextStyle2
MeasureName=MeasureProcesses
X=29
Y=16
Text="Uruchomione Procesy:"

[MeterProcesses]
Meter=STRING
MeterStyle=TextStyle
MeasureName=MeasureProcesses
X=29
Y=15
Text="Uruchomione Procesy:"

[Nr.ProcessesShadow]
MeasureName=MeasureProcesses
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle2
X=160
Y=16

[Nr.Processes]
MeasureName=MeasureProcesses
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle
X=160
Y=15

;Process1---------------------------------

[MeasureProcess1Before]
Measure=Calc
Formula=MeasureProcess1
TopProcess=1
CPUExclude=Idle

[MeasureProcess1NameBefore]
Measure=Calc
Formula=MeasureProcess1Name
TopProcess=2
CPUExclude=Idle

[MeasureProcess1]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=1
CPUExclude=Idle


[MeasureProcess1Name]
Measure=Plugin
Plugin=AdvancedCPU
TopProcess=2
CPUExclude=Idle


[MeterProcess1Shadow]
Meter=STRING
MeterStyle=TextStyle2
MeasureName=MeasureProcess1Before
MeasureName2=MeasureProcess1Name
X=5
Y=30
Text="- %2"
NumOfDecimals=1
Scale=200000

[MeterProcess1]
Meter=STRING
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1Before
MeasureName2=MeasureProcess1Name
X=5
Y=29
Text="- %2"
NumOfDecimals=1
DynamicVariables=1
Scale=200000
 
[MeterProcess1%Shadow]
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle2
MeasureName=MeasureProcess1Before
MeasureName2=MeasureProcess1NameBefore
X=160
Y=30
Text="%1%"
NumOfDecimals=1
Scale=200000 


[MeterProcess1%]
Meter=STRING
StringAlign=Right
MeterStyle=TextStyle
fontColor=#font.color.Process1#
MeasureName=MeasureProcess1Before
MeasureName2=MeasureProcess1NameBefore
X=160
Y=29
Text="%1%"
NumOfDecimals=1
Scale=200000 
DynamicVariables=1
Although one thing I do not understand but it's probably not the right forum section but ask why [MeterProcess1] and [MeterProcess1Shadow] MeasureName2 = MeasureProcess1Name, not MeasureName2 = MeasureProcess1NameBefore because disappears the process name?
modo1302
Posts: 1
Joined: January 21st, 2022, 2:26 pm

Re: Rainmeter 2.3 fix for "delay" issue

Post by modo1302 »

Hi!

been using Rainmeter for a while now, however i'm new to programming configs. I'm facing issues with a delay while trying to change font color while the cpu meter is at 100. I browsed the forum, i tried several fixes found here - with no luck. Does anyone have a clue on why there's a lag in coloring the value?

Code: Select all

[CpuUsage]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=#HWiNFO-CPU0-SensorId#
HWiNFOSensorInstance=#HWiNFO-CPU0-SensorInstance#
HWiNFOEntryId=#HWiNFO-CPU0-Usage#
HWiNFOType=CurrentValue

[MeasureCalcAfter]
Measure=Calc
Formula=CpuUsage
MinValue=0
MaxValue=100
IfCondition=(MeasureCalcAfter = 100)
IfTrueAction=[!SetOption CpuUsageValue FontColor 157,0,0,255][!UpdateMeter CpuUsageValue][!Redraw]
IfFalseAction=[!SetOption CpuUsageValue FontColor 0,0,0,255][!UpdateMeter CpuUsageValue][!Redraw]
DynamicVariables=1

[CpuUsageValue]
Meter=String
MeasureName=MeasureCalcAfter
X=135
Y=22r
Text="Usage: %1%"
MeterStyle=HWiNFOTextStyle
StringAlign=right
DynamicVariables=1
I'd be extremely gratefull for any pointers! ;-)
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Rainmeter 2.3 fix for "delay" issue

Post by sl23 »

If your CPU is maxing out at 100% I think that says it all! :Whistle
- MuLab -
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Rainmeter 2.3 fix for "delay" issue

Post by Active Colors »

modo1302 wrote: January 21st, 2022, 2:30 pm Hi!

been using Rainmeter for a while now, however i'm new to programming configs. I'm facing issues with a delay while trying to change font color while the cpu meter is at 100. I browsed the forum, i tried several fixes found here - with no luck. Does anyone have a clue on why there's a lag in coloring the value?

Code: Select all

[CpuUsage]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=#HWiNFO-CPU0-SensorId#
HWiNFOSensorInstance=#HWiNFO-CPU0-SensorInstance#
HWiNFOEntryId=#HWiNFO-CPU0-Usage#
HWiNFOType=CurrentValue

[MeasureCalcAfter]
Measure=Calc
Formula=CpuUsage
MinValue=0
MaxValue=100
IfCondition=(MeasureCalcAfter = 100)
IfTrueAction=[!SetOption CpuUsageValue FontColor 157,0,0,255][!UpdateMeter CpuUsageValue][!Redraw]
IfFalseAction=[!SetOption CpuUsageValue FontColor 0,0,0,255][!UpdateMeter CpuUsageValue][!Redraw]
DynamicVariables=1

[CpuUsageValue]
Meter=String
MeasureName=MeasureCalcAfter
X=135
Y=22r
Text="Usage: %1%"
MeterStyle=HWiNFOTextStyle
StringAlign=right
DynamicVariables=1
I'd be extremely gratefull for any pointers! ;-)
It is hard to point to anything soecific here. Can you post the whole code?