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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. // Named constants for Chart: '<Root>/FSMTreppe'
  21. const uint8_t FSMTreppe_IN_animation_down = 1U;
  22. const uint8_t FSMTreppe_IN_animation_up = 2U;
  23. const uint8_t FSMTreppe_IN_idle = 3U;
  24. // Model step function
  25. void FSMTreppeModelClass::step()
  26. {
  27. // Chart: '<Root>/FSMTreppe' incorporates:
  28. // Inport: '<Root>/anim_finished'
  29. // Inport: '<Root>/sensor_oben'
  30. // Inport: '<Root>/sensor_unten'
  31. if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
  32. FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_t>
  33. (FSMTreppe_DW.temporalCounter_i1 + 1U);
  34. }
  35. if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) {
  36. FSMTreppe_DW.is_active_c3_FSMTreppe = 1U;
  37. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  38. // Outport: '<Root>/anim_active'
  39. FSMTreppe_Y.anim_active = 0U;
  40. FSMTreppe_DW.got_sensor = 0U;
  41. FSMTreppe_DW.got_anim_finished = 0U;
  42. FSMTreppe_DW.finished_up = 0U;
  43. FSMTreppe_DW.finished_dn = 0U;
  44. } else {
  45. switch (FSMTreppe_DW.is_c3_FSMTreppe) {
  46. case FSMTreppe_IN_animation_down:
  47. // Outport: '<Root>/anim_active'
  48. FSMTreppe_Y.anim_active = 2U;
  49. if ((FSMTreppe_DW.finished_dn == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
  50. 300U)) {
  51. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  52. // Outport: '<Root>/anim_active'
  53. FSMTreppe_Y.anim_active = 0U;
  54. FSMTreppe_DW.got_sensor = 0U;
  55. FSMTreppe_DW.got_anim_finished = 0U;
  56. FSMTreppe_DW.finished_up = 0U;
  57. FSMTreppe_DW.finished_dn = 0U;
  58. } else {
  59. if (FSMTreppe_U.sensor_unten) {
  60. FSMTreppe_DW.got_sensor = 1U;
  61. }
  62. if (FSMTreppe_U.anim_finished) {
  63. FSMTreppe_DW.got_anim_finished = 1U;
  64. }
  65. if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
  66. 1)) {
  67. FSMTreppe_DW.finished_dn = 1U;
  68. }
  69. }
  70. break;
  71. case FSMTreppe_IN_animation_up:
  72. // Outport: '<Root>/anim_active'
  73. FSMTreppe_Y.anim_active = 1U;
  74. if ((FSMTreppe_DW.finished_up == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
  75. 300U)) {
  76. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
  77. // Outport: '<Root>/anim_active'
  78. FSMTreppe_Y.anim_active = 0U;
  79. FSMTreppe_DW.got_sensor = 0U;
  80. FSMTreppe_DW.got_anim_finished = 0U;
  81. FSMTreppe_DW.finished_up = 0U;
  82. FSMTreppe_DW.finished_dn = 0U;
  83. } else {
  84. if (FSMTreppe_U.sensor_oben) {
  85. FSMTreppe_DW.got_sensor = 1U;
  86. }
  87. if (FSMTreppe_U.anim_finished) {
  88. FSMTreppe_DW.got_anim_finished = 1U;
  89. }
  90. if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
  91. 1)) {
  92. FSMTreppe_DW.finished_up = 1U;
  93. }
  94. }
  95. break;
  96. default:
  97. // Outport: '<Root>/anim_active'
  98. // case IN_idle:
  99. FSMTreppe_Y.anim_active = 0U;
  100. if (FSMTreppe_U.sensor_oben) {
  101. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_down;
  102. FSMTreppe_DW.temporalCounter_i1 = 0U;
  103. // Outport: '<Root>/anim_active'
  104. FSMTreppe_Y.anim_active = 2U;
  105. FSMTreppe_DW.got_sensor = 0U;
  106. FSMTreppe_DW.got_anim_finished = 0U;
  107. FSMTreppe_DW.finished_dn = 0U;
  108. } else if (FSMTreppe_U.sensor_unten) {
  109. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_up;
  110. FSMTreppe_DW.temporalCounter_i1 = 0U;
  111. // Outport: '<Root>/anim_active'
  112. FSMTreppe_Y.anim_active = 1U;
  113. FSMTreppe_DW.got_sensor = 0U;
  114. FSMTreppe_DW.got_anim_finished = 0U;
  115. FSMTreppe_DW.finished_up = 0U;
  116. }
  117. break;
  118. }
  119. }
  120. // End of Chart: '<Root>/FSMTreppe'
  121. }
  122. // Model initialize function
  123. void FSMTreppeModelClass::initialize()
  124. {
  125. // (no initialization code required)
  126. }
  127. // Model terminate function
  128. void FSMTreppeModelClass::terminate()
  129. {
  130. // (no terminate code required)
  131. }
  132. // Constructor
  133. FSMTreppeModelClass::FSMTreppeModelClass() :
  134. FSMTreppe_DW(),
  135. FSMTreppe_U(),
  136. FSMTreppe_Y()
  137. {
  138. // Currently there is no constructor body generated.
  139. }
  140. // Destructor
  141. FSMTreppeModelClass::~FSMTreppeModelClass()
  142. {
  143. // Currently there is no destructor body generated.
  144. }
  145. //
  146. // File trailer for generated code.
  147. //
  148. // [EOF]
  149. //