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

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