請先看『使用說明』
Battery Develop Utility under Windows
From LEXWiKi
Contents |
Introduction
Power Board Develop Utility can help you to develop tool to control LEX power board device.
Support power board module
PW405、PW407、PW601.
The binary file you can download from
<FTP>
DLL file(64 bit): PW_Utility_DLL_v2.5.22.51_x64
Sample source file(64 bit): PWUtilityDll_Sample_Src
Sample binary code: PWUtilityDll_Sample_Bin_x64
DLL User Guide: PWUtilityDll_Guide
DLL files descreption
PWUtilityDll.dll: Contains code and data about PWUtilityDll function.
PWUtilityDll.h: Header about PWUtilityDll function.
PWUtilityDll.lib: Import library that link to PWUtilityDll.dll.
LexIo64.dll、LexIo64.sys: Based on WinIO that provids DLL to read hardware data. For x64.
How to use DLL
*Step1. Unzip DLL zip file and put files to your program.
*Step2. Initialize power board module resource.
PW_MODULE_E defined in PWUtilityDll.h
enum PW_MODULE_E { PW_MODULE_PW405 = 0, PW_MODULE_PW407, PW_MODULE_PW601, PW_MODULE_NUM, //Used to record the number of modules };
//------------------------------------------------------------------------------ // Name : PW_InstallPwModule // Description : Initial PW module resource // Arguments : // nModule [in] : PW module. Enum of PW_MODULE_E. // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_InstallPwModule(int nModule);
Example :
if( PW_InstallPwModule(PW_MODULE_PW407) == TRUE ) TRACE(_T("Initial module resource succeed. \n")); else TRACE(_T("Initial module resource failed! \n"));
*Step3. If power board module initialize succeed, you could call PW_CheckPWModuleExist() to check device is still exist or not.
//------------------------------------------------------------------------------ // Name : PW_CheckPWModuleExist // Description : Check specific PW module exist or not. // Arguments : // nModule [in] : PW module. Enum of PW_MODULE_E. // Return : // TRUE : PW module exist // FALSE : PW module does not exist //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_CheckPWModuleExist(int nModule);
Example :
if( PW_CheckPwModuleExist(PW_MODULE_PW407) == TRUE ) TRACE(_T("Specific PW module device exist. \n")); else TRACE(_T("Specific PW module device do not exist \n"));
*Step4. If power board module initialize succeed, you could call PW_GetBatteryAllInfo() to get based battery information at the power board.
BT_CHARGE_STATUS_E defined in PWUtilityDll.h
enum BT_CHARGE_STATUS_E { BT_CHARGE_STATUS_NONE = 0, BT_CHARGE_STATUS_CHARGE, BT_CHARGE_STATUS_DISCHARGE, BT_CHARGE_STATUS_FULL_CHARGE, };
BATTERY_INFO_ST structure content please refer to PWUtilityDll DLL Function Guide
typedef struct _BATTERY_INFO_ST { int nBtExist; //Battery is connected or not TCHAR tcBatteryName[32]; //Power board module name int nPwModule; //Power board module, Enum of PW_MODULE_E int nChargeStatus; //Battery chare status, Enum of BT_CHARGE_STATUS_E LONGLONG llTimestampSec; //The system time point at which the information is obtained, (seconds since Jan 1, 1970). float fTemperature; //Battery temperature, (Unit: Kelvin) float fCurrent; //Battery current (Unit: mA) float fVoltage; //Battery voltage (Unit: mV) float fOutputVoltage; //Battery output voltage (Unit: mV) (PW601 Only) int nChargePercent; //Left capacity of battery (Unit: %) long lBtLeftMins; //Alive time of battery (Unit: Minute). If battery is charging, left time value is '0xFFFF'. long lWarnBits; int nCycleCount; //Battery cycle count int nIsShutdown; long lBatteryStatus; long lSafetyStatus; long lSafetyAlert; long lGaugingStatus; long lOperationStatus; long lPFStatus; long lPFAlert; } BATTERY_INFO_ST;
//------------------------------------------------------------------------------ // Name : PW_GetBatteryAllInfo // Description : Get All of battery information // Arguments : // nModule [in] : PW module // pValStruct [out] : Battery information structure. (BATTERY_INFO_ST) // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_GetBatteryAllInfo(int nModule, void* pValStruct);
*Step5. If you want to get individual information about the battery, call the corresponding function.
All function content and sample please refer to PWUtilityDll DLL Function Guide
Example :
//------------------------------------------------------------------------------ // Name : PW_GetBatteryCurrentInfo // Description : Get current of battery information // Arguments : // nModule [in] : PW module // fCurrent [out] : Battery current // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_GetBatteryCurrentInfo(int nModule, float &fCurrent);
//------------------------------------------------------------------------------ // Name : PW_GetBatteryVoltageInfo // Description : Get voltage of battery information // Arguments : // nModule [in] : PW module // fVoltage [out] : Battery voltage (Unit: mV) // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_GetBatteryVoltageInfo(int nModule, float &fVoltage);
*Final Step. Release power board resource before leaving your program.
//------------------------------------------------------------------------------ // Name : PW_FreePwModule // Description : Release PW module resource // Arguments : // nModule [in] : PW module. Enum of PW_MODULE_E. // Return : // TRUE : Success // FALSE : Failed //------------------------------------------------------------------------------ PWUTILITYDLL_API int PW_FreePwModule(int nModule);
Example :
if( PW_FreePwModule(PW_MODULE_PW407) == TRUE ) TRACE(_T("Release module resource succeed. \n")); else TRACE(_T("Release module resource failed! \n"));