LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Get System information through call Win API?

Dear all
 
I want to get my NoteBook system information in LV, but i don't know how to achieve it, Could anybody give me some tips?
The attached vi is a sample to read system information(from Advanced Pro Tech), but when i run this vi, i can't get the right result. 
My purpose is to get the battery and AC power information.
Thanks!
0 Kudos
Message 1 of 9
(4,409 Views)

You could probably get this info out of the .net framework inside labview. I'll try to work out an example later.

http://www.neowin.net/forum/lofiversion/index.php/t212463.html

0 Kudos
Message 2 of 9
(4,392 Views)
Thank you very much.
 
Now I am trying to get the power status use of GetSystemPowerStatus, and it returns code can reflect the power status.
 
0 Kudos
Message 3 of 9
(4,388 Views)

MilkyStone wrote:
Thank you very much.
 
Now I am trying to get the power status use of GetSystemPowerStatus, and it returns code can reflect the power status.
 

This should work. To get the detailed meaning of the different values try to look at: Microsoft Developer Network: SYSTEM_POWER_STATUS.

Rolf Kalbermatter

Message Edited by rolfk on 01-12-2006 02:35 PM

Rolf Kalbermatter
My Blog
Message 4 of 9
(4,367 Views)

Rolf, is there any special reason you're not using Adapt to Type with the cluster input?
It would definitely be easier than having to calculate that array and the byte swapping.

My guess is that the VI was written before the adapt to type option was available.


___________________
Try to take over the world!
Message 5 of 9
(4,356 Views)
Exactly! If you checkout the VI information->current changes you will see among other things: VI converted from 5.0.1. There was no Adapt to type before 6.0 because that option was virtually impossible to implement when LabVIEW had to support Win3.1.

But there is nothing bad with this approach. Just a little more involved and burning some extra CPU cycles. Somehow we need to utilize the increased CPU speed, don't we Smiley Wink

Rolf Kalbermatter

Message Edited by rolfk on 01-12-2006 03:42 PM

Rolf Kalbermatter
My Blog
Message 6 of 9
(4,355 Views)
Thanks for your patient to give this sample, it's very useful to my application. Before now, I can only read the Ac status and battery capacity using GetSystemPowerStatus, but your vi have ability to get more information about system power, because of I had set wrong type of parameter.
 
But I am so sorry to consult you again, why you add Type cast ,Swap bytes and Swap words after the call Libary function node? As far as I know, we can read these information directly from the output of Call Libary Function Node.
 
Thank you!
0 Kudos
Message 7 of 9
(4,334 Views)


@MilkyStone wrote:
Thanks for your patient to give this sample, it's very useful to my application. Before now, I can only read the Ac status and battery capacity using GetSystemPowerStatus, but your vi have ability to get more information about system power, because of I had set wrong type of parameter.
 
But I am so sorry to consult you again, why you add Type cast ,Swap bytes and Swap words after the call Libary function node? As far as I know, we can read these information directly from the output of Call Libary Function Node.
 
Thank you!


Ok, my previous post basically explains it but here is a more detailed explanation. Before LabVIEW 6.0 the Call Library Node could not be configured to take arbitrary parameters and this VI was created with LabVIEW 5 or maybe even 4.1. The solution then for structure parameters was to calculate its size, preallocate an array of u8 and pass it as an array pointer to the function. On return you of course want to convert it into the actual data structure.

This is done with Typecast. Typecast basically keeps the information in memory as is but changes the type LabVIEW sees in the wire. There is one catch here since Typecast also normalizes any data to make sure the stream side is always Big Endian which is the default byte order in LabVIEW (search here on that term and you will find quite some posts about this). Since the byte stream was already in Little Endian
(we work on a Intel x86 CPU here) the byte ordering of any integer data inside the cluster bigger than 1 byte will be reversed after the Typecast and has to be reversed again by applying the Swap Bytes and Swap Words nodes.

You could avoid all this with newer LabVIEW versions (>=6.0) by configuring the parameter in the Call Library Node to "Adapt to Type" and wire the cluster constant directly to the input side of that parameter and remove the Typecast and Swap xxx functions altogether. This will even result in a few 100ns faster execution Smiley Very Happy

Rolf Kalbermatter

Message Edited by rolfk on 01-13-2006 11:06 AM

Rolf Kalbermatter
My Blog
Message 8 of 9
(4,324 Views)
Thank you for your kindness to explain these tips, and now I see the WHY.
You are the knowledgeable man I had been  met in this forum.
Thank you!
0 Kudos
Message 9 of 9
(4,292 Views)