RMUL2025/User/module/cap.c

56 lines
1.9 KiB
C
Raw Normal View History

2025-03-09 17:26:17 +08:00
/*
*
*/
/* Includes ----------------------------------------------------------------- */
#include "cap.h"
#include "component\capacity.h"
#include "component\limiter.h"
#include "device\can.h"
#include "device\referee.h"
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
#define CAP_CUTOFF_VOLT 12.0f
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Private function -------------------------------------------------------- */
/**
* @brief
*
* @param cap
* @param referee
* @param cap_out
*/
void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
CAN_CapOutput_t *cap_out) {
if (referee->ref_status != REF_STATUS_RUNNING) {
/* 当裁判系统离线时,依然使用裁判系统进程传来的数据 */
cap_out->power_limit = referee->chassis_power_limit;
} else {
/* 当裁判系统在线时,使用算法控制裁判系统输出(即电容输入) */
cap_out->power_limit =
PowerLimit_CapInput(referee->chassis_watt, referee->chassis_power_limit,
referee->chassis_pwr_buff);
}
/* 更新电容状态和百分比 */
cap->cap_status = CAN_CAP_STATUS_RUNNING;
cap->percentage = Capacity_GetCapacitorRemain(cap->cap_feedback.cap_volt,
cap->cap_feedback.input_volt,
CAP_CUTOFF_VOLT);
}
/**
* @brief
*
* @param cap
* @param ui
*/
void Cap_DumpUI(const CAN_Capacitor_t *cap, Referee_CapUI_t *ui) {
ui->percentage = cap->percentage;
ui->status = cap->cap_status;
}