#ifndef DATA_CONFIG_H #define DATA_CONFIG_H #include #include #include #include typedef unsigned char uint8_t; typedef unsigned short uint16_t; extern QString g_strServerIp; // 服务端IP extern QString g_version; #define SLOT_NUM 15 #define CHANNEL_COUNT 4 #define RELAY_COUNT 16 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, kCardRelaySingleNOK = 35, } CardType; // 振动板通道类型 typedef enum { kVibRadial = 0, // 径向位移 kVibAcc = 1, // 加速度 kVibVelocity = 2 // 速度 } VibChannelType; typedef struct SlotConfig_{ int slot; QString slot_type; QPushButton *slot_btn; QLabel *slot_label; SlotConfig_(){ slot_type = ""; } } 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, // 获取继电器状态 KConfigProgress = 25, kTimingCmd = 26, kGetTimeInfo = 27, kGetLogInfo = 28 }; 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 point_name; QString chan_id; 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_upper = 0.0; direct_enable = false; x1_ampl_upper = 0.0; x1_ampl_lower = 0.0; x1_ampl_enable = false; x2_ampl_upper = 0.0; x2_ampl_lower = 0.0; x2_ampl_enable = false; danger_upper = 0.0; danger_enable = false; } } VibAlertDanger; typedef struct SpeedAlert_{ int speed_upper; int speed_lower; bool speed_upper_enable; bool speed_lower_enable; int danger_speed_upper; SpeedAlert_(){ speed_upper = 0; speed_lower = 0; danger_speed_upper = 0; speed_upper_enable = false; speed_lower_enable = false; } } SpeedAlert; typedef struct SingleRelayNOK_{ QString logic_expression; SingleRelayNOK_(){ logic_expression = ""; } } SingleRelayNOK; typedef struct TMRRelay_{ QString logic_expression; TMRRelay_(){ logic_expression = ""; } } TMRRelay; #pragma pack(1) // kUpgradeCard typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 int len; uint8_t card_id; uint8_t crc; char data[0]; } UpgradeCardReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; // 0: 上传成功 } UpgradeRsp; // kUpgradeProgress typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t progress; } UpgradeProgress; // kGetVersionInfo typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t card_id; } GetVersionReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t fpga; // fpga版本号 uint8_t sw; // 软件版本号 char fpga_date[9]; // fpga版本日期 } VersionRsp; // kRelaySetting typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t card_id; // 0xff是本机,其它子卡是1~15 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 head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; } RelaySettingRsp; // kRelayStatus typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t card_id; } RelayStatusReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; // 0: 成功 其它:失败 uint8_t status; // 7 测试状态,8 手动状态,9 工作状态 } RelayStatusRsp; // kUploadConfigFile typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 int len; uint8_t sub_cmd; // 0: 仅上传配置文件,不配置子板 1:配置所有子板 uint8_t crc; char data[0]; } UploadConfigReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; } UploadConfigRsp; typedef struct { 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; // kDownloadConfigFile typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 } DownloadConfigReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; int len; uint8_t crc; char data[0]; } DownloadConfigRsp; // kConfigSubCard = 16 typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t card_id; } ConfigSubCardReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t card_id; uint8_t code; // 0: 成功 1: 没有配置文件 } ConfigSubCardRsp; typedef struct { 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 typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 } BaudrateGetReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t baudrate; } BaudrateGetRsp; //kRS485BaudrateSet typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t baudrate; } BaudrateSetReq; typedef struct { uint8_t head[3]; // 固定值:0xAA55AA uint8_t cmd; uint8_t version; // 版本号,默认为1 uint8_t code; } BaudrateSetRsp; //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; // 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; struct BaseHeader { uint8_t head[3]; // 固定 0xAA 0x55 0xAA uint8_t cmd; }; struct LargeHeaderExtra { uint8_t version; uint8_t code; int32_t len; }; #pragma pack() #endif // DATA_CONFIG_H