Files
BR_YKC/Core/User/Task/YkcTask.c
2026-03-31 15:46:04 +08:00

102 lines
2.7 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.
/**
******************************************************************************
* @file user\task\HeartBeatTask.c
* @author luhuaishuai
* @version v0.1
* @date 2026-1-12
* @brief Briefly describe the function of your function
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "YkcTask.h"
#include "lwip/opt.h"
#include "lwip/api.h"
#include "lwip/sys.h"
/**
* @funNm : YkcTask_Function
* @brief : 云快充平台交互任务
* @param : argument
* @retval: void
*/
uint8_t SETP = 0;
void YkcTask_Function(void const *argument)
{
init_chargers(); /* 初始化桩结构体*/
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); /* 等待桩通讯协议层完成*/
while (1)
{
TaskRunTimeStat.YkcTask.threads_runtime = GetTask_RunTime(YkcTaskID);
TaskRunTimeStat.YkcTask.threads_counter = GetTask_Beatcnt(YkcTaskID);
TaskRunTimeStat.YkcTask.threads_freestack = Get_Free_Stack(YkcTaskID);
switch (SETP)
{
case 0:
{
if (!g_charger_manager.charger_piles[1 - 1].is_online)
{
charger_to_server_0X01(1);
}
else
{
SETP = 1;
}
}
break;
case 1:
{
if (!g_charger_manager.charger_piles[1 - 1].get_model)
charger_to_server_0X09(1); // 桩1计费模型请求
else
SETP = 2;
}
break;
case 2:
{
charger_to_server_0X13(1, 1); // 上传状态
}
break;
default:
break;
}
osDelay(2000);
}
}
/**
* @brief 解析云快充平台下行数据
* @note 解析云快充平台下行数据,根据不同的帧类型调用相应的处理函数
* @param stake_mark 桩编号
* @param pack 指向SERVER_PACK结构体的指针包含下行数据
*/
void handle_ykc_downlink(uint8_t stake_mark, SERVER_PACK *pack)
{
switch (pack->frame_type)
{
case FRAME_TYPE_0X02:
on_cmd_frame_type_0X02(stake_mark, pack);
break;
case FRAME_TYPE_0X04:
on_cmd_frame_type_0X04(stake_mark, pack);
break;
case FRAME_TYPE_0X06:
on_cmd_frame_type_0X06(stake_mark, pack);
break;
case FRAME_TYPE_0X0A:
on_cmd_frame_type_0X0A(stake_mark, pack);
break;
case FRAME_TYPE_0X58:
on_cmd_frame_type_0X58(stake_mark, pack);
break;
case FRAME_TYPE_0X34:
on_cmd_frame_type_0X34(stake_mark, pack);
break;
}
}