将瞬时风速风向,极大极小添加进协议

This commit is contained in:
95384 2024-11-27 16:51:48 +08:00
parent 51e5b07b49
commit 4c91d4bf82
2 changed files with 129 additions and 73 deletions

View File

@ -22,46 +22,50 @@ typedef enum
/* 寄存器地址 */
typedef enum
{
FRT_REGISTER_MIN_WIND_DIRECTION = 0, /* 最小风向 */
FRT_REGISTER_AVERAGE_WIND_DIRECTION = 1, /* 平均风向 */
FRT_REGISTER_MAX_WIND_DIRECTION = 2, /* 最大风向 */
FRT_REGISTER_MIN_WIND_SPEED = 3, /* 最小风速 */
FRT_REGISTER_AVERAGE_WIND_SPEED = 4, /* 平均风速 */
FRT_REGISTER_MAX_WIND_SPEED = 5, /* 最大风速 */
FRT_REGISTER_TEMPERATURE = 6, /* 大气温度 */
FRT_REGISTER_HUMIDITY = 7, /* 大气湿度 */
FRT_REGISTER_PRESSURE = 8, /* 大气压 */
FRT_REGISTER_RAIN = 9, /* 雨量 */
FRT_REGISTER_PRECIPITATION_INTENSITY = 10, /* 总辐射 */
FRT_REGISTER_MIN_WIND_DIRECTION = 0, /* 最小风向 */
FRT_REGISTER_AVERAGE_WIND_DIRECTION = 1, /* 平均风向 */
FRT_REGISTER_INSTANTANEOUS_WIND_DIRECTION = 2, /* 瞬时风向 */
FRT_REGISTER_MAX_WIND_DIRECTION = 3, /* 最大风向 */
FRT_REGISTER_MIN_WIND_SPEED = 4, /* 最小风速 */
FRT_REGISTER_THROUGH_WIND_SPEED = 5, /* 极小风速 */
FRT_REGISTER_AVERAGE_WIND_SPEED = 6, /* 平均风速 */
FRT_REGISTER_INSTANTANEOUS_WIND_SPEED = 7, /* 瞬时风速 */
FRT_REGISTER_PEAK_WIND_SPEED = 8, /* 极大风速 */
FRT_REGISTER_MAX_WIND_SPEED = 9, /* 最大风速 */
FRT_REGISTER_TEMPERATURE = 10, /* 大气温度 */
FRT_REGISTER_HUMIDITY = 11, /* 大气湿度 */
FRT_REGISTER_PRESSURE = 12, /* 大气压 */
FRT_REGISTER_RAIN = 13, /* 雨量 */
FRT_REGISTER_PRECIPITATION_INTENSITY = 14, /* 总辐射 */
FRT_REGISTER_DEVICE_ADDR = 20, /* 设备地址 */
FRT_REGISTER_COMMU_BAUDRATE = 21, /* 波特率 */
FRT_REGISTER_SPEED_AVERAGE_TIME = 22, /* 风速平均时间 */
FRT_REGISTER_TEMPHUM_UPDATE_TIME = 23, /* 温湿度更新时间 */
FRT_REGISTER_RAIN_POWER_CONTROL = 24, /* 雨量电源控制 */
FRT_REGISTER_RAIN_REST = 25, /* 雨量复位 */
FRT_REGISTER_SOFT_REST = 26, /* 软件复位 */
FRT_REGISTER_REST_DEFAULT_SETTING = 27, /* 恢复出厂设置 */
FRT_REGISTER_PROTOCOL_SETTING = 28, /* 设置协议:0-ASCII;1-MODBUS协议 */
FRT_REGISTER_DEVICE_ADDR = 20, /* 设备地址 */
FRT_REGISTER_COMMU_BAUDRATE = 21, /* 波特率 */
FRT_REGISTER_SPEED_AVERAGE_TIME = 22, /* 风速平均时间 */
FRT_REGISTER_TEMPHUM_UPDATE_TIME = 23, /* 温湿度更新时间 */
FRT_REGISTER_RAIN_POWER_CONTROL = 24, /* 雨量电源控制 */
FRT_REGISTER_RAIN_REST = 25, /* 雨量复位 */
FRT_REGISTER_SOFT_REST = 26, /* 软件复位 */
FRT_REGISTER_REST_DEFAULT_SETTING = 27, /* 恢复出厂设置 */
FRT_REGISTER_PROTOCOL_SETTING = 28, /* 设置协议:0-ASCII;1-MODBUS协议 */
FRT_REGISTER_TRANSDUCER_CFG_1R5 = 30, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */
FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */
FRT_REGISTER_DISTANCE = 34, /* 换能器表面距离 */
FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */
FRT_REGISTER_WIND_C = 36, /* 计算得到的风速 */
FRT_REGISTER_LINEAR_POINT_X_1 = 37, /* 线性插值原始点1 */
FRT_REGISTER_LINEAR_POINT_X_2 = 38, /* 线性插值原始点2 */
FRT_REGISTER_LINEAR_POINT_X_3 = 39, /* 线性插值原始点3 */
FRT_REGISTER_LINEAR_POINT_X_4 = 40, /* 线性插值原始点4 */
FRT_REGISTER_LINEAR_POINT_X_5 = 41, /* 线性插值原始点5 */
FRT_REGISTER_LINEAR_POINT_Y_1 = 42, /* 线性插值校准点1 */
FRT_REGISTER_LINEAR_POINT_Y_2 = 43, /* 线性插值校准点2 */
FRT_REGISTER_LINEAR_POINT_Y_3 = 44, /* 线性插值校准点3 */
FRT_REGISTER_LINEAR_POINT_Y_4 = 45, /* 线性插值校准点4 */
FRT_REGISTER_LINEAR_POINT_Y_5 = 46, /* 线性插值校准点5 */
FRT_REGISTER_LINEAR_ENABLE = 47, /* 线性插值使能 */
FRT_REGISTER_TRANSDUCER_CFG_1R5 = 30, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_4R5 = 31, /* 换能器参数 */
FRT_REGISTER_TRANSDUCER_CFG_8R0 = 32, /* 换能器参数 */
FRT_REGISTER_RSSI_RANGE = 33, /* RSSI有效范围 */
FRT_REGISTER_DISTANCE = 34, /* 换能器表面距离 */
FRT_REGISTER_ERROR_LOG = 35, /* 错误日志 */
FRT_REGISTER_WIND_C = 36, /* 计算得到的风速 */
FRT_REGISTER_LINEAR_POINT_X_1 = 37, /* 线性插值原始点1 */
FRT_REGISTER_LINEAR_POINT_X_2 = 38, /* 线性插值原始点2 */
FRT_REGISTER_LINEAR_POINT_X_3 = 39, /* 线性插值原始点3 */
FRT_REGISTER_LINEAR_POINT_X_4 = 40, /* 线性插值原始点4 */
FRT_REGISTER_LINEAR_POINT_X_5 = 41, /* 线性插值原始点5 */
FRT_REGISTER_LINEAR_POINT_Y_1 = 42, /* 线性插值校准点1 */
FRT_REGISTER_LINEAR_POINT_Y_2 = 43, /* 线性插值校准点2 */
FRT_REGISTER_LINEAR_POINT_Y_3 = 44, /* 线性插值校准点3 */
FRT_REGISTER_LINEAR_POINT_Y_4 = 45, /* 线性插值校准点4 */
FRT_REGISTER_LINEAR_POINT_Y_5 = 46, /* 线性插值校准点5 */
FRT_REGISTER_LINEAR_ENABLE = 47, /* 线性插值使能 */
}FRT_MsgRegister;
#pragma pack(push,1)

View File

@ -17,9 +17,13 @@ static u_int16_t FRT_ReadReg(unsigned char regId);
/* 读 */
static u_int16_t FRT_ReadRegMinWindDiretion(void *pMsg);
static u_int16_t FRT_ReadRegAverageWindDirection(void *pMsg);
static u_int16_t FRT_ReadRegInstantaneousWindDirection(void *pMsg);
static u_int16_t FRT_ReadRegMaxWindDirection(void *pMsg);
static u_int16_t FRT_ReadRegMinWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegThroughWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegAverageWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegInstantaneousWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegPeakWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegMaxWindSpeed(void *pMsg);
static u_int16_t FRT_ReadRegTemperature(void *pMsg);
static u_int16_t FRT_ReadRegHumidity(void *pMsg);
@ -83,40 +87,44 @@ FRT_FuncionMsgProcTable_s g_MsgTbl[] =
/* 读寄存器处理表 */
FRT_RegProcTable_s g_RegTbl[] =
{
{ FRT_REGISTER_MIN_WIND_DIRECTION, FRT_ReadRegMinWindDiretion }, /* 最小风向 */
{ FRT_REGISTER_AVERAGE_WIND_DIRECTION, FRT_ReadRegAverageWindDirection }, /* 平均风向 */
{ FRT_REGISTER_MAX_WIND_DIRECTION, FRT_ReadRegMaxWindDirection }, /* 最大风向 */
{ FRT_REGISTER_MIN_WIND_SPEED, FRT_ReadRegMinWindSpeed }, /* 最小风速 */
{ FRT_REGISTER_AVERAGE_WIND_SPEED, FRT_ReadRegAverageWindSpeed }, /* 平均风速 */
{ FRT_REGISTER_MAX_WIND_SPEED, FRT_ReadRegMaxWindSpeed }, /* 最大风速 */
{ FRT_REGISTER_TEMPERATURE, FRT_ReadRegTemperature }, /* 大气温度 */
{ FRT_REGISTER_HUMIDITY, FRT_ReadRegHumidity }, /* 大气湿度 */
{ FRT_REGISTER_PRESSURE, FRT_ReadRegPressure }, /* 大气压 */
{ FRT_REGISTER_RAIN, FRT_ReadRegRain }, /* 雨量 */
{ FRT_REGISTER_PRECIPITATION_INTENSITY, FRT_ReadRegPrecipitationIntensity }, /* 总辐射 */
{ FRT_REGISTER_DEVICE_ADDR, FRT_ReadRegDeviceAddr }, /* 设备地址 */
{ FRT_REGISTER_COMMU_BAUDRATE, FRT_ReadRegCommuBaudRate }, /* 波特率 */
{ FRT_REGISTER_SPEED_AVERAGE_TIME, FRT_ReadRegSpeedAverageTime }, /* 风速平均时间 */
{ FRT_REGISTER_TEMPHUM_UPDATE_TIME, FRT_ReadRegTempHumUpdateTime }, /* 温湿度更新时间 */
{ FRT_REGISTER_RAIN_POWER_CONTROL, FRT_ReadRegRainPowerCtl }, /* 雨量电源时间 */
{ FRT_REGISTER_TRANSDUCER_CFG_1R5, FRT_ReadRegTransducerCFG1R5 }, /* 读换能器参数寄存器值1R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_ReadRegTransducerCFG4R5 }, /* 读换能器参数寄存器值4R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_ReadRegTransducerCFG8R0 }, /* 读换能器参数寄存器值8R0 */
{ FRT_REGISTER_RSSI_RANGE, FRT_ReadRegRSSIRange }, /* 读RSSI有效范围 */
{ FRT_REGISTER_DISTANCE, FRT_ReadRegDISTANCE }, /* 读探头表面有效距离 */
{ FRT_REGISTER_ERROR_LOG, FRT_ReadRegErrorData }, /* 读错误日志 */
{ FRT_REGISTER_WIND_C, FRT_ReadRegWindC }, /* 读计算得到的风速 */
{ FRT_REGISTER_LINEAR_POINT_X_1, FRT_ReadRegPoint_1X }, /* 线性插值原始点1 */
{ FRT_REGISTER_LINEAR_POINT_X_2, FRT_ReadRegPoint_2X }, /* 线性插值原始点2 */
{ FRT_REGISTER_LINEAR_POINT_X_3, FRT_ReadRegPoint_3X }, /* 线性插值原始点3 */
{ FRT_REGISTER_LINEAR_POINT_X_4, FRT_ReadRegPoint_4X }, /* 线性插值原始点4 */
{ FRT_REGISTER_LINEAR_POINT_X_5, FRT_ReadRegPoint_5X }, /* 线性插值原始点5 */
{ FRT_REGISTER_LINEAR_POINT_Y_1, FRT_ReadRegPoint_1Y }, /* 线性插值校准点1 */
{ FRT_REGISTER_LINEAR_POINT_Y_2, FRT_ReadRegPoint_2Y }, /* 线性插值校准点2 */
{ FRT_REGISTER_LINEAR_POINT_Y_3, FRT_ReadRegPoint_3Y }, /* 线性插值校准点3 */
{ FRT_REGISTER_LINEAR_POINT_Y_4, FRT_ReadRegPoint_4Y }, /* 线性插值校准点4 */
{ FRT_REGISTER_LINEAR_POINT_Y_5, FRT_ReadRegPoint_5Y }, /* 线性插值校准点5 */
{ FRT_REGISTER_LINEAR_ENABLE, FRT_ReadRegLinearEnable }, /* 线性插值使能 */
{ FRT_REGISTER_MIN_WIND_DIRECTION, FRT_ReadRegMinWindDiretion }, /* 最小风向 */
{ FRT_REGISTER_AVERAGE_WIND_DIRECTION, FRT_ReadRegAverageWindDirection }, /* 平均风向 */
{ FRT_REGISTER_INSTANTANEOUS_WIND_DIRECTION, FRT_ReadRegInstantaneousWindDirection }, /* 瞬时风向 */
{ FRT_REGISTER_MAX_WIND_DIRECTION, FRT_ReadRegMaxWindDirection }, /* 最大风向 */
{ FRT_REGISTER_MIN_WIND_SPEED, FRT_ReadRegMinWindSpeed }, /* 最小风速 */
{ FRT_REGISTER_THROUGH_WIND_SPEED, FRT_ReadRegThroughWindSpeed }, /* 极小风速 */
{ FRT_REGISTER_AVERAGE_WIND_SPEED, FRT_ReadRegAverageWindSpeed }, /* 平均风速 */
{ FRT_REGISTER_INSTANTANEOUS_WIND_SPEED, FRT_ReadRegInstantaneousWindSpeed }, /* 瞬时风速 */
{ FRT_REGISTER_PEAK_WIND_SPEED, FRT_ReadRegPeakWindSpeed }, /* 极大风速 */
{ FRT_REGISTER_MAX_WIND_SPEED, FRT_ReadRegMaxWindSpeed }, /* 最大风速 */
{ FRT_REGISTER_TEMPERATURE, FRT_ReadRegTemperature }, /* 大气温度 */
{ FRT_REGISTER_HUMIDITY, FRT_ReadRegHumidity }, /* 大气湿度 */
{ FRT_REGISTER_PRESSURE, FRT_ReadRegPressure }, /* 大气压 */
{ FRT_REGISTER_RAIN, FRT_ReadRegRain }, /* 雨量 */
{ FRT_REGISTER_PRECIPITATION_INTENSITY, FRT_ReadRegPrecipitationIntensity }, /* 总辐射 */
{ FRT_REGISTER_DEVICE_ADDR, FRT_ReadRegDeviceAddr }, /* 设备地址 */
{ FRT_REGISTER_COMMU_BAUDRATE, FRT_ReadRegCommuBaudRate }, /* 波特率 */
{ FRT_REGISTER_SPEED_AVERAGE_TIME, FRT_ReadRegSpeedAverageTime }, /* 风速平均时间 */
{ FRT_REGISTER_TEMPHUM_UPDATE_TIME, FRT_ReadRegTempHumUpdateTime }, /* 温湿度更新时间 */
{ FRT_REGISTER_RAIN_POWER_CONTROL, FRT_ReadRegRainPowerCtl }, /* 雨量电源时间 */
{ FRT_REGISTER_TRANSDUCER_CFG_1R5, FRT_ReadRegTransducerCFG1R5 }, /* 读换能器参数寄存器值1R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_4R5, FRT_ReadRegTransducerCFG4R5 }, /* 读换能器参数寄存器值4R5 */
{ FRT_REGISTER_TRANSDUCER_CFG_8R0, FRT_ReadRegTransducerCFG8R0 }, /* 读换能器参数寄存器值8R0 */
{ FRT_REGISTER_RSSI_RANGE, FRT_ReadRegRSSIRange }, /* 读RSSI有效范围 */
{ FRT_REGISTER_DISTANCE, FRT_ReadRegDISTANCE }, /* 读探头表面有效距离 */
{ FRT_REGISTER_ERROR_LOG, FRT_ReadRegErrorData }, /* 读错误日志 */
{ FRT_REGISTER_WIND_C, FRT_ReadRegWindC }, /* 读计算得到的风速 */
{ FRT_REGISTER_LINEAR_POINT_X_1, FRT_ReadRegPoint_1X }, /* 线性插值原始点1 */
{ FRT_REGISTER_LINEAR_POINT_X_2, FRT_ReadRegPoint_2X }, /* 线性插值原始点2 */
{ FRT_REGISTER_LINEAR_POINT_X_3, FRT_ReadRegPoint_3X }, /* 线性插值原始点3 */
{ FRT_REGISTER_LINEAR_POINT_X_4, FRT_ReadRegPoint_4X }, /* 线性插值原始点4 */
{ FRT_REGISTER_LINEAR_POINT_X_5, FRT_ReadRegPoint_5X }, /* 线性插值原始点5 */
{ FRT_REGISTER_LINEAR_POINT_Y_1, FRT_ReadRegPoint_1Y }, /* 线性插值校准点1 */
{ FRT_REGISTER_LINEAR_POINT_Y_2, FRT_ReadRegPoint_2Y }, /* 线性插值校准点2 */
{ FRT_REGISTER_LINEAR_POINT_Y_3, FRT_ReadRegPoint_3Y }, /* 线性插值校准点3 */
{ FRT_REGISTER_LINEAR_POINT_Y_4, FRT_ReadRegPoint_4Y }, /* 线性插值校准点4 */
{ FRT_REGISTER_LINEAR_POINT_Y_5, FRT_ReadRegPoint_5Y }, /* 线性插值校准点5 */
{ FRT_REGISTER_LINEAR_ENABLE, FRT_ReadRegLinearEnable }, /* 线性插值使能 */
};
/* 写寄存器处理表 */
@ -197,6 +205,17 @@ static u_int16_t FRT_ReadRegAverageWindDirection(void *pMsg)
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegInstantaneousWindDirection(void *pMsg)
{
u_int16_t value = (u_int16_t)(g_stMcs_Para.instantaneous_wind_direction *10);
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
@ -219,6 +238,17 @@ static u_int16_t FRT_ReadRegMinWindSpeed(void *pMsg)
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegThroughWindSpeed(void *pMsg)
{
u_int16_t value=(u_int16_t)(g_stMcs_Para.trough_wind_speed *10);
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
@ -230,6 +260,28 @@ static u_int16_t FRT_ReadRegAverageWindSpeed(void *pMsg)
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegInstantaneousWindSpeed(void *pMsg)
{
u_int16_t value=(u_int16_t)(g_stMcs_Para.instantaneous_wind_speed *10);
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
* @retval
*/
static u_int16_t FRT_ReadRegPeakWindSpeed(void *pMsg)
{
u_int16_t value=(u_int16_t)(g_stMcs_Para.peak_wind_speed *10);
return FRT_swap_endian_16(value);
}
/**
* @brief
* @param
@ -538,7 +590,7 @@ static u_int16_t FRT_ReadRegErrorData(void *pMsg)
*/
static u_int16_t FRT_ReadRegWindC(void *pMsg)
{
u_int16_t value=weather_info.wind_c = 0;
u_int16_t value=(u_int16_t)(weather_info.wind_c *10);
return FRT_swap_endian_16(value);
}