Обновление
This commit is contained in:
parent
ba35e232df
commit
800897a0f7
|
|
@ -1,185 +0,0 @@
|
||||||
//
|
|
||||||
// Created by cfif on 20.01.2026.
|
|
||||||
//
|
|
||||||
#include "LinActuatorWork.h"
|
|
||||||
|
|
||||||
|
|
||||||
//#define LOG_SIGN "Lin"
|
|
||||||
#define LOGGER &env->slog.logger
|
|
||||||
|
|
||||||
static bool isBroadCastTriggered(tLinTaskActuator *env, ActuatorCmdBus *actuator_Command_Model_trigger_local) {
|
|
||||||
|
|
||||||
for (uint8_t j = 0; j < env->LIN_ISSR_ALL; ++j) {
|
|
||||||
if (actuator_Command_Model_trigger_local->BUS_ADR[j] != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void showLogCommand(tMma *env, char *LOG_SIGN, uint8_t BUS_ADR, uint8_t COM) {
|
|
||||||
switch (COM) {
|
|
||||||
case LIN_ACT_CFR_NONE: {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - NO COMMAND", BUS_ADR)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LIN_ACT_CFR_MOD: {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - LIN_ACT_CFR_MOD", BUS_ADR)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LIN_ACT_CFR_INI: {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - LIN_ACT_CFR_INI", BUS_ADR)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LIN_ACT_CFR_SET: {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - LIN_ACT_CFR_SET", BUS_ADR)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - UNKNOWN COMMAND", BUS_ADR)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (LOG_LIN_ACTUATOR == 1)
|
|
||||||
#define IS_LOGGING_ENABLED(numAct) \
|
|
||||||
( (numAct == 1 && LOG_LIN1_ACTUATOR == 1) || \
|
|
||||||
(numAct == 2 && LOG_LIN2_ACTUATOR == 1) || \
|
|
||||||
(numAct == 3 && LOG_LIN3_ACTUATOR == 1) )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// actuator_Command_Model_local - Выход модели (команды для актуаторов) ЛОКАЛЬНО
|
|
||||||
// actuator_Command_Model_trigger_local - Выход модели (команды для актуаторов) ЗАХВАТ
|
|
||||||
// actuator_Output_Model_local - Вход модели (состояния актуаторов) ЛОКАЛЬНЫЙ
|
|
||||||
// actuator_Output_Model_model - Вход модели (состояния актуаторов) МОДЕЛИ
|
|
||||||
|
|
||||||
void LinActuatorWork(tMma *env, tLinTaskActuator *linTaskActuator, uint8_t numAct,
|
|
||||||
ActuatorCmdBus *actuator_Command_Model_local,
|
|
||||||
ActuatorCmdBus *actuator_Command_Model_trigger_local,
|
|
||||||
ActuatorCmdBusInput *actuator_Output_Model_local,
|
|
||||||
ActuatorCmdBusInput *actuator_Output_Model_model,
|
|
||||||
bool *triggerCommand,
|
|
||||||
char *LOG_SIGN) {
|
|
||||||
|
|
||||||
if (osMutexAcquire(linTaskActuator->access, 5000) == osOK) {
|
|
||||||
|
|
||||||
// Если актуатор не занят
|
|
||||||
if (linTaskActuator->busy == false) {
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < linTaskActuator->LIN_ISSR_ALL; ++i) {
|
|
||||||
|
|
||||||
linTaskActuator->linCommandActuator[i].POS = actuator_Command_Model_local->POS[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].BUS_ADR = actuator_Command_Model_local->BUS_ADR[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].MODE = actuator_Command_Model_local->MODE[i];
|
|
||||||
|
|
||||||
// Если команда выполнена
|
|
||||||
if (linTaskActuator->linCommandActuator[i].COM == LIN_ACT_CFR_SUCCESSFUL) {
|
|
||||||
#if (LOG_LIN_ACTUATOR == 1)
|
|
||||||
if (IS_LOGGING_ENABLED(numAct)) {
|
|
||||||
LoggerFormatInfo(LOGGER, LOG_SIGN, "BUS_ADR: %d - SUCCESSFUL COMMAND (UNSET BUSY)", i + 1)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// LoggerFormatInfo(LOGGER, LOG_SIGN, "ACTUATOR %d - SUCCESSFUL COMMAND (UNSET BUSY)", numAct)
|
|
||||||
|
|
||||||
actuator_Output_Model_local->Busy = 0;
|
|
||||||
// Разрешение обработки новой команды
|
|
||||||
env->isActuatorNoGetNextCommand[numAct - 1] = false;
|
|
||||||
|
|
||||||
// Обнуляем команду в локальном буфере
|
|
||||||
actuator_Command_Model_local->COM[i] = LIN_ACT_CFR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ТОЛЬКО если команда не SUCCESSFUL, копируем новые данные
|
|
||||||
linTaskActuator->linCommandActuator[i].COM = actuator_Command_Model_local->COM[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].Stall_SET = actuator_Command_Model_local->Stall_SET[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].Lnoise_SET = actuator_Command_Model_local->Lnoise_SET[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].Autos_SET = actuator_Command_Model_local->Autos_SET[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].Speed_SET = actuator_Command_Model_local->Speed_SET[i];
|
|
||||||
linTaskActuator->linCommandActuator[i].Coils_Stop_SET = actuator_Command_Model_local->Coils_Stop_SET[i];
|
|
||||||
|
|
||||||
// Заполнение данных ВХОДЫ МОДЕЛИ
|
|
||||||
actuator_Output_Model_local->in_CPOS_ALL[i] = (int16_t) linTaskActuator->linStateActuator[i].CPOS_ALL;
|
|
||||||
actuator_Output_Model_local->in_Act_Emrf_Slave[i] = (int8_t) linTaskActuator->linStateActuator[i].Emrf_Slave;
|
|
||||||
actuator_Output_Model_local->in_Mode_Slave[i] = (int8_t) linTaskActuator->linStateActuator[i].Mode_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Err1_Supply[i] = (int8_t) linTaskActuator->linStateActuator[i].Error1_Supply_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Err2_Communication[i] = (int8_t) linTaskActuator->linStateActuator[i].Error2_Communication_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Err3_Temperature[i] = (int8_t) linTaskActuator->linStateActuator[i].Error3_Temperature_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Err4_Permanent_Electrical[i] = (int8_t) linTaskActuator->linStateActuator[i].Error4_Permanent_Electrical_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Stall_Slave[i] = linTaskActuator->linStateActuator[i].Stall_Slave;
|
|
||||||
actuator_Output_Model_local->in_Act_Reset[i] = linTaskActuator->linStateActuator[i].Reset_Slave;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Заполнение данных ВХОДЫ МОДЕЛИ
|
|
||||||
actuator_Output_Model_local->Error_Connect = linTaskActuator->error_connect;
|
|
||||||
|
|
||||||
// LoggerFormatInfo(LOGGER, LOG_SIGN, "Busy = %d Error_Connect = %d", actuator_Output_Model_local->Busy, actuator_Output_Model_local->Error_Connect)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
osMutexRelease(linTaskActuator->access);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (osMutexAcquire(env->ModelTask.access, 5000) == osOK) {
|
|
||||||
|
|
||||||
// Если прията команда и актуатор не занят (может принимать команды)
|
|
||||||
if ((*triggerCommand == true) && (env->isActuatorNoGetNextCommand[numAct - 1] == false)) {
|
|
||||||
|
|
||||||
*triggerCommand = false;
|
|
||||||
|
|
||||||
#if (LOG_LIN_ACTUATOR == 1)
|
|
||||||
if (IS_LOGGING_ENABLED(numAct)) {
|
|
||||||
if (isBroadCastTriggered(linTaskActuator, actuator_Command_Model_trigger_local)) {
|
|
||||||
LoggerInfoStatic(LOGGER, LOG_SIGN, "DETECT COMMAND (BROADCAST):")
|
|
||||||
showLogCommand(env, LOG_SIGN, actuator_Command_Model_trigger_local->BUS_ADR[0],
|
|
||||||
actuator_Command_Model_trigger_local->COM[0]);
|
|
||||||
} else {
|
|
||||||
LoggerInfoStatic(LOGGER, LOG_SIGN, "DETECT COMMAND (NO BROADCAST):")
|
|
||||||
for (uint8_t i = 0; i < linTaskActuator->LIN_ISSR_ALL; ++i) {
|
|
||||||
showLogCommand(env, LOG_SIGN, actuator_Command_Model_trigger_local->BUS_ADR[i],
|
|
||||||
actuator_Command_Model_trigger_local->COM[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
actuator_Output_Model_local->Busy = 1;
|
|
||||||
|
|
||||||
// Запрещение обработки новой команды
|
|
||||||
env->isActuatorNoGetNextCommand[numAct - 1] = true;
|
|
||||||
|
|
||||||
// начало --- ВЫХОД МОДЕЛИ ----------
|
|
||||||
|
|
||||||
// ВЫХОД МОДЕЛИ
|
|
||||||
memcpy(actuator_Command_Model_local, actuator_Command_Model_trigger_local, sizeof(ActuatorCmdBus));
|
|
||||||
|
|
||||||
// Сброс STALL в состоянии актуатор (локальном состоянии)
|
|
||||||
|
|
||||||
#if (LOG_LIN_ACTUATOR == 1)
|
|
||||||
if (IS_LOGGING_ENABLED(numAct)) {
|
|
||||||
LoggerInfoStatic(LOGGER, linTaskActuator->SIGN_LOG, "Reset LOCAL STALL (DETECT STALL RESET)")
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (uint8_t i = 0; i < linTaskActuator->LIN_ISSR_ALL; ++i) {
|
|
||||||
actuator_Output_Model_local->in_Act_Stall_Slave[i] = LIN_STALL_STA_OFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
// конец --- ВЫХОД МОДЕЛИ ----------
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ВХОДЫ МОДЕЛИ
|
|
||||||
memcpy(actuator_Output_Model_model, actuator_Output_Model_local, sizeof(ActuatorCmdBusInput));
|
|
||||||
|
|
||||||
osMutexRelease(env->ModelTask.access);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
//
|
|
||||||
// Created by cfif on 20.01.2026.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef HVAC_M7_LINACTUATORWORK_H
|
|
||||||
#define HVAC_M7_LINACTUATORWORK_H
|
|
||||||
|
|
||||||
#include "MainModesArbiter_Private.h"
|
|
||||||
#include "HVAC_model_types.h"
|
|
||||||
|
|
||||||
void LinActuatorWork(tMma *env, tLinTaskActuator *linTaskActuator, uint8_t numAct,
|
|
||||||
ActuatorCmdBus *actuator_Command_Model_local,
|
|
||||||
ActuatorCmdBus *actuator_Command_Model_trigger_local,
|
|
||||||
ActuatorCmdBusInput *actuator_Output_Model_local,
|
|
||||||
ActuatorCmdBusInput *actuator_Output_Model_model,
|
|
||||||
bool *triggerCommand,
|
|
||||||
char *LOG_SIGN);
|
|
||||||
|
|
||||||
#endif //HVAC_M7_LINACTUATORWORK_H
|
|
||||||
|
|
@ -389,7 +389,7 @@ static _Noreturn void Mma_Thread(tMma *env) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LoadDataInFromModel(env);
|
LoadDataInFromModel(env);
|
||||||
|
/*
|
||||||
LinActuatorWork(env, &env->linTaskActuator1, 1,
|
LinActuatorWork(env, &env->linTaskActuator1, 1,
|
||||||
&env->actuator_Ch0_Command_Model_local_1,
|
&env->actuator_Ch0_Command_Model_local_1,
|
||||||
&env->ModelTask.triggerActuatorCmdBus_1,
|
&env->ModelTask.triggerActuatorCmdBus_1,
|
||||||
|
|
@ -410,7 +410,7 @@ static _Noreturn void Mma_Thread(tMma *env) {
|
||||||
&env->actuator_Ch2_Input_Model_local_3,
|
&env->actuator_Ch2_Input_Model_local_3,
|
||||||
&Actuator_Ch2_Status_Model, &env->ModelTask.triggerCommand3, "Ln3 ");
|
&Actuator_Ch2_Status_Model, &env->ModelTask.triggerCommand3, "Ln3 ");
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
SystemDelayMs(50);
|
SystemDelayMs(50);
|
||||||
GpioPinToggle(&env->gpios->led.LED_G);
|
GpioPinToggle(&env->gpios->led.LED_G);
|
||||||
|
|
|
||||||
|
|
@ -83,18 +83,19 @@ typedef struct {
|
||||||
osThreadAttr_t attr;
|
osThreadAttr_t attr;
|
||||||
} thread;
|
} thread;
|
||||||
|
|
||||||
|
CmdBusADCData ADC_Data_Model_local;
|
||||||
|
|
||||||
|
/*
|
||||||
// Входные данные (локальные) для модели
|
// Входные данные (локальные) для модели
|
||||||
ActuatorCmdBus actuator_Ch0_Command_Model_local_1;
|
ActuatorCmdBus actuator_Ch0_Command_Model_local_1;
|
||||||
ActuatorCmdBus actuator_Ch1_Command_Model_local_2;
|
ActuatorCmdBus actuator_Ch1_Command_Model_local_2;
|
||||||
ActuatorCmdBus actuator_Ch2_Command_Model_local_3;
|
ActuatorCmdBus actuator_Ch2_Command_Model_local_3;
|
||||||
|
|
||||||
CmdBusADCData ADC_Data_Model_local;
|
|
||||||
|
|
||||||
// Выходные данные (локальные) для модели
|
// Выходные данные (локальные) для модели
|
||||||
ActuatorCmdBusInput actuator_Ch0_Input_Model_local_1;
|
ActuatorCmdBusInput actuator_Ch0_Input_Model_local_1;
|
||||||
ActuatorCmdBusInput actuator_Ch1_Input_Model_local_2;
|
ActuatorCmdBusInput actuator_Ch1_Input_Model_local_2;
|
||||||
ActuatorCmdBusInput actuator_Ch2_Input_Model_local_3;
|
ActuatorCmdBusInput actuator_Ch2_Input_Model_local_3;
|
||||||
|
*/
|
||||||
|
|
||||||
bool isActuatorNoGetNextCommand[3];
|
bool isActuatorNoGetNextCommand[3];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,8 @@ static void Mma_InitSubSystems(tMma *env) {
|
||||||
|
|
||||||
// Indication_Init(&env->Indication, HVAC_DEV_MODE_STARTUP);
|
// Indication_Init(&env->Indication, HVAC_DEV_MODE_STARTUP);
|
||||||
|
|
||||||
|
ModelTask_Init(&env->ModelTask, &env->linTaskActuator1, &env->linTaskActuator2, &env->linTaskActuator3, &env->slog.logger);
|
||||||
|
|
||||||
CommandLine_Init(&env->cli, &env->slog, &env->serialPorts->SerialPortLog_IO, &env->serialPorts->cliVirtualPortOut_Io);
|
CommandLine_Init(&env->cli, &env->slog, &env->serialPorts->SerialPortLog_IO, &env->serialPorts->cliVirtualPortOut_Io);
|
||||||
CommandLine_StartThread(&env->cli);
|
CommandLine_StartThread(&env->cli);
|
||||||
|
|
||||||
|
|
@ -129,15 +131,40 @@ static void Mma_InitSubSystems(tMma *env) {
|
||||||
CanSpamTransmitter_StartThread(&env->canSpamTransmitter);
|
CanSpamTransmitter_StartThread(&env->canSpamTransmitter);
|
||||||
|
|
||||||
tLinData *linData1 = Lin1_Init(GetLin123CallbackHandler);
|
tLinData *linData1 = Lin1_Init(GetLin123CallbackHandler);
|
||||||
Lin_1_Init(&env->linTaskActuator1, linData1, &env->linPorts->lin1_Io, 9, &env->slog.logger);
|
Lin_1_Init(&env->linTaskActuator1,
|
||||||
|
linData1, &env->linPorts->lin1_Io, 9,
|
||||||
|
|
||||||
|
env->ModelTask.access,
|
||||||
|
&env->ModelTask.triggerActuatorCmdBus_1,
|
||||||
|
&env->ModelTask.triggerCommand1,
|
||||||
|
|
||||||
|
&env->slog.logger);
|
||||||
|
|
||||||
|
|
||||||
Lin1_StartThread(&env->linTaskActuator1);
|
Lin1_StartThread(&env->linTaskActuator1);
|
||||||
|
|
||||||
tLinData *linData2 = Lin2_Init(GetLin123CallbackHandler);
|
tLinData *linData2 = Lin2_Init(GetLin123CallbackHandler);
|
||||||
Lin_2_Init(&env->linTaskActuator2, linData2, &env->linPorts->lin2_Io, 6, &env->slog.logger);
|
Lin_2_Init(&env->linTaskActuator2,
|
||||||
|
linData2, &env->linPorts->lin2_Io, 6,
|
||||||
|
|
||||||
|
env->ModelTask.access,
|
||||||
|
&env->ModelTask.triggerActuatorCmdBus_2,
|
||||||
|
&env->ModelTask.triggerCommand2,
|
||||||
|
|
||||||
|
&env->slog.logger);
|
||||||
|
|
||||||
Lin2_StartThread(&env->linTaskActuator2);
|
Lin2_StartThread(&env->linTaskActuator2);
|
||||||
|
|
||||||
tLinData *linData3 = Lin3_Init(GetLin123CallbackHandler);
|
tLinData *linData3 = Lin3_Init(GetLin123CallbackHandler);
|
||||||
Lin_3_Init(&env->linTaskActuator3, linData3, &env->linPorts->lin3_Io, 8, &env->slog.logger);
|
Lin_3_Init(&env->linTaskActuator3,
|
||||||
|
linData3, &env->linPorts->lin3_Io, 8,
|
||||||
|
|
||||||
|
env->ModelTask.access,
|
||||||
|
&env->ModelTask.triggerActuatorCmdBus_3,
|
||||||
|
&env->ModelTask.triggerCommand3,
|
||||||
|
|
||||||
|
&env->slog.logger);
|
||||||
|
|
||||||
Lin3_StartThread(&env->linTaskActuator3);
|
Lin3_StartThread(&env->linTaskActuator3);
|
||||||
|
|
||||||
tLinData *linData4 = Lin4_Init(GetLin123CallbackHandler);
|
tLinData *linData4 = Lin4_Init(GetLin123CallbackHandler);
|
||||||
|
|
@ -169,9 +196,6 @@ static void Mma_InitSubSystems(tMma *env) {
|
||||||
|
|
||||||
StandBy_Init(&env->standBy);
|
StandBy_Init(&env->standBy);
|
||||||
|
|
||||||
ModelTask_Init(&env->ModelTask, &env->linTaskActuator1, &env->linTaskActuator2, &env->linTaskActuator3, &env->slog.logger);
|
|
||||||
|
|
||||||
|
|
||||||
LoggerInfoStatic(&env->slog.logger, LOG_TASK_MAIN, "End of subsystem initialization")
|
LoggerInfoStatic(&env->slog.logger, LOG_TASK_MAIN, "End of subsystem initialization")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue