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.

FSMTreppe2.cpp 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.29
  11. // Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
  12. // C/C++ source code generated on : Sat Jul 3 17:39:25 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 "FSMTreppe2.h"
  20. #include <stdint.h>
  21. // Named constants for Chart: '<Root>/FSMTreppe'
  22. const uint8_t FSMTreppe_IN_abdimmen_hoch = 1U;
  23. const uint8_t FSMTreppe_IN_abdimmen_runter = 2U;
  24. const uint8_t FSMTreppe_IN_aufdimmen_hoch = 3U;
  25. const uint8_t FSMTreppe_IN_aufdimmen_runter = 4U;
  26. const uint8_t FSMTreppe_IN_inaktiv = 5U;
  27. const uint8_t FSMTreppe_IN_ruhezustand = 6U;
  28. const uint8_t FSMTreppe_IN_warten_hoch = 7U;
  29. const uint8_t FSMTreppe_IN_warten_runter = 8U;
  30. // Model step function
  31. void FSMTreppeModelClass::step()
  32. {
  33. // Chart: '<Root>/FSMTreppe' incorporates:
  34. // Inport: '<Root>/anim_beendet'
  35. // Inport: '<Root>/ldr_schwelle'
  36. // Inport: '<Root>/sensor_oben'
  37. // Inport: '<Root>/sensor_unten'
  38. if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
  39. FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_t>
  40. (FSMTreppe_DW.temporalCounter_i1 + 1U);
  41. }
  42. if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) {
  43. FSMTreppe_DW.is_active_c3_FSMTreppe = 1U;
  44. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
  45. // Outport: '<Root>/status'
  46. FSMTreppe_Y.status = 0U;
  47. } else {
  48. switch (FSMTreppe_DW.is_c3_FSMTreppe) {
  49. case FSMTreppe_IN_abdimmen_hoch:
  50. // Outport: '<Root>/dimmrichtung'
  51. FSMTreppe_Y.dimmrichtung = 0U;
  52. // Outport: '<Root>/status'
  53. FSMTreppe_Y.status = 4U;
  54. if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  55. {
  56. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
  57. // Outport: '<Root>/status'
  58. FSMTreppe_Y.status = 1U;
  59. }
  60. break;
  61. case FSMTreppe_IN_abdimmen_runter:
  62. // Outport: '<Root>/dimmrichtung'
  63. FSMTreppe_Y.dimmrichtung = 0U;
  64. // Outport: '<Root>/status'
  65. FSMTreppe_Y.status = 7U;
  66. if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  67. {
  68. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
  69. // Outport: '<Root>/status'
  70. FSMTreppe_Y.status = 1U;
  71. }
  72. break;
  73. case FSMTreppe_IN_aufdimmen_hoch:
  74. // Outport: '<Root>/laufrichtung'
  75. FSMTreppe_Y.laufrichtung = 1U;
  76. // Outport: '<Root>/dimmrichtung'
  77. FSMTreppe_Y.dimmrichtung = 1U;
  78. // Outport: '<Root>/status'
  79. FSMTreppe_Y.status = 2U;
  80. if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  81. {
  82. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_hoch;
  83. FSMTreppe_DW.temporalCounter_i1 = 0U;
  84. // Outport: '<Root>/status'
  85. FSMTreppe_Y.status = 3U;
  86. }
  87. break;
  88. case FSMTreppe_IN_aufdimmen_runter:
  89. // Outport: '<Root>/laufrichtung'
  90. FSMTreppe_Y.laufrichtung = 0U;
  91. // Outport: '<Root>/dimmrichtung'
  92. FSMTreppe_Y.dimmrichtung = 1U;
  93. // Outport: '<Root>/status'
  94. FSMTreppe_Y.status = 5U;
  95. if (FSMTreppe_U.anim_beendet || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  96. {
  97. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_runter;
  98. FSMTreppe_DW.temporalCounter_i1 = 0U;
  99. // Outport: '<Root>/status'
  100. FSMTreppe_Y.status = 6U;
  101. }
  102. break;
  103. case FSMTreppe_IN_inaktiv:
  104. // Outport: '<Root>/status'
  105. FSMTreppe_Y.status = 0U;
  106. if (FSMTreppe_U.ldr_schwelle == 1.0) {
  107. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
  108. // Outport: '<Root>/status'
  109. FSMTreppe_Y.status = 1U;
  110. }
  111. break;
  112. case FSMTreppe_IN_ruhezustand:
  113. // Outport: '<Root>/status'
  114. FSMTreppe_Y.status = 1U;
  115. if (FSMTreppe_U.sensor_unten) {
  116. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_hoch;
  117. FSMTreppe_DW.temporalCounter_i1 = 0U;
  118. // Outport: '<Root>/laufrichtung'
  119. FSMTreppe_Y.laufrichtung = 1U;
  120. // Outport: '<Root>/dimmrichtung'
  121. FSMTreppe_Y.dimmrichtung = 1U;
  122. // Outport: '<Root>/status'
  123. FSMTreppe_Y.status = 2U;
  124. } else if (FSMTreppe_U.sensor_oben) {
  125. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_runter;
  126. FSMTreppe_DW.temporalCounter_i1 = 0U;
  127. // Outport: '<Root>/laufrichtung'
  128. FSMTreppe_Y.laufrichtung = 0U;
  129. // Outport: '<Root>/dimmrichtung'
  130. FSMTreppe_Y.dimmrichtung = 1U;
  131. // Outport: '<Root>/status'
  132. FSMTreppe_Y.status = 5U;
  133. } else if (FSMTreppe_U.ldr_schwelle == 0.0) {
  134. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
  135. // Outport: '<Root>/status'
  136. FSMTreppe_Y.status = 0U;
  137. }
  138. break;
  139. case FSMTreppe_IN_warten_hoch:
  140. // Outport: '<Root>/status'
  141. FSMTreppe_Y.status = 3U;
  142. if (FSMTreppe_U.sensor_oben || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  143. {
  144. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_hoch;
  145. FSMTreppe_DW.temporalCounter_i1 = 0U;
  146. // Outport: '<Root>/dimmrichtung'
  147. FSMTreppe_Y.dimmrichtung = 0U;
  148. // Outport: '<Root>/status'
  149. FSMTreppe_Y.status = 4U;
  150. }
  151. break;
  152. default:
  153. // Outport: '<Root>/status'
  154. // case IN_warten_runter:
  155. FSMTreppe_Y.status = 6U;
  156. if (FSMTreppe_U.sensor_unten || (FSMTreppe_DW.temporalCounter_i1 >= 500U))
  157. {
  158. FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_runter;
  159. FSMTreppe_DW.temporalCounter_i1 = 0U;
  160. // Outport: '<Root>/dimmrichtung'
  161. FSMTreppe_Y.dimmrichtung = 0U;
  162. // Outport: '<Root>/status'
  163. FSMTreppe_Y.status = 7U;
  164. }
  165. break;
  166. }
  167. }
  168. // End of Chart: '<Root>/FSMTreppe'
  169. }
  170. // Model initialize function
  171. void FSMTreppeModelClass::initialize()
  172. {
  173. // (no initialization code required)
  174. }
  175. // Model terminate function
  176. void FSMTreppeModelClass::terminate()
  177. {
  178. // (no terminate code required)
  179. }
  180. // Constructor
  181. FSMTreppeModelClass::FSMTreppeModelClass() :
  182. FSMTreppe_DW(),
  183. FSMTreppe_U(),
  184. FSMTreppe_Y()
  185. {
  186. // Currently there is no constructor body generated.
  187. }
  188. // Destructor
  189. FSMTreppeModelClass::~FSMTreppeModelClass()
  190. {
  191. // Currently there is no destructor body generated.
  192. }
  193. //
  194. // File trailer for generated code.
  195. //
  196. // [EOF]
  197. //