ESP8266 Treppenlichtsteuerung mit OTA zum Firmware Upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FSMTreppe.cpp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //
  2. // Academic License - for use in teaching, academic research, and meeting
  3. // course requirements at degree granting institutions only. Not for
  4. // government, commercial, or other organizational use.
  5. //
  6. // File: FSMTreppe.cpp
  7. //
  8. // Code generated for Simulink model 'FSMTreppe'.
  9. //
  10. // Model version : 1.22
  11. // Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
  12. // C/C++ source code generated on : Fri Jul 2 17:45:36 2021
  13. //
  14. // Target selection: ert.tlc
  15. // Embedded hardware selection: ARM Compatible->ARM Cortex-M
  16. // Code generation objectives: Unspecified
  17. // Validation result: Not run
  18. //
  19. #include "FSMTreppe.h"
  20. #include "FSMTreppe_private.h"
  21. // Named constants for Chart: '<Root>/FSMTreppe'
  22. const uint8_T FSMTreppe_IN_animation_down = 1U;
  23. const uint8_T FSMTreppe_IN_animation_up = 2U;
  24. const uint8_T FSMTreppe_IN_idle = 3U;
  25. // Model step function
  26. void FSMTreppeModelClass::step()
  27. {
  28. // Chart: '<Root>/FSMTreppe' incorporates:
  29. // Inport: '<Root>/anim_finished'
  30. // Inport: '<Root>/sensor_oben'
  31. // Inport: '<Root>/sensor_unten'
  32. if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
  33. FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_T>
  34. (FSMTreppe_DW.temporalCounter_i1 + 1U);
  35. }
  36. if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) {
  37. FSMTreppe_DW.is_active_c3_FSMTreppe = 1U;
  38. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  39. // Outport: '<Root>/anim_active'
  40. FSMTreppe_Y.anim_active = 0U;
  41. FSMTreppe_DW.got_sensor = 0U;
  42. FSMTreppe_DW.got_anim_finished = 0U;
  43. FSMTreppe_DW.finished_up = 0U;
  44. FSMTreppe_DW.finished_dn = 0U;
  45. } else {
  46. switch (FSMTreppe_DW.is_c3_FSMTreppe) {
  47. case FSMTreppe_IN_animation_down:
  48. // Outport: '<Root>/anim_active'
  49. FSMTreppe_Y.anim_active = 2U;
  50. if ((FSMTreppe_DW.finished_dn == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
  51. 300U)) {
  52. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  53. // Outport: '<Root>/anim_active'
  54. FSMTreppe_Y.anim_active = 0U;
  55. FSMTreppe_DW.got_sensor = 0U;
  56. FSMTreppe_DW.got_anim_finished = 0U;
  57. FSMTreppe_DW.finished_up = 0U;
  58. FSMTreppe_DW.finished_dn = 0U;
  59. } else {
  60. if (FSMTreppe_U.sensor_unten) {
  61. FSMTreppe_DW.got_sensor = 1U;
  62. }
  63. if (FSMTreppe_U.anim_finished) {
  64. FSMTreppe_DW.got_anim_finished = 1U;
  65. }
  66. if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
  67. 1)) {
  68. FSMTreppe_DW.finished_dn = 1U;
  69. }
  70. }
  71. break;
  72. case FSMTreppe_IN_animation_up:
  73. // Outport: '<Root>/anim_active'
  74. FSMTreppe_Y.anim_active = 1U;
  75. if ((FSMTreppe_DW.finished_up == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
  76. 300U)) {
  77. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  78. // Outport: '<Root>/anim_active'
  79. FSMTreppe_Y.anim_active = 0U;
  80. FSMTreppe_DW.got_sensor = 0U;
  81. FSMTreppe_DW.got_anim_finished = 0U;
  82. FSMTreppe_DW.finished_up = 0U;
  83. FSMTreppe_DW.finished_dn = 0U;
  84. } else {
  85. if (FSMTreppe_U.sensor_oben) {
  86. FSMTreppe_DW.got_sensor = 1U;
  87. }
  88. if (FSMTreppe_U.anim_finished) {
  89. FSMTreppe_DW.got_anim_finished = 1U;
  90. }
  91. if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
  92. 1)) {
  93. FSMTreppe_DW.finished_up = 1U;
  94. }
  95. }
  96. break;
  97. default:
  98. // Outport: '<Root>/anim_active'
  99. // case IN_idle:
  100. FSMTreppe_Y.anim_active = 0U;
  101. if (FSMTreppe_U.sensor_oben) {
  102. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_down;
  103. FSMTreppe_DW.temporalCounter_i1 = 0U;
  104. // Outport: '<Root>/anim_active'
  105. FSMTreppe_Y.anim_active = 2U;
  106. FSMTreppe_DW.got_sensor = 0U;
  107. FSMTreppe_DW.got_anim_finished = 0U;
  108. FSMTreppe_DW.finished_dn = 0U;
  109. } else if (FSMTreppe_U.sensor_unten) {
  110. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_up;
  111. FSMTreppe_DW.temporalCounter_i1 = 0U;
  112. // Outport: '<Root>/anim_active'
  113. FSMTreppe_Y.anim_active = 1U;
  114. FSMTreppe_DW.got_sensor = 0U;
  115. FSMTreppe_DW.got_anim_finished = 0U;
  116. FSMTreppe_DW.finished_up = 0U;
  117. }
  118. break;
  119. }
  120. }
  121. // End of Chart: '<Root>/FSMTreppe'
  122. }
  123. // Model initialize function
  124. void FSMTreppeModelClass::initialize()
  125. {
  126. // (no initialization code required)
  127. }
  128. // Model terminate function
  129. void FSMTreppeModelClass::terminate()
  130. {
  131. // (no terminate code required)
  132. }
  133. // Constructor
  134. FSMTreppeModelClass::FSMTreppeModelClass() :
  135. FSMTreppe_DW(),
  136. FSMTreppe_U(),
  137. FSMTreppe_Y(),
  138. FSMTreppe_M()
  139. {
  140. // Currently there is no constructor body generated.
  141. }
  142. // Destructor
  143. FSMTreppeModelClass::~FSMTreppeModelClass()
  144. {
  145. // Currently there is no destructor body generated.
  146. }
  147. // Real-Time Model get method
  148. FSMTreppeModelClass::RT_MODEL_FSMTreppe_T * FSMTreppeModelClass::getRTM()
  149. {
  150. return (&FSMTreppe_M);
  151. }
  152. //
  153. // File trailer for generated code.
  154. //
  155. // [EOF]
  156. //