#ifndef WORK_THREAD_H
|
#define WORK_THREAD_H
|
|
#include <QDateTime>
|
#include <QTimer>
|
#include <qthread.h>
|
#include <QDir>
|
#include "Drivers/rs485_driver.h"
|
#include "data_define.h"
|
#include "Drivers/module_drv.h"
|
#include "Drivers/LoRaCell.h"
|
#include "check_obj.h"
|
#include "Drivers/rs485_wired_cell.h"
|
|
const QString DATA_ROOT_DIR = dataDir;
|
|
#define CapType_Rest 0
|
#define CapType_Sum 1
|
#define CapType_Percent 2
|
|
class Work_Thread : public QThread
|
{
|
Q_OBJECT
|
|
public:
|
Work_Thread();
|
virtual void run();
|
~Work_Thread();
|
public:
|
static const int CMD_StartDischarge = 1;
|
static const int CMD_PauseDischarge = 2;
|
static const int CMD_StopDischarge = 3;
|
static const int CMD_StartCharge = 4;
|
static const int CMD_PauseCharge = 5;
|
static const int CMD_StopCharge = 6;
|
static const int CMD_Adj_StartDis = 7;
|
static const int CMD_Adj_StopDis = 8;
|
static const int CMD_Adj_StartChr = 9;
|
static const int CMD_Adj_StopChr = 10;
|
static const int CMD_StartFanWork = 11;
|
static const int CMD_PowerSwithOn = 12;
|
static const int CMD_PowerSwithOff = 13;
|
static const int CMD_StopFanWork = 14;
|
|
static const int CMD_SetMonomerAddr = 21;
|
static const int CMD_SetMonomerFre = 22;
|
static const int CMD_SetMadjIndex = 23;
|
static const int CMD_SetMonomerAdj = 24;
|
|
static const int CMD_SetIntCurrZero = 31;
|
static const int CMD_SetIntCurrSlope = 32;
|
static const int CMD_SetExtCurrZero = 33;
|
static const int CMD_SetExtCurrSlope = 34;
|
static const int CMD_SetOnlineVolSlope = 35;
|
static const int CMD_SetGroupVolSlope = 36;
|
|
static const int CMD_ReadSysConfInfo = 41;
|
static const int CMD_SetSysConfInfo = 42;
|
|
static const int CMD_ChargeNull = 43;
|
static const int CMD_ChargeRLYON = 44;
|
static const int CMD_ChargeRLYOFF = 45;
|
|
//校准1
|
static const int CMD_SetOnlVolZero = 50;
|
static const int CMD_SetOnlVolSlope = 51;
|
static const int CMD_SetGrpVolZero = 52;
|
static const int CMD_SetGrpVolSlope = 53;
|
static const int CMD_SetDisCurrZero = 54;
|
static const int CMD_SetDisCurrSlope = 55;
|
static const int CMD_SetChrCurrZero = 56;
|
static const int CMD_SetChrCurrSlope = 57;
|
static const int CMD_SetECurrZero = 58;
|
static const int CMD_SetECurrSlope = 59;
|
static const int CMD_SetDisCur = 60;
|
static const int CMD_SetChrCur = 61;
|
static const int CMD_StartZCharge = 66;
|
|
public:
|
FBO_DATA fboData;
|
LOCAL_DATA localData;
|
ICON_STATE iconState;
|
SYS_PARAM sysParam;
|
void initWorkPageShow(void);
|
void enterpage_init();
|
void PauseWorkThread(void);
|
void StartWorkThread(void);
|
bool CheckDiskState(const QString &disk);
|
SYS_State GetSysState(void);
|
RS485Driver *rs485;
|
QString battName;
|
CT_DATE_TIME getTestFileTime();
|
CT_DATE_TIME testStartTime;
|
bool openWorkPage;
|
QString testFileName;
|
TEST_PARAM_XML testParam;
|
|
bool if_cn; //true 中文 false 英文
|
bool IF_J9Close;
|
bool CheckFain(void);
|
bool Check_Mashine_Type;
|
|
void continuetest(CHECK_DATA check_data, FBO_DATA fbo_data);
|
void set_app_checkcount();
|
void setPowerCtrl(quint16);
|
void WriteEndFile(QString filename, FBO_DATA);
|
void delay_ms(quint16 time);
|
void set_ifinit(bool);
|
|
bool adj_mon_vol(int cmd, int num, int num2);
|
void set_readmode(int);
|
void set_addrsingle(int addr);
|
QString get_loraversion();
|
void getmodulevol(void *data);
|
void GetBattVolData(void *data);
|
int ctrlJDQ();
|
quint8 get_DCDC_count();
|
|
quint8 get_mon_source();
|
quint8 DATAVERSION;
|
|
private:
|
bool WORK_RUN_EN;
|
//RS485Driver *rs485;
|
|
quint8 Adj_TestState;
|
|
|
ADJ_PARAM_XML adjParam;
|
QTimer *timer_1s;
|
|
SYS_State sysState;
|
|
quint16 PowerCtrl;
|
quint16 PWM_Ctrl;
|
quint16 chargeChangeCurr;
|
|
quint16 monomerLowCount;
|
quint16 sumVOL[4];
|
quint16 SingleVolBuff[MONOMER_NUM_MAX];
|
|
int MaxCur;//A
|
int MaxPOWER;//KW*10
|
|
ModuleDrv *nrf905module;
|
LORACELL *lora;
|
|
RS485_WIRED *rs485wired;
|
|
quint8 mon_source;//0 IO单体 3 有线单体
|
void mon_source_distinguish();
|
|
// quint16 AdjCurParam;
|
int if_steady;
|
|
int delayupdate;
|
quint16 work_preset_cur;//放电电流参数赋值
|
quint8 DCDC_count;
|
quint8 nullChargingState;
|
|
private:
|
void ShowPageData(void);
|
QString format_data_name(void);
|
|
void initTest(const quint8 type);
|
|
int OpenDischargePower();
|
int CloseDischargePower(const quint8 workstate);
|
void StartTestingFrom();
|
void ResumeTestingFrom();
|
void SuspendTesting(const quint8 pausetype);
|
void StopTesting(const quint8 stoptype);
|
|
void StartChargeTest(const quint8 workstate);
|
void ResumeChargeFrom(const quint8 workstate);
|
void SuspendChargeTest(const quint8 pausetype);
|
int OpenChargePower(quint8 workstate);
|
int CloseChargePower(const quint8 workstate);
|
|
quint16 getMonomerLowCount(void);
|
void AnalyseRecvData(void);
|
|
void CheckIfStop(void);
|
void CheckIfStop_Dispause();
|
void UpdateState(void);
|
void ControlDisCur();
|
void ControlDisCurGDTQ_ONE(quint16 setcurrent);
|
void ControlDisCurGDTQ_TWO(quint16 setcurrent);
|
void ControlDisCurGDTQ_THREE(quint16 setcurrent);
|
void ControlDisCurGDTQ_FIVE(quint16 setcurrent);
|
|
void CheckChargeAlarm(void);
|
void CheckChargeAlarm_Pause();
|
|
void CheckIconState(void);
|
bool CheckMonomerExist(void);
|
|
double N_TO_10H(int n_H);
|
double GetMonomerCap(double STDAH, int HourRate, double SumAH, double MaxMonomerVol,
|
double MonomerVol, double MonomerVolType, int CapType);
|
|
void CalRemainData(void);
|
void CalResData(void);
|
void ClearRemainData(void);
|
void initparam();
|
void IF_USEloader(bool en);
|
void ReadIOParam();
|
|
bool IF_SET905ok;
|
void Set905Param(void);
|
void CPControlChargeCurrent2415();
|
void CPControlChargeCurrent4815();
|
void CPControlChargeCurrent4830();
|
void ControlChargeCurrent60010();
|
void CPControlChargeCurrent10480();
|
double GetChargeLimitCurrent(void);
|
void CPControlAdj10480();
|
|
void CPControlChargeCurrent10480_240V();
|
void CPControlAdj10480_240V();
|
|
int check_count;/*调用4次*/
|
bool if_need_init;
|
void SaveContinueFile();/*五个地方调用 充放电启动、暂停、停止时调用*/
|
void APP_check();/*run里调用*/
|
void setIOboardState();
|
int ctrlJDQ_other();
|
int ctrlJDQ_940();
|
|
signals:
|
void SendThreadState(int,int);
|
void SendSysconfInfo(SYS_CONFIG);
|
void SentInterface(int);
|
void sendMgBox(quint8);
|
void sendAddrFreResult(int,int);
|
public slots:
|
void RecvCommData(COMM_DATA dt);
|
void RecvSysCtrlCMD(int,QString);
|
void RecvSysConfCMD(int, SYS_CONFIG);
|
void RecvCurrAdjCMD(int,int);
|
void RecvTestParam(TEST_PARAM_XML);
|
void Timer1s_timeout(void);
|
void RecvSysParam(SYS_PARAM);
|
void RecvAdjParam(ADJ_PARAM_XML);
|
void RecvAdjCmd(int, quint16);
|
void RecvSysAddrFre(int cmd,int param);
|
|
void RecvInterface(int inter);
|
void RecvNRF905Data(N905_MODULE_DATA dt);
|
void RecvMonAddrandFre(int, quint16, quint16);
|
};
|
|
|
|
#endif // WORK_THREAD_H
|