09-24-2008 09:58 PM
Greetings All-
I would like to monitor my UPS (Eaton/Powerware 9125) and shut down my application (and then Windows) when the power fails. Here is, or rather was, my strategy: use the built in web server in the UPS to read the power status, and then take action.
Here is the problem: when I use "URL Get Document.vi" to read the web page, the content I want is not there! (I can see it when I use Firefox to connect to the UPS!!) Instead, I find this not very helpful bit of code:
<SCRIPT LANGUAGE="JAVASCRIPT1.2" src="Menu.js">
</SCRIPT>
<Script>
var nTitle = "UPS Web Card";
CheckTitle(nTitle);
</Script>
Is there a way to execute that javascript and pull out the bit of data I'm looking for? (It's just a string that would be "SYSTEM NORMAL" or "ON BATTERY".)
An alternative solution (if you are patient enough to have read this far): I can install a service on my XP machine that will monitor the UPS for me and shut down Windows 5 minutes (for example) after the power goes out. Now the challenge is making LabVIEW aware of the impending shutdown, so I can close all my files and etc. The service will log the power failure to the Windows System Application Log. It can also pop up a message on the desktop. It is not obvious to me how to capture either of these events in LabVIEW. If it is obvious to you, please tell me how!
...and option 3: apparently, it is possible to recieve notice of a power failure from the UPS through something called "SNMP NMS". I know absolutely nothing about this, not even where to start.
Thanks to all in advance,
-GN
09-25-2008 03:51 AM - edited 09-25-2008 03:53 AM
To option 2: you need to check for the 'application exit?' event in your program, thiscard the event and start your own shutdown code.
To question 3:
http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
Felix
09-25-2008 04:17 AM
Probably it will return the same as 'URL Get Document', but you could try using the datasocket read function to get the website. Wire 'http://<UPS-IP-address>' to connection in and specify string as type.
Daniel
09-25-2008 04:24 AM
Hi GN,
I guess you've looked into using the UPS's RS232 port without success(?) I've used a UPS that would send a message (on COM port) on power-down, and had a loop poll the input buffer every second or so. By knowing within a second or two when a power-down was triggered, the application had plenty of time to close gracefully.
SNMP is a scheme for addressing - reading and changing - values on network devices. There are free SNMP tools which would allow you to 1) Poll the status of the UPS, or (possibly) 2) Repeatedly wait (in a loop) for the UPS to send an SNMP message that a power-down was started (same as serial-port scheme.) Once the SNMP server is installed and launched, LabVIEW would do "Set"s and "Gets" via command line calls using System Exec.vi
I've only used SNMP with a few devices and don't know what the "NMS" means. Anyway, if the serial-port option is available, it would be much simpler.
Re: web-page woes, I hope someone posts a solution - I'd be interested too!
Cheers.
09-25-2008 09:53 AM
Felix-
Do you have an example that does this? I saw a similar suggestion in another thread, but could not figure out how to detect the event. My only experience with "events" is using an event structure to read button presses an other user inputs on the front panel of a VI.
tbd-
I have not explored using the serial port. I actually need to monitor several UPSs, so a network connection seemed, at the time, like a much simpler approach. I could do that as a last resort, but I am not ready to give up yet.... Since there is no documentation, I would have to install com port monitoring software and try and decode the conversation between the UPS and manufacturer's monitoring software.
As far as extracting the info from the web page, I got as far as the attached VI by reading this thread.
But it still is just getting the HTML fluff, and not the data that the javascript is writing to the screen. It's really annoying, because with this VI, I have a display on the VI front panel in which I can see the string I want to get. It's right there! I can almost touch it! But noooooo, I can't have it
Well, if anyone has a smarter thought that I'm capable of, I'm all ears.
-GN
(Attachment is in 8.5.1)
09-25-2008 10:07 AM
Just a guess... probably the UPS doesn't return proper HTML and the URL Get Document only returns the HTML body. Have you tried using "URL Get HTTP Document" and check also the header contents to see if this carries the information?
09-25-2008 12:12 PM
Dan-
Both methods return the same result and agree with the View Source action of my Firefox browser. The challenge seems to be the javascript.
09-26-2008 03:21 AM
Hi GN,
After digging through Eaton's web-site for an ICD describing either the RS232 command-set or the SNMP interface, the best I could come up with was the SNMP MIB for Powerware products - if you get desperate enough to go the SNMP route, you'll need the MIB. The MIB defines the path to specific devices and objects. See "xupsUpsShutdownPending".
I've invested a few hours/days automating web interfaces and have twice run into pages that refused to have their Document's loaded, though it seemed for different reasons each time. So for all I know there may be a simple route around/through this JavaScript issue. Sometimes VBers run into the same problems we do - and their solutions often work for us. You might try to find a VB discussion about exactly this issue - and if there's a solution, try translating the solution into LabVIEW. At the end of this thread, Eric V provides an interesting link on converting VB to LabVIEW.
Cheers!
09-29-2008 08:25 AM
Thanks to all who helped out with this! We solved the problem by discovering that the javascript was simply loading a separate page on the UPS web server. By downloading that page directly, the information we were looking for appeared in clear text!
-GN
(Remember: two weeks in the lab can save an hour in the library!)