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