TSI_Config/data_config.h
2025-04-17 20:33:26 +08:00

373 lines
8.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef DATA_CONFIG_H
#define DATA_CONFIG_H
#include <QString>
#include <QPushButton>
#include <QLabel>
#include <QList>
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
extern QString g_strServerIp; // 服务端IP
#define SLOT_NUM 15
#define CHANNEL_COUNT 4
typedef enum {
kCardNone = 0,
kCardCpu = 1,
kCardVibSingle = 10,
kCardVibTMRPrimary = 11,
kCardVibTMRBackup = 12,
kCardVibDoublePrimary = 13,
kCardVibDoubleBackup = 14,
kCardSpeedSingle = 20,
kCardSpeedTMRPrimary = 21,
kCardSpeedTMRBackup = 22,
kCardKeyphaseSingle = 30,
kCardKeyphaseDouble = 31,
kCardRelaySingle = 32,
kCardRelayTMRPrimary = 33,
kCardRelayTMRBackup = 34,
} CardType;
// 振动板通道类型
typedef enum {
kVibRadial = 0, // 径向位移
kVibAcc = 1, // 加速度
kVibVelocity = 2 // 速度
} VibChannelType;
typedef struct {
int slot;
QString slot_type;
QString chan_display;
QString rack_type;
QPushButton *slot_btn;
QLabel *slot_label;
} SlotConfig;
enum CMTCommand {
kEigenvalueCmd = 1,
kExceptionInfo = 2,
kUpgradeCard = 3,
kGetVersionInfo = 4,
kRelaySetting = 5,
kRelayStatus = 6,
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波特率获取
kConfigIPv4 = 19, // 配置IP地址
kConfigMac = 20, // 配置Mac地址
kRebootCard = 21, // 重启板卡
kGetCardDcValue = 22, // 获取子板平均值
kGetRelayStatus = 23, // 获取继电器状态
};
enum RS485Baudrate {
kBaudrate2400 = 0,
kBaudrate4800 = 1,
kBaudrate9600 = 2, // 默认值
kBaudrate19200 = 3,
kBaudrate38400 = 4,
kBaudrate57600 = 5,
kBaudrate115200 = 6
};
// 振动板采样率
typedef enum {
kVibSR16K = 0, // 16k
kVibSR32K = 1, // 32k
kVibSR64k = 2, // 64k
kVibSR128K = 3, // 128k
} VibSamplingRate;
// 振动板机架类型
typedef enum {
kVibRackSingle = 0, // 单一
kVibRackTMR = 1 // 三冗余
} VibRackType;
typedef struct {
int id;
// QString channel_name;
bool standby;
bool active;
int rack_type; // VibRackType
// char tmr_group[32];
int channel_type; // VibChannelType
int transducer_id;
float scale_factor;
int sampling_rate; // VibSamplingRate
float normal_voltage_low;
float normal_voltage_high;
bool power;
} SeismicMonitor;
typedef enum {
kFilterTypeLowPass = 0,
kFilterTypeHighPass = 1,
kFilterTypeBandPass = 2,
} FilterType;
typedef struct {
int low;
int high;
bool checked;
} Filter;
//typedef struct {
// Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
//} AllFilter;
typedef struct {
QString type;
int full_sacle_range;
int bias_voltage;
float clamp_value;
int phase_lag;
bool checked;
float custom;
} Variables;
typedef struct {
int full_scale_range;
float clamp_value;
float custom;
} DirectImpl;
typedef struct {
bool checked;
int full_scale_range;
float clamp_value;
float custom;
int phase_lag;
} XImpl;
typedef struct {
bool checked;
int full_scale_range;
float clamp_value;
float custom;
} RadialImpl;
typedef struct {
int alert;
float danger;
bool active_100ms;
} Delay;
typedef struct {
bool rms_active;
bool integrate_active;
bool alert_latching;
bool danger_latching;
bool timed_ok;
int recorder_output;
bool two_ma_clamp;
float trip_multiply;
QString comparision;
int comparision_percentage;
} Alert_Variables;
typedef struct {
int recorder_output;
bool two_ma_clamp;
float trip_multiply;
int comparision;
int percentage;
} RecorderOut;
typedef struct {
int id;
bool active;
float normal_voltage_low;
float normal_voltage_high;
int speed_peek;
int default_speed;
bool automatic_threshold;
float threshold;
float hysteresis;
int events_per_revolution;
int record_output;
bool two_ma_clamp;
bool alert_latching;
bool overspeed_latching;
bool normal_latching;
} TachometerVariables;
typedef struct {
bool active;
float normal_voltage_low;
float normal_voltage_high;
bool automatic_threshold;
float threshold;
float hysteresis;
int events_per_revolution;
} KeyphaseVariables;
typedef struct {
QString transducer_name;
double scale_factor;
} Transducer;
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_(){
direct_enable = false;
x1_ampl_enable = false;
x2_ampl_enable = false;
danger_enable = false;
}
} VibAlertDanger;
typedef struct{
float speed_upper;
float speed_lower;
bool speed_upper_enable;
bool speed_lower_enable;
float speed_bnd_upper;
float speed_bnd_lower;
bool speed_bnd_enable;
float danger_speed_upper;
float danger_speed_lower;
bool danger_speed_upper_enable;
bool danger_speed_lower_enable;
} SpeedAlert;
#pragma pack(1)
typedef struct {
uint8_t head[3]; // 固定值0xAA55AA
uint8_t cmd; // 命令
int len; // 数据长度
uint8_t crc; // 数据 CRC 校验和
char data[0]; // 文件内容
} PackageHead;
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
char data[0];
} UpgradeCardReq;
typedef struct {
uint8_t code; // 0: 上传成功
} UpgradeRsp;
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
} GetVersionReq;
typedef struct {
uint8_t fpga; // fpga版本号
uint8_t sw; // 软件版本号
char fpga_data[9]; // fpga版本日期
} VersionRsp;
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
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 工作状态
} RelaySettingReq;
typedef struct {
uint8_t code;
} RelaySettingRsp;
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
} RelayStatusReq;
typedef struct {
uint8_t status; // 7 测试状态,8 手动状态,9 工作状态
} RelayStatusRsp;
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;
// cmd: kConfigIPv4
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char ip[16];
char netmask[16];
} ConfigIPv4Req;
// 配置IP的响应结构为CommonRsp
// cmd: kConfigMac
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char mac[18];
} ConfigMacReq;
// 配置MAC的响应结构为CommonRsp
// 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;
#pragma pack()
#endif // DATA_CONFIG_H