10-30-2024 03:01 PM
Hi David,
This solution sounds great. I don't know what you mean by "Windows built-in UPS support" is this something I install, activate, access from the control panel? Thanks.
Regards,
Andrew
Solved! Go to Solution.
10-30-2024 05:18 PM
Andrew,
I had to go back and review that thread; it's been a while. Let me make sure I know what you're after - do you just want to check status on a UPS attached to a computer running a Windows OS? If so, at least for the APC UPSes I've encountered, attaching the UPS via USB should cause Windows to add a device under the "Batteries" class in Device Manager. If that's so, you should be able to make use of the code I'm posting here. It's UPS-manufacturer agnostic - in fact it'll also report on a laptop's battery. It uses some pretty ancient Windows kernel32 call to query status of a backup battery. The rest of it is a registration for a Windows System .NET event (power system status change), with a VI callback that does the kernel32 call to fetch updated state info. I cobbled it together to have it handled within a LabVIEW user event. It is somewhat derivative of work done by @PhillipBrooks (this guy), so send him a virtual beer first if you find it useful.
But, short answer, yes, Windows has had more-or-less generic support for UPS/backup power monitoring for several releases.
To all: please note, NONE of this is really related to the start of the thread, which was about someone trying to use a ModBus interface to talk to a specific manufacturer's UPS.
Best regards,
Dave
10-30-2024 05:22 PM
ALD1,
This thread was last replied to 4.5 years ago so there's not a great chance of getting a direct reply.
However, what he probably meant was that Windows sees a UPS as a battery, somewhat like it works with a built-in battery on a laptop. You can see a power percentage, and configure special things to happen at certain battery levels.
See this:
http://dontcodetired.com/blog/post/Installing-and-Configuring-a-UPS-with-Windows-10
10-31-2024 08:45 AM
Luckily, there is a way to split threads that have been accidentally posted to an unrelated zombie thread. Unfortunately, I can't really fix the title of the "Resurrection Post."
11-01-2024 12:15 PM
Andrew,
Thanks for the kudos and the accepted answer!
No special installation, Windows just routinely adds a battery class device when a UPS is attached via USB. My recollection is that the APC SmartUPS device driver seems to convert that device’s name into something brand-specific (if you install their driver), but it didn’t seem necessary.
Having a battery-class device enumerated in the Windows Device Manager appears to be sufficient to get the battery status icon to show up in the system tray. Which (I think) means the DLL call (system32, the routine is like GetPowerStatus() but don’t quote me, look in my code), will return valid values.
Best of luck!
Dave