// // Created by cfif on 19.12.2025. // #include "Model_Task.h" #include #include #include "Model_actuator.h" void ModelTask_Init( tModelTask *env ) { Model_actuator_initialize(); env->access = osMutexNew(NULL); InitThreadAtrStatic(&env->thread.attr, "ModelTask", env->thread.controlBlock, env->thread.stack, osPriorityNormal); env->thread.id = 0; } static bool setActuatorBusy(tModelTask *env) { for (uint8_t i = 0; i < 9; ++i) { if (rtY.Out1.COM[i] != 0) { env->triggerCommand = true; for (uint8_t j = 0; j < 9; ++j) { env->numCommand[j] = rtY.Out1.COM[j]; } rtU.in_Busy_Ch0 = 1; return true; } } return false; } static _Noreturn void ModelTask_Thread(tModelTask *env) { for (;;) { if (osMutexAcquire(env->access, 1000) == osOK) { Model_actuator_step(); setActuatorBusy(env); osMutexRelease(env->access); } SystemDelayMs(100); } } 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); } }