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.

FSMTreppe3.cpp 7.8KB

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