Declarations.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "Declarations.h"
  5. /*! \file Implementation of the state machine 'Declarations'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean declarations_check_main_region_A_tr0_tr0(const Declarations* handle);
  9. static sc_boolean declarations_check_main_region_A_tr1_tr1(const Declarations* handle);
  10. static sc_boolean declarations_check_main_region_B_tr0_tr0(const Declarations* handle);
  11. static sc_boolean declarations_check_main_region_B_tr1_tr1(const Declarations* handle);
  12. static sc_boolean declarations_check_main_region_B_tr2_tr2(const Declarations* handle);
  13. static sc_boolean declarations_check_main_region_B_tr3_tr3(const Declarations* handle);
  14. static void declarations_effect_main_region_A_tr0(Declarations* handle);
  15. static void declarations_effect_main_region_A_tr1(Declarations* handle);
  16. static void declarations_effect_main_region_B_tr0(Declarations* handle);
  17. static void declarations_effect_main_region_B_tr1(Declarations* handle);
  18. static void declarations_effect_main_region_B_tr2(Declarations* handle);
  19. static void declarations_effect_main_region_B_tr3(Declarations* handle);
  20. static void declarations_enact_main_region_A(Declarations* handle);
  21. static void declarations_enseq_main_region_A_default(Declarations* handle);
  22. static void declarations_enseq_main_region_B_default(Declarations* handle);
  23. static void declarations_enseq_main_region_default(Declarations* handle);
  24. static void declarations_exseq_main_region_A(Declarations* handle);
  25. static void declarations_exseq_main_region_B(Declarations* handle);
  26. static void declarations_exseq_main_region(Declarations* handle);
  27. static void declarations_react_main_region_A(Declarations* handle);
  28. static void declarations_react_main_region_B(Declarations* handle);
  29. static void declarations_react_main_region__entry_Default(Declarations* handle);
  30. static void declarations_clearInEvents(Declarations* handle);
  31. static void declarations_clearOutEvents(Declarations* handle);
  32. void declarations_init(Declarations* handle)
  33. {
  34. sc_integer i;
  35. for (i = 0; i < DECLARATIONS_MAX_ORTHOGONAL_STATES; ++i)
  36. {
  37. handle->stateConfVector[i] = Declarations_last_state;
  38. }
  39. handle->stateConfVectorPosition = 0;
  40. declarations_clearInEvents(handle);
  41. declarations_clearOutEvents(handle);
  42. /* Default init sequence for statechart Declarations */
  43. handle->iface.varA = bool_false;
  44. handle->iface.varB = 1;
  45. handle->iface.varC = 1.0;
  46. handle->iface.varD = "myString";
  47. handle->iface.varE = 0x10;
  48. handle->ifaceIfA.varA = bool_false;
  49. handle->ifaceIfA.varB = 1;
  50. handle->ifaceIfA.varC = 1.0;
  51. handle->ifaceIfA.varD = "myString";
  52. handle->ifaceIfA.varE = 0x10;
  53. handle->internal.varInA = bool_false;
  54. handle->internal.varInB = 1;
  55. handle->internal.varInC = 1.0;
  56. handle->internal.varInD = "myString";
  57. handle->internal.varInE = 0x10;
  58. }
  59. void declarations_enter(Declarations* handle)
  60. {
  61. /* Default enter sequence for statechart Declarations */
  62. declarations_enseq_main_region_default(handle);
  63. }
  64. void declarations_exit(Declarations* handle)
  65. {
  66. /* Default exit sequence for statechart Declarations */
  67. declarations_exseq_main_region(handle);
  68. }
  69. sc_boolean declarations_isActive(const Declarations* handle)
  70. {
  71. sc_boolean result;
  72. if (handle->stateConfVector[0] != Declarations_last_state)
  73. {
  74. result = bool_true;
  75. }
  76. else
  77. {
  78. result = bool_false;
  79. }
  80. return result;
  81. }
  82. /*
  83. * Always returns 'false' since this state machine can never become final.
  84. */
  85. sc_boolean declarations_isFinal(const Declarations* handle)
  86. {
  87. return bool_false;
  88. }
  89. static void declarations_clearInEvents(Declarations* handle)
  90. {
  91. handle->iface.evA_raised = bool_false;
  92. handle->iface.evC_raised = bool_false;
  93. handle->iface.evE_raised = bool_false;
  94. handle->ifaceIfA.evA_raised = bool_false;
  95. handle->ifaceIfA.evC_raised = bool_false;
  96. handle->ifaceIfA.evE_raised = bool_false;
  97. handle->internal.evInA_raised = bool_false;
  98. handle->internal.evInB_raised = bool_false;
  99. handle->internal.evInC_raised = bool_false;
  100. handle->internal.evInD_raised = bool_false;
  101. handle->internal.evInE_raised = bool_false;
  102. handle->internal.evInF_raised = bool_false;
  103. }
  104. static void declarations_clearOutEvents(Declarations* handle)
  105. {
  106. handle->iface.evB_raised = bool_false;
  107. handle->iface.evD_raised = bool_false;
  108. handle->iface.evF_raised = bool_false;
  109. handle->ifaceIfA.evB_raised = bool_false;
  110. handle->ifaceIfA.evD_raised = bool_false;
  111. handle->ifaceIfA.evF_raised = bool_false;
  112. }
  113. void declarations_runCycle(Declarations* handle)
  114. {
  115. declarations_clearOutEvents(handle);
  116. for (handle->stateConfVectorPosition = 0;
  117. handle->stateConfVectorPosition < DECLARATIONS_MAX_ORTHOGONAL_STATES;
  118. handle->stateConfVectorPosition++)
  119. {
  120. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  121. {
  122. case Declarations_main_region_A :
  123. {
  124. declarations_react_main_region_A(handle);
  125. break;
  126. }
  127. case Declarations_main_region_B :
  128. {
  129. declarations_react_main_region_B(handle);
  130. break;
  131. }
  132. default:
  133. break;
  134. }
  135. }
  136. declarations_clearInEvents(handle);
  137. }
  138. sc_boolean declarations_isStateActive(const Declarations* handle, DeclarationsStates state)
  139. {
  140. sc_boolean result = bool_false;
  141. switch (state)
  142. {
  143. case Declarations_main_region_A :
  144. result = (sc_boolean) (handle->stateConfVector[0] == Declarations_main_region_A
  145. );
  146. break;
  147. case Declarations_main_region_B :
  148. result = (sc_boolean) (handle->stateConfVector[0] == Declarations_main_region_B
  149. );
  150. break;
  151. default:
  152. result = bool_false;
  153. break;
  154. }
  155. return result;
  156. }
  157. void declarationsIface_raise_evA(Declarations* handle)
  158. {
  159. handle->iface.evA_raised = bool_true;
  160. }
  161. void declarationsIface_raise_evC(Declarations* handle, sc_boolean value)
  162. {
  163. handle->iface.evC_value = value;
  164. handle->iface.evC_raised = bool_true;
  165. }
  166. void declarationsIface_raise_evE(Declarations* handle, sc_real value)
  167. {
  168. handle->iface.evE_value = value;
  169. handle->iface.evE_raised = bool_true;
  170. }
  171. sc_boolean declarationsIface_israised_evB(const Declarations* handle)
  172. {
  173. return handle->iface.evB_raised;
  174. }
  175. sc_boolean declarationsIface_israised_evD(const Declarations* handle)
  176. {
  177. return handle->iface.evD_raised;
  178. }
  179. sc_integer declarationsIface_get_evD_value(const Declarations* handle)
  180. {
  181. return handle->iface.evD_value;
  182. }
  183. sc_boolean declarationsIface_israised_evF(const Declarations* handle)
  184. {
  185. return handle->iface.evF_raised;
  186. }
  187. sc_string declarationsIface_get_evF_value(const Declarations* handle)
  188. {
  189. return handle->iface.evF_value;
  190. }
  191. sc_boolean declarationsIface_get_varA(const Declarations* handle)
  192. {
  193. return handle->iface.varA;
  194. }
  195. void declarationsIface_set_varA(Declarations* handle, sc_boolean value)
  196. {
  197. handle->iface.varA = value;
  198. }
  199. sc_integer declarationsIface_get_varB(const Declarations* handle)
  200. {
  201. return handle->iface.varB;
  202. }
  203. void declarationsIface_set_varB(Declarations* handle, sc_integer value)
  204. {
  205. handle->iface.varB = value;
  206. }
  207. sc_real declarationsIface_get_varC(const Declarations* handle)
  208. {
  209. return handle->iface.varC;
  210. }
  211. void declarationsIface_set_varC(Declarations* handle, sc_real value)
  212. {
  213. handle->iface.varC = value;
  214. }
  215. sc_string declarationsIface_get_varD(const Declarations* handle)
  216. {
  217. return handle->iface.varD;
  218. }
  219. void declarationsIface_set_varD(Declarations* handle, sc_string value)
  220. {
  221. handle->iface.varD = value;
  222. }
  223. sc_integer declarationsIface_get_varE(const Declarations* handle)
  224. {
  225. return handle->iface.varE;
  226. }
  227. void declarationsIface_set_varE(Declarations* handle, sc_integer value)
  228. {
  229. handle->iface.varE = value;
  230. }
  231. void declarationsIfaceIfA_raise_evA(Declarations* handle)
  232. {
  233. handle->ifaceIfA.evA_raised = bool_true;
  234. }
  235. void declarationsIfaceIfA_raise_evC(Declarations* handle, sc_boolean value)
  236. {
  237. handle->ifaceIfA.evC_value = value;
  238. handle->ifaceIfA.evC_raised = bool_true;
  239. }
  240. void declarationsIfaceIfA_raise_evE(Declarations* handle, sc_real value)
  241. {
  242. handle->ifaceIfA.evE_value = value;
  243. handle->ifaceIfA.evE_raised = bool_true;
  244. }
  245. sc_boolean declarationsIfaceIfA_israised_evB(const Declarations* handle)
  246. {
  247. return handle->ifaceIfA.evB_raised;
  248. }
  249. sc_boolean declarationsIfaceIfA_israised_evD(const Declarations* handle)
  250. {
  251. return handle->ifaceIfA.evD_raised;
  252. }
  253. sc_integer declarationsIfaceIfA_get_evD_value(const Declarations* handle)
  254. {
  255. return handle->ifaceIfA.evD_value;
  256. }
  257. sc_boolean declarationsIfaceIfA_israised_evF(const Declarations* handle)
  258. {
  259. return handle->ifaceIfA.evF_raised;
  260. }
  261. sc_string declarationsIfaceIfA_get_evF_value(const Declarations* handle)
  262. {
  263. return handle->ifaceIfA.evF_value;
  264. }
  265. sc_boolean declarationsIfaceIfA_get_varA(const Declarations* handle)
  266. {
  267. return handle->ifaceIfA.varA;
  268. }
  269. void declarationsIfaceIfA_set_varA(Declarations* handle, sc_boolean value)
  270. {
  271. handle->ifaceIfA.varA = value;
  272. }
  273. sc_integer declarationsIfaceIfA_get_varB(const Declarations* handle)
  274. {
  275. return handle->ifaceIfA.varB;
  276. }
  277. void declarationsIfaceIfA_set_varB(Declarations* handle, sc_integer value)
  278. {
  279. handle->ifaceIfA.varB = value;
  280. }
  281. sc_real declarationsIfaceIfA_get_varC(const Declarations* handle)
  282. {
  283. return handle->ifaceIfA.varC;
  284. }
  285. void declarationsIfaceIfA_set_varC(Declarations* handle, sc_real value)
  286. {
  287. handle->ifaceIfA.varC = value;
  288. }
  289. sc_string declarationsIfaceIfA_get_varD(const Declarations* handle)
  290. {
  291. return handle->ifaceIfA.varD;
  292. }
  293. void declarationsIfaceIfA_set_varD(Declarations* handle, sc_string value)
  294. {
  295. handle->ifaceIfA.varD = value;
  296. }
  297. sc_integer declarationsIfaceIfA_get_varE(const Declarations* handle)
  298. {
  299. return handle->ifaceIfA.varE;
  300. }
  301. void declarationsIfaceIfA_set_varE(Declarations* handle, sc_integer value)
  302. {
  303. handle->ifaceIfA.varE = value;
  304. }
  305. /* implementations of all internal functions */
  306. static sc_boolean declarations_check_main_region_A_tr0_tr0(const Declarations* handle)
  307. {
  308. return handle->internal.evInA_raised;
  309. }
  310. static sc_boolean declarations_check_main_region_A_tr1_tr1(const Declarations* handle)
  311. {
  312. return handle->internal.evInC_raised;
  313. }
  314. static sc_boolean declarations_check_main_region_B_tr0_tr0(const Declarations* handle)
  315. {
  316. return handle->internal.evInB_raised;
  317. }
  318. static sc_boolean declarations_check_main_region_B_tr1_tr1(const Declarations* handle)
  319. {
  320. return handle->internal.evInD_raised;
  321. }
  322. static sc_boolean declarations_check_main_region_B_tr2_tr2(const Declarations* handle)
  323. {
  324. return handle->internal.evInE_raised;
  325. }
  326. static sc_boolean declarations_check_main_region_B_tr3_tr3(const Declarations* handle)
  327. {
  328. return handle->internal.evInF_raised;
  329. }
  330. static void declarations_effect_main_region_A_tr0(Declarations* handle)
  331. {
  332. declarations_exseq_main_region_A(handle);
  333. declarations_enseq_main_region_B_default(handle);
  334. }
  335. static void declarations_effect_main_region_A_tr1(Declarations* handle)
  336. {
  337. declarations_exseq_main_region_A(handle);
  338. declarations_enseq_main_region_A_default(handle);
  339. }
  340. static void declarations_effect_main_region_B_tr0(Declarations* handle)
  341. {
  342. declarations_exseq_main_region_B(handle);
  343. declarations_enseq_main_region_A_default(handle);
  344. }
  345. static void declarations_effect_main_region_B_tr1(Declarations* handle)
  346. {
  347. declarations_exseq_main_region_B(handle);
  348. declarations_enseq_main_region_B_default(handle);
  349. }
  350. static void declarations_effect_main_region_B_tr2(Declarations* handle)
  351. {
  352. declarations_exseq_main_region_B(handle);
  353. declarations_enseq_main_region_B_default(handle);
  354. }
  355. static void declarations_effect_main_region_B_tr3(Declarations* handle)
  356. {
  357. declarations_exseq_main_region_B(handle);
  358. declarations_enseq_main_region_A_default(handle);
  359. }
  360. /* Entry action for state 'A'. */
  361. static void declarations_enact_main_region_A(Declarations* handle)
  362. {
  363. /* Entry action for state 'A'. */
  364. handle->internal.varInA = bool_false;
  365. handle->internal.varInB = 1;
  366. handle->internal.varInC = 1.1;
  367. handle->internal.varInD = "blub";
  368. handle->internal.varInE = 1;
  369. }
  370. /* 'default' enter sequence for state A */
  371. static void declarations_enseq_main_region_A_default(Declarations* handle)
  372. {
  373. /* 'default' enter sequence for state A */
  374. declarations_enact_main_region_A(handle);
  375. handle->stateConfVector[0] = Declarations_main_region_A;
  376. handle->stateConfVectorPosition = 0;
  377. }
  378. /* 'default' enter sequence for state B */
  379. static void declarations_enseq_main_region_B_default(Declarations* handle)
  380. {
  381. /* 'default' enter sequence for state B */
  382. handle->stateConfVector[0] = Declarations_main_region_B;
  383. handle->stateConfVectorPosition = 0;
  384. }
  385. /* 'default' enter sequence for region main region */
  386. static void declarations_enseq_main_region_default(Declarations* handle)
  387. {
  388. /* 'default' enter sequence for region main region */
  389. declarations_react_main_region__entry_Default(handle);
  390. }
  391. /* Default exit sequence for state A */
  392. static void declarations_exseq_main_region_A(Declarations* handle)
  393. {
  394. /* Default exit sequence for state A */
  395. handle->stateConfVector[0] = Declarations_last_state;
  396. handle->stateConfVectorPosition = 0;
  397. }
  398. /* Default exit sequence for state B */
  399. static void declarations_exseq_main_region_B(Declarations* handle)
  400. {
  401. /* Default exit sequence for state B */
  402. handle->stateConfVector[0] = Declarations_last_state;
  403. handle->stateConfVectorPosition = 0;
  404. }
  405. /* Default exit sequence for region main region */
  406. static void declarations_exseq_main_region(Declarations* handle)
  407. {
  408. /* Default exit sequence for region main region */
  409. /* Handle exit of all possible states (of Declarations.main_region) at position 0... */
  410. switch(handle->stateConfVector[ 0 ])
  411. {
  412. case Declarations_main_region_A :
  413. {
  414. declarations_exseq_main_region_A(handle);
  415. break;
  416. }
  417. case Declarations_main_region_B :
  418. {
  419. declarations_exseq_main_region_B(handle);
  420. break;
  421. }
  422. default: break;
  423. }
  424. }
  425. /* The reactions of state A. */
  426. static void declarations_react_main_region_A(Declarations* handle)
  427. {
  428. /* The reactions of state A. */
  429. if (declarations_check_main_region_A_tr0_tr0(handle) == bool_true)
  430. {
  431. declarations_effect_main_region_A_tr0(handle);
  432. } else
  433. {
  434. if (declarations_check_main_region_A_tr1_tr1(handle) == bool_true)
  435. {
  436. declarations_effect_main_region_A_tr1(handle);
  437. }
  438. }
  439. }
  440. /* The reactions of state B. */
  441. static void declarations_react_main_region_B(Declarations* handle)
  442. {
  443. /* The reactions of state B. */
  444. if (declarations_check_main_region_B_tr0_tr0(handle) == bool_true)
  445. {
  446. declarations_effect_main_region_B_tr0(handle);
  447. } else
  448. {
  449. if (declarations_check_main_region_B_tr1_tr1(handle) == bool_true)
  450. {
  451. declarations_effect_main_region_B_tr1(handle);
  452. } else
  453. {
  454. if (declarations_check_main_region_B_tr2_tr2(handle) == bool_true)
  455. {
  456. declarations_effect_main_region_B_tr2(handle);
  457. } else
  458. {
  459. if (declarations_check_main_region_B_tr3_tr3(handle) == bool_true)
  460. {
  461. declarations_effect_main_region_B_tr3(handle);
  462. }
  463. }
  464. }
  465. }
  466. }
  467. /* Default react sequence for initial entry */
  468. static void declarations_react_main_region__entry_Default(Declarations* handle)
  469. {
  470. /* Default react sequence for initial entry */
  471. declarations_enseq_main_region_A_default(handle);
  472. }