Init
This commit is contained in:
commit
ca6580420b
|
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// Created by zemon on 06.08.24.
|
||||||
|
//
|
||||||
|
#include "XfcProtTable.h"
|
||||||
|
#include "ComIntPowerManager.h"
|
||||||
|
|
||||||
|
void XfcProtMethodsAdd_PowerManagerInit(tXfcPower *env, tPowerManagement *power, bool *fl_telematicaIsActive, bool *telematicaServerIsActive){
|
||||||
|
env->powerManagement = power;
|
||||||
|
env->fl_telematicaIsActive = fl_telematicaIsActive;
|
||||||
|
env->fl_telematicaServerIsActive = telematicaServerIsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XfcProtMethodsAdd_PowerManager(tXfcProtTable *protTab, tXfcPower *power) {
|
||||||
|
XfcProtTable_AddStatic(protTab, "GET_BAT_VOLTAGE", XfcProtMethod_BattaryVoltageGet, power);
|
||||||
|
XfcProtTable_AddStatic(protTab, "GET_BOARD_VOLTAGE", XfcProtMethod_BoardVoltageGet, power);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// Created by zemon on 06.08.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SMART_COMPONENTS_COMINTPOWERMANAGER_H
|
||||||
|
#define SMART_COMPONENTS_COMINTPOWERMANAGER_H
|
||||||
|
|
||||||
|
#include "XfcProtProcessorUtilDefines.h"
|
||||||
|
#include "PowerManagment.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VOLTAGE,
|
||||||
|
} tXfcPowerType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tPowerManagement *powerManagement;
|
||||||
|
uint16_t voltage;
|
||||||
|
bool *fl_telematicaIsActive;
|
||||||
|
bool *fl_telematicaServerIsActive;
|
||||||
|
} tXfcPower;
|
||||||
|
|
||||||
|
void XfcProtMethodsAdd_PowerManager(tXfcProtTable *protTab, tXfcPower *audioCodec);
|
||||||
|
|
||||||
|
void XfcProtMethodsAdd_PowerManagerInit(tXfcPower *env, tPowerManagement *power, bool *fl_telematicaIsActive, bool *telematicaServerIsActive);
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_BattaryVoltageGet(tXfcArray *request, tXfcArray *response, tXfcPower *power);
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_BoardVoltageGet(tXfcArray *request, tXfcArray *response, tXfcPower *power);
|
||||||
|
|
||||||
|
#endif //SMART_COMPONENTS_COMINTPOWERMANAGER_H
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
//
|
||||||
|
// Created by zemon on 24.07.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ComIntPowerManager.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_GetVoltsBoardVar(tXfcArray *request, tXfcArray *response, tXfcPower *env, char *paramValueID_text, uint8_t paramValueID_len) {
|
||||||
|
// Текстовый вид ID
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramValueID_len);
|
||||||
|
XFC_CMD_TX_ADD_ARR(paramValueID_text, paramValueID_len);
|
||||||
|
|
||||||
|
if (memcmp(paramValueID_text, "VOLTAGE", sizeof("VOLTAGE") - 1) == 0) {
|
||||||
|
uint8_t len = 2;
|
||||||
|
// Размер данных
|
||||||
|
XFC_CMD_TX_ADD_RAW(len);
|
||||||
|
// Данные
|
||||||
|
uint16_t value;
|
||||||
|
if((*env->fl_telematicaIsActive == true)||(*env->fl_telematicaServerIsActive == true)) {
|
||||||
|
value = env->powerManagement->powerSusystem->boardPower.currentBoardVoltageOfSerbisePO;
|
||||||
|
} else {
|
||||||
|
value = 65000;
|
||||||
|
}
|
||||||
|
XFC_CMD_TX_ADD_ARR(&value, len);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_GetVoltsBatVar(tXfcArray *request, tXfcArray *response, tXfcPower *env, char *paramValueID_text, uint8_t paramValueID_len) {
|
||||||
|
// Текстовый вид ID
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramValueID_len);
|
||||||
|
XFC_CMD_TX_ADD_ARR(paramValueID_text, paramValueID_len);
|
||||||
|
|
||||||
|
if (memcmp(paramValueID_text, "VOLTAGE", sizeof("VOLTAGE") - 1) == 0) {
|
||||||
|
uint8_t len = 2;
|
||||||
|
// Размер данных
|
||||||
|
XFC_CMD_TX_ADD_RAW(len);
|
||||||
|
// Данные
|
||||||
|
uint16_t value = env->powerManagement->powerSusystem->battery.currentBatVoltage;
|
||||||
|
XFC_CMD_TX_ADD_ARR(&value, len);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_BoardVoltageGet(tXfcArray *request, tXfcArray *response, tXfcPower *env){
|
||||||
|
// Чтение всех параметров
|
||||||
|
if (XfcArrayGetDataSize(request) == 0) {
|
||||||
|
|
||||||
|
uint16_t paramCount = 1;
|
||||||
|
// Количество параметров
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramCount);
|
||||||
|
|
||||||
|
uint8_t paramValueID_len;
|
||||||
|
char paramValueID_text[20];
|
||||||
|
|
||||||
|
paramValueID_len = sizeof("VOLTAGE") - 1;
|
||||||
|
paramValueID_text[0] = '\0';
|
||||||
|
strcat(paramValueID_text, "VOLTAGE");
|
||||||
|
if (!XfcProtMethod_GetVoltsBoardVar(request, response, env, paramValueID_text, paramValueID_len)) {
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Чтение избранных параметров
|
||||||
|
uint16_t paramCount;
|
||||||
|
XFC_CMD_RX_GET_RAW(paramCount);
|
||||||
|
|
||||||
|
// Количество параметров
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramCount);
|
||||||
|
|
||||||
|
for (uint16_t count = 0; count < paramCount; ++count) {
|
||||||
|
// Получение текстового id параметра
|
||||||
|
uint8_t paramValueID_len;
|
||||||
|
XFC_CMD_RX_GET_RAW(paramValueID_len);
|
||||||
|
char paramValueID_text[paramValueID_len];
|
||||||
|
XFC_CMD_RX_GET_ARR(paramValueID_text, paramValueID_len);
|
||||||
|
|
||||||
|
if(!XfcProtMethod_GetVoltsBoardVar(request, response, env, paramValueID_text, paramValueID_len)) {
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t XfcProtMethod_BattaryVoltageGet(tXfcArray *request, tXfcArray *response, tXfcPower *env){
|
||||||
|
|
||||||
|
// Чтение всех параметров
|
||||||
|
if (XfcArrayGetDataSize(request) == 0) {
|
||||||
|
|
||||||
|
uint16_t paramCount = 1;
|
||||||
|
// Количество параметров
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramCount);
|
||||||
|
|
||||||
|
uint8_t paramValueID_len;
|
||||||
|
char paramValueID_text[20];
|
||||||
|
|
||||||
|
paramValueID_len = sizeof("VOLTAGE") - 1;
|
||||||
|
paramValueID_text[0] = '\0';
|
||||||
|
strcat(paramValueID_text, "VOLTAGE");
|
||||||
|
if (!XfcProtMethod_GetVoltsBatVar(request, response, env, paramValueID_text, paramValueID_len)) {
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Чтение избранных параметров
|
||||||
|
uint16_t paramCount;
|
||||||
|
XFC_CMD_RX_GET_RAW(paramCount);
|
||||||
|
|
||||||
|
// Количество параметров
|
||||||
|
XFC_CMD_TX_ADD_RAW(paramCount);
|
||||||
|
|
||||||
|
for (uint16_t count = 0; count < paramCount; ++count) {
|
||||||
|
// Получение текстового id параметра
|
||||||
|
uint8_t paramValueID_len;
|
||||||
|
XFC_CMD_RX_GET_RAW(paramValueID_len);
|
||||||
|
char paramValueID_text[paramValueID_len];
|
||||||
|
XFC_CMD_RX_GET_ARR(paramValueID_text, paramValueID_len);
|
||||||
|
|
||||||
|
if(!XfcProtMethod_GetVoltsBatVar(request, response, env, paramValueID_text, paramValueID_len)) {
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_EXECUTION_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return XFC_TRANSPORT_PROTOCOL_RESPONSE_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"./"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"./**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue