1148 lines
49 KiB
C
1148 lines
49 KiB
C
//
|
|
// Created by cfif on 19.12.2025.
|
|
//
|
|
#include "Model_Task.h"
|
|
#include <SystemDelayInterface.h>
|
|
#include <CmsisRtosThreadUtils.h>
|
|
#include "HVAC_model.h"
|
|
#include "memory.h"
|
|
#include "SystemDelayInterface.h"
|
|
#include "fc7xxx_driver_smc.h"
|
|
|
|
#define LOG_SIGN "ModelTask"
|
|
#define LOGGER env->logger
|
|
|
|
//tStatus_Sensor_For_Model model_Status_Sensor_For_Model_input;
|
|
tStatus_Actuator_For_Model model_Status_Actuator_DoorsActuator_For_Model_input;
|
|
//tStatus_Duct_Tgt_For_Model model_Status_Duct_Tgt_For_Model_input;
|
|
//tStatus_Eva_Tgt_For_Model model_Status_Eva_Tgt_For_Model_input;
|
|
tStatus_IO_For_Model model_Status_IO_For_Model_input;
|
|
tStatus_Pwm_For_Model model_Status_Pwm_For_Model_input;
|
|
tStatus_eComp_For_Model model_Status_eComp_For_Model_input;
|
|
tStatus_External_For_Model model_Status_External_For_Model_input;
|
|
tStatus_EMS_For_Model model_Status_EMS_For_Model_input;
|
|
tStatus_Ionizer_Aroma_For_Model model_Status_Ionizer_Aroma_For_Model_input;
|
|
//tStatus_Duct_Select_For_Model model_Status_Duct_Select_For_Model_input;
|
|
|
|
tStatus_Set_For_Model model_Status_Set_For_Model_output;
|
|
tStatus_Actuator_For_Model model_Status_Actuator_DoorsActuator_For_Model_output;
|
|
tStatus_Duct_Tgt_For_Model model_Status_Duct_Tgt_For_Model_output;
|
|
tStatus_Eva_Tgt_For_Model model_Status_Eva_Tgt_For_Model_output;
|
|
tStatus_IO_For_Model model_Status_IO_For_Model_output;
|
|
tStatus_Pwm_For_Model model_Status_Pwm_For_Model_output;
|
|
tStatus_eComp_For_Model model_Status_eComp_For_Model_output;
|
|
tStatus_External_For_Model model_Status_External_For_Model_output;
|
|
tStatus_EMS_For_Model model_Status_EMS_For_Model_output;
|
|
tStatus_Ionizer_Aroma_For_Model model_Status_Ionizer_Aroma_For_Model_output;
|
|
tStatus_Duct_Select_For_Model model_Status_Duct_Select_For_Model_output;
|
|
|
|
|
|
//uint32_t __attribute__((section(".stack_data"))) tModelTask_stack[1024];
|
|
|
|
void ModelTask_Init(
|
|
tModelTask *env,
|
|
tLinTaskActuator *linTaskActuator1,
|
|
tLinTaskActuator *linTaskActuator2,
|
|
tLinTaskActuator *linTaskActuator3,
|
|
|
|
tLin4TaskSensor *lin4TaskSensor,
|
|
tLin5TaskSensor *lin5TaskSensor,
|
|
|
|
tPwms *pwms,
|
|
|
|
tGpios *gpios,
|
|
|
|
tAdc0Task *adc0Task,
|
|
tAdc1Task *adc1Task,
|
|
|
|
tCanSpamReceiver *canSpamReceiver,
|
|
tCanSpamTransmitter *canSpamTransmitter,
|
|
tCanSpamDebugTransmitter *canSpamDebugTransmitter,
|
|
tDiagnostic *diagnostic,
|
|
|
|
tCanUds *canUds,
|
|
|
|
tLoggerInterface *logger
|
|
) {
|
|
env->linTaskActuator1 = linTaskActuator1;
|
|
env->linTaskActuator2 = linTaskActuator2;
|
|
env->linTaskActuator3 = linTaskActuator3;
|
|
|
|
env->lin4TaskSensor = lin4TaskSensor;
|
|
env->lin5TaskSensor = lin5TaskSensor;
|
|
|
|
env->pwms = pwms;
|
|
env->gpios = gpios;
|
|
|
|
env->canUds = canUds;
|
|
|
|
env->adc0Task = adc0Task;
|
|
env->adc1Task = adc1Task;
|
|
|
|
env->canSpamReceiver = canSpamReceiver;
|
|
env->canSpamTransmitter = canSpamTransmitter;
|
|
env->canSpamDebugTransmitter = canSpamDebugTransmitter;
|
|
|
|
env->diagnostic = diagnostic;
|
|
|
|
env->access = osMutexNew(NULL);
|
|
env->logger = logger;
|
|
InitThreadAtrStatic(&env->thread.attr, "ModelTask", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
|
|
|
|
// env->thread.stack = tModelTask_stack;
|
|
// InitThreadAtr(&env->thread.attr,"ModelTask",&env->thread.controlBlock,sizeof(env->thread.controlBlock),env->thread.stack,sizeof(env->thread.stack),osPriorityNormal);
|
|
env->thread.id = 0;
|
|
|
|
}
|
|
|
|
|
|
static bool getActProc(tModelTask *env, uint8_t numAct, uint8_t numIndex, uint16_t maxPos, uint16_t proc) {
|
|
uint16_t pos = (maxPos * proc) / 1000;
|
|
|
|
if (numAct == 1) {
|
|
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[numIndex] = numIndex + 1;
|
|
env->triggerActuatorCmdBus_1.POS[numIndex] = pos;
|
|
env->triggerActuatorCmdBus_1.MODE[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_1.COM[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_1.Stall_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_1.Lnoise_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_1.Autos_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_1.Speed_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_1.Coils_Stop_SET[numIndex] = 3;
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
if (numAct == 2) {
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[numIndex] = numIndex + 1;
|
|
env->triggerActuatorCmdBus_2.POS[numIndex] = pos;
|
|
env->triggerActuatorCmdBus_2.MODE[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_2.COM[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_2.Stall_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_2.Lnoise_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_2.Autos_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_2.Speed_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_2.Coils_Stop_SET[numIndex] = 3;
|
|
|
|
return true;
|
|
}
|
|
|
|
if (numAct == 3) {
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[numIndex] = numIndex + 1;
|
|
env->triggerActuatorCmdBus_3.POS[numIndex] = pos;
|
|
env->triggerActuatorCmdBus_3.MODE[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_3.COM[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_3.Stall_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_3.Lnoise_SET[numIndex] = 0;
|
|
env->triggerActuatorCmdBus_3.Autos_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_3.Speed_SET[numIndex] = 3;
|
|
env->triggerActuatorCmdBus_3.Coils_Stop_SET[numIndex] = 3;
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static bool isUDS_Captured(tModelTask *env, uint8_t index, uint8_t numAct) {
|
|
|
|
|
|
if (numAct == 1) {
|
|
|
|
|
|
if ((index == 0) && (model_Status_Set_For_Model_output.Motor_Def)) {
|
|
getActProc(env, numAct, 0, rtY.Status_Actuator_model_IO.Motor_Def,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Def);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 1) && (model_Status_Set_For_Model_output.Motor_REC)) {
|
|
getActProc(env, numAct, 1, rtY.Status_Actuator_model_IO.Motor_REC,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_REC);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 2) && (model_Status_Set_For_Model_output.Motor_OSA)) {
|
|
getActProc(env, numAct, 2, rtY.Status_Actuator_model_IO.Motor_OSA,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_OSA);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 3) && (model_Status_Set_For_Model_output.Motor_Temp1_FL)) {
|
|
getActProc(env, numAct, 3, rtY.Status_Actuator_model_IO.Motor_Temp1_FL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp1_FL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 4) && (model_Status_Set_For_Model_output.Motor_Vent_CFL)) {
|
|
getActProc(env, numAct, 4, rtY.Status_Actuator_model_IO.Motor_Vent_CFL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_CFL);
|
|
return true;
|
|
}
|
|
|
|
|
|
if ((index == 5) && (model_Status_Set_For_Model_output.Motor_Vent_SFL)) {
|
|
getActProc(env, numAct, 5, rtY.Status_Actuator_model_IO.Motor_Vent_SFL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_SFL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 6) && (model_Status_Set_For_Model_output.Motor_Temp2_FL)) {
|
|
getActProc(env, numAct, 6, rtY.Status_Actuator_model_IO.Motor_Temp2_FL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp2_FL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 7) && (model_Status_Set_For_Model_output.Motor_Foot_1FL)) {
|
|
getActProc(env, numAct, 7, rtY.Status_Actuator_model_IO.Motor_Foot_1FL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_1FL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 8) && (model_Status_Set_For_Model_output.Motor_Foot_2FL)) {
|
|
getActProc(env, numAct, 8, rtY.Status_Actuator_model_IO.Motor_Foot_2FL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_2FL);
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (numAct == 2) {
|
|
|
|
|
|
if ((index == 0) && (model_Status_Set_For_Model_output.Motor_Temp1_FR)) {
|
|
getActProc(env, numAct, 0, rtY.Status_Actuator_model_IO.Motor_Temp1_FR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp1_FR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 1) && (model_Status_Set_For_Model_output.Motor_Vent_CFR)) {
|
|
getActProc(env, numAct, 1, rtY.Status_Actuator_model_IO.Motor_Vent_CFR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_CFR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 2) && (model_Status_Set_For_Model_output.Motor_Vent_SFR)) {
|
|
getActProc(env, numAct, 2, rtY.Status_Actuator_model_IO.Motor_Vent_SFR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_SFR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 3) && (model_Status_Set_For_Model_output.Motor_Temp2_FR)) {
|
|
getActProc(env, numAct, 3, rtY.Status_Actuator_model_IO.Motor_Temp2_FR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp2_FR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 4) && (model_Status_Set_For_Model_output.Motor_Foot_1FR)) {
|
|
getActProc(env, numAct, 4, rtY.Status_Actuator_model_IO.Motor_Foot_1FR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_1FR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 5) && (model_Status_Set_For_Model_output.Motor_Foot_2FR)) {
|
|
getActProc(env, numAct, 5, rtY.Status_Actuator_model_IO.Motor_Foot_2FR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_2FR);
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (numAct == 3) {
|
|
|
|
|
|
if ((index == 0) && (model_Status_Set_For_Model_output.Motor_Temp_RR)) {
|
|
getActProc(env, numAct, 0, rtY.Status_Actuator_model_IO.Motor_Temp_RR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp_RR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 1) && (model_Status_Set_For_Model_output.Motor_Temp_RL)) {
|
|
getActProc(env, numAct, 1, rtY.Status_Actuator_model_IO.Motor_Temp_RL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Temp_RL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 2) && (model_Status_Set_For_Model_output.Motor_Vent_SRL)) {
|
|
getActProc(env, numAct, 2, rtY.Status_Actuator_model_IO.Motor_Vent_SRL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_SRL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 3) && (model_Status_Set_For_Model_output.Motor_Foot_RL)) {
|
|
getActProc(env, numAct, 3, rtY.Status_Actuator_model_IO.Motor_Foot_RL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_RL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 4) && (model_Status_Set_For_Model_output.Motor_Vent_CRL)) {
|
|
getActProc(env, numAct, 4, rtY.Status_Actuator_model_IO.Motor_Vent_CRL,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_CRL);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 5) && (model_Status_Set_For_Model_output.Motor_Vent_CRR)) {
|
|
getActProc(env, numAct, 5, rtY.Status_Actuator_model_IO.Motor_Vent_CRR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_CRR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 6) && (model_Status_Set_For_Model_output.Motor_Foot_RR)) {
|
|
getActProc(env, numAct, 6, rtY.Status_Actuator_model_IO.Motor_Foot_RR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Foot_RR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 7) && (model_Status_Set_For_Model_output.Motor_Vent_SRR)) {
|
|
getActProc(env, numAct, 7, rtY.Status_Actuator_model_IO.Motor_Vent_SRR,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_Vent_SRR);
|
|
return true;
|
|
}
|
|
|
|
if ((index == 8) && (model_Status_Set_For_Model_output.Motor_SealingValve)) {
|
|
getActProc(env, numAct, 8, rtY.Status_Actuator_model_IO.Motor_SealingValve,
|
|
model_Status_Actuator_DoorsActuator_For_Model_output.Motor_SealingValve);
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
static bool setActuatorBusy(tModelTask *env) {
|
|
|
|
|
|
if (env->triggerCommand1 == false) {
|
|
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator1->LIN_ISSR_ALL; ++i) {
|
|
bool isCaptured = isUDS_Captured(env, i, 1);
|
|
|
|
|
|
if (isCaptured) {
|
|
asm("nop");
|
|
}
|
|
|
|
if ((rtY.Actuator_Ch0_Command_Model_out.COM[i] != 0) || isCaptured) {
|
|
|
|
env->triggerCommand1 = true;
|
|
|
|
if (isCaptured) {
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN1_ACTUATOR == 1)
|
|
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): UDS CAPTURED", i,
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i])
|
|
#endif
|
|
#endif
|
|
|
|
} else {
|
|
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i] = rtY.Actuator_Ch0_Command_Model_out.BUS_ADR[i];
|
|
env->triggerActuatorCmdBus_1.POS[i] = rtY.Actuator_Ch0_Command_Model_out.POS[i];
|
|
env->triggerActuatorCmdBus_1.MODE[i] = rtY.Actuator_Ch0_Command_Model_out.MODE[i];
|
|
env->triggerActuatorCmdBus_1.COM[i] = rtY.Actuator_Ch0_Command_Model_out.COM[i];
|
|
env->triggerActuatorCmdBus_1.Stall_SET[i] = rtY.Actuator_Ch0_Command_Model_out.Stall_SET[i];
|
|
env->triggerActuatorCmdBus_1.Lnoise_SET[i] = rtY.Actuator_Ch0_Command_Model_out.Lnoise_SET[i];
|
|
env->triggerActuatorCmdBus_1.Autos_SET[i] = rtY.Actuator_Ch0_Command_Model_out.Autos_SET[i];
|
|
env->triggerActuatorCmdBus_1.Speed_SET[i] = rtY.Actuator_Ch0_Command_Model_out.Speed_SET[i];
|
|
env->triggerActuatorCmdBus_1.Coils_Stop_SET[i] = rtY.Actuator_Ch0_Command_Model_out.Coils_Stop_SET[i];
|
|
|
|
// memcpy(&env->triggerActuatorCmdBus_1, &rtY.Actuator_Ch0_Command_Model_out, sizeof(ActuatorCmdBus));
|
|
}
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN1_ACTUATOR == 1)
|
|
|
|
switch (env->triggerActuatorCmdBus_1.COM[i]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
i,
|
|
env->triggerActuatorCmdBus_1.BUS_ADR[i],
|
|
env->triggerActuatorCmdBus_1.COM[i])
|
|
}
|
|
}
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
Actuator_Ch0_Status_Model.Busy = 1;
|
|
// break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (env->triggerCommand2 == false) {
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator2->LIN_ISSR_ALL; ++i) {
|
|
bool isCaptured = isUDS_Captured(env, i, 2);
|
|
if ((rtY.Actuator_Ch1_Command_Mode_out.COM[i] != 0) || isCaptured) {
|
|
|
|
env->triggerCommand2 = true;
|
|
|
|
if (isCaptured) {
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN2_ACTUATOR == 1)
|
|
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): UDS CAPTURED", i,
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i])
|
|
#endif
|
|
#endif
|
|
|
|
} else {
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i] = rtY.Actuator_Ch1_Command_Mode_out.BUS_ADR[i];
|
|
env->triggerActuatorCmdBus_2.POS[i] = rtY.Actuator_Ch1_Command_Mode_out.POS[i];
|
|
env->triggerActuatorCmdBus_2.MODE[i] = rtY.Actuator_Ch1_Command_Mode_out.MODE[i];
|
|
env->triggerActuatorCmdBus_2.COM[i] = rtY.Actuator_Ch1_Command_Mode_out.COM[i];
|
|
env->triggerActuatorCmdBus_2.Stall_SET[i] = rtY.Actuator_Ch1_Command_Mode_out.Stall_SET[i];
|
|
env->triggerActuatorCmdBus_2.Lnoise_SET[i] = rtY.Actuator_Ch1_Command_Mode_out.Lnoise_SET[i];
|
|
env->triggerActuatorCmdBus_2.Autos_SET[i] = rtY.Actuator_Ch1_Command_Mode_out.Autos_SET[i];
|
|
env->triggerActuatorCmdBus_2.Speed_SET[i] = rtY.Actuator_Ch1_Command_Mode_out.Speed_SET[i];
|
|
env->triggerActuatorCmdBus_2.Coils_Stop_SET[i] = rtY.Actuator_Ch1_Command_Mode_out.Coils_Stop_SET[i];
|
|
|
|
// memcpy(&env->triggerActuatorCmdBus_2, &rtY.Actuator_Ch1_Command_Mode_out, sizeof(ActuatorCmdBus));
|
|
}
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN2_ACTUATOR == 1)
|
|
|
|
|
|
switch (env->triggerActuatorCmdBus_2.COM[i]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
i,
|
|
env->triggerActuatorCmdBus_2.BUS_ADR[i],
|
|
env->triggerActuatorCmdBus_2.COM[i])
|
|
}
|
|
}
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
Actuator_Ch1_Status_Model.Busy = 1;
|
|
// break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (env->triggerCommand3 == false) {
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator3->LIN_ISSR_ALL; ++i) {
|
|
bool isCaptured = isUDS_Captured(env, i, 3);
|
|
if ((rtY.Actuator_Ch2_Command_Model_out.COM[i] != 0) || isCaptured) {
|
|
|
|
env->triggerCommand3 = true;
|
|
|
|
if (isCaptured) {
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN3_ACTUATOR == 1)
|
|
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): UDS CAPTURED", i,
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i])
|
|
#endif
|
|
#endif
|
|
|
|
} else {
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i] = rtY.Actuator_Ch2_Command_Model_out.BUS_ADR[i];
|
|
env->triggerActuatorCmdBus_3.POS[i] = rtY.Actuator_Ch2_Command_Model_out.POS[i];
|
|
env->triggerActuatorCmdBus_3.MODE[i] = rtY.Actuator_Ch2_Command_Model_out.MODE[i];
|
|
env->triggerActuatorCmdBus_3.COM[i] = rtY.Actuator_Ch2_Command_Model_out.COM[i];
|
|
env->triggerActuatorCmdBus_3.Stall_SET[i] = rtY.Actuator_Ch2_Command_Model_out.Stall_SET[i];
|
|
env->triggerActuatorCmdBus_3.Lnoise_SET[i] = rtY.Actuator_Ch2_Command_Model_out.Lnoise_SET[i];
|
|
env->triggerActuatorCmdBus_3.Autos_SET[i] = rtY.Actuator_Ch2_Command_Model_out.Autos_SET[i];
|
|
env->triggerActuatorCmdBus_3.Speed_SET[i] = rtY.Actuator_Ch2_Command_Model_out.Speed_SET[i];
|
|
env->triggerActuatorCmdBus_3.Coils_Stop_SET[i] = rtY.Actuator_Ch2_Command_Model_out.Coils_Stop_SET[i];
|
|
|
|
// memcpy(&env->triggerActuatorCmdBus_3, &rtY.Actuator_Ch2_Command_Model_out, sizeof(ActuatorCmdBus));
|
|
}
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN3_ACTUATOR == 1)
|
|
|
|
|
|
switch (env->triggerActuatorCmdBus_3.COM[i]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", i,
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
i,
|
|
env->triggerActuatorCmdBus_3.BUS_ADR[i],
|
|
env->triggerActuatorCmdBus_3.COM[i])
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
Actuator_Ch2_Status_Model.Busy = 1;
|
|
// break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
/*
|
|
static bool setActuatorBusy(tModelTask *env) {
|
|
|
|
|
|
if (env->triggerCommand1 == false) {
|
|
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator1->LIN_ISSR_ALL; ++i) {
|
|
if (Actuator_Ch0_Command_Model.COM[i] != 0) {
|
|
|
|
env->triggerCommand1 = true;
|
|
|
|
memcpy(&env->triggerActuatorCmdBus_1, &Actuator_Ch0_Command_Model, sizeof(ActuatorCmdBus));
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN1_ACTUATOR == 1)
|
|
for (uint8_t j = 0; j < env->linTaskActuator1->LIN_ISSR_ALL; ++j) {
|
|
switch (Actuator_Ch0_Command_Model.COM[j]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", j,
|
|
Actuator_Ch0_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", j,
|
|
Actuator_Ch0_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", j,
|
|
Actuator_Ch0_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN1 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
j,
|
|
Actuator_Ch0_Command_Model.BUS_ADR[j],
|
|
Actuator_Ch0_Command_Model.COM[j])
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
Actuator_Ch0_Status_Model.Busy = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (env->triggerCommand2 == false) {
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator2->LIN_ISSR_ALL; ++i) {
|
|
if (Actuator_Ch1_Command_Model.COM[i] != 0) {
|
|
|
|
env->triggerCommand2 = true;
|
|
|
|
memcpy(&env->triggerActuatorCmdBus_2, &Actuator_Ch1_Command_Model, sizeof(ActuatorCmdBus));
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN2_ACTUATOR == 1)
|
|
|
|
for (uint8_t j = 0; j < env->linTaskActuator2->LIN_ISSR_ALL; ++j) {
|
|
switch (Actuator_Ch1_Command_Model.COM[j]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", j,
|
|
Actuator_Ch1_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", j,
|
|
Actuator_Ch1_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", j,
|
|
Actuator_Ch1_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN2 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
j,
|
|
Actuator_Ch1_Command_Model.BUS_ADR[j],
|
|
Actuator_Ch1_Command_Model.COM[j])
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
Actuator_Ch1_Status_Model.Busy = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (env->triggerCommand3 == false) {
|
|
|
|
for (uint8_t i = 0; i < env->linTaskActuator3->LIN_ISSR_ALL; ++i) {
|
|
if (Actuator_Ch2_Command_Model.COM[i] != 0) {
|
|
|
|
env->triggerCommand3 = true;
|
|
|
|
memcpy(&env->triggerActuatorCmdBus_3, &Actuator_Ch2_Command_Model, sizeof(ActuatorCmdBus));
|
|
|
|
#if (LOG_LIN_ACTUATOR == 1)
|
|
#if (LOG_LIN3_ACTUATOR == 1)
|
|
|
|
for (uint8_t j = 0; j < env->linTaskActuator3->LIN_ISSR_ALL; ++j) {
|
|
switch (Actuator_Ch2_Command_Model.COM[j]) {
|
|
case LIN_ACT_CFR_MOD: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_MOD (SET BUSY)", j,
|
|
Actuator_Ch2_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
case LIN_ACT_CFR_INI: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_INI (SET BUSY)", j,
|
|
Actuator_Ch2_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_SET: {
|
|
LoggerFormatTrace(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND LIN_ACT_CFR_SET (SET BUSY)", j,
|
|
Actuator_Ch2_Command_Model.BUS_ADR[j])
|
|
break;
|
|
}
|
|
|
|
case LIN_ACT_CFR_NONE: {
|
|
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
LoggerFormatError(LOGGER, LOG_SIGN,
|
|
"LIN3 (ADR[%d] = %d): TRIGGERED COMMAND = %d UNKNOWN !!! (SET BUSY)",
|
|
j,
|
|
Actuator_Ch2_Command_Model.BUS_ADR[j],
|
|
Actuator_Ch2_Command_Model.COM[j])
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
#endif
|
|
|
|
Actuator_Ch2_Status_Model.Busy = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return false;
|
|
}
|
|
*/
|
|
|
|
__attribute__((section(".save_data"))) volatile CmdCAN_CCU_STAT1_Bus CCU_STAT1_MODEL_SAVE;
|
|
__attribute__((section(".save_data"))) volatile CmdCAN_CCU_STAT2_Bus CCU_STAT2_MODEL_SAVE;
|
|
__attribute__((section(".save_data"))) volatile CmdCAN_CCU_STAT3_Bus CCU_STAT3_MODEL_SAVE;
|
|
__attribute__((section(".save_data"))) volatile CCU_Msg1_Bus CCU_MSG1_MODEL_SAVE;
|
|
|
|
|
|
void InitWakeupModel(tModelTask *env) {
|
|
|
|
HVAC_model_initialize();
|
|
|
|
if (RGM_SRS_WAKEUP_MASK == (RGM->SRS & RGM_SRS_WAKEUP_MASK)) {
|
|
LoggerInfoStatic(LOGGER, LOG_SIGN, "Wake up from standby")
|
|
rtDW.sleep_model = 1;
|
|
} else {
|
|
|
|
memset((void *) &CCU_STAT1_MODEL_SAVE, 0, sizeof(env->ccu_candb_tx.CCU_Stat1));
|
|
memset((void *) &CCU_STAT2_MODEL_SAVE, 0, sizeof(env->ccu_candb_tx.CCU_Stat2));
|
|
memset((void *) &CCU_STAT3_MODEL_SAVE, 0, sizeof(env->ccu_candb_tx.CCU_Stat3));
|
|
memset((void *) &CCU_MSG1_MODEL_SAVE, 0, sizeof(env->ccu_candb_tx.CCU_Msg1));
|
|
|
|
LoggerInfoStatic(LOGGER, LOG_SIGN, "Cold boot (power-on reset)")
|
|
|
|
|
|
rtDW.sleep_model = 0;
|
|
}
|
|
}
|
|
|
|
|
|
#define SLEEP_TIME 3000
|
|
|
|
static _Noreturn void ModelTask_Thread(tModelTask *env) {
|
|
|
|
for (;;) {
|
|
|
|
if (GPIO_ReadPins((uint8_t) PORT_E, PORT_PIN_16)) {
|
|
if (env->sleep_time == 0) {
|
|
env->sleep_time = SystemGetMs() + SLEEP_TIME;
|
|
}
|
|
} else {
|
|
env->sleep_time = 0;
|
|
}
|
|
|
|
if ((env->sleep_time > 0) && (env->sleep_time < SystemGetMs())) {
|
|
SMC_SetSystemMode(SMC_MODE_STANBY_3);
|
|
}
|
|
|
|
if (osMutexAcquire(env->access, 1000) == osOK) {
|
|
|
|
//LoggerFormatError(LOGGER, LOG_SIGN, "Step END = %d", SystemGetMs())
|
|
|
|
rtDW.t_now = SystemGetMs();
|
|
|
|
getCmdBusADCData(env->adc0Task, &rtDW.ADC_Data_Model);
|
|
|
|
|
|
getCmdBusADC2Data(env->adc1Task,
|
|
(CmdBusADC2Data *) &rtDW.ADC_Data_Model.VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB);
|
|
|
|
|
|
//начало--------------------------------------------------PWM-----------------------------------------------------------
|
|
PWM_Get.pwmPercentFront = env->pwms->pwmFrontCaptureIO.getPwm(env->pwms->pwmFrontCaptureIO.env);
|
|
PWM_Get.pwmPercentRear = env->pwms->pwmRearCaptureIO.getPwm(env->pwms->pwmRearCaptureIO.env);
|
|
PWM_Get.pwmPercentFrontReserved = env->pwms->pwmFrontCaptureIO.getPwm(
|
|
env->pwms->pwmFrontReservedCaptureIO.env);
|
|
PWM_Get.pwmPercentRearReserved = env->pwms->pwmRearCaptureIO.getPwm(
|
|
env->pwms->pwmRearReservedCaptureIO.env);
|
|
|
|
model_Status_Pwm_For_Model_input.Pwm_Front = PWM_Get.pwmPercentFront * 10;
|
|
model_Status_Pwm_For_Model_input.Pwm_Rear = PWM_Get.pwmPercentRear * 10;
|
|
//конец--------------------------------------------------PWM------------------------------------------------------------
|
|
|
|
|
|
//начало--------------------------------------------------CAN-----------------------------------------------------------
|
|
get_CanSpamReceiver(env->canSpamReceiver);
|
|
|
|
if (model_Status_Set_For_Model_output.EMS == 1) {
|
|
rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL.EMS_eCompChiller_Req = model_Status_EMS_For_Model_output.EMS_Chiller_Req;
|
|
}
|
|
|
|
model_Status_EMS_For_Model_input.EMS_Chiller_Req = rtDW.CCUCAN_EMS_HVC_REQ_MSG_MODEL.EMS_eCompChiller_Req;
|
|
|
|
|
|
bool isT15 = rtDW.CCUCAN_BCM_VEH_STATE_model.BCM_T15_Stat;
|
|
//конец--------------------------------------------------CAN------------------------------------------------------------
|
|
|
|
|
|
//начало-------------------------------------------------SlEEP----------------------------------------------------------
|
|
|
|
memcpy((void *) &rtDW.CCU_STAT1_WAKEUP_MODEL, (void *) &CCU_STAT1_MODEL_SAVE,
|
|
sizeof(CmdCAN_CCU_STAT1_WakeUp_Bus));
|
|
memcpy((void *) &rtDW.CCU_STAT2_WAKEUP_MODEL, (void *) &CCU_STAT2_MODEL_SAVE,
|
|
sizeof(CmdCAN_CCU_STAT2_WakeUp_Bus));
|
|
memcpy((void *) &rtDW.CCU_STAT3_WAKEUP_MODEL, (void *) &CCU_STAT3_MODEL_SAVE,
|
|
sizeof(CmdCAN_CCU_STAT3_WakeUp_Bus));
|
|
memcpy((void *) &rtDW.CCU_Msg1_WakeUp_model, (void *) &CCU_MSG1_MODEL_SAVE, sizeof(CCU_Msg1_WakeUp_Bus));
|
|
|
|
|
|
//конец--------------------------------------------------SLEEP----------------------------------------------------------
|
|
|
|
Lin4_Output_Get_From_Model(env->lin4TaskSensor);
|
|
Lin5_Output_Get_From_Model(env->lin5TaskSensor);
|
|
|
|
|
|
HVAC_model_step();
|
|
|
|
|
|
rtDW.sleep_model = 0;
|
|
|
|
Lin5_Input_Set_From_Model(env->lin5TaskSensor);
|
|
|
|
CanUdsOutput_Get_Model(env->canUds);
|
|
|
|
|
|
setActuatorBusy(env);
|
|
|
|
|
|
//начало--------------------------------------------------GPIO----------------------------------------------------------
|
|
// Включение 5V (1 - ВКЛ)
|
|
GpioPinSet(&env->gpios->power.SW5V_EN, rtY.PowerEnable_Model.SW5V_EN);
|
|
// Контроль напряжения борт-сети (1 - ВКЛ)
|
|
GpioPinSet(&env->gpios->power.PBATT_CK_EN, rtY.PowerEnable_Model.PBATT_CK_EN);
|
|
|
|
env->TwoWayValve_EN = rtY.PowerEnable_Model.TwoWayValve_EN;
|
|
env->EN_BATTChiller = rtY.PowerEnable_Model.EN_BATTChiller;
|
|
env->Incar_Motor_Front_EN = rtY.PowerEnable_Model.Incar_Motor_Front_EN;
|
|
env->Incar_Motor_Rear_EN = rtY.PowerEnable_Model.Incar_Motor_Rear_EN;
|
|
env->ShutOffFront_EN = rtY.PowerEnable_Model.ShutOffFront_EN;
|
|
env->ShutOffRear_EN = rtY.PowerEnable_Model.ShutOffRear_EN;
|
|
env->PtcRelayDriver1_EN = rtY.PowerEnable_Model.PtcRelayDriver1_EN;
|
|
env->PtcRelayDriver2_EN = rtY.PowerEnable_Model.PtcRelayDriver2_EN;
|
|
|
|
if (model_Status_Set_For_Model_output.IO == 1) {
|
|
|
|
if (model_Status_IO_For_Model_output._2_Way_Valve == 0) {
|
|
env->TwoWayValve_EN = false;
|
|
} else {
|
|
env->TwoWayValve_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.IncarMotor_Front == 0) {
|
|
env->Incar_Motor_Front_EN = false;
|
|
} else {
|
|
env->Incar_Motor_Front_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.IncarMotor_Rear == 0) {
|
|
env->Incar_Motor_Rear_EN = false;
|
|
} else {
|
|
env->Incar_Motor_Rear_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.ShutOff_Chiller == 0) {
|
|
env->EN_BATTChiller = false;
|
|
} else {
|
|
env->EN_BATTChiller = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.ShutOff_Front == 0) {
|
|
env->ShutOffFront_EN = false;
|
|
} else {
|
|
env->ShutOffFront_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.IncarMotor_Rear == 0) {
|
|
env->ShutOffRear_EN = false;
|
|
} else {
|
|
env->ShutOffRear_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.PTC_1 == 0) {
|
|
env->PtcRelayDriver1_EN = false;
|
|
} else {
|
|
env->PtcRelayDriver1_EN = true;
|
|
}
|
|
|
|
if (model_Status_IO_For_Model_output.PTC_2 == 0) {
|
|
env->PtcRelayDriver2_EN = false;
|
|
} else {
|
|
env->PtcRelayDriver2_EN = true;
|
|
}
|
|
|
|
} else {
|
|
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_TwoWayValveAndReservePowerSupply.TwoWayValve_EN,
|
|
env->TwoWayValve_EN);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_TwoWayValveAndReservePowerSupply.TwoWayValve_EN_Diag, true);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_TwoWayValveAndReservePowerSupply.ReservePower_EN,
|
|
rtY.PowerEnable_Model.ReservePower_EN);
|
|
|
|
GpioPinSet(&env->gpios->power.BTS4175SGAXUMA1_ShutOFFValveBatteryChiller.EN_BATTChiller,
|
|
env->EN_BATTChiller);
|
|
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_FrontRearIncarMotor.Incar_Motor_Front_EN,
|
|
env->Incar_Motor_Front_EN);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_FrontRearIncarMotor.Incar_EN_Diag, true);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_FrontRearIncarMotor.Incar_Motor_Rear_EN,
|
|
env->Incar_Motor_Rear_EN);
|
|
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_ShutOFFValveFrontRear.ShutOffFront_EN, env->ShutOffFront_EN);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_ShutOFFValveFrontRear.ShutOff_EN_Diag, true);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_ShutOFFValveFrontRear.ShutOffRear_EN, env->ShutOffRear_EN);
|
|
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_2xChannelPTCPower.PtcRelayDriver1_EN,
|
|
env->PtcRelayDriver1_EN);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_2xChannelPTCPower.PtcRelayDriver_EN_Diag, true);
|
|
GpioPinSet(&env->gpios->power.BTS5180_2EKA_2xChannelPTCPower.PtcRelayDriver2_EN,
|
|
env->PtcRelayDriver2_EN);
|
|
}
|
|
|
|
model_Status_IO_For_Model_input._2_Way_Valve = env->TwoWayValve_EN;
|
|
model_Status_IO_For_Model_input.IncarMotor_Front = env->Incar_Motor_Front_EN;
|
|
model_Status_IO_For_Model_input.IncarMotor_Rear = env->Incar_Motor_Rear_EN;
|
|
model_Status_IO_For_Model_input.ShutOff_Chiller = env->EN_BATTChiller;
|
|
model_Status_IO_For_Model_input.ShutOff_Front = env->ShutOffFront_EN;
|
|
model_Status_IO_For_Model_input.ShutOff_Rear = env->ShutOffRear_EN;
|
|
model_Status_IO_For_Model_input.PTC_1 = env->PtcRelayDriver1_EN;
|
|
model_Status_IO_For_Model_input.PTC_2 = env->PtcRelayDriver2_EN;
|
|
|
|
|
|
|
|
// GpioPinSet(&env->gpios->power.BTS4175SGAXUMA1_ReservePowerOutput.EN_ReservePower, rtY.PowerEnable_Model.EN_ReservePower);
|
|
GpioPinSet(&env->gpios->power.BTS4175SGAXUMA1_PowerReserve.EN_PowerReserve,
|
|
rtY.PowerEnable_Model.EN_PowerReserve);
|
|
|
|
GpioPinSet(&env->gpios->power.VN7008AJ_FrontLINActuatorPowerDriverAB.LIN_ActPower_AB,
|
|
rtY.PowerEnable_Model.LIN_ActPower_AB);
|
|
GpioPinSet(&env->gpios->power.VN7008AJ_FrontLINActuatorPowerDriverAB.EN_CurrentSensing_AB, true);
|
|
|
|
GpioPinSet(&env->gpios->power.VN7008AJ_RearLINActuatorPowerDriverC.LIN_ActPower_C,
|
|
rtY.PowerEnable_Model.LIN_ActPower_C);
|
|
GpioPinSet(&env->gpios->power.VN7008AJ_RearLINActuatorPowerDriverC.EN_CurrentSensing_C, true);
|
|
|
|
GpioPinSet(&env->gpios->power.BTS5120_2EKA_ShutoffValvePowerTXV.ShutOffTXV1_EN,
|
|
rtY.PowerEnable_Model.ShutOffTXV1_EN);
|
|
GpioPinSet(&env->gpios->power.BTS5120_2EKA_ShutoffValvePowerTXV.ShutOffTXV_EN_Diag, true);
|
|
GpioPinSet(&env->gpios->power.BTS5120_2EKA_ShutoffValvePowerTXV.ShutOffTXV2_EN,
|
|
rtY.PowerEnable_Model.ShutOffTXV2_EN);
|
|
//конец--------------------------------------------------GPIO-----------------------------------------------------------
|
|
|
|
|
|
|
|
//начало--------------------------------------------------PWM-----------------------------------------------------------
|
|
if (model_Status_Set_For_Model_output.Pwm == 1) {
|
|
rtY.PWM_Get_f.pwmPercentFront = model_Status_Pwm_For_Model_output.Pwm_Front / 10;
|
|
rtY.PWM_Get_f.pwmPercentRear = model_Status_Pwm_For_Model_output.Pwm_Rear / 10;
|
|
}
|
|
|
|
env->pwms->pwmFrontIo.setActivePercent(env->pwms->pwmFrontIo.env, rtY.PWM_Get_f.pwmPercentFront);
|
|
env->pwms->pwmRearIo.setActivePercent(env->pwms->pwmRearIo.env, rtY.PWM_Get_f.pwmPercentRear);
|
|
env->pwms->pwmFrontReservedIo.setActivePercent(env->pwms->pwmFrontReservedIo.env,
|
|
rtY.PWM_Get_f.pwmPercentFrontReserved);
|
|
env->pwms->pwmRearReservedIo.setActivePercent(env->pwms->pwmRearReservedIo.env,
|
|
rtY.PWM_Get_f.pwmPercentRearReserved);
|
|
//конец--------------------------------------------------PWM------------------------------------------------------------
|
|
|
|
//начало-------------------------------------------------SlEEP----------------------------------------------------------
|
|
if (isT15) {
|
|
memcpy((void *) &CCU_STAT1_MODEL_SAVE, &rtY.CCU_Stat1_model, sizeof(CmdCAN_CCU_STAT1_Bus));
|
|
memcpy((void *) &CCU_STAT2_MODEL_SAVE, &rtY.CCU_Stat2_model, sizeof(CmdCAN_CCU_STAT2_Bus));
|
|
memcpy((void *) &CCU_STAT3_MODEL_SAVE, &rtY.CCU_Stat3_model, sizeof(CmdCAN_CCU_STAT3_Bus));
|
|
memcpy((void *) &CCU_MSG1_MODEL_SAVE, &rtY.CCU_Msg1_model, sizeof(CCU_Msg1_Bus));
|
|
}
|
|
//конец--------------------------------------------------SLEEP----------------------------------------------------------
|
|
|
|
//начало--------------------------------------------------CAN-----------------------------------------------------------
|
|
memcpy(&env->ccu_candb_tx.CCU_Errors, &rtY.CCU_Errors_model, sizeof(env->ccu_candb_tx.CCU_Errors));
|
|
memcpy(&env->ccu_candb_tx.CCU_Stat1, &rtY.CCU_Stat1_model, sizeof(env->ccu_candb_tx.CCU_Stat1));
|
|
memcpy(&env->ccu_candb_tx.CCU_Stat2, &rtY.CCU_Stat2_model, sizeof(env->ccu_candb_tx.CCU_Stat2));
|
|
memcpy(&env->ccu_candb_tx.CCU_HVC_Req_Msg, &rtY.CCUCAN_HVC_REQ_MSG_MODEL,
|
|
sizeof(env->ccu_candb_tx.CCU_HVC_Req_Msg));
|
|
memcpy(&env->ccu_candb_tx.CCU_Msg3, &rtY.CCU_Msg3_model, sizeof(env->ccu_candb_tx.CCU_Msg3));
|
|
memcpy(&env->ccu_candb_tx.CCU_Msg1, &rtY.CCU_Msg1_model, sizeof(env->ccu_candb_tx.CCU_Msg1));
|
|
|
|
|
|
if (model_Status_Set_For_Model_output.eComp == 1) {
|
|
env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompSpeedReq_Val_ro = model_Status_eComp_For_Model_output.Pwm_Front;
|
|
|
|
// request to EMS for closing the low temperature circuit valve
|
|
// 2 : "Open Valve request"
|
|
// 1 : "Close Valve request"
|
|
// 0 : "No request"
|
|
if (model_Status_eComp_For_Model_output.LowTempValve == 0) {
|
|
env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_LowTempValve_Req = 1;
|
|
} else {
|
|
env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_LowTempValve_Req = 2;
|
|
}
|
|
|
|
// 0 = Off!0 = On
|
|
//1 Byte
|
|
//[0x00] Off
|
|
//[0x01..0xFF] On; Inverse value: 0x01
|
|
if (model_Status_eComp_For_Model_output.eComp_Statue_Request == 0) {
|
|
env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompReq_Stat = 0;
|
|
} else {
|
|
env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompReq_Stat = 1;
|
|
}
|
|
|
|
}
|
|
model_Status_eComp_For_Model_input.Pwm_Front = env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompSpeedReq_Val_ro;
|
|
model_Status_eComp_For_Model_input.LowTempValve = env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_LowTempValve_Req;
|
|
model_Status_eComp_For_Model_input.eComp_Statue_Request = env->ccu_candb_tx.CCU_HVC_Req_Msg.CCU_eCompReq_Stat;
|
|
|
|
|
|
if (model_Status_Set_For_Model_output.External == 1) {
|
|
env->ccu_candb_tx.CCU_Msg3.CCU_FAN_Req = model_Status_External_For_Model_output.CoolingFan / 10;
|
|
}
|
|
model_Status_External_For_Model_input.CoolingFan = env->ccu_candb_tx.CCU_Msg3.CCU_FAN_Req;
|
|
|
|
|
|
set_CanSpamTransmitter(env->canSpamTransmitter, &env->ccu_candb_tx);
|
|
|
|
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Act0, &rtY.dbgCAN_dbg_Act0_model, sizeof(env->ccu_candb_dbg_tx.dbg_Act0));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Act1, &rtY.dbgCAN_dbg_Act1_model, sizeof(env->ccu_candb_dbg_tx.dbg_Act1));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Act2, &rtY.dbgCAN_dbg_Act2_model, sizeof(env->ccu_candb_dbg_tx.dbg_Act2));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Sen_Duct, &rtY.dbgCAN_dbg_Sen_Duct_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Sen_Duct));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Sen_Eva, &rtY.dbgCAN_dbg_Sen_Eva_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Sen_Eva));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Logic_Blower, &rtY.dbgCAN_dbg_Logic_Blower_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_Blower));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Sen_Amb, &rtY.dbgCAN_dbg_Sen_Amb_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Sen_Amb));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Sen_Incar, &rtY.dbgCAN_dbg_Sen_Incar_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Sen_Incar));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Sen_0, &rtY.dbgCAN_dbg_Sen_0_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Sen_0));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Logic_Ac, &rtY.dbg_Logic_Ac_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_Ac));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_CCU_IO, &rtY.dbgCAN_CCU_IO_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_CCU_IO));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Logic_Rec, &rtY.dbgCAN_Logic_Rec_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_Rec));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Logic_State, &rtY.dbgCAN_Logic_State_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_State));
|
|
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Auto_AF, &rtY.dbgCAN_Auto_AF_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Auto_AF));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Auto_Duct, &rtY.dbgCAN_Auto_Duct_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Auto_Duct));
|
|
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Logic_Valve, &rtY.dbg_Logic_Valve_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_Valve));
|
|
//конец--------------------------------------------------CAN------------------------------------------------------------
|
|
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_Drs, &rtY.dbg_Drs_t_model, sizeof(env->ccu_candb_dbg_tx.dbg_Drs));
|
|
memcpy(&env->ccu_candb_dbg_tx.dbg_LIN_AirQS_Stat, &rtY.dbg_LIN_AirQS_Stat_t_model,
|
|
sizeof(env->ccu_candb_dbg_tx.dbg_Logic_Valve));
|
|
|
|
Lin4_Input_Set_From_Model(env->lin4TaskSensor);
|
|
|
|
set_CanDebugSpamTransmitter(env->canSpamDebugTransmitter, &env->ccu_candb_dbg_tx);
|
|
|
|
set_Dtc_state(env->diagnostic);
|
|
|
|
|
|
CanUdsInput_Set_Model(env->canUds);
|
|
|
|
env->isRunning = true;
|
|
osMutexRelease(env->access);
|
|
} else {
|
|
LoggerErrorStatic(LOGGER, LOG_SIGN, "Access error ModelTask_Thread");
|
|
}
|
|
|
|
SystemDelayMs(10);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
void ModelTask_StartThread(tModelTask *env) {
|
|
if (!env->thread.id) {
|
|
env->thread.id = osThreadNew((osThreadFunc_t) (ModelTask_Thread), (void *) (env), &env->thread.attr);
|
|
} else {
|
|
osThreadResume(env->thread.id);
|
|
}
|
|
}
|
|
|
|
void ModelTask_StopThread(tModelTask *env) {
|
|
if (env->thread.id) {
|
|
osThreadSuspend(env->thread.id);
|
|
}
|
|
} |