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

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