294 lines
11 KiB
C++
294 lines
11 KiB
C++
#ifndef MAINWINDOW_H
|
||
#define MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include <QStandardItem>
|
||
#include <QStandardItemModel>
|
||
#include <QGridLayout>
|
||
#include <batt.h>
|
||
#include <modbusrtu.h>
|
||
|
||
class ComLogin;
|
||
class QSettings;
|
||
class QLabel;
|
||
class QFile;
|
||
class AppProto;
|
||
class Appproto_English;
|
||
class ChartPaint;
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
namespace Ui {
|
||
class MainWindow;
|
||
}
|
||
QT_END_NAMESPACE
|
||
|
||
class MainWindow : public QMainWindow
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
MainWindow(QWidget *parent = nullptr);
|
||
~MainWindow();
|
||
|
||
public:
|
||
Ui::MainWindow *ui;
|
||
|
||
public:
|
||
QStandardItemModel *model;
|
||
|
||
QStandardItemModel *modelBCU; //设置BCU目录
|
||
QStandardItem *rootItem;
|
||
|
||
QStandardItemModel *model_history_alarm;
|
||
QStandardItemModel *model_get_version;
|
||
|
||
ComLogin *m_ComLogin;
|
||
AppProto *m_AppProto;
|
||
Appproto_English *m_AppProto_English;
|
||
QSettings *ini;
|
||
QFile *logFile;
|
||
QLabel *statusBarConnectedIcon;
|
||
QLabel *statusBarConnectedType;
|
||
QLabel *statusBarCompany;
|
||
QLabel *statusBarBcu;
|
||
QLabel *statusBarVersion;
|
||
// ChartPaint *chartPat;
|
||
QString currentBCU = "BCU01";
|
||
|
||
|
||
int BCUNumbers;
|
||
// QGridLayout *gridLayout;
|
||
// QHBoxLayout *hBoxLayout;
|
||
|
||
batt *bat;
|
||
bool pageDebugLogFlag = false;
|
||
QList<QLabel*> labelListVol;
|
||
QList<QLabel*> labelListTempt;
|
||
QList<int> sgl_vol_info;
|
||
QList<int> sgl_tempt_info;
|
||
QList<int> base_info1_45;
|
||
QList<int> base_info47_49_51_53_55;
|
||
QList<int> base_info57_78;
|
||
QList<int> base_info83_106;
|
||
int battery_count;
|
||
ModbusRTU *m_modbusrtu_main;
|
||
int lan;
|
||
|
||
int tabWidget_paraset_index = 0;
|
||
|
||
QList<QLabel*> trouble_list;
|
||
QList<int> trouble_list_flag;
|
||
|
||
bool trouble_history = 1;
|
||
|
||
int count_history_alarm = 0; //如果不放到全局变量中去,每次刷新的都是同一个报警的内容,无法达到历史告警的作用
|
||
|
||
|
||
|
||
private:
|
||
enum DataType{
|
||
TypeRecvData,
|
||
TypeSendData
|
||
};
|
||
|
||
public:
|
||
/* 默认选择语言枚举 */
|
||
enum DEFAULT_LANG{
|
||
LANGUAGE_ENG,
|
||
LANGUAGE_CHN
|
||
};
|
||
|
||
/* 显示状态栏 */
|
||
bool showStatusBar;
|
||
|
||
enum PAGE{
|
||
PAGE_HOME,
|
||
PAGE_BATTERY,
|
||
PAGE_PARASET,
|
||
PAGE_DEBUG,
|
||
PAGE_FLASH,
|
||
PAGE_SETUP,
|
||
PAGE_RECORD
|
||
};
|
||
|
||
|
||
|
||
private:
|
||
void init();
|
||
void setMenuStyle();
|
||
void pageBatteryInit();
|
||
void pageHomeHistoryAlarm();
|
||
void pageFlashGetVersion();
|
||
void pageParaSetInit();
|
||
void pageParaSetInit_alert_value();
|
||
void pageParaSetInit_alert_delay();
|
||
void pageParaSetInit_alert_release_value();
|
||
void pageParaSetInit_alert_release_delay();
|
||
void pageParaSetInit_alert_dropcurr_rate();
|
||
void pageParaSetInit_alert_solve_measure();
|
||
void pageParaSetInit_DIDO_setting();
|
||
void pageParaSetInit_balance_setting();
|
||
void pageParaSetInit_SOX_setting();
|
||
void pageParaSetInit_other_setting();
|
||
|
||
void sglChartInit(int bat_count);
|
||
void sgl_info_process(QList<int> sgl_info, QList<QLabel*> labelList);
|
||
int findMaxIndex(const QList<int> sgl_info);
|
||
int findMinIndex(const QList<int> sgl_info);
|
||
|
||
void trubleListInit();
|
||
|
||
public slots:
|
||
// void setNum(QString value);
|
||
void getLanNumberSlot(int number);
|
||
|
||
signals:
|
||
void showLogin();
|
||
void closeLogin();
|
||
void write_regs_signals(int addr, const uint16_t data);
|
||
void read_regs_signals(int addr, int nb, uint16_t *data, int row);
|
||
// void read_regs_input_signals_vol(int addr, int nb, uint16_t *data);
|
||
// void read_regs_input_signals_temp(int addr, int nb, uint16_t *data);
|
||
void row_of_bmus_index(int index);
|
||
|
||
void closeThread();
|
||
|
||
public:
|
||
void slot_getBcuNumberFromDialoglogin(int number);
|
||
void slot_pageDebugDisplayMessage(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeSglDataMessage(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeSglTempt(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeBaseInfo1_45(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeBaseInfo57_78(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeBaseInfo83_106(QByteArray byteArray, int dataType, uint16_t *data);
|
||
void slot_pageHomeBaseInfo47_49_51_53_55(QList<int> byteArray, int dataType);
|
||
void slot_pageParaSetShow(QByteArray byteArray, int dataType, int row, int nb);
|
||
void slot_pageHomeFault(QByteArray byteArray, int dataType, uint16_t *data);
|
||
|
||
protected:
|
||
void closeEvent(QCloseEvent *e) override;
|
||
|
||
private slots:
|
||
void on_pageParaSetCheck_stateChanged(int arg1);
|
||
void on_pageParaSetRead_clicked();
|
||
void on_pageParaSetWrite_clicked();
|
||
void on_tabChanged(int index);
|
||
void on_comBoxBCUSelect(int index);
|
||
// void on_horizontalSlider_valueChanged(int value);
|
||
|
||
void on_btn_close_pos_clicked();
|
||
|
||
void on_btn_open_pos_clicked();
|
||
|
||
void on_btn_close_neg_clicked();
|
||
|
||
void on_btn_open_neg_clicked();
|
||
|
||
void on_btn_close_prechg_clicked();
|
||
|
||
void on_btn_open_prechg_clicked();
|
||
|
||
void on_btnImport_clicked();
|
||
|
||
public:
|
||
struct Battery_data {
|
||
uint16_t pack_total_voltage; // 电池组总压
|
||
uint16_t pack_total_current; // 电池组总电流
|
||
uint16_t soc; // SOC
|
||
uint16_t soh; // SOH
|
||
uint16_t soe; // SOE
|
||
uint16_t rated_total_voltage; // 额定总压
|
||
uint16_t rated_capacity; // 额定容量
|
||
uint16_t remaining_capacity; // 剩余容量
|
||
uint16_t rated_energy; // 额定电量
|
||
uint16_t remaining_energy; // 剩余电量
|
||
uint16_t slave_total_num_bmu; // 从机总数(BMU)
|
||
uint16_t online_slave_num_bmu; // 在线从机总数(BMU)
|
||
uint16_t total_battery_num; // 电池总数
|
||
uint16_t online_battery_num; // 在线电池总数
|
||
uint16_t total_temperature_sensor_num; // 温感总数
|
||
uint16_t online_temperature_sensor_num; // 在线温感总数
|
||
uint16_t max_allowed_discharge_current; // 最大允许放电电流
|
||
uint16_t max_allowed_discharge_power; // 最大允许放电功率
|
||
uint16_t max_allowed_charge_current; // 最大允许充电电流
|
||
uint16_t max_allowed_charge_power; // 最大允许充电功率
|
||
uint16_t positive_insulation_resistance; // 正极绝缘阻值
|
||
uint16_t negative_insulation_resistance; // 负极绝缘阻值
|
||
uint16_t average_cell_voltage; // 单体平均电压
|
||
uint16_t max_cell_voltage_difference; // 单体最大压差
|
||
uint16_t highest_cell_voltage; // 最高单体电压
|
||
uint16_t highest_cell_voltage_slave_num; // 最高单体电压从机号
|
||
uint16_t highest_cell_voltage_cell_num; // 最高单体电压编号
|
||
uint16_t lowest_cell_voltage; // 最低单体电压
|
||
uint16_t lowest_cell_voltage_slave_num; // 最低单体电压从机号
|
||
uint16_t lowest_cell_voltage_cell_num; // 最低单体电压编号
|
||
uint16_t average_cell_temperature; // 单体平均温度
|
||
uint16_t max_temperature_difference; // 最大温差
|
||
uint16_t highest_cell_temperature; // 最高单体温度
|
||
uint16_t highest_cell_temperature_slave_num; // 最高单体温度从机号
|
||
uint16_t highest_cell_temperature_cell_num; // 最高单体温度编号
|
||
uint16_t lowest_cell_temperature; // 最低单体温度
|
||
uint16_t lowest_cell_temperature_slave_num; // 最低单体温度从机号
|
||
uint16_t lowest_cell_temperature_cell_num; // 最低单体温度编号
|
||
uint16_t daily_charge_capacity; // 日充电容量
|
||
uint16_t daily_charge_energy; // 日充电电量
|
||
uint16_t daily_discharge_capacity; // 日放电容量
|
||
uint16_t daily_discharge_energy; // 日放电电量
|
||
uint16_t daily_charge_time; // 日充电时间
|
||
uint16_t daily_discharge_time; // 日放电时间
|
||
uint16_t cumulative_charge_capacity; // 累计充电容量
|
||
uint16_t cumulative_charge_energy; // 累计充电电量
|
||
uint16_t cumulative_discharge_capacity; // 累计放电容量
|
||
uint16_t cumulative_discharge_energy; // 累计放电电量
|
||
uint16_t cumulative_charge_time; // 累计充电时间
|
||
uint16_t cumulative_discharge_time; // 累计放电时间
|
||
uint16_t bcu_working_status; // BCU工作状态
|
||
uint16_t total_negative_relay_status; // 总负继电器状态
|
||
uint16_t total_positive_relay_status; // 总正继电器状态
|
||
uint16_t discharge_relay_status; // 放电继电器状态
|
||
uint16_t charge_relay_status; // 充电继电器状态
|
||
uint16_t precharge_relay_status; // 预充继电器状态
|
||
uint16_t relay_status; // 继电器状态
|
||
uint16_t switch_status; // 开关量状态
|
||
uint16_t fault_status; // 故障状态
|
||
uint16_t fault_level_1_to_8; // 故障1~8的故障等级
|
||
uint16_t fault_level_9_to_16; // 故障9~16的故障等级
|
||
uint16_t fault_level_17_to_24; // 故障17~24的故障等级
|
||
uint16_t fault_level_25_to_32; // 故障25~32的故障等级
|
||
uint16_t fault_level_33_to_40; // 故障33~40的故障等级
|
||
uint16_t fault_level_41_to_48; // 故障41~48的故障等级
|
||
uint16_t fault_level_49_to_56; // 故障49~56的故障等级
|
||
uint16_t fault_level_57_to_64; // 故障57~64的故障等级
|
||
uint16_t battery_system_cycle_count; // 电池系统循环次数
|
||
uint16_t max_allowed_charge_cell_voltage; // 最大允许充电单体电压
|
||
uint16_t min_allowed_discharge_cell_voltage; // 最小允许放电单体电压
|
||
uint16_t max_allowed_charge_total_voltage; // 最大允许充电总压
|
||
uint16_t min_allowed_discharge_total_voltage; // 最小允许放电总压
|
||
uint16_t sampled_total_voltage; // 采样总压
|
||
uint16_t first_level_fault_1_to_16; // 一级故障(故障位1~16)
|
||
uint16_t first_level_fault_17_to_32; // 一级故障(故障位17~32)
|
||
uint16_t first_level_fault_33_to_48; // 一级故障(故障位33~48)
|
||
uint16_t first_level_fault_49_to_64; // 一级故障(故障位49~64)
|
||
uint16_t second_level_fault_1_to_16; // 二级故障(故障位1~16)
|
||
uint16_t second_level_fault_17_to_32; // 二级故障(故障位17~32)
|
||
uint16_t second_level_fault_33_to_48; // 二级故障(故障位33~48)
|
||
uint16_t second_level_fault_49_to_64; // 二级故障(故障位49~64)
|
||
uint16_t third_level_fault_1_to_16; // 三级故障(故障位1~16)
|
||
uint16_t third_level_fault_17_to_32; // 三级故障(故障位17~32)
|
||
uint16_t third_level_fault_33_to_48; // 三级故障(故障位33~48)
|
||
uint16_t third_level_fault_49_to_64; // 三级故障(故障位49~64)
|
||
uint16_t bcu_state_machine; // BCU状态机
|
||
uint16_t charging_status; // 充电状态
|
||
uint16_t discharging_status; // 放电状态
|
||
uint16_t high_voltage_closed_status; // 高压闭合状态
|
||
uint16_t fan_status; // 风扇状态
|
||
uint16_t total_alarm; // 总告警
|
||
uint16_t total_fault; // 总故障
|
||
uint16_t bcu_address; // BCU地址
|
||
uint16_t bcu_main_loop_status; // BCU主回路状态
|
||
uint16_t bcu_loop_closed_command; // BCU回路闭合指令
|
||
uint16_t bcu_allowed_to_close_main_loop; // BCU是否允许闭合主回路
|
||
};
|
||
};
|
||
#endif // MAINWINDOW_H
|