Jump to content

Script pauses


Recommended Posts

Hello I created a script that monitors all the copiers on my network and then displays the current counter in real time. However after about 15-30 seconds the script stops updating. Any ideas why?

Code:

#include <string.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Aseptic Solutions Copier Count", 369, 370, 356, 265)
$Label1 = GUICtrlCreateLabel("484 Downstairs:", 40, 32, 154, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$Label2 = GUICtrlCreateLabel("484 Upstairs:", 69, 120, 126, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$Label3 = GUICtrlCreateLabel("536:", 144, 197, 44, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$Label4 = GUICtrlCreateLabel("458:", 144, 275, 44, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$Label5 = GUICtrlCreateLabel("RICOH Aficio MP 4002", 40, 56, 141, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label6 = GUICtrlCreateLabel("10.1.188.79", 41, 73, 72, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label7 = GUICtrlCreateLabel("RICOH Aficio MP C4501", 46, 143, 150, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label8 = GUICtrlCreateLabel("10.1.188.82", 47, 160, 72, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label9 = GUICtrlCreateLabel("LANIER MP 4000/LD040", 35, 220, 149, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label10 = GUICtrlCreateLabel("", 36, 237, 4, 4)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label11 = GUICtrlCreateLabel("10.1.188.81", 35, 237, 72, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label12 = GUICtrlCreateLabel("RICOH Aficio MP 2851", 48, 298, 141, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label13 = GUICtrlCreateLabel("10.1.188.80", 48, 315, 72, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$Label14 = GUICtrlCreateLabel("0", 208, 32, 129, 33, $SS_RIGHT)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x008000)
$Label15 = GUICtrlCreateLabel("0", 208, 114, 129, 33, $SS_RIGHT)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x008000)
$Label16 = GUICtrlCreateLabel("0", 200, 195, 137, 33, $SS_RIGHT)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x008000)
$Label17 = GUICtrlCreateLabel("0", 208, 277, 129, 33, $SS_RIGHT)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Dim $IP_ADDRESS
$IP_ADDRESS = "10.1.188.79"
$IP_ADDRESS2 = "10.1.188.80"
$IP_ADDRESS3 = "10.1.188.81"
$IP_ADDRESS4 = "10.1.188.82"
$PORT = "161"
$Count = "0x302C02010104067075626C6963A01F0202000102010002010030133011060C2B060102012B0A0201040101050100"
$Count1 = "0x302C02010104067075626C6963A01F0202000102010002010030133011060C2B060102012B0A0201040101050100"
$CountMax = 5
$result_count=getsnmp($IP_ADDRESS,$Count,$CountMax)
$result_count2=getsnmp($IP_ADDRESS2,$Count1,$CountMax)
$result_count3=getsnmp($IP_ADDRESS3,$Count,$CountMax)
$result_count4=getsnmp($IP_ADDRESS4,$Count,$CountMax)
GUICtrlSetData($Label14,$result_count)
GUICtrlSetData($Label17,$result_count2)
GUICtrlSetData($Label16,$result_count3)
GUICtrlSetData($Label15,$result_count4)
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
Dim $IP_ADDRESS
$IP_ADDRESS = "10.1.188.79"
$IP_ADDRESS2 = "10.1.188.80"
$IP_ADDRESS3 = "10.1.188.81"
$IP_ADDRESS4 = "10.1.188.82"
$PORT = "161"
$Count = "0x302C02010104067075626C6963A01F0202000102010002010030133011060C2B060102012B0A0201040101050100"
$Count1 = "0x302C02010104067075626C6963A01F0202000102010002010030133011060C2B060102012B0A0201040101050100"
$CountMax = 5
$result_count=getsnmp($IP_ADDRESS,$Count,$CountMax)
$result_count2=getsnmp($IP_ADDRESS2,$Count1,$CountMax)
$result_count3=getsnmp($IP_ADDRESS3,$Count,$CountMax)
$result_count4=getsnmp($IP_ADDRESS4,$Count,$CountMax)
MsgBox(1,"",$result_count & " " & $result_count2 & " " & $result_count3 & " " & $result_count4)

Func getsnmp($IP_ADDRESS,$CMD,$MAXRESULT)
UDPStartUp()
$Start = 1
$Socket = UDPopen($IP_ADDRESS, $Port)
UDPSend($Socket, $CMD)
While (1)
$srcv = UDPRecv($Socket, 2048)
If ($srcv <> "") Then
$result_getsnmp=Dec(stringright($srcv,$MAXRESULT))
Return $result_getsnmp
ExitLoop
EndIf
sleep(100)
WEnd
UDPCloseSocket($Socket)
UDPShutdown()
EndFunc
Link to comment
Share on other sites

stack overflow?

I see no sleeps.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

Yep that was it I was hoping I could keep it real time, but added a 3 second delay and it works perfectly. Thanks!

Even a 1 second delay may suffice. Who's to say it's not real-time? Even real-time apps have delays. It's required for the CPU to not become overloaded with information to process. The definition of real-time is a little loose pertaining to the actual time-frame it uses. Some apps consider real-time a 1 minute refresh... others a few seconds etc.

EDIT: To keep processing low, you could do a 1 minute auto-refresh. And add a button to perform a force refresh. Then if there are certain times of the day when there's a heavy workload that needs extra attention, set the sleep to 1 second until the job is done etc.

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

Even a 1 second delay may suffice. Who's to say it's not real-time? Even real-time apps have delays. It's required for the CPU to not become overloaded with information to process. The definition of real-time is a little loose pertaining to the actual time-frame it uses. Some apps consider real-time a 1 minute refresh... others a few seconds etc.

EDIT: To keep processing low, you could do a 1 minute auto-refresh. And add a button to perform a force refresh. Then if there are certain times of the day when there's a heavy workload that needs extra attention, set the sleep to 1 second until the job is done etc.

Very true a 3 second delay works great for this and honestly it seems instantly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...