添加瞬时风速风向,极大极小风速(协议还未添加)
This commit is contained in:
parent
eb69ce74d0
commit
51e5b07b49
|
@ -110,16 +110,20 @@ extern Weather_param weather_info;
|
|||
|
||||
typedef struct _mcs_para{
|
||||
float32_t min_wind_direction; /* 最小风向 */
|
||||
float32_t average_wind_direction;/* 平均风向 */
|
||||
float32_t average_wind_direction; /* 平均风向 */
|
||||
float32_t instantaneous_wind_direction; /* 瞬时风向 */
|
||||
float32_t max_wind_direction; /* 最大风向 */
|
||||
float32_t min_wind_speed; /* 最小风速 */
|
||||
float32_t trough_wind_speed; /* 极小风速 */
|
||||
float32_t average_wind_speed; /* 平均风速 */
|
||||
float32_t instantaneous_wind_speed; /* 瞬时风速 */
|
||||
float32_t peak_wind_speed; /* 极大风速 */
|
||||
float32_t max_wind_speed; /* 最大风速 */
|
||||
float32_t temperature; /* 环境温度 */
|
||||
float32_t humidity; /* 环境湿度 */
|
||||
float32_t pressure; /* 压强 */
|
||||
float32_t precipitation; /* 雨量 */
|
||||
float32_t precipitation_intensity;/* 光辐射 */
|
||||
float32_t precipitation_intensity; /* 光辐射 */
|
||||
}mcs_para;
|
||||
extern mcs_para g_stMcs_Para;
|
||||
|
||||
|
|
|
@ -549,6 +549,9 @@ void wind_task(void const * argument)
|
|||
}
|
||||
/// term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle);
|
||||
}
|
||||
//瞬时风速风向
|
||||
g_stMcs_Para.instantaneous_wind_direction = av_angle;
|
||||
g_stMcs_Para.instantaneous_wind_speed = av_speed;
|
||||
///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity);
|
||||
//HAL_Delay(1);
|
||||
//osDelay(3//
|
||||
|
@ -834,22 +837,32 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
|
|||
float temp_max_direction = win_10min.ave_direction_data[0];
|
||||
float temp_min_speed = win_10min.ave_speed_data[0];
|
||||
float temp_max_speed = win_10min.ave_speed_data[0];
|
||||
//遍历10min内所有数据寻找最大最小
|
||||
float temp_trough_min_speed = win_10min.ave_speed_data[0];
|
||||
float temp_peak_max_speed = win_10min.ave_speed_data[0];
|
||||
//遍历10min内所有数据寻找最大最小极大极小
|
||||
for (int i = 0; i < win_10min.count; i++) {
|
||||
// 最大最小
|
||||
if (win_10min.ave_direction_data[i] < temp_min_direction) {
|
||||
temp_min_direction = win_10min.ave_direction_data[i]; // 更新风向最小值
|
||||
}
|
||||
if (win_10min.ave_direction_data[i] > temp_max_direction) {
|
||||
else if (win_10min.ave_direction_data[i] > temp_max_direction) {
|
||||
temp_max_direction = win_10min.ave_direction_data[i]; // 更新风向最大值
|
||||
}
|
||||
if (win_10min.ave_speed_data[i] < temp_min_speed) {
|
||||
temp_min_speed = win_10min.ave_speed_data[i]; // 更新风速最小值
|
||||
}
|
||||
if (win_10min.ave_speed_data[i] > temp_max_speed) {
|
||||
else if (win_10min.ave_speed_data[i] > temp_max_speed) {
|
||||
temp_max_speed = win_10min.ave_speed_data[i]; // 更新风速最大值
|
||||
}
|
||||
// 极大极小
|
||||
if (win_10min.speed_data[i] < temp_trough_min_speed) {
|
||||
temp_trough_min_speed = win_10min.speed_data[i]; // 更新风速极小值
|
||||
}
|
||||
|
||||
else if (win_10min.speed_data[i] > temp_peak_max_speed) {
|
||||
temp_peak_max_speed = win_10min.speed_data[i]; // 更新风速极大值
|
||||
}
|
||||
}
|
||||
// 更新最大最小极大极小风速风向
|
||||
g_stMcs_Para.min_wind_direction = temp_min_direction;
|
||||
g_stMcs_Para.average_wind_direction = win_10min.ave_direction_data[win_10min.index];
|
||||
g_stMcs_Para.max_wind_direction = temp_max_direction;
|
||||
|
@ -858,6 +871,10 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
|
|||
g_stMcs_Para.average_wind_speed = win_10min.ave_speed_data[win_10min.index];
|
||||
g_stMcs_Para.max_wind_speed = temp_max_speed;
|
||||
|
||||
// 极大极小风速
|
||||
g_stMcs_Para.trough_wind_speed = temp_trough_min_speed;
|
||||
g_stMcs_Para.peak_wind_speed = temp_peak_max_speed;
|
||||
|
||||
win_10min.index = (win_10min.index + 1) % /*AVE_TIME*/g_stConfigInfo.speed_average_time; //更新索引
|
||||
}
|
||||
|
||||
|
@ -909,7 +926,7 @@ void tem_hum_update_task(void const * argument)
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
// 风速风向更新
|
||||
my_update_mcs_param(av_speed, av_angle);
|
||||
my_update_mcs_param(g_stMcs_Para.instantaneous_wind_speed, g_stMcs_Para.instantaneous_wind_direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ void MX_FREERTOS_Init(void) {
|
|||
osThreadDef(anemometer, wind_task, osPriorityHigh, 0, 256);// ˇçË١çĎň
|
||||
anemometerHandle = osThreadCreate(osThread(anemometer), NULL);
|
||||
|
||||
osThreadDef(temhum_update_task, tem_hum_update_task, osPriorityAboveNormal, 0, 128);//温湿度,大气压更新
|
||||
osThreadDef(temhum_update_task, tem_hum_update_task, osPriorityAboveNormal, 0, 256);//温湿度,大气压更新
|
||||
temhum_update_taskHandle = osThreadCreate(osThread(temhum_update_task), NULL);
|
||||
|
||||
// osThreadDef(sensorTask, SensorTask, osPriorityRealtime, 0, 128);
|
||||
|
|
Loading…
Reference in New Issue