TSI_Config/data_config.h

561 lines
13 KiB
C
Raw Normal View History

2025-02-15 11:50:15 +08:00
#ifndef DATA_CONFIG_H
#define DATA_CONFIG_H
#include <QString>
#include <QPushButton>
2025-03-11 16:42:00 +08:00
#include <QLabel>
2025-02-18 10:55:51 +08:00
#include <QList>
2025-02-15 11:50:15 +08:00
2025-03-01 13:40:11 +08:00
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
2025-03-04 16:00:19 +08:00
extern QString g_strServerIp; // 服务端IP
2025-05-15 18:09:43 +08:00
extern QString g_version;
2025-03-04 16:00:19 +08:00
2025-03-29 18:05:12 +08:00
#define SLOT_NUM 15
#define CHANNEL_COUNT 4
2025-05-06 10:17:16 +08:00
#define RELAY_COUNT 16
2025-03-29 18:05:12 +08:00
typedef enum {
kCardNone = 0,
kCardCpu = 1,
kCardVibSingle = 10,
kCardVibTMRPrimary = 11,
kCardVibTMRBackup = 12,
kCardVibDoublePrimary = 13,
kCardVibDoubleBackup = 14,
2025-03-29 18:05:12 +08:00
kCardSpeedSingle = 20,
kCardSpeedTMRPrimary = 21,
kCardSpeedTMRBackup = 22,
kCardKeyphaseSingle = 30,
kCardKeyphaseDouble = 31,
kCardRelaySingle = 32,
kCardRelayTMRPrimary = 33,
kCardRelayTMRBackup = 34,
2025-04-19 16:25:33 +08:00
kCardRelaySingleNOK = 35,
2025-03-29 18:05:12 +08:00
} CardType;
// 振动板通道类型
typedef enum {
kVibRadial = 0, // 径向位移
kVibAcc = 1, // 加速度
kVibVelocity = 2, // 速度
kVibThrust = 3, //轴向位移
kVibPressurePulsation = 4 //动态压力脉动
2025-03-29 18:05:12 +08:00
} VibChannelType;
2025-04-21 20:57:37 +08:00
typedef struct SlotConfig_{
2025-02-15 11:50:15 +08:00
int slot;
2025-03-23 14:03:48 +08:00
QString slot_type;
2025-03-28 14:13:30 +08:00
QPushButton *slot_btn;
QLabel *slot_label;
2025-04-21 20:57:37 +08:00
SlotConfig_(){
slot_type = "";
}
2025-03-28 14:13:30 +08:00
} SlotConfig;
2025-02-15 11:50:15 +08:00
2025-03-03 21:57:15 +08:00
enum CMTCommand {
kEigenvalueCmd = 1,
kExceptionInfo = 2,
kUpgradeCard = 3,
2025-03-04 16:00:19 +08:00
kGetVersionInfo = 4,
2025-03-05 16:56:07 +08:00
kRelaySetting = 5,
2025-03-13 15:10:35 +08:00
kRelayStatus = 6,
2025-04-11 20:27:45 +08:00
kUpgradeProgress = 7,
kCalibrationMode = 8,
kGetDcValue = 9,
kSetCalibrationCoe = 10,
kGetCalibrationCoe = 11,
kClearCalibrationCoe = 12,
kGetWaveData = 13,
kUploadConfigFile = 14,
kDownloadConfigFile = 15,
kConfigSubCard = 16, // 请求无包体,响应有包体
kRS485BaudrateSet = 17, // RS485波特率配置
kRS485BaudrateGet = 18, // RS485波特率获取
2025-04-17 20:33:26 +08:00
kConfigIPv4 = 19, // 配置IP地址
kConfigMac = 20, // 配置Mac地址
kRebootCard = 21, // 重启板卡
kGetCardDcValue = 22, // 获取子板平均值
kGetRelayStatus = 23, // 获取继电器状态
2025-05-15 18:09:43 +08:00
KConfigProgress = 25,
kTimingCmd = 26,
kGetTimeInfo = 27,
kGetLogInfo = 28
2025-04-11 20:27:45 +08:00
};
enum RS485Baudrate {
kBaudrate2400 = 0,
kBaudrate4800 = 1,
kBaudrate9600 = 2, // 默认值
kBaudrate19200 = 3,
kBaudrate38400 = 4,
kBaudrate57600 = 5,
kBaudrate115200 = 6
2025-03-03 21:57:15 +08:00
};
2025-03-29 09:53:29 +08:00
// 振动板采样率
typedef enum {
kVibSR16K = 0, // 16k
kVibSR32K = 1, // 32k
kVibSR64k = 2, // 64k
kVibSR128K = 3, // 128k
} VibSamplingRate;
// 振动板机架类型
typedef enum {
kVibRackSingle = 0, // 单一
kVibRackTMR = 1 // 三冗余
} VibRackType;
2025-02-18 10:55:51 +08:00
2025-03-28 14:13:30 +08:00
typedef struct {
2025-02-18 10:55:51 +08:00
int id;
2025-04-21 17:23:38 +08:00
QString point_name;
2025-04-23 14:44:58 +08:00
QString chan_id;
2025-02-18 10:55:51 +08:00
bool standby;
bool active;
2025-03-29 09:53:29 +08:00
int rack_type; // VibRackType
2025-04-01 15:03:59 +08:00
// char tmr_group[32];
2025-03-29 09:53:29 +08:00
int channel_type; // VibChannelType
2025-04-01 15:03:59 +08:00
int transducer_id;
float scale_factor;
2025-03-29 09:53:29 +08:00
int sampling_rate; // VibSamplingRate
2025-02-18 10:55:51 +08:00
float normal_voltage_low;
float normal_voltage_high;
bool power;
bool keyphase;
int keyphase_slot;
int keyphase_ch;
2025-03-28 14:13:30 +08:00
} SeismicMonitor;
2025-02-25 11:18:20 +08:00
2025-03-29 18:05:12 +08:00
typedef enum {
kFilterTypeLowPass = 0,
kFilterTypeHighPass = 1,
kFilterTypeBandPass = 2,
} FilterType;
2025-03-28 14:13:30 +08:00
typedef struct {
2025-02-25 11:18:20 +08:00
int low;
int high;
bool checked;
} Filter;
2025-04-01 17:52:25 +08:00
//typedef struct {
// Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
//} AllFilter;
2025-03-29 18:05:12 +08:00
2025-03-28 14:13:30 +08:00
typedef struct {
2025-02-25 11:18:20 +08:00
QString type;
2025-03-28 15:32:39 +08:00
int full_sacle_range;
2025-02-25 11:18:20 +08:00
int bias_voltage;
float clamp_value;
int phase_lag;
bool checked;
2025-03-28 15:32:39 +08:00
float custom;
2025-02-25 11:18:20 +08:00
} Variables;
2025-03-29 18:05:12 +08:00
typedef struct {
2025-04-01 15:03:59 +08:00
int full_scale_range;
2025-03-29 18:05:12 +08:00
float clamp_value;
float custom;
} DirectImpl;
typedef struct {
bool checked;
2025-04-01 15:03:59 +08:00
int full_scale_range;
2025-03-29 18:05:12 +08:00
float clamp_value;
float custom;
int phase_lag;
} XImpl;
typedef struct {
bool checked;
2025-04-01 15:03:59 +08:00
int full_scale_range;
2025-03-29 18:05:12 +08:00
float clamp_value;
float custom;
} RadialImpl;
2025-03-28 14:13:30 +08:00
typedef struct {
2025-02-25 11:18:20 +08:00
int alert;
float danger;
bool active_100ms;
2025-03-29 18:05:12 +08:00
} Delay;
2025-03-28 14:13:30 +08:00
typedef struct {
2025-02-25 11:18:20 +08:00
bool rms_active;
bool integrate_active;
bool alert_latching;
bool danger_latching;
bool timed_ok;
2025-03-28 15:32:39 +08:00
int recorder_output;
2025-02-25 11:18:20 +08:00
bool two_ma_clamp;
2025-03-20 14:38:14 +08:00
float trip_multiply;
2025-02-25 11:18:20 +08:00
QString comparision;
int comparision_percentage;
} Alert_Variables;
2025-03-29 18:05:12 +08:00
typedef struct {
int recorder_output;
bool two_ma_clamp;
float trip_multiply;
2025-04-01 15:03:59 +08:00
int comparision;
int percentage;
2025-03-29 18:05:12 +08:00
} RecorderOut;
2025-03-28 14:13:30 +08:00
typedef struct {
2025-03-21 10:42:24 +08:00
int id;
bool active;
float normal_voltage_low;
float normal_voltage_high;
2025-04-02 14:07:37 +08:00
int speed_peek;
int default_speed;
2025-03-21 10:42:24 +08:00
bool automatic_threshold;
float threshold;
float hysteresis;
int events_per_revolution;
2025-04-02 14:07:37 +08:00
int record_output;
2025-03-21 10:42:24 +08:00
bool two_ma_clamp;
bool alert_latching;
bool overspeed_latching;
bool normal_latching;
2025-04-02 14:07:37 +08:00
} TachometerVariables;
2025-03-21 10:42:24 +08:00
2025-04-02 14:28:53 +08:00
typedef struct {
bool active;
float normal_voltage_low;
float normal_voltage_high;
bool automatic_threshold;
float threshold;
float hysteresis;
int events_per_revolution;
} KeyphaseVariables;
2025-03-28 14:13:30 +08:00
typedef struct {
QString transducer_name;
double scale_factor;
2025-03-28 14:13:30 +08:00
} Transducer;
2025-04-16 13:55:32 +08:00
typedef struct VibAlertDanger_{
float direct_upper;
bool direct_enable;
float x1_ampl_upper;
float x1_ampl_lower;
bool x1_ampl_enable;
float x2_ampl_upper;
float x2_ampl_lower;
bool x2_ampl_enable;
int danger_param; //0 直接值1 1倍频幅值2 2倍频幅值
float danger_upper;
bool danger_enable;
VibAlertDanger_(){
2025-04-19 16:25:33 +08:00
direct_upper = 0.0;
2025-04-16 13:55:32 +08:00
direct_enable = false;
2025-04-19 16:25:33 +08:00
x1_ampl_upper = 0.0;
x1_ampl_lower = 0.0;
2025-04-16 13:55:32 +08:00
x1_ampl_enable = false;
2025-04-19 16:25:33 +08:00
x2_ampl_upper = 0.0;
x2_ampl_lower = 0.0;
2025-04-16 13:55:32 +08:00
x2_ampl_enable = false;
2025-04-19 16:25:33 +08:00
danger_upper = 0.0;
2025-04-16 13:55:32 +08:00
danger_enable = false;
}
} VibAlertDanger;
2025-04-19 16:25:33 +08:00
typedef struct SpeedAlert_{
2025-04-25 16:29:08 +08:00
int speed_upper;
int speed_lower;
2025-04-16 13:55:32 +08:00
bool speed_upper_enable;
bool speed_lower_enable;
2025-04-25 16:29:08 +08:00
int danger_speed_upper;
2025-04-19 16:25:33 +08:00
SpeedAlert_(){
speed_upper = 0;
speed_lower = 0;
danger_speed_upper = 0;
2025-04-25 19:44:45 +08:00
speed_upper_enable = false;
speed_lower_enable = false;
2025-04-19 16:25:33 +08:00
}
2025-04-16 13:55:32 +08:00
} SpeedAlert;
2025-04-11 20:27:45 +08:00
2025-04-19 16:25:33 +08:00
typedef struct SingleRelayNOK_{
QString logic_expression;
SingleRelayNOK_(){
logic_expression = "";
}
} SingleRelayNOK;
2025-04-19 19:54:56 +08:00
typedef struct TMRRelay_{
QString logic_expression;
TMRRelay_(){
logic_expression = "";
}
} TMRRelay;
2025-03-01 13:40:11 +08:00
#pragma pack(1)
2025-05-14 10:34:21 +08:00
// kUpgradeCard
2025-05-07 19:46:31 +08:00
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
2025-05-14 10:34:21 +08:00
uint8_t version; // 版本号默认为1
2025-05-07 19:46:31 +08:00
int len;
2025-05-14 10:34:21 +08:00
uint8_t card_id;
uint8_t crc;
2025-03-01 13:40:11 +08:00
char data[0];
} UpgradeCardReq;
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code; // 0: 上传成功
2025-03-01 13:40:11 +08:00
} UpgradeRsp;
2025-05-14 10:34:21 +08:00
// kUpgradeProgress
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t progress;
} UpgradeProgress;
// kGetVersionInfo
2025-03-03 21:57:15 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
2025-03-03 21:57:15 +08:00
} GetVersionReq;
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t fpga; // fpga版本号
uint8_t sw; // 软件版本号
char fpga_date[9]; // fpga版本日期
2025-03-03 21:57:15 +08:00
} VersionRsp;
2025-05-14 10:34:21 +08:00
// kRelaySetting
2025-03-04 16:00:19 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id; // 0xff是本机其它子卡是115
uint8_t led_id; // ok 灯 0xff,rx/tx 灯 0xf1,板卡测试模式 0xee,板卡状态 0xe1,其他 1 ~ 16
2025-03-05 16:56:07 +08:00
uint8_t led_operate; // 0 OFF,1 ON,2 红色,3 绿色,4 红色1Hz闪烁,5 红色2Hz闪烁,6 绿色闪烁,7 测试状态,8 手动状态,9 工作状态
2025-03-04 16:00:19 +08:00
} RelaySettingReq;
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
2025-03-04 16:00:19 +08:00
uint8_t code;
} RelaySettingRsp;
2025-05-14 10:34:21 +08:00
// kRelayStatus
2025-03-05 16:56:07 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
2025-03-05 16:56:07 +08:00
} RelayStatusReq;
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code; // 0: 成功 其它:失败
2025-03-05 16:56:07 +08:00
uint8_t status; // 7 测试状态,8 手动状态,9 工作状态
} RelayStatusRsp;
2025-05-14 10:34:21 +08:00
// kUploadConfigFile
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
int len;
uint8_t sub_cmd; // 0: 仅上传配置文件,不配置子板 1配置所有子板
uint8_t crc;
2025-04-11 20:27:45 +08:00
char data[0];
2025-05-14 10:34:21 +08:00
} UploadConfigReq;
2025-04-11 20:27:45 +08:00
2025-05-15 18:09:43 +08:00
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code;
} UploadConfigRsp;
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code; // 子板配置错误码
uint8_t subcard_id; // 子板编号从1开始
uint8_t stage; // 0: 配置开始 1配置结束
} UploadConfigProgress;
2025-05-14 23:14:50 +08:00
2025-05-14 10:34:21 +08:00
// kDownloadConfigFile
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
} DownloadConfigReq;
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code;
int len;
uint8_t crc;
char data[0];
} DownloadConfigRsp;
2025-04-11 20:27:45 +08:00
2025-05-15 18:09:43 +08:00
// kConfigSubCard = 16
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
} ConfigSubCardReq;
2025-04-11 20:27:45 +08:00
2025-05-15 18:09:43 +08:00
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
uint8_t code; // 0: 成功 1: 没有配置文件
} ConfigSubCardRsp;
2025-04-11 20:27:45 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code; // 子板配置错误码
uint8_t subcard_id; // 子板编号从1开始
uint8_t stage; // 0: 配置开始 1配置结束
} ConfigSubCardProgress;
// kRS485BaudrateGet
2025-04-17 20:33:26 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
} BaudrateGetReq;
2025-04-11 20:27:45 +08:00
2025-04-17 20:33:26 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t baudrate;
} BaudrateGetRsp;
//kRS485BaudrateSet
2025-04-17 20:33:26 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t baudrate;
} BaudrateSetReq;
2025-04-17 20:33:26 +08:00
typedef struct {
2025-05-14 10:34:21 +08:00
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code;
} BaudrateSetRsp;
2025-04-17 20:33:26 +08:00
2025-05-14 23:14:50 +08:00
//kConfigIPv4
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t ethn; // 0: eth0, 1: eth1
char ip[16];
char netmask[16];
char gw[16];
} ConfigIPv4Req;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code;
} ConfigIPv4Rsp;
//ConfigMacReq
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t ethn; // 0: eth0, 1: eth1
char mac[18];
} ConfigMacReq;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code;
} ConfigMacRsp;
2025-05-15 18:09:43 +08:00
// kGetLogInfo = 28
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
uint8_t level;
} GetSubCardLogReq;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t card_id;
uint8_t code;
uint32_t len;
char data[0]; // 请保存为.tar.gz文件
} GetSubCardLogRsp;
// cmd: kTimingCmd = 26
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint32_t ts; // 时间戳
} SetTimingReq;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint8_t code; // 0: 成功 其它:失败
} SetTimingRsp;
// cmd: kGetTimeInfo = 27
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
} GetTimeInfoReq;
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd;
uint8_t version; // 版本号默认为1
uint32_t ts; // 时间戳
} GetTimeInfoRsp;
2025-05-14 23:14:50 +08:00
struct BaseHeader {
uint8_t head[3]; // 固定 0xAA 0x55 0xAA
uint8_t cmd;
};
struct LargeHeaderExtra {
uint8_t version;
uint8_t code;
int32_t len;
};
2025-04-17 20:33:26 +08:00
2025-03-01 13:40:11 +08:00
#pragma pack()
2025-02-15 11:50:15 +08:00
#endif // DATA_CONFIG_H