230 lines
5.3 KiB
C
230 lines
5.3 KiB
C
|
|
#ifndef BATTERYINFO_H
|
|||
|
|
#define BATTERYINFO_H
|
|||
|
|
|
|||
|
|
#include <QObject>
|
|||
|
|
#include "GDUModule/glink/glink_m/glink_m.h"
|
|||
|
|
#include "GDUModule/glink/glink_np/glink_np.h"
|
|||
|
|
|
|||
|
|
class BatteryInfo : public QObject
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
public:
|
|||
|
|
explicit BatteryInfo(QObject *parent = nullptr);
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte1
|
|||
|
|
* 格式:uint8
|
|||
|
|
* 拨码地址,即电池编号 1-n
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(char number READ number NOTIFY batteryInfoNotify)
|
|||
|
|
char number(){
|
|||
|
|
return batteryInfo->number;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte2
|
|||
|
|
* 格式:uint8
|
|||
|
|
* 通讯状态, 0表示正常 1表示异常
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(char status READ status NOTIFY batteryInfoNotify)
|
|||
|
|
char status(){
|
|||
|
|
return batteryInfo->status;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte3 - byte4
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电池电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol READ vol NOTIFY batteryInfoNotify)
|
|||
|
|
short vol(){
|
|||
|
|
return batteryInfo->vol;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte5 - byte8
|
|||
|
|
* 格式:int32
|
|||
|
|
* 电池电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(int cur READ cur NOTIFY batteryInfoNotify)
|
|||
|
|
int cur(){
|
|||
|
|
return batteryInfo->cur;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte9 - byte10
|
|||
|
|
* 格式:int16
|
|||
|
|
* 电池温度,单位度
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short temp READ temp NOTIFY batteryInfoNotify)
|
|||
|
|
short temp(){
|
|||
|
|
return batteryInfo->temp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte11
|
|||
|
|
* 格式:uint8
|
|||
|
|
* 电量百分比
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(char percentage READ percentage NOTIFY batteryInfoNotify)
|
|||
|
|
char percentage(){
|
|||
|
|
return batteryInfo->percentage;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte12 - byte13
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电池剩余容量,单位mah
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short remain READ remain NOTIFY batteryInfoNotify)
|
|||
|
|
short remain(){
|
|||
|
|
return batteryInfo->remain;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte14 - byte15
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯1电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_one READ vol_one NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_one(){
|
|||
|
|
return batteryInfo->vol_one;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte16 - byte17
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯2电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_two READ vol_two NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_two(){
|
|||
|
|
return batteryInfo->vol_two;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte18 - byte19
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯3电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_three READ vol_three NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_three(){
|
|||
|
|
return batteryInfo->vol_three;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte20 - byte21
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯4电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_four READ vol_four NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_four(){
|
|||
|
|
return batteryInfo->vol_four;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte22 - byte23
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯5电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_five READ vol_five NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_five(){
|
|||
|
|
return batteryInfo->vol_five;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte24 - byte25
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯6电压,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short vol_six READ vol_six NOTIFY batteryInfoNotify)
|
|||
|
|
short vol_six(){
|
|||
|
|
return batteryInfo->vol_six;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte26 - byte27
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电芯间最大压差,单位MV
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short differential_pressure READ differential_pressure NOTIFY batteryInfoNotify)
|
|||
|
|
short differential_pressure(){
|
|||
|
|
return batteryInfo->differential_pressure;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte28
|
|||
|
|
* 格式:uint8
|
|||
|
|
* 电池锁定状态
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(char lock READ lock NOTIFY batteryInfoNotify)
|
|||
|
|
char lock(){
|
|||
|
|
return batteryInfo->lock;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte29 - byte30
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电池满电电量
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short Full_power READ Full_power NOTIFY batteryInfoNotify)
|
|||
|
|
short Full_power(){
|
|||
|
|
return batteryInfo->Full_power;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte31 - byte32
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电池充放电循环次数
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short Charging_num READ Charging_num NOTIFY batteryInfoNotify)
|
|||
|
|
short Charging_num(){
|
|||
|
|
return batteryInfo->Charging_num;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte33 - byte34
|
|||
|
|
* 格式:uint16
|
|||
|
|
* 电池校验出错状态
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short error READ error NOTIFY batteryInfoNotify)
|
|||
|
|
short error(){
|
|||
|
|
return batteryInfo->error;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte35
|
|||
|
|
* 格式:uint8
|
|||
|
|
* 异常计数
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(char error_num READ error_num NOTIFY batteryInfoNotify)
|
|||
|
|
char error_num(){
|
|||
|
|
return batteryInfo->error_num;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* 偏移地址:byte36 - byte37
|
|||
|
|
* 格式:uint16
|
|||
|
|
* RunTimeToEmpty
|
|||
|
|
*/
|
|||
|
|
Q_PROPERTY(short RunTimeToEmpty READ RunTimeToEmpty NOTIFY batteryInfoNotify)
|
|||
|
|
short RunTimeToEmpty(){
|
|||
|
|
return batteryInfo->RunTimeToEmpty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//飞机电池信息
|
|||
|
|
glink_m_aircraft_battery_z4b_battery_t *batteryInfo = glink_m_aircraft_battery_z4b_battery_createEmptyInfo();
|
|||
|
|
|
|||
|
|
//更新电池信息
|
|||
|
|
void updateBatteryInfo(){
|
|||
|
|
batteryInfoNotify();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
signals:
|
|||
|
|
void batteryInfoNotify();
|
|||
|
|
|
|||
|
|
public slots:
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // BATTERYINFO_H
|