// // Academic License - for use in teaching, academic research, and meeting // course requirements at degree granting institutions only. Not for // government, commercial, or other organizational use. // // File: FSMTreppe.cpp // // Code generated for Simulink model 'FSMTreppe'. // // Model version : 1.22 // Simulink Coder version : 9.5 (R2021a) 14-Nov-2020 // C/C++ source code generated on : Fri Jul 2 17:45:36 2021 // // Target selection: ert.tlc // Embedded hardware selection: ARM Compatible->ARM Cortex-M // Code generation objectives: Unspecified // Validation result: Not run // #include "FSMTreppe.h" // Named constants for Chart: '/FSMTreppe' const uint8_t FSMTreppe_IN_animation_down = 1U; const uint8_t FSMTreppe_IN_animation_up = 2U; const uint8_t FSMTreppe_IN_idle = 3U; // Model step function void FSMTreppeModelClass::step() { // Chart: '/FSMTreppe' incorporates: // Inport: '/anim_finished' // Inport: '/sensor_oben' // Inport: '/sensor_unten' if (FSMTreppe_DW.temporalCounter_i1 < 511U) { FSMTreppe_DW.temporalCounter_i1 = static_cast (FSMTreppe_DW.temporalCounter_i1 + 1U); } if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) { FSMTreppe_DW.is_active_c3_FSMTreppe = 1U; FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle; // Outport: '/anim_active' FSMTreppe_Y.anim_active = 0U; FSMTreppe_DW.got_sensor = 0U; FSMTreppe_DW.got_anim_finished = 0U; FSMTreppe_DW.finished_up = 0U; FSMTreppe_DW.finished_dn = 0U; } else { switch (FSMTreppe_DW.is_c3_FSMTreppe) { case FSMTreppe_IN_animation_down: // Outport: '/anim_active' FSMTreppe_Y.anim_active = 2U; if ((FSMTreppe_DW.finished_dn == 1) || (FSMTreppe_DW.temporalCounter_i1 >= 300U)) { FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle; // Outport: '/anim_active' FSMTreppe_Y.anim_active = 0U; FSMTreppe_DW.got_sensor = 0U; FSMTreppe_DW.got_anim_finished = 0U; FSMTreppe_DW.finished_up = 0U; FSMTreppe_DW.finished_dn = 0U; } else { if (FSMTreppe_U.sensor_unten) { FSMTreppe_DW.got_sensor = 1U; } if (FSMTreppe_U.anim_finished) { FSMTreppe_DW.got_anim_finished = 1U; } if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor == 1)) { FSMTreppe_DW.finished_dn = 1U; } } break; case FSMTreppe_IN_animation_up: // Outport: '/anim_active' FSMTreppe_Y.anim_active = 1U; if ((FSMTreppe_DW.finished_up == 1) || (FSMTreppe_DW.temporalCounter_i1 >= 300U)) { FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle; // Outport: '/anim_active' FSMTreppe_Y.anim_active = 0U; FSMTreppe_DW.got_sensor = 0U; FSMTreppe_DW.got_anim_finished = 0U; FSMTreppe_DW.finished_up = 0U; FSMTreppe_DW.finished_dn = 0U; } else { if (FSMTreppe_U.sensor_oben) { FSMTreppe_DW.got_sensor = 1U; } if (FSMTreppe_U.anim_finished) { FSMTreppe_DW.got_anim_finished = 1U; } if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor == 1)) { FSMTreppe_DW.finished_up = 1U; } } break; default: // Outport: '/anim_active' // case IN_idle: FSMTreppe_Y.anim_active = 0U; if (FSMTreppe_U.sensor_oben) { FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_down; FSMTreppe_DW.temporalCounter_i1 = 0U; // Outport: '/anim_active' FSMTreppe_Y.anim_active = 2U; FSMTreppe_DW.got_sensor = 0U; FSMTreppe_DW.got_anim_finished = 0U; FSMTreppe_DW.finished_dn = 0U; } else if (FSMTreppe_U.sensor_unten) { FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_up; FSMTreppe_DW.temporalCounter_i1 = 0U; // Outport: '/anim_active' FSMTreppe_Y.anim_active = 1U; FSMTreppe_DW.got_sensor = 0U; FSMTreppe_DW.got_anim_finished = 0U; FSMTreppe_DW.finished_up = 0U; } break; } } // End of Chart: '/FSMTreppe' } // Model initialize function void FSMTreppeModelClass::initialize() { // (no initialization code required) } // Model terminate function void FSMTreppeModelClass::terminate() { // (no terminate code required) } // Constructor FSMTreppeModelClass::FSMTreppeModelClass() : FSMTreppe_DW(), FSMTreppe_U(), FSMTreppe_Y() { // Currently there is no constructor body generated. } // Destructor FSMTreppeModelClass::~FSMTreppeModelClass() { // Currently there is no destructor body generated. } // // File trailer for generated code. // // [EOF] //