TSI_Config/data_config.h

397 lines
8.7 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-03-29 18:05:12 +08:00
#define SLOT_NUM 15
#define CHANNEL_COUNT 4
2025-04-19 16:25:33 +08:00
#define RELAY_COUNT 8
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 // 速度
} 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-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;
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-16 13:55:32 +08:00
float speed_upper;
float speed_lower;
bool speed_upper_enable;
bool speed_lower_enable;
float danger_speed_upper;
2025-04-19 16:25:33 +08:00
SpeedAlert_(){
speed_upper = 0;
speed_lower = 0;
danger_speed_upper = 0;
}
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)
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd; // 命令
2025-03-03 21:57:15 +08:00
int len; // 数据长度
2025-03-01 13:40:11 +08:00
uint8_t crc; // 数据 CRC 校验和
char data[0]; // 文件内容
} PackageHead;
2025-03-03 21:57:15 +08:00
2025-03-01 13:40:11 +08:00
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
char data[0];
} UpgradeCardReq;
typedef struct {
uint8_t code; // 0: 上传成功
} UpgradeRsp;
2025-03-03 21:57:15 +08:00
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
} GetVersionReq;
typedef struct {
uint8_t fpga; // fpga版本号
uint8_t sw; // 软件版本号
char fpga_data[9]; // fpga版本日期
} VersionRsp;
2025-03-04 16:00:19 +08:00
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
2025-03-05 16:56:07 +08:00
uint8_t led_id; // ok 灯 0xff,rx/tx 灯 0xf1,板卡测试模式 0xee,板卡状态 0xe1,其他 1 ~ 16
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 {
uint8_t code;
} RelaySettingRsp;
2025-03-05 16:56:07 +08:00
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
} RelayStatusReq;
typedef struct {
uint8_t status; // 7 测试状态,8 手动状态,9 工作状态
} RelayStatusRsp;
2025-04-11 20:27:45 +08:00
typedef struct {
char data[0];
} UploadConfigReq, DownloadConfigRsp;
typedef struct {
uint8_t code;
} UploadConfigRsp, DownloadConfigReq;
typedef struct {
uint8_t card_id;
} ConfigSubCardReq;
typedef struct {
uint8_t code; // 0: success 1: 无配置文件 2失败
} ConfigSubCardRsp;
typedef struct {
uint8_t baudrate; // kRS485BaudrateSet, kRS485BaudrateGet
} BaudrateSetReq, BaudrateGetRsp;
typedef struct {
uint8_t code; // 0: success
} BaudrateSetRsp;
2025-04-17 20:33:26 +08:00
// cmd: kConfigIPv4
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char ip[16];
char netmask[16];
2025-04-21 17:23:38 +08:00
char gw[16];
2025-04-17 20:33:26 +08:00
} ConfigIPv4Req;
// 配置IP的响应结构为CommonRsp
// cmd: kConfigMac
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char mac[18];
} ConfigMacReq;
// 配置MAC的响应结构为CommonRsp
2025-04-11 20:27:45 +08:00
2025-04-17 20:33:26 +08:00
// cmd: kRebootCard
typedef struct {
uint8_t card_id; // 0: cpu板卡 115对应相应槽位
} RebootCardReq;
// 此命令无响应,可观察各板卡灯的变化情况
// cmd: kGetCardDcValue
typedef struct {
uint8_t card_id; // 1 ~ 15
} GetCardDcValueReq;
typedef struct {
float dc_value[4];
} GetCardDcValueRsp;
// cmd: kGetRelayStatus
typedef struct {
uint8_t card_id;
} GetRelayStatusReq;
typedef struct {
uint8_t card_id;
uint16_t status; // 0: 正常 1开出, 从低位到高位分别为继电器的通道1 16
} GetRelayStatusRsp;
2025-03-01 13:40:11 +08:00
#pragma pack()
2025-02-15 11:50:15 +08:00
#endif // DATA_CONFIG_H