123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- //
- // 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.65
- // Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
- // C/C++ source code generated on : Tue Sep 7 08:47:00 2021
- //
- // Target selection: ert.tlc
- // Embedded hardware selection: ARM Compatible->ARM Cortex-M
- // Code generation objectives: Unspecified
- // Validation result: Not run
- //
- #include "FSMTreppe.h"
- #include "FSMTreppe_private.h"
-
- // Named constants for Chart: '<Root>/FSMTreppe'
- const uint8_T FSMTreppe_IN_abdimmen_hoch = 1U;
- const uint8_T FSMTreppe_IN_abdimmen_ldr = 2U;
- const uint8_T FSMTreppe_IN_abdimmen_runter = 3U;
- const uint8_T FSMTreppe_IN_aufdimmen_hoch = 4U;
- const uint8_T FSMTreppe_IN_aufdimmen_ldr = 5U;
- const uint8_T FSMTreppe_IN_aufdimmen_runter = 6U;
- const uint8_T FSMTreppe_IN_dimm_regelung = 7U;
- const uint8_T FSMTreppe_IN_inaktiv = 8U;
- const uint8_T FSMTreppe_IN_ruhezustand = 9U;
- const uint8_T FSMTreppe_IN_warten_hoch = 10U;
- const uint8_T FSMTreppe_IN_warten_runter = 11U;
-
- // Model step function
- void FSMTreppeModelClass::step()
- {
- // Chart: '<Root>/FSMTreppe' incorporates:
- // Inport: '<Root>/anim_beendet'
- // Inport: '<Root>/ldr_changed'
- // Inport: '<Root>/ldr_schwelle'
- // Inport: '<Root>/sensor_oben'
- // Inport: '<Root>/sensor_unten'
-
- if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
- FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_T>
- (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_inaktiv;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 0U;
- } else {
- switch (FSMTreppe_DW.is_c3_FSMTreppe) {
- case FSMTreppe_IN_abdimmen_hoch:
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 6U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 3U;
- }
- break;
-
- case FSMTreppe_IN_abdimmen_ldr:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 2U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 0U;
- }
- break;
-
- case FSMTreppe_IN_abdimmen_runter:
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 9U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 3U;
- }
- break;
-
- case FSMTreppe_IN_aufdimmen_hoch:
- // Outport: '<Root>/laufrichtung'
- FSMTreppe_Y.laufrichtung = 1U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 4U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_hoch;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 5U;
- }
- break;
-
- case FSMTreppe_IN_aufdimmen_ldr:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 1U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 3U;
- }
- break;
-
- case FSMTreppe_IN_aufdimmen_runter:
- // Outport: '<Root>/laufrichtung'
- FSMTreppe_Y.laufrichtung = 0U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 7U;
- if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_runter;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 8U;
- }
- break;
-
- case FSMTreppe_IN_dimm_regelung:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 10U;
- if ((FSMTreppe_DW.temporalCounter_i1 >= 500U) || (FSMTreppe_U.anim_beendet
- == 1U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 3U;
- }
- break;
-
- case FSMTreppe_IN_inaktiv:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 0U;
- if (FSMTreppe_U.ldr_schwelle == 1U) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_ldr;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 1U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
- }
- break;
-
- case FSMTreppe_IN_ruhezustand:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 3U;
- if (FSMTreppe_U.sensor_unten == 1U) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_hoch;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/laufrichtung'
- FSMTreppe_Y.laufrichtung = 1U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 4U;
- } else if (FSMTreppe_U.sensor_oben == 1U) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_runter;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/laufrichtung'
- FSMTreppe_Y.laufrichtung = 0U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 1U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 7U;
- } else if (FSMTreppe_U.ldr_schwelle == 0U) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_ldr;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 2U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
- } else if (FSMTreppe_U.ldr_changed == 1U) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_dimm_regelung;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 10U;
- }
- break;
-
- case FSMTreppe_IN_warten_hoch:
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 5U;
- if ((FSMTreppe_U.sensor_oben == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_hoch;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 6U;
- }
- break;
-
- default:
- // Outport: '<Root>/status'
- // case IN_warten_runter:
- FSMTreppe_Y.status = 8U;
- if ((FSMTreppe_U.sensor_unten == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
- 500U)) {
- FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_runter;
- FSMTreppe_DW.temporalCounter_i1 = 0U;
-
- // Outport: '<Root>/dimmrichtung'
- FSMTreppe_Y.dimmrichtung = 0U;
-
- // Outport: '<Root>/status'
- FSMTreppe_Y.status = 9U;
- }
- break;
- }
- }
-
- // End of Chart: '<Root>/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(),
- FSMTreppe_M()
- {
- // Currently there is no constructor body generated.
- }
-
- // Destructor
- FSMTreppeModelClass::~FSMTreppeModelClass()
- {
- // Currently there is no destructor body generated.
- }
-
- // Real-Time Model get method
- FSMTreppeModelClass::RT_MODEL_FSMTreppe_T * FSMTreppeModelClass::getRTM()
- {
- return (&FSMTreppe_M);
- }
-
- //
- // File trailer for generated code.
- //
- // [EOF]
- //
|