Jump to content

Get system power state


Recommended Posts

Hello

I've had some issues with a laptop that is used for data acquisition. Sometimes the people unplug the power and don't plug it in again. To not loose too much data, I had to find a was for LabView to know the power source and the fill level of the battery.

This vi is done with LabView 7.1 and uses a call to the windows library kernel32.dll to get the data. It should work on any windows system since Windows 2000. Maybe it is useful to other LV users as well.

The second vi just calls the first one in 500ms intervals and shows the results.

If you have ideas for improvement, let me know.

kruemi

PowerStatus.vi

ShowPowerStatus.vi

  • Like 2
Link to comment
  • 4 weeks later...

I posted this on the NI forums several years ago. I used .NET to monitor the power status instead of polling a DLL.

I registered for a callback event and then used a LabVIEW notifier to pass the status to other LV code...

dotNET+SystemPower.PNG

http://decibel.ni.co...t/docs/DOC-1154

Meh, and I've not been able to find it. Yours looks way nicer than mine :-)

It would be nice if there was a way to make that stuff platform independet, but I don't think this will be possible soon .-(

DLL-Calls often are a bit of a hassle to implement. Especially when you don't have access to header files. The upside is, that I'm using a dll that is sitting in every windows version since Windows 2000. So th solution is quite portable inside the windows line.

kruemi

Link to comment
On 4/18/2011 at 8:50 AM, kruemi said:

Meh, and I've not been able to find it. Yours looks way nicer than mine :-)

It would be nice if there was a way to make that stuff platform independet, but I don't think this will be possible soon .-(

It's possible but not without writing a DLL/shared library for every platform you want to support. For Windows straighforward, for MacOS X quite a bit of digging in the Carbon framework and for Linux a bit of a pain to do, since it can vary depending on kernel version, distribution and packaging.

Quote

DLL-Calls often are a bit of a hassle to implement. Especially when you don't have access to header files. The upside is, that I'm using a dll that is sitting in every windows version since Windows 2000. So th solution is quite portable inside the windows line.

And not to forget, that it doesn't invoke a .NET monster framework to get at some low level system information that is accessed through several other layers by the .Net library.

Edited by rolfk
  • Like 1
Link to comment
  • 4 years later...

Hi Kruemi...

Your PowerStatus.vi is very useful for me...

but i need to know how you know that we can get the battery information like BatteryFullLifeTime,BatteryLifeTime, BatteryLifePercent, ACLineStatus etc and what there is another else?

And also how you know use that data type, example unsigned byte for ACLineStatus and long integer for BatteryFullLifeTime

hope you can help me, may be you can make a video for me

thank a lot 

post-54582-0-31150900-1459661137.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.