#include <stdint.h>
#include "server_common.h"
#include "version.h"
#include <string.h>
#include "charge_logic.h"
#include "fault_detect.h"
#include "rtc_driver.h"
#define GUN_OFFLINE 0
#define GUN_FAULT 1
#define GUN_IDLE 2
#define GUN_CHARGING 3
static uint16_t pack_serial = 0;
#define TO_SERVER_ENERGY(val) (100.0*val/3600)
typedef struct{
uint32_t sec;
uint8_t send_cnt;
uint8_t ack_flag;
PACK_DATA_0X3B bill;
}CURRENT_BILL;
static CURRENT_BILL s_current_bill[2] = {0};
void set_bill_ack_flag(uint8_t *trade_serial)
{
for(uint8_t i = 0;i < 2;i++){
if(!memcmp(s_current_bill[i].bill.trade_serial,trade_serial,TRADE_SERIAL_LENGTH)){
s_current_bill[i].ack_flag = 1;
}
}
}
/*
#define PACK_MONITOR_INTERVAL (30*1000)
static TimerHandle_t pack_monitor_timer = NULL;
static void pack_monitor_timer_proc(void)
{
if(pack_monitor_timer){
}
}
void init_pack_monitor_timer(void)
{
pack_monitor_timer = xTimerCreate("MONITOR_TIMER",PACK_MONITOR_INTERVAL,pdFALSE,( void * ) 0,pack_monitor_timer_proc);
}*/
void charger_to_server_0X01(void)
{
PACK_DATA_0X01 data = {0};
load_charger_serial(data.charger_serial);
data.charger_type = CHARGER_TYPE_AC;
data.gun_num = 2;
data.protocol_ver = SERVER_PROTOCOL_VER;
memcpy(data.software_ver,SW_VERSION,strlen(SW_VERSION));
data.net_conn_type = 0;
memset(data.sim,0x0,sizeof(data.sim));
for(uint8_t i = 0;i < 10;i++){
data.sim[i] = 0x01;
}
data.tele_factory = 0x04;
pack_and_send_server_data(FRAME_TYPE_0X01,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X01));
pack_serial++;
}
void charger_to_server_0X03(uint8_t gun_index,uint8_t gun_status)
{
PACK_DATA_0X03 data = {0};
load_charger_serial(data.charger_serial);
data.gun_index = gun_index;
data.gun_status = gun_status;
pack_and_send_server_data(FRAME_TYPE_0X03,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X03));
pack_serial++;
}
void charger_to_server_0X05(uint8_t num)
{
PACK_DATA_0X05 data = {0};
load_charger_serial(data.charger_serial);
data.fee_model_no = num;
pack_and_send_server_data(FRAME_TYPE_0X05,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X05));
pack_serial++;
}
void charger_to_server_0X09(void)
{
PACK_DATA_0X09 data = {0};
load_charger_serial(data.charger_serial);
pack_and_send_server_data(FRAME_TYPE_0X09,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X09));
pack_serial++;
}
uint8_t get_real_status_for_server(uint8_t idx)
{
uint8_t status = GUN_IDLE;
idx = idx - 1;
if(is_gun_fault_occur(idx)){
status = GUN_FAULT;
}else if((get_user_current_action(idx) == USER_ACTION_START_CHARGE)||(get_user_current_action(idx) == USER_ACTION_BOOK_CHARGE)){
status = GUN_CHARGING;
}else if(get_user_current_action(idx) == USER_ACTION_IDLE){
status = GUN_IDLE;
}else{
}
return status;
}
void charger_to_server_0X13(uint8_t gun_index)
{
PACK_DATA_0X13 data = {0};
CHARGING_GUN_CTRL *gun_ctrl = NULL;
gun_ctrl = get_charge_ctrl(gun_index-1);
load_charger_serial(data.charger_serial);
load_trade_serial(gun_index,data.trade_serial);
data.gun_index = gun_index;
data.status = get_real_status_for_server(gun_index);
data.gun_back = 0x02;
data.gun_is_insert = !!get_gun_status(gun_index-1);
data.out_voltage = gun_ctrl->voltage;//0.1V
data.charge_energy = TO_SERVER_ENERGY(gun_ctrl->charge_energy);//*100/3600;//0.0001kwh
data.out_current = gun_ctrl->current/10;//0.1A
data.charge_time = gun_ctrl->charge_time/60;
data.charge_money = gun_ctrl->charge_money*100;
pack_and_send_server_data(FRAME_TYPE_0X13,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X13));
pack_serial++;
}
void charger_to_server_0X19(uint8_t gun_index)
{
PACK_DATA_0X19 data = {0};
load_charger_serial(data.charger_serial);
load_trade_serial(gun_index,data.trade_serial);
pack_and_send_server_data(FRAME_TYPE_0X19,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X19));
pack_serial++;
}
void charger_to_server_0X31(uint8_t gun_index,uint32_t card_id)
{
PACK_DATA_0X31 data = {0};
load_charger_serial(data.charger_serial);
data.gun_index = gun_index;
memcpy(&data.card_no[4],&card_id,4);
data.start_mode = 0x01;
data.password_flag = 0x0;
//data.password
memset((uint8_t *)&data.vin,0x0,sizeof(data.vin));
pack_and_send_server_data(FRAME_TYPE_0X31,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X31));
pack_serial++;
}
void charger_to_server_0X33(uint8_t gun_index,uint8_t result,uint8_t err_code)
{
PACK_DATA_0X33 data = {0};
load_charger_serial(data.charger_serial);
load_trade_serial(gun_index,data.trade_serial);
data.gun_index = gun_index;
data.result = result;
data.err_code = err_code;
pack_and_send_server_data(FRAME_TYPE_0X33,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X33));
pack_serial++;
}
void charger_to_server_0X35(uint8_t gun_index)
{
PACK_DATA_0X35 data = {0};
load_charger_serial(data.charger_serial);
data.gun_index = gun_index;
pack_and_send_server_data(FRAME_TYPE_0X35,0,pack_serial,(uint8_t *)&data,sizeof(PACK_DATA_0X35));
pack_serial++;
}
void load_charge_bill(uint8_t gun_index,uint8_t stop_reason,PACK_DATA_0X3B *data)
{
CHARGING_GUN_CTRL *gun_ctrl = NULL;
FEE_MODEL *fee = NULL;
gun_ctrl = get_charge_ctrl(gun_index-1);
fee = gun_ctrl->fee_model;
load_trade_serial(gun_index,data->trade_serial);
load_charger_serial(data->charger_serial);
data->gun_index = gun_index;
memcpy(&data->phy_cardid[4],&gun_ctrl->card_id,4);
data->trade_flag = gun_ctrl->start_mode;
get_cp56time_from_sec(data->start_time,gun_ctrl->charge_start_time);
get_cp56time_from_sec(data->end_time,gun_ctrl->charge_time+gun_ctrl->charge_start_time);
get_cp56time_from_sec(data->trade_data,get_current_rtc_sec());
data->shark_price = fee->shark_fee_ratio + fee->shark_service_ratio;
data->shark_energy = TO_SERVER_ENERGY(gun_ctrl->type_energy[0]);//*100/3600;
data->shark_money = 1.0*gun_ctrl->type_energy[0]/3600/1000*data->shark_price;
data->loss_shark_energy = 0;
data->peak_price = fee->peak_fee_ratio + fee->peak_service_ratio;
data->peak_energy = TO_SERVER_ENERGY(gun_ctrl->type_energy[1]);//*100/3600;
data->peak_money = 1.0*gun_ctrl->type_energy[1]/3600/1000*data->peak_price;
data->loss_peak_energy = 0;
data->flat_price = fee->flat_fee_ratio + fee->flat_service_ratio;
data->flat_energy = TO_SERVER_ENERGY(gun_ctrl->type_energy[2]);//*100/3600;
data->flat_money = 1.0*gun_ctrl->type_energy[2]/3600/1000*data->flat_price;
data->loss_flat_energy = 0;
data->valley_price = fee->valley_fee_ratio + fee->valley_service_ratio;
data->valley_energy = TO_SERVER_ENERGY(gun_ctrl->type_energy[3]);//*100/3600;
data->valley_money = 1.0*gun_ctrl->type_energy[3]/3600/1000*data->valley_price;
data->loss_valley_energy = 0;
memset(data->meter_start_value,0,sizeof(data->meter_start_value));
data->meter_end_value[0] = (gun_ctrl->charge_energy*100/3600) & 0xFF;
data->meter_end_value[1] = (gun_ctrl->charge_energy*100/3600 >> 8) & 0xFF;
data->meter_end_value[2] = (gun_ctrl->charge_energy*100/3600 >> 16) & 0xFF;
data->meter_end_value[3] = (gun_ctrl->charge_energy*100/3600 >> 24) & 0xFF;
data->meter_end_value[4] = 0;
data->stop_reason = stop_reason;
data->total_energy = gun_ctrl->charge_energy*100/3600;
data->loss_total_energy = 0;
data->consumption = gun_ctrl->charge_money*100;
}
void charger_to_server_0x3B(uint8_t gun_index,uint32_t card_id,uint8_t trade_flag,uint8_t stop_reason)
{
PACK_DATA_0X3B
没有合适的资源?快使用搜索试试~ 我知道了~
MCU云快充协议C语言实现库软件源代码.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共6个文件
h:3个
c:3个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
MCU云快充协议C语言实现库软件源代码: #define FRAME_TYPE_0X01 0x01//充电桩登录认证 #define FRAME_TYPE_0X02 0x02 #define FRAME_TYPE_0X03 0x03//充电桩心跳包 #define FRAME_TYPE_0X04 0x04 #define FRAME_TYPE_0X05 0x05//计费模型验证请求 #define FRAME_TYPE_0X06 0x06 #define FRAME_TYPE_0X09 0x09//充电桩计费模型请求 #define FRAME_TYPE_0X0A 0x0A #define FRAME_TYPE_0X12 0x12//读取实时监测数据 //charger ---> server #define FRAME_TYPE_0X13 0x13//离线监测数据 #define FRAME_TYPE_0X15 0x15//充电
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![xls](https://img-home.csdnimg.cn/images/20210720083658.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 6 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- HandlerXU2024-07-15总算找到了自己想要的资源,对自己的启发很大,感谢分享~
- m0_614225592024-07-05资源内容详尽,对我有使用价值,谢谢资源主的分享。
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
GJZGRB
- 粉丝: 2847
- 资源: 7623
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 9301ff42a3ad6b9f291c5a15f506b637.pdf
- 小米9高通9008免权限救砖刷机教程+工具
- 06已知一个有序数组arr,和一个数字num 返回数组中是否含有这个数字 (使用二分法).zip
- 冒泡排序 每相邻的2个数比较,较大的数向后交换 排到最后一个位置时,它就是整个数组的最大值,第一轮结束
- 打造专业图像处理软件:Qt界面设计与自定义控件.pdf
- 从开发到发布:Qt与OpenCV项目的打包与跨平台部署.pdf
- OpenCV与Qt集成入门:基础知识与环境搭建.pdf
- perl脚本nTrakcer-mast管理系统
- sql规范iao-Cup-Province-m笔记
- vue3Trakcer-ma笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)