1626 lines
41 KiB
C++
1626 lines
41 KiB
C++
#include "unitsimulator.h"
|
|
|
|
#include <QDebug>
|
|
#include "xlru_bytes_def.h"
|
|
#include "xlru_lcu.h"
|
|
|
|
uint8_t LCU_Status_byte[5] = {0, 0, 0, 0, 0};
|
|
uint8_t PPS_Status_byte[6] = {0, 0, 0, 0, 0, 0};
|
|
uint8_t PSM_Status_byte[4] = {0, 0, 0, 0};
|
|
|
|
//00000001 0x01
|
|
//00000010 0x02
|
|
//00000100 0x04
|
|
//00001000 0x08
|
|
//00010000 0x10
|
|
//00100000 0x20
|
|
//01000000 0x40
|
|
//10000000 0x80
|
|
|
|
//LSB
|
|
#define PSM_IN_AMP_LSB (double)0.1 //DC_BUS_CURRENT measure
|
|
#define PSM_OUT_VOLT_LSB (double)0.1 //5V, 3V3_int, 15V, -15V measure
|
|
#define PPS_CURR_LSB (double)0.1
|
|
|
|
struct comm_header_t //5
|
|
{
|
|
char som;
|
|
char unit;
|
|
char fcs;
|
|
char comm_status;
|
|
char msg_id;
|
|
|
|
} __attribute__((packed));
|
|
|
|
//************************************
|
|
//PSM
|
|
struct psm_status_body_t
|
|
{
|
|
comm_header_t header; //non corrisponde con la definizione pag 21, documento TNXXXXXX GRIFO-E PSM IDD Rev.0_Draft1.docx
|
|
char sts;
|
|
char hazard;
|
|
char fast;
|
|
char wow;
|
|
char ac;
|
|
char bs;
|
|
char dc;
|
|
char pfc;
|
|
char out_rail[4];
|
|
char in_amp[2];
|
|
char volts[4][4];
|
|
char temperature[2];
|
|
char eti[4];
|
|
char counter[4];
|
|
char sw_major[2];
|
|
char sw_minor[2];
|
|
char unc_counter[2];
|
|
char byte4[2];
|
|
char byte3[2];
|
|
char byte2[2];
|
|
char byte1[2];
|
|
//char spare1[2];
|
|
char last_recycle;
|
|
char last_recycle_reason;
|
|
//char spare1; //55
|
|
|
|
} __attribute__((packed));
|
|
|
|
//************************************
|
|
//PPS
|
|
struct pps_status_body_t
|
|
{
|
|
comm_header_t header; //5
|
|
char sts;
|
|
char health;
|
|
char wow;
|
|
char hazard;
|
|
char current_limit;
|
|
char hold_up_status[2];
|
|
char rx_board[2];
|
|
char tx1_board[2];
|
|
char tx2_board[2];
|
|
char tx3_board[2];
|
|
char general[2];
|
|
char rx_version[2];
|
|
char rx_release[2];
|
|
char tx1_version[2];
|
|
char tx1_release[2];
|
|
char tx2_version[2];
|
|
char tx2_release[2];
|
|
char tx3_version[2];
|
|
char tx3_release[2];
|
|
char rx_temp[2];
|
|
char tx1_temp[2];
|
|
char tx2_temp[2];
|
|
char tx3_temp[2];
|
|
char inlet_temp[2];
|
|
char outlet_temp[2];
|
|
char curr[2]; //52
|
|
char tx1_curr[2]; //54
|
|
char tx2_curr[2]; //56
|
|
char tx3_curr[2]; //58
|
|
char tx1_curr_max[2]; //60
|
|
char tx2_curr_max[2]; //62
|
|
char tx3_curr_max[2]; //64
|
|
char tx1_curr_avg[2]; //66
|
|
char tx2_curr_avg[2]; //68
|
|
char tx3_curr_avg[2]; //70
|
|
char rx_phaseR_min[2]; //72
|
|
char rx_phaseS_min[2]; //74
|
|
char rx_phaseT_min[2]; //76
|
|
char rx_phaseR_max[2]; //78
|
|
char rx_phaseS_max[2]; //80
|
|
char rx_phaseT_max[2]; //82
|
|
char spare1[2]; //84
|
|
|
|
} __attribute__((packed));
|
|
|
|
//************************************
|
|
//LCU
|
|
struct lcu_status_body_t
|
|
{
|
|
comm_header_t header; //5
|
|
char sts;
|
|
char bit;
|
|
char bypass;
|
|
char health;
|
|
char hazard;
|
|
char spare1[2];
|
|
char spare2[2];
|
|
char byte1[2];
|
|
char byte2[2];
|
|
char byte3[2];
|
|
char byte4[2];
|
|
char byte5[2];
|
|
char board_temp[2];
|
|
char mts[2];
|
|
char mfs[2];
|
|
char ts1[2];
|
|
char ts2[2];
|
|
char ts3[2];
|
|
char ts4[2];
|
|
char ts5[2];
|
|
char ts6[2];
|
|
char spare3[2];
|
|
char fs1[2];
|
|
char fs2[2];
|
|
char ps[2];
|
|
char spare4[2];
|
|
char ver[2];
|
|
char rel[2];
|
|
char override;
|
|
char spare5;
|
|
char spare6[2]; //60
|
|
|
|
} __attribute__((packed));
|
|
|
|
//************************************
|
|
//LCU
|
|
struct lcu_eti_body_t
|
|
{
|
|
comm_header_t header; //5
|
|
char spare1[2];
|
|
char spare2[2];
|
|
char spare3[2];
|
|
char eti[6];
|
|
char spare4[2]; //14
|
|
} __attribute__((packed));
|
|
|
|
|
|
template<typename T_, unsigned int S_> struct lru_generic_message_t
|
|
{
|
|
typedef T_ payload_t;
|
|
enum { payload_size=sizeof(T_)};
|
|
|
|
union msg_union_t {
|
|
struct msg_raw_t {
|
|
char d[payload_size];
|
|
} raw;
|
|
T_ sts;
|
|
} payload;
|
|
char checksum[2]; //2
|
|
char eom; //1
|
|
|
|
//Payload size check
|
|
static_assert(payload_size>=(S_+5), "payload too small");
|
|
static_assert(payload_size<=(S_+5), "payload too big");
|
|
} __attribute__((packed));
|
|
|
|
template<typename T_> void checksum(char* r, const T_& msg)
|
|
{
|
|
unsigned int size=sizeof msg;
|
|
unsigned int chk=0;
|
|
const unsigned char* p=reinterpret_cast<const unsigned char*>(&msg);
|
|
for(unsigned int i=0; i<size; ++i)
|
|
{
|
|
unsigned int tmp=p[i];
|
|
chk+=tmp & 0x0FF;
|
|
}
|
|
chk=chk & 0x00FF;
|
|
r[0]="0123456789ABCDEF"[chk>>4];
|
|
r[1]="0123456789ABCDEF"[chk & 0x0F];
|
|
}
|
|
|
|
static lru_generic_message_t<psm_status_body_t, 56> psm_status;
|
|
static lru_generic_message_t<pps_status_body_t, 79> pps_status;
|
|
static lru_generic_message_t<lcu_status_body_t, 55> lcu_status;
|
|
static lru_generic_message_t<lcu_eti_body_t, 14> lcu_eti;
|
|
|
|
static char last_fcs;
|
|
static char last_unit;
|
|
|
|
static void psm_init()
|
|
{
|
|
memset(&psm_status, STATUS_SPARE, sizeof psm_status);
|
|
|
|
psm_status.payload.sts.header.som=SOM_REPLY;
|
|
psm_status.payload.sts.header.unit='1';
|
|
psm_status.payload.sts.header.fcs='a';
|
|
psm_status.payload.sts.header.comm_status=ACK_NO_ERROR;
|
|
psm_status.payload.sts.header.msg_id='S';
|
|
|
|
psm_status.payload.sts.sts='G';
|
|
psm_status.payload.sts.hazard='N';
|
|
psm_status.payload.sts.fast='c';
|
|
psm_status.payload.sts.wow='w';
|
|
psm_status.payload.sts.ac='A';
|
|
psm_status.payload.sts.bs='N';
|
|
psm_status.payload.sts.dc='N';
|
|
psm_status.payload.sts.pfc='N';
|
|
psm_status.payload.sts.out_rail[0]='N';
|
|
psm_status.payload.sts.out_rail[1]='N';
|
|
psm_status.payload.sts.out_rail[2]='N';
|
|
psm_status.payload.sts.out_rail[3]='N';
|
|
psm_status.payload.sts.last_recycle = '_';
|
|
|
|
memset(psm_status.payload.sts.in_amp, '0', sizeof(psm_status.payload.sts.in_amp));
|
|
memset(psm_status.payload.sts.volts, '0', sizeof(psm_status.payload.sts.volts));
|
|
memset(psm_status.payload.sts.temperature, '0', sizeof(psm_status.payload.sts.temperature));
|
|
memset(psm_status.payload.sts.eti, '0', sizeof(psm_status.payload.sts.eti));
|
|
memset(psm_status.payload.sts.counter, '0', sizeof(psm_status.payload.sts.counter));
|
|
memset(psm_status.payload.sts.sw_major, '0', sizeof(psm_status.payload.sts.sw_major));
|
|
memset(psm_status.payload.sts.sw_minor, '0', sizeof(psm_status.payload.sts.sw_minor));
|
|
memset(psm_status.payload.sts.unc_counter, '0', sizeof(psm_status.payload.sts.unc_counter));
|
|
memset(psm_status.payload.sts.byte1, '0', sizeof(psm_status.payload.sts.byte1));
|
|
memset(psm_status.payload.sts.byte2, '0', sizeof(psm_status.payload.sts.byte2));
|
|
memset(psm_status.payload.sts.byte3, '0', sizeof(psm_status.payload.sts.byte3));
|
|
memset(psm_status.payload.sts.byte4, '0', sizeof(psm_status.payload.sts.byte4));
|
|
|
|
checksum(psm_status.checksum, psm_status.payload.raw);
|
|
|
|
psm_status.eom='\r';
|
|
|
|
qDebug()<<"PSM payload size="<<psm_status.payload_size;
|
|
}
|
|
|
|
static void pps_init()
|
|
{
|
|
memset(&pps_status, STATUS_SPARE, sizeof pps_status);
|
|
|
|
pps_status.payload.sts.header.som=SOM_REPLY;
|
|
pps_status.payload.sts.header.unit='1';
|
|
pps_status.payload.sts.header.fcs='a';
|
|
pps_status.payload.sts.header.comm_status=ACK_NO_ERROR;
|
|
pps_status.payload.sts.header.msg_id='S';
|
|
|
|
pps_status.payload.sts.sts='G';
|
|
pps_status.payload.sts.health='G';
|
|
pps_status.payload.sts.wow='w';
|
|
pps_status.payload.sts.hazard='_';
|
|
pps_status.payload.sts.current_limit='_';
|
|
|
|
pps_status.payload.sts.hold_up_status[0] = '0';
|
|
pps_status.payload.sts.hold_up_status[1] = '0';
|
|
pps_status.payload.sts.rx_board[0] = '0';
|
|
pps_status.payload.sts.rx_board[1] = '0';
|
|
pps_status.payload.sts.tx1_board[0] = '0';
|
|
pps_status.payload.sts.tx1_board[1] = '0';
|
|
pps_status.payload.sts.tx2_board[0] = '0';
|
|
pps_status.payload.sts.tx2_board[1] = '0';
|
|
pps_status.payload.sts.tx3_board[0] = '0';
|
|
pps_status.payload.sts.tx3_board[1] = '0';
|
|
pps_status.payload.sts.general[0] = '0';
|
|
pps_status.payload.sts.general[1] = '0';
|
|
|
|
|
|
pps_status.payload.sts.rx_version[0] = '0';
|
|
pps_status.payload.sts.rx_version[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_release[0] = '0';
|
|
pps_status.payload.sts.rx_release[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_version[0] = '0';
|
|
pps_status.payload.sts.tx1_version[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_release[0] = '0';
|
|
pps_status.payload.sts.tx1_release[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_version[0] = '0';
|
|
pps_status.payload.sts.tx2_version[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_release[0] = '0';
|
|
pps_status.payload.sts.tx2_release[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_version[0] = '0';
|
|
pps_status.payload.sts.tx3_version[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_release[0] = '0';
|
|
pps_status.payload.sts.tx3_release[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_temp[0] = '0';
|
|
pps_status.payload.sts.rx_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_temp[0] = '0';
|
|
pps_status.payload.sts.tx1_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_temp[0] = '0';
|
|
pps_status.payload.sts.tx2_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_temp[0] = '0';
|
|
pps_status.payload.sts.tx3_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.inlet_temp[0] = '0';
|
|
pps_status.payload.sts.inlet_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.outlet_temp[0] = '0';
|
|
pps_status.payload.sts.outlet_temp[1] = '0';
|
|
|
|
pps_status.payload.sts.curr[0] = '0';
|
|
pps_status.payload.sts.curr[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_curr[0] = '0';
|
|
pps_status.payload.sts.tx1_curr[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_curr[0] = '0';
|
|
pps_status.payload.sts.tx2_curr[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_curr[0] = '0';
|
|
pps_status.payload.sts.tx3_curr[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_curr_max[0] = '0';
|
|
pps_status.payload.sts.tx1_curr_max[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_curr_max[0] = '0';
|
|
pps_status.payload.sts.tx2_curr_max[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_curr_max[0] = '0';
|
|
pps_status.payload.sts.tx3_curr_max[1] = '0';
|
|
|
|
pps_status.payload.sts.tx1_curr_avg[0] = '0';
|
|
pps_status.payload.sts.tx1_curr_avg[1] = '0';
|
|
|
|
pps_status.payload.sts.tx2_curr_avg[0] = '0';
|
|
pps_status.payload.sts.tx2_curr_avg[1] = '0';
|
|
|
|
pps_status.payload.sts.tx3_curr_avg[0] = '0';
|
|
pps_status.payload.sts.tx3_curr_avg[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseR_min[0] = '0';
|
|
pps_status.payload.sts.rx_phaseR_min[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseS_min[0] = '0';
|
|
pps_status.payload.sts.rx_phaseS_min[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseT_min[0] = '0';
|
|
pps_status.payload.sts.rx_phaseT_min[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseR_max[0] = '0';
|
|
pps_status.payload.sts.rx_phaseR_max[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseS_max[0] = '0';
|
|
pps_status.payload.sts.rx_phaseS_max[1] = '0';
|
|
|
|
pps_status.payload.sts.rx_phaseT_max[0] = '0';
|
|
pps_status.payload.sts.rx_phaseT_max[1] = '0';
|
|
|
|
checksum(pps_status.checksum, pps_status.payload.raw);
|
|
|
|
pps_status.eom='\r';
|
|
|
|
qDebug()<<"PPS payload size="<<pps_status.payload_size;
|
|
}
|
|
|
|
static void lcu_init()
|
|
{
|
|
memset(&lcu_status, STATUS_SPARE, sizeof lcu_status);
|
|
|
|
lcu_status.payload.sts.header.som=SOM_REPLY;
|
|
lcu_status.payload.sts.header.unit='3';
|
|
lcu_status.payload.sts.header.fcs='a';
|
|
lcu_status.payload.sts.header.comm_status=ACK_NO_ERROR;
|
|
lcu_status.payload.sts.header.msg_id='s';
|
|
|
|
lcu_status.payload.sts.sts='G';
|
|
lcu_status.payload.sts.bit='_';
|
|
lcu_status.payload.sts.bypass='_';
|
|
lcu_status.payload.sts.health='G';
|
|
lcu_status.payload.sts.hazard='_';
|
|
|
|
lcu_status.payload.sts.ts1[0] = '0';
|
|
lcu_status.payload.sts.ts1[1] = '0';
|
|
lcu_status.payload.sts.ts2[0] = '0';
|
|
lcu_status.payload.sts.ts2[1] = '0';
|
|
lcu_status.payload.sts.ts3[0] = '0';
|
|
lcu_status.payload.sts.ts3[1] = '0';
|
|
lcu_status.payload.sts.ts4[0] = '0';
|
|
lcu_status.payload.sts.ts4[1] = '0';
|
|
lcu_status.payload.sts.ts5[0] = '0';
|
|
lcu_status.payload.sts.ts5[1] = '0';
|
|
lcu_status.payload.sts.ts6[0] = '0';
|
|
lcu_status.payload.sts.ts6[1] = '0';
|
|
|
|
lcu_status.payload.sts.board_temp[0] = '0';
|
|
lcu_status.payload.sts.board_temp[1] = '0';
|
|
|
|
lcu_status.payload.sts.mts[0] = '0';
|
|
lcu_status.payload.sts.mts[1] = '0';
|
|
|
|
lcu_status.payload.sts.mfs[0] = '0';
|
|
lcu_status.payload.sts.mfs[1] = '0';
|
|
|
|
lcu_status.payload.sts.fs1[0] = '0';
|
|
lcu_status.payload.sts.fs1[1] = '0';
|
|
|
|
lcu_status.payload.sts.fs2[0] = '0';
|
|
lcu_status.payload.sts.fs2[1] = '0';
|
|
|
|
lcu_status.payload.sts.ps[0] = '0';
|
|
lcu_status.payload.sts.ps[1] = '0';
|
|
|
|
lcu_status.payload.sts.byte1[0] = '0';
|
|
lcu_status.payload.sts.byte1[1] = '0';
|
|
lcu_status.payload.sts.byte2[0] = '0';
|
|
lcu_status.payload.sts.byte2[1] = '0';
|
|
lcu_status.payload.sts.byte3[0] = '0';
|
|
lcu_status.payload.sts.byte3[1] = '0';
|
|
lcu_status.payload.sts.byte4[0] = '0';
|
|
lcu_status.payload.sts.byte4[1] = '0';
|
|
lcu_status.payload.sts.byte5[0] = '0';
|
|
lcu_status.payload.sts.byte5[1] = '0';
|
|
|
|
lcu_status.payload.sts.ver[0] = '0';
|
|
lcu_status.payload.sts.ver[1] = '0';
|
|
lcu_status.payload.sts.rel[0] = '0';
|
|
lcu_status.payload.sts.rel[1] = '0';
|
|
lcu_status.payload.sts.override = '_';
|
|
|
|
checksum(lcu_status.checksum, lcu_status.payload.raw);
|
|
|
|
lcu_status.eom='\r';
|
|
|
|
qDebug()<<"LCU payload size="<<lcu_status.payload_size;
|
|
|
|
|
|
lcu_eti.payload.sts.header.som=SOM_REPLY;
|
|
lcu_eti.payload.sts.header.unit='3';
|
|
lcu_eti.payload.sts.header.fcs='a';
|
|
lcu_eti.payload.sts.header.comm_status=ACK_NO_ERROR;
|
|
lcu_eti.payload.sts.header.msg_id='s';
|
|
|
|
lcu_eti.payload.sts.spare1[0] = '0';
|
|
lcu_eti.payload.sts.spare1[1] = '0';
|
|
lcu_eti.payload.sts.spare2[0] = '0';
|
|
lcu_eti.payload.sts.spare2[1] = '0';
|
|
lcu_eti.payload.sts.spare3[0] = '0';
|
|
lcu_eti.payload.sts.spare3[1] = '0';
|
|
|
|
lcu_eti.payload.sts.eti[0] = '0';
|
|
lcu_eti.payload.sts.eti[1] = '0';
|
|
lcu_eti.payload.sts.eti[2] = '0';
|
|
lcu_eti.payload.sts.eti[3] = '0';
|
|
lcu_eti.payload.sts.eti[4] = '0';
|
|
lcu_eti.payload.sts.eti[5] = '0';
|
|
|
|
lcu_eti.payload.sts.spare4[0] = '0';
|
|
lcu_eti.payload.sts.spare4[1] = '0';
|
|
|
|
checksum(lcu_eti.checksum, lcu_eti.payload.raw);
|
|
|
|
lcu_eti.eom='\r';
|
|
|
|
qDebug()<<"LCU ETI payload size="<<lcu_eti.payload_size;
|
|
|
|
|
|
}
|
|
|
|
int8_t check_temp(int16_t n)
|
|
{
|
|
if(n > 128)
|
|
return 128;
|
|
else if(n < -127)
|
|
return -127;
|
|
else
|
|
return n;
|
|
}
|
|
|
|
UnitSimulator::UnitSimulator(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
psm_init();
|
|
pps_init();
|
|
lcu_init();
|
|
}
|
|
|
|
|
|
void processChange(int t, char byte1[2])
|
|
{
|
|
char tmp[3] = { 0 };
|
|
|
|
t = check_temp(t);
|
|
|
|
snprintf(tmp, 3, "%02X", (uint8_t)t);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
}
|
|
|
|
void processChangeETI(int t, char byte1[6])
|
|
{
|
|
char tmp[7] = { 0 };
|
|
|
|
//t = check_temp(t);
|
|
|
|
snprintf(tmp, 7, "%06X", (uint32_t)t);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
byte1[2] = tmp[2];
|
|
byte1[3] = tmp[3];
|
|
byte1[4] = tmp[4];
|
|
byte1[5] = tmp[5];
|
|
}
|
|
|
|
void processChangeLsb(double t, char byte1[2], float lsb)
|
|
{
|
|
char tmp[3] = { 0 };
|
|
|
|
t = t / lsb;
|
|
|
|
int new_t = (int)(t + 0.5);
|
|
//t = check_temp(t);
|
|
|
|
snprintf(tmp, 3, "%02X", (uint8_t)new_t);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
}
|
|
|
|
void processChange4(int t, char byte1[4])
|
|
{
|
|
char tmp[5] = { 0 };
|
|
|
|
t = check_temp(t);
|
|
|
|
snprintf(tmp, 5, "%04X", t);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
byte1[2] = tmp[2];
|
|
byte1[3] = tmp[3];
|
|
}
|
|
|
|
|
|
int UnitSimulator::checkMessage(const QByteArray& data)
|
|
{
|
|
static QByteArray accumulator;
|
|
const char* p=data.constData();
|
|
int n=data.size();
|
|
int unit=0;
|
|
|
|
for(int i=0; i<n; ++i)
|
|
{
|
|
if (p[i]==SOM)
|
|
{
|
|
accumulator.clear();
|
|
}
|
|
accumulator.append(p[i]);
|
|
if (p[i]=='\r')
|
|
{
|
|
if (accumulator.size()>4)
|
|
{
|
|
const char* m=accumulator.constData();
|
|
if (m[0]==SOM)
|
|
{
|
|
char u=m[1];
|
|
unit=u-'0';
|
|
if ((unit<0) || (unit>3))
|
|
unit=0;
|
|
last_fcs=m[2];
|
|
last_unit=u;
|
|
|
|
pendingMessage=accumulator;
|
|
|
|
if (u=='1')
|
|
{
|
|
Q_EMIT psmCommand(QString("%1").arg(m[5]));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
accumulator.clear();
|
|
}
|
|
}
|
|
if (accumulator.size()>512)
|
|
accumulator.clear();
|
|
return unit;
|
|
}
|
|
|
|
int UnitSimulator::get_type_mess(const QByteArray& data)
|
|
{
|
|
static QByteArray accumulator;
|
|
const char* p=data.constData();
|
|
int n=data.size();
|
|
int type_mess=0;
|
|
|
|
for(int i=0; i<n; ++i)
|
|
{
|
|
if (p[i]==SOM)
|
|
{
|
|
accumulator.clear();
|
|
}
|
|
accumulator.append(p[i]);
|
|
if (p[i]=='\r')
|
|
{
|
|
if (accumulator.size()>4)
|
|
{
|
|
const char* m=accumulator.constData();
|
|
if (m[0]==SOM)
|
|
{
|
|
|
|
if (m[4]=='T' || m[4]=='t')
|
|
type_mess = 1;
|
|
|
|
pendingMessage=accumulator;
|
|
break;
|
|
}
|
|
}
|
|
accumulator.clear();
|
|
}
|
|
}
|
|
if (accumulator.size()>512)
|
|
accumulator.clear();
|
|
return type_mess;
|
|
}
|
|
|
|
QByteArray UnitSimulator::genPSMStatus() const
|
|
{
|
|
psm_status.payload.sts.header.fcs=last_fcs;
|
|
psm_status.payload.sts.header.unit=last_unit;
|
|
checksum(psm_status.checksum, psm_status.payload.raw);
|
|
|
|
QByteArray d(&psm_status.payload.raw.d[0], sizeof psm_status);
|
|
qDebug()<<"SIM"<<d;
|
|
return d;
|
|
}
|
|
|
|
QByteArray UnitSimulator::genLCUStatus() const
|
|
{
|
|
lcu_status.payload.sts.header.fcs=last_fcs;
|
|
lcu_status.payload.sts.header.unit=last_unit;
|
|
checksum(lcu_status.checksum, lcu_status.payload.raw);
|
|
|
|
QByteArray d(&lcu_status.payload.raw.d[0], sizeof lcu_status);
|
|
qDebug()<<"SIM"<<d;
|
|
return d;
|
|
}
|
|
|
|
QByteArray UnitSimulator::genLCUEti() const
|
|
{
|
|
lcu_eti.payload.sts.header.fcs=last_fcs;
|
|
lcu_eti.payload.sts.header.unit=last_unit;
|
|
lcu_eti.payload.sts.header.msg_id = 't';
|
|
checksum(lcu_eti.checksum, lcu_eti.payload.raw);
|
|
|
|
QByteArray d(&lcu_eti.payload.raw.d[0], sizeof lcu_eti);
|
|
qDebug()<<"SIM"<<d;
|
|
return d;
|
|
}
|
|
|
|
QByteArray UnitSimulator::genPPSStatus() const
|
|
{
|
|
pps_status.payload.sts.header.fcs=last_fcs;
|
|
pps_status.payload.sts.header.unit=last_unit;
|
|
checksum(pps_status.checksum, pps_status.payload.raw);
|
|
|
|
QByteArray d(&pps_status.payload.raw.d[0], sizeof pps_status);
|
|
qDebug()<<"SIM"<<d;
|
|
return d;
|
|
}
|
|
|
|
QByteArray UnitSimulator::psmStatus() const
|
|
{
|
|
return genPSMStatus();
|
|
}
|
|
|
|
QByteArray UnitSimulator::ppsStatus() const
|
|
{
|
|
return genPPSStatus();
|
|
}
|
|
|
|
QByteArray UnitSimulator::lcuStatus() const
|
|
{
|
|
return genLCUStatus();
|
|
}
|
|
|
|
QByteArray UnitSimulator::lcuEti() const
|
|
{
|
|
return genLCUEti();
|
|
}
|
|
|
|
|
|
void UnitSimulator::pmsGo(bool go)
|
|
{
|
|
psm_status.payload.sts.sts=go ? 'G' : 'N';
|
|
}
|
|
|
|
//*******************************************************************
|
|
//LCU
|
|
|
|
void UnitSimulator::cdLCUModeStatus(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.sts = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cdLCUProgress(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.bit = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cdLCUHealth(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.health = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cdLCUByPass(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.bypass = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cdLCUHazard(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.hazard = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cdLCUOverride(const QString &t)
|
|
{
|
|
lcu_status.payload.sts.override = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::dsbTS1(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts1 );
|
|
}
|
|
|
|
void UnitSimulator::dsbTS2(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts2 );
|
|
}
|
|
|
|
void UnitSimulator::dsbTS3(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts3 );
|
|
}
|
|
|
|
void UnitSimulator::dsbTS4(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts4 );
|
|
}
|
|
|
|
void UnitSimulator::dsbTS5(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts5 );
|
|
}
|
|
|
|
void UnitSimulator::dsbTS6(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ts6 );
|
|
}
|
|
|
|
void UnitSimulator::dsbBoardTemp(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.board_temp );
|
|
}
|
|
|
|
|
|
void UnitSimulator::dsbMTS(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.mts );
|
|
}
|
|
|
|
void UnitSimulator::dsbMFS(int t)
|
|
{
|
|
processChangeLsb(t,lcu_status.payload.sts.mfs , LCU_MOTOR_VEL_LSB);
|
|
}
|
|
|
|
void UnitSimulator::dsbFS1(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.fs1 );
|
|
}
|
|
|
|
void UnitSimulator::dsbFS2(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.fs2 );
|
|
}
|
|
|
|
void UnitSimulator::dsbPS(double t)
|
|
{
|
|
processChangeLsb(t,lcu_status.payload.sts.ps, LCU_LIQUID_OUTLET_PRESSURE_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbLCURelease(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.rel );
|
|
}
|
|
|
|
void UnitSimulator::sbLCUVersion(int t)
|
|
{
|
|
processChange(t,lcu_status.payload.sts.ver );
|
|
}
|
|
|
|
void UnitSimulator::sbLCUETI(int t)
|
|
{
|
|
processChangeETI(t,lcu_eti.payload.sts.eti );
|
|
}
|
|
|
|
|
|
void cbMgnLCU(int t, int idxByte, uint8_t flag, char byte1[2])
|
|
{
|
|
if (t==0)
|
|
LCU_Status_byte[idxByte] &= ~flag;
|
|
else
|
|
LCU_Status_byte[idxByte] |= flag;
|
|
|
|
char tmp[3] = { 0 };
|
|
|
|
snprintf(tmp, 3, "%02X", LCU_Status_byte[idxByte]);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
}
|
|
|
|
void UnitSimulator::cbLCU11(int t)
|
|
{
|
|
cbMgnLCU(t, 0, Bit_PhaseA_failure, lcu_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU12(int t)
|
|
{
|
|
cbMgnLCU(t, 0, Bit_PhaseB_failure, lcu_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU13(int t)
|
|
{
|
|
cbMgnLCU(t, 0, Bit_PhaseC_failure, lcu_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU14(int t)
|
|
{
|
|
cbMgnLCU(t, 0, Bit_Phase_Sequence_failure, lcu_status.payload.sts.byte1);
|
|
}
|
|
|
|
|
|
void UnitSimulator::cbLCU17(int t)
|
|
{
|
|
cbMgnLCU(t, 0, Bit_Pressure_Sensor_fail, lcu_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU21(int t)
|
|
{
|
|
cbMgnLCU(t, 1, Bit_Temperature_Hazard, lcu_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU22(int t)
|
|
{
|
|
cbMgnLCU(t, 1, Bit_Temperature_Warning, lcu_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU23(int t)
|
|
{
|
|
cbMgnLCU(t, 1, Bit_NVM_Access_Warning, lcu_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU24(int t)
|
|
{
|
|
cbMgnLCU(t, 1, Bit_Board_Error_failure, lcu_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU25(int t)
|
|
{
|
|
cbMgnLCU(t, 1, Bit_Link_failure, lcu_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU31(int t)
|
|
{
|
|
cbMgnLCU(t, 2, Bit_motor_speed_sensor_fail, lcu_status.payload.sts.byte3);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU32(int t)
|
|
{
|
|
cbMgnLCU(t, 2, Bit_motor_temperature_hazard2, lcu_status.payload.sts.byte3);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU33(int t)
|
|
{
|
|
cbMgnLCU(t, 2, Bit_motor_temperature_hazard, lcu_status.payload.sts.byte3);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU34(int t)
|
|
{
|
|
cbMgnLCU(t, 2, Bit_motor_failure, lcu_status.payload.sts.byte3);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU38(int t)
|
|
{
|
|
cbMgnLCU(t, 2, Bit_motor_temp_sensor_fail, lcu_status.payload.sts.byte3);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU41(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_temp_sensor_fail_AESA_TS1, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU42(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_temp_sensor_fail_PPS_TS2, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU43(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_temp_sensor_fail_Combo_TS3, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU44(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_outlet_temp_sensor_fail_TS4, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU45(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_air_temp_sensor_fail_TS5, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU46(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_outlet_air_temp_sensor_fail_TS6, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU47(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_flow_sensor_AESA_FS1, lcu_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbLCU48(int t)
|
|
{
|
|
cbMgnLCU(t, 3, Bit_inlet_flow_sensor_PPS_FS2, lcu_status.payload.sts.byte4);
|
|
}
|
|
|
|
void UnitSimulator::cbLCU51(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_filter_HE_warning, lcu_status.payload.sts.byte5);
|
|
}
|
|
void UnitSimulator::cbLCU52(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_AESA_Stream_warning, lcu_status.payload.sts.byte5);
|
|
}
|
|
void UnitSimulator::cbLCU53(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_PPS_Stream_warning, lcu_status.payload.sts.byte5);
|
|
}
|
|
//void cbLCU54(int t);
|
|
void UnitSimulator::cbLCU55(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_filter_HE_failure, lcu_status.payload.sts.byte5);
|
|
|
|
}
|
|
void UnitSimulator::cbLCU56(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_AESA_stream_failure, lcu_status.payload.sts.byte5);
|
|
|
|
}
|
|
void UnitSimulator::cbLCU57(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_Dirty_PPS_stream_failure, lcu_status.payload.sts.byte5);
|
|
}
|
|
void UnitSimulator::cbLCU58(int t)
|
|
{
|
|
cbMgnLCU(t, 4, Bit_By_Pass_failure, lcu_status.payload.sts.byte5);
|
|
|
|
}
|
|
|
|
//*****************************************************************
|
|
//PSM
|
|
|
|
void UnitSimulator::cdPSMModeStatus(const QString &t)
|
|
{
|
|
psm_status.payload.sts.sts = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMHazard(const QString &t)
|
|
{
|
|
psm_status.payload.sts.hazard = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSM3Sec(const QString &t)
|
|
{
|
|
psm_status.payload.sts.fast = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMWow(const QString &t)
|
|
{
|
|
psm_status.payload.sts.wow = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMAc(const QString &t)
|
|
{
|
|
psm_status.payload.sts.ac = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMbs(const QString &t)
|
|
{
|
|
psm_status.payload.sts.bs = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMdc(const QString &t)
|
|
{
|
|
psm_status.payload.sts.dc = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMpfc(const QString &t){
|
|
psm_status.payload.sts.pfc = (t.toLatin1().data())[0];
|
|
}
|
|
void UnitSimulator::cbPSMvolt3v3(const QString &t)
|
|
{
|
|
psm_status.payload.sts.out_rail[0] = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMvolt5(const QString &t)
|
|
{
|
|
psm_status.payload.sts.out_rail[1] = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMvolt12(const QString &t)
|
|
{
|
|
psm_status.payload.sts.out_rail[2] = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMvoltneg12(const QString &t)
|
|
{
|
|
psm_status.payload.sts.out_rail[3] = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPSMLastRecycle(const QString &t)
|
|
{
|
|
psm_status.payload.sts.last_recycle = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::editLastRecycleReasonFromEif(const QString &t)
|
|
{
|
|
if (t.isEmpty())
|
|
psm_status.payload.sts.last_recycle_reason = '_';
|
|
else
|
|
psm_status.payload.sts.last_recycle_reason = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::sbPSMInAmp(double t)
|
|
{
|
|
t = round(t / PSM_IN_AMP_LSB);
|
|
processChange((int)t,psm_status.payload.sts.in_amp );
|
|
}
|
|
void UnitSimulator::sbPSMOutVolt3v3(double t)
|
|
{
|
|
t = round(t / PSM_OUT_VOLT_LSB);
|
|
processChange4((int)t,psm_status.payload.sts.volts[0] );
|
|
}
|
|
|
|
void UnitSimulator::sbPSMOutVolt5v(double t)
|
|
{
|
|
t = round(t / PSM_OUT_VOLT_LSB);
|
|
processChange4((int)t,psm_status.payload.sts.volts[1] );
|
|
}
|
|
|
|
void UnitSimulator::sbPSMOutVolt15v(double t)
|
|
{
|
|
t = round(t / PSM_OUT_VOLT_LSB);
|
|
processChange4((int)t,psm_status.payload.sts.volts[2] );
|
|
}
|
|
|
|
void UnitSimulator::sbPSMOutVoltm15v(double t)
|
|
{
|
|
t = round(t / PSM_OUT_VOLT_LSB);
|
|
processChange4((int)t,psm_status.payload.sts.volts[3] );
|
|
}
|
|
|
|
void UnitSimulator::sbPSMTemp(int t)
|
|
{
|
|
processChange(t,psm_status.payload.sts.temperature );
|
|
}
|
|
void UnitSimulator::sbPSMETI(int t)
|
|
{
|
|
processChange4(t,psm_status.payload.sts.eti );
|
|
}
|
|
void UnitSimulator::sbPSMOnCount(int t)
|
|
{
|
|
processChange4(t,psm_status.payload.sts.counter );
|
|
}
|
|
void UnitSimulator::sbPSMUncCount(int t)
|
|
{
|
|
processChange(t,psm_status.payload.sts.unc_counter );
|
|
}
|
|
void UnitSimulator::sbPSMVer(int t)
|
|
{
|
|
processChange(t,psm_status.payload.sts.sw_major);
|
|
}
|
|
void UnitSimulator::sbPSMRel(int t)
|
|
{
|
|
processChange(t,psm_status.payload.sts.sw_minor );
|
|
}
|
|
|
|
void cbMgnPSMS(int t, int idxByte, uint8_t flag, char byte1[2])
|
|
{
|
|
if (t==0)
|
|
PSM_Status_byte[idxByte] &= ~flag;
|
|
else
|
|
PSM_Status_byte[idxByte] |= flag;
|
|
|
|
char tmp[3] = { 0 };
|
|
|
|
snprintf(tmp, 3, "%02X", PSM_Status_byte[idxByte]);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
}
|
|
|
|
void UnitSimulator::cbPSM11(int t)
|
|
{
|
|
//cbMgnPSMS(t, 0, PSM1_Bit, psm_status.payload.sts.byte1);
|
|
cbMgnPSMS(t, 0, PSM1_Bit0_PSM_recycle_panic, psm_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbPSM12(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit1_PSM_EIF_comm, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM13(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit2_rs422_comm, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM14(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit3_rs485_comm, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM15(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit4_rs232_comm, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM16(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit5_ov_temp_haz_2, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM17(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit6_ov_board_temp, psm_status.payload.sts.byte1);
|
|
}
|
|
void UnitSimulator::cbPSM18(int t)
|
|
{
|
|
cbMgnPSMS(t, 0, PSM1_Bit7_ov_dc_bus_current, psm_status.payload.sts.byte1);
|
|
}
|
|
|
|
void UnitSimulator::cbPSM21(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit0_ov_m15v, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM22(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit1_uv_m15v, psm_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbPSM23(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit2_ov_15v, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM24(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit3_uv_15v, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM25(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit4_ov_5v, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM26(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit5_uv_5v, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM27(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit6_ov_3v3, psm_status.payload.sts.byte2);
|
|
}
|
|
void UnitSimulator::cbPSM28(int t)
|
|
{
|
|
cbMgnPSMS(t, 1, PSM2_Bit7_uv_3v3, psm_status.payload.sts.byte2);
|
|
}
|
|
|
|
void UnitSimulator::cbPSM31(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit0_ov_13v_b, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM32(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit1_uv_13v_b, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM33(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit2_wow_out, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM34(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit3_3sec_in, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM35(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit4_uv_350v, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM36(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit5_ov_350v, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM37(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit6_blko_tst, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM38(int t)
|
|
{
|
|
cbMgnPSMS(t, 2, PSM3_Bit7_pwr_err, psm_status.payload.sts.byte3);
|
|
}
|
|
void UnitSimulator::cbPSM41(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit0_rdr_on_sts, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM42(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit1_lcu_rdy_uc, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM43(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit2_uc_interlock_o, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM44(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit3_ac_loss, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM45(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit4_ps_interlock_n, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM46(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit5_ov_temp_haz, psm_status.payload.sts.byte4);
|
|
}
|
|
void UnitSimulator::cbPSM47(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit6_uv_270v, psm_status.payload.sts.byte4);
|
|
}
|
|
|
|
void UnitSimulator::cbPSM48(int t)
|
|
{
|
|
cbMgnPSMS(t, 3, PSM4_Bit7_battle_short_cmd, psm_status.payload.sts.byte4);
|
|
}
|
|
|
|
//*****************************************************************
|
|
//PPS
|
|
|
|
void UnitSimulator::cbPPSModeStatus(const QString &t)
|
|
{
|
|
pps_status.payload.sts.sts = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPPShazard(const QString &t)
|
|
{
|
|
pps_status.payload.sts.hazard = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPPShealth(const QString &t)
|
|
{
|
|
pps_status.payload.sts.health = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPPSwow(const QString &t)
|
|
{
|
|
pps_status.payload.sts.wow = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void UnitSimulator::cbPPSlimit(const QString &t)
|
|
{
|
|
pps_status.payload.sts.current_limit = (t.toLatin1().data())[0];
|
|
}
|
|
|
|
void cbMgnPPS(int t, int idxByte, uint8_t flag, char byte1[2])
|
|
{
|
|
if (t==0)
|
|
PPS_Status_byte[idxByte] &= ~flag;
|
|
else
|
|
PPS_Status_byte[idxByte] |= flag;
|
|
|
|
char tmp[3] = { 0 };
|
|
|
|
snprintf(tmp, 3, "%02X", PPS_Status_byte[idxByte]);
|
|
|
|
byte1[0] = tmp[0];
|
|
byte1[1] = tmp[1];
|
|
}
|
|
|
|
|
|
//PPS BIT DEFINITIONS
|
|
void UnitSimulator::cbPPS11(int t)
|
|
{
|
|
cbMgnPPS(t, 0, PPS1_Bit1_HoldUp_LP_Under_Voltage_Fail, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS12(int t)
|
|
{
|
|
cbMgnPPS(t, 0, PPS1_Bit2_HoldUp_HP_Under_Voltage_Fail, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS13(int t)
|
|
{
|
|
//cbMgnPPS(t, 0, PPS1_Bit3_HoldUp_LP_Under_Voltage_Fail, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS14(int t)
|
|
{
|
|
//cbMgnPPS(t, 0, PPS1_Bit4_HoldUp_LP_Charging_Time_Fail, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS16(int t)
|
|
{
|
|
cbMgnPPS(t, 0, PPS1_Bit6_AC_Power_Unbalance_Fail_Ph1, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS17(int t)
|
|
{
|
|
cbMgnPPS(t, 0, PPS1_Bit7_AC_Power_Unbalance_Fail_Ph2, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
void UnitSimulator::cbPPS18(int t)
|
|
{
|
|
cbMgnPPS(t, 0, PPS1_Bit7_AC_Power_Unbalance_Fail_Ph3, pps_status.payload.sts.hold_up_status);
|
|
}
|
|
|
|
|
|
/*Byte 2*/
|
|
void UnitSimulator::cbPPS21(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit1_RX_Link_Fail, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS22(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit2_RX_Input_DC_Overcurrent_Fail, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS23(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit3_RX_Rectified_DC_Under_Voltage_Fail_Ac_Power_Loss, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS25(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit5_Output_RX_Over_Voltage_Fail, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS26(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit6_Output_RX_Under_Voltage_Fail, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS27(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit7_RX_Hazard1, pps_status.payload.sts.rx_board);
|
|
}
|
|
void UnitSimulator::cbPPS28(int t)
|
|
{
|
|
cbMgnPPS(t, 1, PPS2_Bit8_RX_Hazard2, pps_status.payload.sts.rx_board);
|
|
}
|
|
|
|
/*Byte 3*/
|
|
|
|
void UnitSimulator::cbPPS31(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit1_TX1_link_with_RX, pps_status.payload.sts.tx1_board);
|
|
}
|
|
void UnitSimulator::cbPPS32(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit2_TX1_Input_DC_Over_Current_Fail, pps_status.payload.sts.tx1_board);
|
|
}
|
|
|
|
void UnitSimulator::cbPPS33(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit3_TX1_Rectified_DC_Under_Voltage_Fail_270_uv, pps_status.payload.sts.tx1_board);
|
|
}
|
|
|
|
void UnitSimulator::cbPPS34(int t)
|
|
{
|
|
// cbMgnPPS(t, 2, PPS3_Bit4_TX1_Rectified_DC_Over_Voltage_Fail, pps_status.payload.sts.tx1_board);
|
|
}
|
|
void UnitSimulator::cbPPS35(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit5_Output_TX1_Over_Voltage_Fail, pps_status.payload.sts.tx1_board);
|
|
}
|
|
void UnitSimulator::cbPPS36(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit6_Output_TX1_Over_Voltage_Fail, pps_status.payload.sts.tx1_board);
|
|
}
|
|
void UnitSimulator::cbPPS37(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit7_TX1_Hazard1, pps_status.payload.sts.tx1_board);
|
|
}
|
|
void UnitSimulator::cbPPS38(int t)
|
|
{
|
|
cbMgnPPS(t, 2, PPS3_Bit8_TX1_Hazard2, pps_status.payload.sts.tx1_board);
|
|
}
|
|
|
|
/*Byte 4*/
|
|
void UnitSimulator::cbPPS41(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit1_TX2_link_with_RX, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS42(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit2_TX2_Input_DC_Over_Current_Fail, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS43(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit3_TX2_Rectified_DC_Under_Voltage_Fail_270_uv, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS44(int t)
|
|
{
|
|
//cbMgnPPS(t, 3, PPS4_Bit4_TX2_Rectified_DC_Over_Voltage_Fail, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS45(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit5_Output_TX2_Over_Voltage_Fail, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS46(int t){
|
|
cbMgnPPS(t, 3, PPS4_Bit6_Output_TX2_Over_Voltage_Fail, pps_status.payload.sts.tx2_board);
|
|
}
|
|
|
|
void UnitSimulator::cbPPS47(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit7_TX2_Hazard1, pps_status.payload.sts.tx2_board);
|
|
}
|
|
void UnitSimulator::cbPPS48(int t)
|
|
{
|
|
cbMgnPPS(t, 3, PPS4_Bit8_TX2_Hazard2, pps_status.payload.sts.tx2_board);
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
char general[2];*/
|
|
/*Byte 5*/
|
|
void UnitSimulator::cbPPS51(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit1_TX3_link_with_RX, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS52(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit2_TX3_Input_DC_Over_Current_Fail, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS53(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit3_TX3_Rectified_DC_Under_Voltage_Fail_270_uv, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS54(int t)
|
|
{
|
|
//cbMgnPPS(t, 4, PPS5_Bit4_TX3_Rectified_DC_Over_Voltage_Fail, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS55(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit5_Output_TX3_Over_Voltage_Fail, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS56(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit6_Output_TX3_Over_Voltage_Fail, pps_status.payload.sts.tx3_board);
|
|
}
|
|
void UnitSimulator::cbPPS57(int t){
|
|
cbMgnPPS(t, 4, PPS5_Bit7_TX3_Hazard1, pps_status.payload.sts.tx3_board);
|
|
}
|
|
|
|
void UnitSimulator::cbPPS58(int t)
|
|
{
|
|
cbMgnPPS(t, 4, PPS5_Bit8_TX3_Hazard2, pps_status.payload.sts.tx3_board);
|
|
}
|
|
|
|
/*Byte 6*/
|
|
void UnitSimulator::cbPPS61(int t)
|
|
{
|
|
cbMgnPPS(t, 5, PPS6_Bit1_WOW_Tellback_1, pps_status.payload.sts.general);
|
|
}
|
|
void UnitSimulator::cbPPS62(int t)
|
|
{
|
|
cbMgnPPS(t, 5, PPS6_Bit2_WOW_Tellback_2, pps_status.payload.sts.general);
|
|
}
|
|
void UnitSimulator::cbPPS63(int t){
|
|
cbMgnPPS(t, 5, PPS6_Bit3_WOW_Tellback_3, pps_status.payload.sts.general);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXver(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.rx_version);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXrel(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.rx_release);
|
|
}
|
|
void UnitSimulator::sbPPSTX1rel(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx1_release);
|
|
}
|
|
void UnitSimulator::sbPPSTX2rel(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx2_release);
|
|
}
|
|
void UnitSimulator::sbPPSTX3rel(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx3_release);
|
|
}
|
|
void UnitSimulator::sbPPSTX1ver(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx1_version);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX2ver(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx2_version);
|
|
}
|
|
void UnitSimulator::sbPPSTX3ver(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx3_version);
|
|
}
|
|
void UnitSimulator::sbPPSRXtemp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.rx_temp);
|
|
}
|
|
void UnitSimulator::sbPPSTX1temp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx1_temp);
|
|
}
|
|
void UnitSimulator::sbPPSTX2temp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx2_temp);
|
|
}
|
|
void UnitSimulator::sbPPSTX3temp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.tx3_temp);
|
|
}
|
|
void UnitSimulator::sbPPSInletTemp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.inlet_temp);
|
|
}
|
|
void UnitSimulator::sbPPSOutletTemp(int t)
|
|
{
|
|
processChange(t,pps_status.payload.sts.outlet_temp);
|
|
}
|
|
void UnitSimulator::sbPPSCurr(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.curr, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX1current(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx1_curr, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX2current(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx2_curr, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX3current(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx3_curr, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX1currentMAX_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx1_curr_max, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX2currentMAX_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx2_curr_max, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX3currentMAX_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx3_curr_max, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX1currentAVG_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx1_curr_avg, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX2currentAVG_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx2_curr_avg, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSTX3currentAVG_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.tx3_curr_avg, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseRmin_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseR_min, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseSmin_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseS_min, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseTmin_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseT_min, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseRmax_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseR_max, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseSmax_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseS_max, PPS_CURR_LSB);
|
|
}
|
|
|
|
void UnitSimulator::sbPPSRXPhaseTmax_2(double t)
|
|
{
|
|
processChangeLsb(t, pps_status.payload.sts.rx_phaseT_max, PPS_CURR_LSB);
|
|
}
|
|
|