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.

FSMTreppe4.cpp 8.5KB

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