It is currently April 26th, 2024, 2:26 am

Calculating Change of a Measure

Tips and Tricks from the Rainmeter Community
AMV
Posts: 4
Joined: June 19th, 2015, 1:02 am

Calculating Change of a Measure

Post by AMV »

Knowing the actual value of a measure is useful, but sometimes it is better to know the CHANGE in the measure instead (or if you are more mathematically inclined, the DERIVATIVE). This is the closest way I can find to finding it.

Code: Select all

[Variables]
Update_Cycle_Time=100
Average_Size=(Trunc(Round(1000/#Update_Cycle_Time#,0)))
[Rainmeter]
Update= #Update_Cycle_Time#
[CPU]
Measure=CPU
AverageSize=#Average_Size#
MaxValue=100
[Calc_CPU_Ave2]
Measure=Calc
Formula=CPU
AverageSize=2
[Calc_Change_CPU]
Measure=Calc
Formula=(2*(CPU-Calc_CPU_Ave2))
AverageSize=#Average_Size#
DynamicVariables=1
MaxValue=10
MinValue=-10
Things get much more complicated when using it with something like network activity. By nature it tends to be very dramatically large in changes, so the quantity has to be log(x) to make it seem more linear when used in a meter. And since Log(x) has some odd behavior then x<=0, there has to be a lot of conditional stuff to make it work.

Code: Select all

[Variables]
Update_Cycle_Time=100
Average_Size=(Trunc(Round(1000/#Update_Cycle_Time#,0)))
Current_Upload_Rate_Record=83683991.9
Current_Download_Rate_Record=1144248303.2
[Rainmeter]
Update= #Update_Cycle_Time#
[Measure_Upload]
Measure=NetOut
AverageSize=#Average_Size#
IfCondition= (#CURRENTSECTION# > #Current_Upload_Rate_Record#)
IfTrueAction= [!WriteKeyValue Variables Current_Upload_Rate_Record "[#CURRENTSECTION#]"][!Refresh]
DynamicVariables=1
[Calc_Upload_Ave2]
Measure=Calc
Formula=Measure_Upload
AverageSize=2
[Calc_Upload_Change]
Measure=Calc
Formula=((Measure_Upload-Calc_Upload_Ave2) = 0 ? 0 : Log((Abs(Trunc(2*(Measure_Upload-Calc_Upload_Ave2))))))*Sgn(Measure_Upload-Calc_Upload_Ave2)
DynamicVariables=1
MaxValue=(Log(Trunc(#Current_Upload_Rate_Record#)))
MinValue=(-1*Log(Trunc(#Current_Upload_Rate_Record#)))
AverageSize=#Average_Size#
[Measure_Download]
Measure=NetIn
AverageSize=#Average_Size#
IfCondition= (#CURRENTSECTION# > #Current_Download_Rate_Record#)
IfTrueAction=[!WriteKeyValue Variables Current_Download_Rate_Record "[#CURRENTSECTION#]"][!Refresh]
DynamicVariables=1
[Calc_Download_Ave2]
Measure=Calc
Formula=Measure_Download
AverageSize=2
[Calc_Download_Change]
Measure=Calc
Formula=((Measure_Download-Calc_Download_Ave2) = 0 ? 0 : Log((Abs(Trunc(2*(Measure_Download-Calc_Download_Ave2))))))*Sgn(Measure_Download-Calc_Download_Ave2)
DynamicVariables=1
MaxValue=(Log(Trunc(#Current_Download_Rate_Record#)))
MinValue=(-1*Log(Trunc(#Current_Download_Rate_Record#)))
AverageSize=#Average_Size#
Attached should be a gif that demonstrates what I am talking about.
In general it is useful for when the simple motion of the meter (in this case, an analog dial) is enough to let you know something is happening.
GIF.gif
I suppose that the integral could also be "calculated", but it does not seem to as handy knowing how much data was downloaded
You do not have the required permissions to view the files attached to this post.