Release:5.20灰测

This commit is contained in:
2026-05-21 10:01:28 +08:00
parent 8a5a32b139
commit fd65e9c6a2
68 changed files with 4329 additions and 1489 deletions

View File

@@ -0,0 +1,19 @@
/**
******************************************************************************
* @file user\global\board_config.h
* @author luhuaishuai
* @version v0.1
* @date 2023-10-11
* @brief Briefly describe the function of your function
******************************************************************************
*/
#ifndef __BOARD_CONFIG_H
#define __BOARD_CONFIG_H
/* Private includes ----------------------------------------------------------*/
#define LINK_SERVER_PORT 6001 // 网关UDP服务端口
#define LINK_APP_PORT 6002 // 桩通讯端口
#define LINK_STAKE_PORT 6001 // 桩通讯端口
#endif /* __BOARD_CONFIG_H */

View File

@@ -5,42 +5,46 @@ ChargerManager g_charger_manager = {0};
/*充电桩序列号*/
const uint8_t piles_serial[6][7] = {
// {0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x01},
{0x32, 0x01, 0x06, 0x01, 0x16, 0x92, 0x45},
{0x32, 0x01, 0x06, 0x01, 0x16, 0x92, 0x44},
{0x32, 0x01, 0x06, 0x01, 0x16, 0x92, 0x43},
{0x32, 0x01, 0x06, 0x01, 0x16, 0x92, 0x42},
{0x32, 0x01, 0x06, 0x01, 0x11, 0x15, 0x58},
{0x32, 0x01, 0x06, 0x01, 0x11, 0x16, 0x54},
{0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x01},
{0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x02},
{0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x03},
{0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x04},
{0x88, 0x26, 0x01, 0x13, 0x12, 0x00, 0x05},
{0x32, 0x01, 0x06, 0x01, 0x11, 0x15, 0x54},
};
/**
* @brief 初始化充电桩管理器
* @note 初始化充电桩管理器,设置充电桩数量和每个充电桩的初始状态
*/
void init_chargers(void) {
void init_chargers(void)
{
g_charger_manager.charger_count = MAX_CHARGER_COUNT;
for (int i = 0; i < g_charger_manager.charger_count; i++) {
for (int i = 0; i < g_charger_manager.charger_count; i++)
{
ChargerPile *ctx = &g_charger_manager.charger_piles[i];
memcpy(ctx->login_info.charger_serial, piles_serial[i], 7);
memcpy(ctx->charger_serial, piles_serial[i], CHARGER_SERIAL_LENGTH);
memcpy(ctx->login_info.charger_serial, piles_serial[i], CHARGER_SERIAL_LENGTH);
ctx->get_model = false;
ctx->is_udp_online = false;
ctx->step = 0;
ctx->step_tick = 0;
ctx->login_info.charger_type = CHARGER_TYPE_DC;
ctx->login_info.gun_num = MAX_GUN_PER_CHARGER;
ctx->login_info.protocol_ver = 0x10; // V1.6
strcpy((char*)ctx->login_info.software_ver, "V4.1.50");
strcpy((char *)ctx->login_info.software_ver, "V4.1.50");
ctx->login_info.net_conn_type = 0; // SIM
memset(ctx->login_info.sim, 0, 10);
ctx->login_info.tele_factory = 0x00; // 移动
// 初始化枪
for (int g = 0; g < ctx->login_info.gun_num; g++) {
for (int g = 0; g < ctx->login_info.gun_num; g++)
{
ctx->guns[g].gun_index = g + 1;
ctx->guns[g].gun_step = 0;
ctx->guns[g].gun_step_tick = 0;
ctx->guns[g].real_time_data.status = 0; // 离线
}
}

View File

@@ -8,37 +8,61 @@
#define MAX_CHARGER_COUNT 2 // 充电桩数量
#define MAX_GUN_PER_CHARGER 2 // 每个充电桩最多枪数
enum CHARGER_STATE
{
IDLE_CHARGER_STATE = 0, // 空闲状态
REDAY_CHARGER_START_STATE = 1, // 等待桩启动回应
SUCCESS_CHARGER_STATE = 2, // 桩启动成功
FAIL_CHARGER_STATE = 3, // 桩启动失败
CHARGER_STATE_CHARGING = 4, // 桩充电中
REDAY_CHARGER_STOP_STATE = 5, // 等待桩停止回应
SUCCESS_CHARGER_STOP_STATE = 6, // 桩停止成功
FAIL_CHARGER_STOP_STATE = 7, // 桩停止失败
CHARGER_STATE_CHARGE_DONE = 8, // 桩充电完成
CHARGER_STATE_STOPPED = 9, // 桩主动停止
};
/* 充电枪结构体*/
typedef struct
{
uint8_t gun_index; // 枪索引
uint8_t gun_index; // 枪索引
uint8_t charger_state; // 枪充电流程状态
uint8_t gun_step; // 枪独立状态步进
uint32_t gun_step_tick; // 枪非阻塞延时时间戳(ms)
uint8_t is_get_bill; // 是否获取账单数据
uint8_t trade_serial[TRADE_SERIAL_LENGTH]; // 交易流水号
PACK_DATA_0X33 charging_feedback; // 远程启机反馈数据
PACK_DATA_0X13 real_time_data; // 实时数据
PACK_DATA_0X03 heartbeat_status_data; // 心跳状态数据
PACK_DATA_0X3B fee_data; // 计费数据
PACK_DATA_0X23 bms_demand; // 充电过程BMS需求、充电机输出
PACK_DATA_0X25 bms_info; // 充电过程BMS信息
PACK_DATA_0X13 real_time_data; // 实时数据
} ChargerGun;
/* 单个充电桩结构体*/
typedef struct
{
PACK_DATA_0X01 login_info;
bool is_online; //云快充是否连接
bool is_udp_online; //是否本地在线
bool get_model;
uint16_t last_heartbeat_time; // 最后一次心跳时间
ChargerGun guns[MAX_GUN_PER_CHARGER]; // 充电枪数组
bool is_online; // 云快充是否连接
bool is_udp_online; // 是否本地在线
bool get_model; // 是否获取计费模型
uint8_t step; // 桩初始化/运行状态步进
uint32_t step_tick; // 非阻塞延时时间戳(ms)
PACK_DATA_0X01 login_info; // 登录信息数据
uint8_t charger_serial[CHARGER_SERIAL_LENGTH]; // 桩编号
ChargerGun guns[MAX_GUN_PER_CHARGER]; // 充电枪数组
} ChargerPile;
/*全局充电桩管理结构体*/
typedef struct
{
uint8_t charger_count; // 桩索引
uint8_t charger_count; // 桩索引
ChargerPile charger_piles[MAX_CHARGER_COUNT]; // 充电桩数组
FEE_MODEL fee_model_global ; //全局计费模型
FEE_MODEL fee_model_global; // 全局计费模型
} ChargerManager;
extern ChargerManager g_charger_manager;
void init_chargers(void); //初始化全局充电桩
void init_chargers(void); // 初始化全局充电桩
#endif /* __DC_PILE_H */

View File

@@ -12,7 +12,6 @@
/* Includes -------------------------------------------------------------------*/
#include "drv_init.h"
#include "_hal_init.h"
@@ -20,9 +19,9 @@
* @brief 初始化全局系统
* @note 初始化全局系统包括HAL层和驱动层的初始化
*/
void g_Init(void)
void g_init(void)
{
_hal_all_Init();
drv_all_Init();
}
drv_all_init();
os_init();
}

View File

@@ -5,7 +5,7 @@
/* Exported functions prototypes ------------------------------------------------------------------------*/
void g_Init(void);
void g_init(void);

View File

@@ -36,6 +36,7 @@
#include "semphr.h"
#include "event_groups.h"
#include "stream_buffer.h"
#include "timers.h"
/* Os */
#include "os_task.h"
@@ -47,13 +48,13 @@
#include "server_to_charger.h"
#include "g_dcpile.h"
/* _hal */
#include "_hal_usart.h"
/* driver */
#include "cJSON.h"
#include "server_common.h"
#include "charger_to_server.h"
#include "drv_usart.h"
/* macro ------------------------------------------------------------------------------------------------*/
#define ON 1
@@ -73,8 +74,6 @@
#define DEBUG 1 // 调试模式
#define YKC_SERVER_IP "121.43.69.62" // YKC 服务器 IP 地址
#define YKC_SERVER_PORT 8767 // YKC 服务器端口号
/*- I/O 输出-*/