It is currently May 3rd, 2024, 9:13 pm

SOLVED: Message Box - user on the network is online/offline

Get help with creating, editing & fixing problems with skins
User avatar
Shinson
Posts: 17
Joined: April 14th, 2011, 5:45 am

SOLVED: Message Box - user on the network is online/offline

Post by Shinson »

Howdy...

The blabla regarding the background:

I created a skin, which informs me if a user/computer on the network is online or offline; I abused the pingplugin to realize this. This is pretty handy, because I can see that "Computer3rdFloor" is online, without phoning through the house, trying to reach someone who can tell me the status or just ping the pc with some other command.

Works pretty charming, but I recognized that the skin loses some functionality when it's set to stay on the desktop. I mean, I do not need the information all the time - just in some cases...

Now I thought it would be more charming, if a message box would pop up, when one of the computers on the network go off- or online.

Perhaps it is time for a new "message box skin", but right now I would be happy to secure the basic functionality. Therefore I just created a vbs-file with the following code:

Code: Select all

x=msgbox("Computer3rdFloor is online.",64,"Status")
Executing that file will create such a message box (imagine the same for the offline state).

The actual skin, that informs me if a certain computer is online contains code like:

Code: Select all

[mPingComputer3rdFloor]
Measure=Plugin
Plugin=Plugins\PingPlugin.dll
DestAddress=#Computer3rdFloor_ID#
UpdateRate=2

[mActionComputer3rdFloor]
Measure=Calc
Formula=mPingComputer3rdFloor
IfAboveValue=1000
IfAboveAction=!execute [!RainmeterShowMeter txtOfflineComputer3rdFloor][!RainmeterHideMeter txtOnlineComputer3rdFloor]
IfBelowValue=999
IfBelowAction=!execute [!RainmeterShowMeter txtOnlineComputer3rdFloor][!RainmeterHideMeter txtOfflineComputer3rdFloor]
Now I thought some minimal addition to the above code would do:
[mPingComputer3rdFloor]
Measure=Plugin
Plugin=Plugins\PingPlugin.dll
DestAddress=#Computer3rdFloor_ID#
UpdateRate=2

[mActionComputer3rdFloor]
Measure=Calc
Formula=mPingComputer3rdFloor
IfAboveValue=1000
IfAboveAction=!execute [!RainmeterShowMeter txtOfflineComputer3rdFloor][!RainmeterHideMeter txtOnlineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOffline.vbs"]
IfBelowValue=999
IfBelowAction=!execute [!RainmeterShowMeter txtOnlineComputer3rdFloor][!RainmeterHideMeter txtOfflineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOnline.vbs"]
...but I'm superwrong.

The main trouble:
When I start the skin the message box pops up, telling me that the Computer3rdFloor is offline. After the skin is done with the ping measure (a sec later) the message box pops up again, telling me that the Computer3rdFloor is online.

After that it works just like it should:
Telling me if a computer is on- or offline.

The riddle:
Yes. Indeed the computer is kind of offline, when ping measure is not finished. And indeed the computer is online a sec later after finishing it's job.
But this is kind of annoying. I don't need the message after starting the skin, where I can see clearly which computer is online or not. It's more like a gimmick, during the day... kind of an useful information... And with around five computers in the house, I am totally "message boxed" as soon the skin is started.

Thought about implementing a timer, that "overrides" the first on- or offline check, but with the above code I'm not getting the picture how to manage that.

Guys - I've got my wires crossed somewhere... need some food for thought. Help would be really appreciated!

Thanks in advance!

Regards,
Shinson
Last edited by Shinson on May 31st, 2011, 2:57 pm, edited 1 time in total.
What doesn't kill you, just makes you stranger.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Message Box - user on the network is online/offline

Post by poiru »

Try removing the Calc, i.e.:

Code: Select all

[mPingComputer3rdFloor]
Measure=Plugin
Plugin=Plugins\PingPlugin.dll
DestAddress=#Computer3rdFloor_ID#
UpdateRate=2
IfAboveValue=1000
IfAboveAction=!execute [!RainmeterShowMeter txtOfflineComputer3rdFloor][!RainmeterHideMeter txtOnlineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOffline.vbs"]
IfBelowValue=999
IfBelowAction=!execute [!RainmeterShowMeter txtOnlineComputer3rdFloor][!RainmeterHideMeter txtOfflineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOnline.vbs"]
User avatar
Shinson
Posts: 17
Joined: April 14th, 2011, 5:45 am

Re: Message Box - user on the network is online/offline

Post by Shinson »

poiru wrote:Try removing the Calc
Oh yes... thanks... pretty nice reduction of code. Will be surely of use and calc is anyway absolute overrated. ;-)

But, I'm afraid, this will not eliminate the first message that comes up. So, if a computer on the network is online(/offline), a message box with the message "online"(/"offline") will still appear (on skin startup). No chance to override that? I only need message if something changes...

Regards,
Shinson
What doesn't kill you, just makes you stranger.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Message Box - user on the network is online/offline

Post by santa_ryan »

What happens is that the "Ping Measure" starts up with a value of 0. This means that it is below the value, and therefore will fire. When i get home ill play with it, and find a workaround for you. I already have something in mind.

Try the following:

Code: Select all

[mPingComputer3rdFloor]
Measure=Plugin
Plugin=Plugins\PingPlugin.dll
DestAddress=#Computer3rdFloor_ID#
UpdateRate=2

[StartupCounter]
Measure=Calc
Formula=Counter % 4
IfAboveValue=2
IfAboveValue=!RainmeterEnableMeasure mActionComputer3rdFloor
IfEqualValue=3
IfEqualAction=!RainmeterEnableMeasure StartupCounterDisable

[StartupCounterDisable]
Measure=Calc
Formula=[StartupCounter]
DynamicVariables=1
IfEqualValue=4
IfEqualAction=!Execute [!RainmeterDisableMeasure StartupCounter][!RainmeterDisableMeasure StartupCounterDisable]
Disabled=1

[mActionComputer3rdFloor]
Measure=Calc
Formula=mPingComputer3rdFloor
IfAboveValue=1000
IfAboveAction=!execute [!RainmeterShowMeter txtOfflineComputer3rdFloor][!RainmeterHideMeter txtOnlineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOffline.vbs"]
IfBelowValue=999
IfBelowAction=!execute [!RainmeterShowMeter txtOnlineComputer3rdFloor][!RainmeterHideMeter txtOfflineComputer3rdFloor]["#CurrentPath#\Computer3rdFloorOnline.vbs"]
Disabled=1
What im doing is using 3 calcs. One is a counter, one is a "DisableCounter" switch, and the other is the messaging calc.

The counter will enable the message calc after 3 seconds has elapsed (which should be enough time for the ping measure to start outputting results). Also after 3 seconds has elapsed, it activates the CounterStartUpDisable calc. This one monitors the counter so that when it hits 4 (the reset value), it will disable the counter. This works because theres a 1 second delay handoff between calcs, so in actuality the counter is at 0. If 3 seconds isnt enough, then your going to need to add however many seconds are needed extra to the counter calcs reset number, the ifabove value, the ifequal value, and the IfEqualValue of the disabler.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Shinson
Posts: 17
Joined: April 14th, 2011, 5:45 am

Re: Message Box - user on the network is online/offline

Post by Shinson »

Hm... this could be at least kind of an approach... :great:

I'll play a bit with your given code. I feel kind of lucky today, perhaps we are here hot on the trail of the lot...

Will post, if I found something to work with...

Regards,
Shinson
What doesn't kill you, just makes you stranger.
User avatar
Shinson
Posts: 17
Joined: April 14th, 2011, 5:45 am

Re: Message Box - user on the network is online/offline

Post by Shinson »

OK... played around:

That won't work either. The trouble is, that the measure will fire above and below a certain ping value. That's because there are two messages (one for "online" and one for "offline"). So the counter will only delay things... :x

Perhaps it's possible to save the state (on- or offline) in a value via RainMeterSetValue and only if that specific value changes, measure will fire... By the look of it, that code has to get more calc... and I have to get more headache. "Dr. Watson, we have a new riddle..." O.O

Regards,
Shinson
What doesn't kill you, just makes you stranger.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Message Box - user on the network is online/offline

Post by santa_ryan »

I can see this working in lua, but in pure rainmeter code, it will take quite a bit..
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Shinson
Posts: 17
Joined: April 14th, 2011, 5:45 am

Re: Message Box - user on the network is online/offline

Post by Shinson »

OK... Looks like I made it. Looks like it was all a matter of timing. Thanks to "santa_ryan" I had enough food for thought, regarding some delays in the code. What was pretty necessary:
I figured out, that the pingplugin fires strangely during start and shutdown (e. g. shutdown of a computer on the network). Kind of a calibration or something... During that, the measures out of the ping are not reliable.
Also the measures are not reliable while idle. It looks like the pingplugin fires from time to time with questionable measures, even if no computer on the network is available.

Understood or not, I decided to make those measures more reliable:

1st: Therefore I packed a counter innit, just to make sure everything is fine to fire. This one will also just measure if something changes and then pop up a message box, if so.

2nd: A second counter (splitted into 3 separate counters) makes sure, that there is no mismeasure within.

3rd: A calculation that verifies "2nd".

Don't ask me why I put the shown numbers in those calcs and measures. I just figured out, that I really have to give the measures and calcs their due time... and that is what my lab thinks is nice:

Code: Select all

[msrPingComputer3rdFloor]
Measure=Plugin
Plugin=Plugins\PingPlugin.dll
DestAddress=#Computer3rdFloor_ID#
UpdateRate=2
Timeout=#varTimeOut#
DynamicVariables=1
IfAboveValue=99
IfAboveAction=!execute [!RainmeterShowMeter txtOfflineComputer3rdFloor][!RainmeterHideMeter txtOnlineComputer3rdFloor]
IfBelowValue=100
IfBelowAction=!execute [!RainmeterShowMeter txtOnlineComputer3rdFloor][!RainmeterHideMeter txtOfflineComputer3rdFloor]



[msrDelayCountComputer3rdFloor]
Measure=Calc
Formula=Counter % 10
IfAboveValue=8
IfAboveAction=!execute [!RainmeterEnableMeasureGroup Group_Count_Computer3rdFloor][!RainmeterDisableMeasure msrDelayCountComputer3rdFloor]



[msrComputer3rdFloorCount1]
Measure=Calc
Formula=Counter % 3
IfAboveValue=1
IfAboveAction=!execute [!RainmeterEnableMeasure msrCheckComputer3rdFloor1]
Group=Group_Count_Computer3rdFloor
Disabled=1

[msrComputer3rdFloorCount2]
Measure=Calc
Formula=Counter % 4
IfAboveValue=2
IfAboveAction=!execute [!RainmeterEnableMeasure msrCheckComputer3rdFloor2]
Group=Group_Count_Computer3rdFloor
Disabled=1

[msrComputer3rdFloorCount3]
Measure=Calc
Formula=Counter % 5
IfAboveValue=3
IfAboveAction=!execute [!RainmeterEnableMeasure msrCheckComputer3rdFloor3]
Group=Group_Count_Computer3rdFloor
Disabled=1



[msrCheckComputer3rdFloor1]
Measure=Calc
Formula=[msrPingComputer3rdFloor]
IfAboveValue=99
IfAboveAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor1 3]
IfBelowValue=100
IfBelowAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor1 4]
DynamicVariables=1
Disabled=1

[msrCheckComputer3rdFloor2]
Measure=Calc
Formula=[msrPingComputer3rdFloor]
IfAboveValue=99
IfAboveAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor2 5]
IfBelowValue=100
IfBelowAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor2 6]
DynamicVariables=1
Disabled=1

[msrCheckComputer3rdFloor3]
Measure=Calc
Formula=[msrPingComputer3rdFloor]
IfAboveValue=99
IfAboveAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor3 7]
IfBelowValue=100
IfBelowAction=!execute [!RainmeterSetVariable varStateComputer3rdFloor3 8]
DynamicVariables=1
Disabled=1



[msrCheckDownComputer3rdFloor]
Measure=Calc
Formula=#varStateComputer3rdFloor1#+#varStateComputer3rdFloor2#+#varStateComputer3rdFloor3#
IfEqualValue=15
IfEqualAction=!execute [!RainMeterEnableMeasure msrUpComputer3rdFloor]
DynamicVariables=1

[msrCheckUpComputer3rdFloor]
Measure=Calc
Formula=#varStateComputer3rdFloor1#+#varStateComputer3rdFloor2#+#varStateComputer3rdFloor3#
IfEqualValue=18
IfEqualAction=!execute [!RainMeterEnableMeasure msrDownComputer3rdFloor]
DynamicVariables=1



[msrDownComputer3rdFloor]
Measure=Calc
Formula=[msrCheckUpComputer3rdFloor]
IfEqualValue=15
IfEqualAction=!execute ["#CurrentPath#\Computer3rdFloorOffline.vbs"][!RainMeterDisableMeasure msrDownComputer3rdFloor]
DynamicVariables=1
Disabled=1

[msrUpComputer3rdFloor]
Measure=Calc
Formula=[msrCheckDownComputer3rdFloor]
IfEqualValue=18
IfEqualAction=!execute ["#CurrentPath#\Computer3rdFloorOnline.vbs"][!RainMeterDisableMeasure msrUpComputer3rdFloor]
DynamicVariables=1
Disabled=1
Well, I might really have to tidy up that code, but for now, I am pretty happy that this is working without lua. Don't get me wrong, I really appreciate that Rainmeter is able to go along with lua, but I really love to keep it simple... kind of...

Oh, and thanks "poiru", too. As you might see, your suggestion is implemented, too! ;-)

Regards,
Shinson
What doesn't kill you, just makes you stranger.