Clock.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #ifndef CLOCK_H_
  2. #define CLOCK_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'clock'.
  8. */
  9. //! enumeration of all states
  10. typedef enum {
  11. clock_main_displays ,
  12. clock_main_displays__region0_regular_beep_test ,
  13. clock_main_displays__region0_regular_beep_test_regular_update ,
  14. clock_main_displays__region0_regular_beep_test_regular_update__region0_sec ,
  15. clock_main_displays__region0_regular_beep_test_regular_update__region0_min ,
  16. clock_main_displays__region0_regular_beep_test_regular_update__region0_hr ,
  17. clock_main_displays__region0_regular_beep_test_regular_update__region0_mode ,
  18. clock_main_displays__region0_regular_beep_test_regular_time ,
  19. clock_main_displays__region0_regular_beep_test_regular_date ,
  20. clock_main_displays__region0_regular_beep_test_beep_test_off ,
  21. clock_main_displays__region0_regular_beep_test_beep_test_beep ,
  22. clock_main_displays__region0_wait ,
  23. clock_main_alarms_beep ,
  24. clock_main_alarms_beep_r1_alarm_1_beeps ,
  25. clock_main_alarms_beep_r1_alarm_2_beeps ,
  26. clock_main_alarms_beep_r1_both_beep ,
  27. clock_main_stopwatch ,
  28. clock_main_stopwatch_r1_zero ,
  29. clock_main_stopwatch_r1_display_run ,
  30. clock_main_stopwatch_r1_display_run_display_regular ,
  31. clock_main_stopwatch_r1_display_run_display_lap ,
  32. clock_main_stopwatch_r1_display_run_run_on ,
  33. clock_main_stopwatch_r1_display_run_run_off ,
  34. clock_main_settings ,
  35. clock_main_settings_r1_alarm_1 ,
  36. clock_main_settings_r1_alarm_1_r1_off ,
  37. clock_main_settings_r1_alarm_1_r1_on ,
  38. clock_main_settings_r1_update_1 ,
  39. clock_main_settings_r1_update_1_r1_hr ,
  40. clock_main_settings_r1_update_1_r1_min ,
  41. clock_main_settings_r1_update_2 ,
  42. clock_main_settings_r1_update_2_r1_hr ,
  43. clock_main_settings_r1_update_2_r1_min ,
  44. clock_main_settings_r1_alarm_2 ,
  45. clock_main_settings_r1_alarm_2_r1_off ,
  46. clock_main_settings_r1_alarm_2_r1_on ,
  47. clock_main_settings_r1_chime ,
  48. clock_main_settings_r1_chime_r1_off ,
  49. clock_main_settings_r1_chime_r1_on ,
  50. clock_alarm_1_disabled ,
  51. clock_alarm_1_enabled ,
  52. clock_alarm_2_disabled ,
  53. clock_alarm_2_enabled ,
  54. clock_chime___status_disabled ,
  55. clock_chime___status_enabled ,
  56. clock_chime___status_enabled_r1_quiet ,
  57. clock_chime___status_enabled_r1_beep ,
  58. clock_light_off ,
  59. clock_light_on ,
  60. clock_power_ok ,
  61. clock_power_blink ,
  62. Clock_last_state
  63. } ClockStates;
  64. //! Type definition of the data structure for the ClockIface interface scope.
  65. typedef struct {
  66. sc_boolean a_p_raised;
  67. sc_boolean b_p_raised;
  68. sc_boolean b_r_raised;
  69. sc_boolean c_p_raised;
  70. sc_boolean c_r_raised;
  71. sc_boolean d_p_raised;
  72. sc_boolean d_r_raised;
  73. } ClockIface;
  74. //! Type definition of the data structure for the ClockIfaceClock interface scope.
  75. typedef struct {
  76. sc_integer second;
  77. sc_integer minute;
  78. sc_integer hour;
  79. sc_integer time;
  80. sc_integer al1_time;
  81. sc_integer al2_time;
  82. } ClockIfaceClock;
  83. //! Type definition of the data structure for the ClockIfaceStopwatch interface scope.
  84. typedef struct {
  85. sc_integer time;
  86. sc_integer lap;
  87. } ClockIfaceStopwatch;
  88. //! Type definition of the data structure for the ClockIfaceBattery interface scope.
  89. typedef struct {
  90. sc_boolean low_raised;
  91. sc_boolean replace_raised;
  92. sc_integer max_energy;
  93. sc_real min_energy;
  94. sc_integer energy;
  95. } ClockIfaceBattery;
  96. //! Type definition of the data structure for the ClockInternal interface scope.
  97. typedef struct {
  98. sc_integer delta;
  99. } ClockInternal;
  100. //! Type definition of the data structure for the ClockTimeEvents interface scope.
  101. typedef struct {
  102. sc_boolean clock_main_displays__region0_regular_beep_test_regular_update_time_event_0_raised;
  103. sc_boolean clock_main_displays__region0_regular_beep_test_regular_date_time_event_0_raised;
  104. sc_boolean clock_main_displays__region0_wait_time_event_0_raised;
  105. sc_boolean clock_main_alarms_beep_time_event_0_raised;
  106. sc_boolean clock_main_stopwatch_r1_display_run_run_on_time_event_0_raised;
  107. sc_boolean clock_chime___status_enabled_r1_beep_time_event_0_raised;
  108. sc_boolean clock_time_event_0_raised;
  109. } ClockTimeEvents;
  110. //! the maximum number of orthogonal states defines the dimension of the state configuration vector.
  111. #define CLOCK_MAX_ORTHOGONAL_STATES 7
  112. //! dimension of the state configuration vector for history states
  113. #define CLOCK_MAX_HISTORY_STATES 10
  114. /*! Type definition of the data structure for the Clock state machine.
  115. This data structure has to be allocated by the client code. */
  116. typedef struct {
  117. ClockStates stateConfVector[CLOCK_MAX_ORTHOGONAL_STATES];
  118. ClockStates historyVector[CLOCK_MAX_HISTORY_STATES];
  119. sc_ushort stateConfVectorPosition;
  120. ClockIface iface;
  121. ClockIfaceClock ifaceClock;
  122. ClockIfaceStopwatch ifaceStopwatch;
  123. ClockIfaceBattery ifaceBattery;
  124. ClockInternal internal;
  125. ClockTimeEvents timeEvents;
  126. } Clock;
  127. /*! Initializes the Clock state machine data structures. Must be called before first usage.*/
  128. extern void clock_init(Clock* handle);
  129. /*! Activates the state machine */
  130. extern void clock_enter(Clock* handle);
  131. /*! Deactivates the state machine */
  132. extern void clock_exit(Clock* handle);
  133. /*! Performs a 'run to completion' step. */
  134. extern void clock_runCycle(Clock* handle);
  135. /*! Raises a time event. */
  136. extern void clock_raiseTimeEvent(Clock* handle, sc_eventid evid);
  137. /*! Raises the in event 'a_p' that is defined in the default interface scope. */
  138. extern void clockIface_raise_a_p(Clock* handle);
  139. /*! Raises the in event 'b_p' that is defined in the default interface scope. */
  140. extern void clockIface_raise_b_p(Clock* handle);
  141. /*! Raises the in event 'b_r' that is defined in the default interface scope. */
  142. extern void clockIface_raise_b_r(Clock* handle);
  143. /*! Raises the in event 'c_p' that is defined in the default interface scope. */
  144. extern void clockIface_raise_c_p(Clock* handle);
  145. /*! Raises the in event 'c_r' that is defined in the default interface scope. */
  146. extern void clockIface_raise_c_r(Clock* handle);
  147. /*! Raises the in event 'd_p' that is defined in the default interface scope. */
  148. extern void clockIface_raise_d_p(Clock* handle);
  149. /*! Raises the in event 'd_r' that is defined in the default interface scope. */
  150. extern void clockIface_raise_d_r(Clock* handle);
  151. /*! Gets the value of the variable 'second' that is defined in the interface scope 'clock'. */
  152. extern sc_integer clockIfaceClock_get_second(Clock* handle);
  153. /*! Gets the value of the variable 'minute' that is defined in the interface scope 'clock'. */
  154. extern sc_integer clockIfaceClock_get_minute(Clock* handle);
  155. /*! Sets the value of the variable 'minute' that is defined in the interface scope 'clock'. */
  156. extern void clockIfaceClock_set_minute(Clock* handle, sc_integer value);
  157. /*! Gets the value of the variable 'hour' that is defined in the interface scope 'clock'. */
  158. extern sc_integer clockIfaceClock_get_hour(Clock* handle);
  159. /*! Sets the value of the variable 'hour' that is defined in the interface scope 'clock'. */
  160. extern void clockIfaceClock_set_hour(Clock* handle, sc_integer value);
  161. /*! Gets the value of the variable 'time' that is defined in the interface scope 'clock'. */
  162. extern sc_integer clockIfaceClock_get_time(Clock* handle);
  163. /*! Sets the value of the variable 'time' that is defined in the interface scope 'clock'. */
  164. extern void clockIfaceClock_set_time(Clock* handle, sc_integer value);
  165. /*! Gets the value of the variable 'al1_time' that is defined in the interface scope 'clock'. */
  166. extern sc_integer clockIfaceClock_get_al1_time(Clock* handle);
  167. /*! Sets the value of the variable 'al1_time' that is defined in the interface scope 'clock'. */
  168. extern void clockIfaceClock_set_al1_time(Clock* handle, sc_integer value);
  169. /*! Gets the value of the variable 'al2_time' that is defined in the interface scope 'clock'. */
  170. extern sc_integer clockIfaceClock_get_al2_time(Clock* handle);
  171. /*! Sets the value of the variable 'al2_time' that is defined in the interface scope 'clock'. */
  172. extern void clockIfaceClock_set_al2_time(Clock* handle, sc_integer value);
  173. /*! Gets the value of the variable 'time' that is defined in the interface scope 'stopwatch'. */
  174. extern sc_integer clockIfaceStopwatch_get_time(Clock* handle);
  175. /*! Sets the value of the variable 'time' that is defined in the interface scope 'stopwatch'. */
  176. extern void clockIfaceStopwatch_set_time(Clock* handle, sc_integer value);
  177. /*! Gets the value of the variable 'lap' that is defined in the interface scope 'stopwatch'. */
  178. extern sc_integer clockIfaceStopwatch_get_lap(Clock* handle);
  179. /*! Sets the value of the variable 'lap' that is defined in the interface scope 'stopwatch'. */
  180. extern void clockIfaceStopwatch_set_lap(Clock* handle, sc_integer value);
  181. /*! Raises the in event 'low' that is defined in the interface scope 'battery'. */
  182. extern void clockIfaceBattery_raise_low(Clock* handle);
  183. /*! Raises the in event 'replace' that is defined in the interface scope 'battery'. */
  184. extern void clockIfaceBattery_raise_replace(Clock* handle);
  185. /*! Gets the value of the variable 'max_energy' that is defined in the interface scope 'battery'. */
  186. extern sc_integer clockIfaceBattery_get_max_energy(Clock* handle);
  187. /*! Gets the value of the variable 'min_energy' that is defined in the interface scope 'battery'. */
  188. extern sc_real clockIfaceBattery_get_min_energy(Clock* handle);
  189. /*! Gets the value of the variable 'energy' that is defined in the interface scope 'battery'. */
  190. extern sc_integer clockIfaceBattery_get_energy(Clock* handle);
  191. /*! Sets the value of the variable 'energy' that is defined in the interface scope 'battery'. */
  192. extern void clockIfaceBattery_set_energy(Clock* handle, sc_integer value);
  193. /*! Checks if the specified state is active. */
  194. extern sc_boolean clock_isActive(Clock* handle, ClockStates state);
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif /* CLOCK_H_ */