Announcement

Collapse
No announcement yet.

Need the equivillant of wscript.Sleep 1000 in vbscript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael McSharry
    replied
    Homeseer is a single process that internally manages the sequencing of scripts and servicing of events. When hs.waitsec/hs.waitevents is used then it provides a mechanism by which the homeseer internal scheduler can regain control. It does provide control back to the OS, but in general while waiting it is the process that requests use of the CPU, hence the bookkeeping of the time used by each process shows homeseer to be a heavy user during these wait times. If homeseer has anything else to do besides just wait then it will do it. If other processes have something to do then they will also have the opportunity to do it. The high CPU utilization is more of a bookkeeping thing than an actual high utilization.

    If the concern is with keeping the apparent utilization down, then run the scripts that do sleep/wait/delay in a separate process. In this case the sleep time will be bookkept with the system and not be charged to homeseer. Of course use the sleep function, timer control, dispatch timer, or other method of time control in the separate process. If you use hs.waitevents/hs.waitsecs I suspect that homeseer will be charged with the delay time.

    If you run Guardian Angel then false trips can result due to scripts running in the homeseer process that have long delay loops. If you do not run it, or other CPU utilization monitor, then the high utilization is only cosmetic.

    Leave a comment:


  • GC
    Guest replied
    Rupp,

    hs.WaitSecs may have been using DoEvents (I am pretty sure it was) and while the CPU shows 100% utilization, DoEvents indeed allow other processes to get CPU.

    Nonetheless, like I wrote you might want to check with Rich because he is about to implement a new method for that command whereby it will not utilize CPU.

    Leave a comment:


  • Rupp
    replied
    I tried and since HS.Waitsecs runs the cpu to 100% nothing else processes so the wait doesn't accomplish a thing. The WScript.sleep statement does work in a vbs file and I have it working in a .vbs WSH file but I wanted to run it in a script via HS. I guess the bottom line is HS.Waitsecs need to really sleep and not use 100% processor usage. Thanks for the replys.

    -Rupp
    ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.

    Leave a comment:


  • paugusto
    Guest replied
    Rupp,

    Are you trying to use Wscript.Sleep in a script run by HomeSeer (script.txt) rather than Windows Script Hosting (script.vbs)? If you're running it in HS, how about using hs.waitsecs 1? If you need a smaller delay then try the method Michael McSharry posted here.

    If you're launching a seperate WSH process then Wscript.Sleep should work without any extra object definition as demonstrated in Michael's sleep.vbs.


    Paul

    Leave a comment:


  • Rupp
    replied
    I'm simply trying to use WScript.sleep(1000) in a a script and I need to know how to get to instanciate(sp?) a WScript object in vb script.

    -Rupp
    ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.

    Leave a comment:


  • GC
    Guest replied
    Hey Guys,

    I'm coming into this late and did not really read through the whole thread, but the topic caught my eye so I thought I'd chime in.

    In trying to get the CPU usage down a bit in a plug-in I am writing for HomeSeer, Rich and I ran through some different delay methods. The easiest one which is to loop DoEvents (hs.WaitEvents) with something like timer() to control the time works, but although it allows other processes to have the CPU, it shows the program consuming most of the available time. So then Rich told me about the Sleep command. It definitely reduces your CPU usage, but it also has the disadvantage in that you don't get any CPU at all so you can't "wake up" early if you need to. Using this method with some controls in place helped reduce the CPU usage a great deal. The problem was that we were calling it for some really short periods which it is not good for, and we were calling it many times with short durations to add up to one long duration because we did not want to be "asleep at the wheel" at a critical time.

    The end result I found somewhere is a method for waiting that does not take CPU, and you can "wake" from the sleep when any objects in your program change state - e.g. when a COM control has data or something.

    Rich decided he liked that new method as well, so we are currently testing it in my plug-in and Rich has given me a version of the Ocelot plug-in with it and they both appear to work fine. If this continues, then Rich may implement this type of wait in the hs.WaitEvents command and in other places where there are waits in HomeSeer.

    This is all just a bunch of words to say, check with Rich as a better way to cause a delay may become part of HomeSeer soon.

    Leave a comment:


  • Rupp
    replied
    I tried to use WScript.sleep in a HS script and it errored. I guess I need to know how to create the object to use this object in a script (WScript.sleep ). I receive an error "Object required WScript ..."

    -Rupp
    ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.

    Leave a comment:


  • Nitrox
    replied
    What about WScript.sleep(10000) ?

    -Nitrox

    Leave a comment:


  • skybolt
    replied
    Not sure I really understand the question, but here goes. WScript.sleep is vbscript so calling WScript.sleep(1000) would suspend the script for 1 sec. if you need to go longer just loop aroud the object like this

    for slp = 1 to 10
    WScript.sleep(1000)
    Next slp

    But I don't think thats what you were asking for?
    if so I hope this helps.

    -Orlando

    Leave a comment:


  • Rupp
    started a topic Need the equivillant of wscript.Sleep 1000 in vbscript

    Need the equivillant of wscript.Sleep 1000 in vbscript

    Any suggestions.

    -Rupp
    ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.
Working...
X