Declarations.c 15 KB

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