Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

Close
Important Announcement: WELCOME to the new Schneider Electric Community! Community is now no longer part of Exchange, and is now rebranded under se.com. If you have any bookmarks and links saved, we request you to update them to ensure that you continue accessing our community from this new location. For any issues that you might encounter as part of this change, please reach out to SchneiderCommunity.Support@se.com, and the team will help to get your issues resolved.
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
82396members
349901posts

WM_POWERBROADCAST

APC UPS for Home and Office Forum

Schneider Electric support forum for our APC offers including Home Office UPS, Surge Protectors, UTS, software and services and associated products designed to share knowledge, installation, and configuration.

Solved
rh500_apc
Crewman
Crewman
0 Likes
2
201

WM_POWERBROADCAST

This was originally posted on APC forums on 3/16/2013


Hi,

I have both a BK350EI and a BE700G-GK.

Windows 7 x64.

I'm trying to make a VC2008 c++ program detect when the UPS is on battery power.

Is there a way to detect "power off line" status via the existing windows APIs for this purpose. If not - Why not?

Is the only benefit of this device some low sounding beeps that goes of 10 minutes before the power is cut?

i.e a delay of the power cut, but if no one hears the alarm no one hears the beeps there are no benefits at all?

There must be a way to write a program that can detect the power problem - I want to do that using WIN32 and c++...

Have tried two different approaches:

1. fails to detect anything when the UPS plug is removed from the wall.

SYSTEM_POWER_STATUS stPS;

GetSystemPowerStatus(&stPS);

- same info returned both when on battery and when on line power.

2. fails to detect anything when the UPS plug is removed from the wall.

WM_POWERBROADCAST via

hPowerSourceNotify = RegisterPowerSettingNotification( hWnd, &GUID_ACDC_POWER_SOURCE, DEVICE_NOTIFY_WINDOW_HANDLE );

hBatteryPowerNotify = RegisterPowerSettingNotification( hWnd, &GUID_BATTERY_PERCENTAGE_REMAINING, DEVICE_NOTIFY_WINDOW_HANDLE );

- no events are sent when on battery.


The USB cable to the computer should add expected benefits, not confined to the PowerChute software.


How do you access useful info from the UPS device using VC2008 c++ in windows?


Regards

/Ronnie



Accepted Solutions
rh500_apc
Crewman
Crewman
0 Likes
0
201

Re: WM_POWERBROADCAST

This was originally posted on APC forums on 3/18/2013


Thanks for your reply,

I managed to get it working.

First i tried writing for the HID Power Device spec by using hidapi-0.7.0, and probably it can be made working with more effort...

But I abandoned that and installed the alternate drivers from www.apcupsd.org.

The program apcaccess displayed all the info I could want, and i looked in the source and implemented the status-command via sockets and parsed the text to get what i wanted.

One could parse the output of apcaccess instead, to skip the socket handling.

It seems wrong that such facilities are not made available by APC, you have paid for a  product that is crippled by default.

I realize that the registry could be used to monitor (limited) status, but it seems more like a hack.

/Ronnie

See Answer In Context

2 Replies 2
voidstar_apc
Janeway
Janeway
0 Likes
0
200

Re: WM_POWERBROADCAST

This was originally posted on APC forums on 3/17/2013


Hi Ronnie,

I've never tried to use VC2008 to monitor a UPS, but here's two approaches I'd attempt:

1) Since the UPS is a standard USB HID Power Device (spec is here), you could try looking at the PowerSummary ACPresent usage.

2) I've also heard that PowerChute maintains several registry keys with useful information. I haven't investigated this, but you might look to see if there's one that shows AC present.

3) You can replace PowerChute's shutdown program with your own like these guys over here.

I think the windows API functions aren't working for you because PowerChute needs to disable windows' built-in UPS support in order to function correctly. Hopefully you can still get the information you need using the above methods, and if not, you can uninstall PowerChute to re-enable Windows' UPS support.

Let us know how you make out.

rh500_apc
Crewman
Crewman
0 Likes
0
202

Re: WM_POWERBROADCAST

This was originally posted on APC forums on 3/18/2013


Thanks for your reply,

I managed to get it working.

First i tried writing for the HID Power Device spec by using hidapi-0.7.0, and probably it can be made working with more effort...

But I abandoned that and installed the alternate drivers from www.apcupsd.org.

The program apcaccess displayed all the info I could want, and i looked in the source and implemented the status-command via sockets and parsed the text to get what i wanted.

One could parse the output of apcaccess instead, to skip the socket handling.

It seems wrong that such facilities are not made available by APC, you have paid for a  product that is crippled by default.

I realize that the registry could be used to monitor (limited) status, but it seems more like a hack.

/Ronnie