Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2010
    Location
    Coonabarabran, NSW, Australia
    Posts
    63

    Default Poweroff script for digital loggers

    Dear all, just wandering if anybody out has done a poweroff script for the popular web power switch II made by digital loggers. By chance it is the one I use in my observatory If so please contact me, thanks

    Clear Skies
    Marco Lorenzi
    www.glitteringlights.com

  2. #2
    Join Date
    Oct 2005
    Location
    Mesa, AZ
    Posts
    26,860

    Default

    Marco --

    I have!! Here, in JavaScript is a function that you can call which will turn on or off an outlet. You have to edit the script for the location of the ECP2.exe program, the IP address/Port of your switch, and the username/password. This is written to run in ACP's console, not via cscript/command shell.

    Code:
    //
    // Send a command to the power controller, wait for exit, check errors
    // then if successful, wait 5 seconds to space power changes out. The
    // 'on' parameter is true to turn on, false to turn off, 'label' is used 
    // for logging, and 'outlet' is the outlet number. This function is used
    // in both the startup and shutdown scripts.
    //
    function DoPowerCommand(label, outlet, on)
    {
        Console.PrintLine("Turning " + (on ? "on " : "off ") + label + "..."); // Announce our intentions
        var tid = Util.ShellExec("C:/Scripts/ECP2.exe", 
                            "192.168.x.x:4890 username:password " + outlet + (on ? "on" : "off"), 
                            6);                                             // Execute command (minimized, no focus)
        var i;
        for(i = 0; i < 10; i++) {                                           // Wait up to 10 sec
            if(!Util.IsTaskActive(tid)) break;
            Util.WaitForMilliseconds(1000);                                 // Wait 1 sec here
        }
        if(i >= 10)                                                         // Wait failed?
            throw "**Power command program failed to exit in 10 sec.";
        if(Util.GetTaskExitStatus(tid) !== 0)                               // Exited with failure status?
            throw "**Power command program exited with error status.";
        Console.PrintLine("...OK");
        Util.WaitForMilliseconds(5000);                                     // Assure 5 sec before next power cmd
    }
    ECP2.exe comes with the switch. If you need a copy I can post it here.
    -- Bob

  3. #3
    Join Date
    Feb 2010
    Location
    Coonabarabran, NSW, Australia
    Posts
    63

    Default

    Thanks Bob! Yes please post the ECP2.exe here, I have not in my pc downunder (I have UU.exe than it is maybe similar..)

    Thanks
    Marco

  4. #4
    Join Date
    Oct 2005
    Location
    Mesa, AZ
    Posts
    26,860

    Default

    OK, here it is.
    Attached Files Attached Files
    -- Bob

  5. #5

    Default

    Hi Guys,

    Great script!

    I am using the WPS3 and the UU.WP32.exe utility program, so I have modified the script file accordingly to suit.

    However when I try to run it from the ACP console, I get the following:
    "Script Error"
    ACP Script Error: No Main() function in script

    Have I missed an obvious step here???

    I assume I can call the script file anything I want, as long as its saved with an extension xxx.js and is in the scripts folder of ACP.
    I edited in notepad and saved it with a .js extension

    Cheers
    Mark

  6. #6
    Join Date
    Oct 2005
    Location
    Mesa, AZ
    Posts
    26,860

    Default

    Mark --

    I gave Marco the function to include in his script. Clearly the function DoPowerCommand() takes several parameters (the name of what's being powered on/off, the outlet number, and the on/off as True or False). That function needs to be called from other code, presumably which would be part of a larger script which would be in a main() function.
    -- Bob

  7. #7

    Default

    Bob,

    Yes, I finally figured out the code and realised it had pass through parameters.
    My code skills are limited so i am struggling along.
    My ultimate goal is to have a tiddler for the WPSIII available through the web acp console, similar to the AAG weather tiddler.

    I also noticed that the tiddlers disappear after performing a Hotfix upgrade??
    Is this normal behaviour, if so how can one mitigate against it?

    Cheers
    Mark

  8. #8
    Join Date
    Oct 2005
    Location
    Mesa, AZ
    Posts
    26,860

    Default

    Check in the authoring documentation, there are scripts that you run in the web content area that can export your tiddlers and import them after upgrading. There is one that will identify all of your Custom tagged ones too. The biggest pain is that you have to re-edit the MainMenu tiddler if you add to the menu(s) on the left. I hope to somehow make this customizable to some degree in the future some time.
    -- Bob

 

 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ASCOM Switch Driver for Digital Loggers Switch
    By Jeff Lewis in forum Hardware/Software/Driver Topics Not Directly Related to Our Software
    Replies: 18
    Last Post: Apr 7, 2017, 17:30
  2. Poweroff script for APC Units
    By Steve Reilly in forum Add-Ons, Enhancements, and Helper Components
    Replies: 4
    Last Post: Jun 4, 2014, 16:54
  3. Connecting Digital Dome Works (DDW) to ACP
    By Don Bartholomew in forum Hardware/Software/Driver Topics Not Directly Related to Our Software
    Replies: 1
    Last Post: Aug 31, 2012, 23:19
  4. Digital DomeWorks (DDW) User Pins in ACP Web Browser
    By Robert Capon in forum Pre-Sales Technical Questions and Help
    Replies: 0
    Last Post: Feb 21, 2012, 21:04
  5. Digital Domeworks Timout
    By Paul Shulins in forum Hardware/Software/Driver Topics Not Directly Related to Our Software
    Replies: 7
    Last Post: Nov 3, 2009, 00:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •