g0b1vetx-board/Board/data.h
2023-11-30 08:10:01 +08:00

214 lines
3.6 KiB
C

#ifndef _DATA_H
#define _DATA_H
#include <stdint.h>
#define SLUICE_COUTN 1// 当前处理几口闸
#define WATER_COUTN 6// 当前接入n个流量计
#define SUBTOPIC_COUNT 1 // 订阅topic 数量
#define SLUCIE_EXEC_COUNT 20// 闸门异常时间
#define VERSION "V2.0.1"
extern uint32_t g_ifconfig;
extern uint32_t g_ifupdate;
typedef struct StrIndex_t
{
char str[10];
int index;
}StrIndex_t;
// 巴歇尔槽流量计
typedef struct ParShallInfo_t
{
double w; // 喉道宽
double c;
double m;
double minLeve;
double maxLeve;
double minFlow;
double maxFlow;
}ParShallInfo_t;
typedef struct LeveInfo_t
{
uint16_t Y[100]; // 水位
uint16_t Key[100]; // 流量
}LeveInfo_t;
// 水位流量关系表数据
typedef struct WaterLeveInfo_t
{
uint16_t X[100]; // 单位 mm
LeveInfo_t Key[100];
}WaterLeveInfo_t;
// 闸门信息
typedef struct SluiceData_t
{
int32_t gopen; // 读取到的开度 单位 mm / %0.1
int32_t sopen; // 设定开度 单位 mm / %0.1
int32_t lload; // 左荷重 单位 kg
int32_t rload; // 右荷重 单位 kg
int32_t ecode; // 编码器原始数据
int32_t currt; // 设备电流
} SluiceData_t;
// 系统信息
typedef struct SysData_t
{
uint32_t Vbat;// 电池电压
char iccid[32] ;
int16_t Csq;// 信号强度
int netState; // 网络状态
int ecdState; // 编码器状态
int flowState;// 流量计状态
int ldState; // 荷重状态
int scram; // 急停被按下
char fileName[64]; // 文件名
int fileSize; // 文件大小
} SysData_t;
// 水量参数
typedef struct WaterData_t
{
int64_t ttWater; // 累计流量 单位 m3
int32_t thisFlow; // 瞬时流量 单位 m3
int32_t thisLevel; // 水位
int32_t thisSpeed; // 流速
int32_t thisPress; // 压力
int32_t thisTemp; // 温度
} WaterData_t;
typedef enum Ctrl_Mode_t
{
CTRL_FOPEN = 0,
CTRL_ZOPEN = 1
}Ctrl_Mode_t;
typedef enum MotorType_t
{
MT_MG_1000, // 米格1000
MT_QH_V100, // 强华 1.0 版本
MT_QH_V200, // 强华 2.0 版本
MT_ZS_V100, // 中盛 4-20 ma
MT_JZ_V200, // 金志 4-20 ma
MT_DY_V100, // 大禹锥型阀
MT_KG_V100, // 开关量模块
MT_KR_V100, // 徐州正天闸位计
} MotorType_t;
typedef enum S4851Type_t
{
ST_MG_1000, // 米格1000
ST_QH_V100, // 强华 1.0 版本
ST_QH_V200, // 强华 2.0 版本
ST_AT_V100, // 奥图编码器
ST_DY_V100, // 大禹锥形阀
ST_KG_V100, // 开关量模块
ST_KR_V100, // 徐州正天闸位计
} S4851Type_t;
typedef enum S4852Type_t
{
ST_RDS_600, // rds600 雷达流速一体机
ST_TDS_300, // tds300 超声波流量计
ST_HT_V100, // 华天液位计
ST_ZK_JSZK, // 精水中科多普勒
ST_DJX_100, // 丁家峡闸门 读取开度
ST_RDS_300, // 雷达流量计
} S4852Type_t;
typedef enum SOFTFLOWType_t
{
NONE,
WATER,
PARSHALL//
}SOFTFLOWType_t;
typedef enum SiteType_t
{
SiteSluice, // 闸门站
SiteFlow, // 流量站
SiteSee, // 渗流渗压站
SiteColl, // 采集站
SiteServer, // 串口服务器
SiteLevel // 水位站
}SiteType_t;
typedef enum DownDataType_t
{
DownRun = 0,
DownStop = 1,
DownOpen = 2,
DownClose = 3,
DownRegistAns = 4,
DownHeartAns = 5, // 心跳
DownUpdate = 6, // 升级
DownReboot = 7, // 重启
DownConfig = 8, // 修改参数
DownRead = 9, // 读取参数
}DownDataType_t;
extern const StrIndex_t cSiteType[];
// 通过邮箱传输给驱动层
typedef struct TypeIndexMail_t
{
uint16_t Type;
uint16_t index;
}TypeIndexMail_t;
extern SluiceData_t SluiceData[SLUICE_COUTN];
extern WaterData_t WaterData[WATER_COUTN];
extern SysData_t SysData;
extern const WaterLeveInfo_t LeveInfo;
extern const ParShallInfo_t ParShallTale[];
int cMotorGetType (char * str);
int c4851GetType(char * str);
int c4852GetType(char * str);
int cU485GetType(char *str);
// 读取控制模式
int cCtrlGetType(char * str);
int cDownType2Index(char * str);
int cSiteType2Index(char * str);
#endif