/* Generated by itemis CREATE code generator. */

#ifndef SC_PREFIX_H_
#define SC_PREFIX_H_

#ifdef __cplusplus
extern "C" { 
#endif

/*!
* Forward declaration for the Sc_prefix state machine.
*/
typedef struct Sc_prefix Sc_prefix;

/*!
* Forward declaration of the data structure for the Sc_prefixInternal interface scope.
*/
typedef struct Sc_prefixInternal Sc_prefixInternal;

/*!
* Forward declaration of the data structure for the Sc_prefixTimeEvents interface scope.
*/
typedef struct Sc_prefixTimeEvents Sc_prefixTimeEvents;

#ifdef __cplusplus
}
#endif

#include "../../app/inc/operation.h"
#include "sc_types.h"

#ifdef __cplusplus
extern "C" { 
#endif 

/*! \file
Header of the state machine 'sc_prefix'.
*/

#ifndef SC_PREFIX_EVENTQUEUE_BUFFERSIZE
#define SC_PREFIX_EVENTQUEUE_BUFFERSIZE 20
#endif
#ifndef SC_PREFIX_IN_EVENTQUEUE_BUFFERSIZE
#define SC_PREFIX_IN_EVENTQUEUE_BUFFERSIZE SC_PREFIX_EVENTQUEUE_BUFFERSIZE
#endif
#ifndef SC_PREFIX_INTERNAL_EVENTQUEUE_BUFFERSIZE
#define SC_PREFIX_INTERNAL_EVENTQUEUE_BUFFERSIZE SC_PREFIX_EVENTQUEUE_BUFFERSIZE
#endif
#ifndef SC_INVALID_EVENT_VALUE
#define SC_INVALID_EVENT_VALUE 0
#endif
/*! Define number of states in the state enum */
#define SC_PREFIX_STATE_COUNT 11

/*! Define dimension of the state configuration vector for orthogonal states. */
#define SC_PREFIX_MAX_ORTHOGONAL_STATES 3
/*! Define maximum number of time events that can be active at once */
#define SC_PREFIX_MAX_PARALLEL_TIME_EVENTS 2

/*! Define indices of states in the StateConfVector */
#define SCVI_SC_PREFIX_BUTTON_A_ST_BUTTON_UP 0
#define SCVI_SC_PREFIX_BUTTON_A_ST_BUTTON_FALLING 0
#define SCVI_SC_PREFIX_BUTTON_A_ST_BUTTON_DOWN 0
#define SCVI_SC_PREFIX_BUTTON_A_ST_BUTTON_RISING 0
#define SCVI_SC_PREFIX_SYSTEM_ST_SYSTEM_IDLE 1
#define SCVI_SC_PREFIX_SYSTEM_ST_SYSTEM_ACTIVE 1
#define SCVI_SC_PREFIX_LED_A_ST_LED_OFF 2
#define SCVI_SC_PREFIX_LED_A_ST_LED_ON 2
#define SCVI_SC_PREFIX_LED_A_ST_LED_BLINK 2
#define SCVI_SC_PREFIX_LED_A_ST_LED_BLINK_R1_ST_LED_ON 2
#define SCVI_SC_PREFIX_LED_A_ST_LED_BLINK_R1_ST_LED_OFF 2


/* 
 * Enum of event names in the statechart.
 */
typedef enum  {
	Sc_prefix_invalid_event = SC_INVALID_EVENT_VALUE,
	Sc_prefix_internal_ev_button_a_down,
	Sc_prefix_internal_ev_button_a_up,
	Sc_prefix_internal_ev_led_a_blink,
	Sc_prefix_internal_ev_led_a_on,
	Sc_prefix_internal_ev_led_a_off,
	Sc_prefix_sc_prefix_Button_A_ST_BUTTON_UP_time_event_0,
	Sc_prefix_sc_prefix_Button_A_ST_BUTTON_FALLING_time_event_0,
	Sc_prefix_sc_prefix_Button_A_ST_BUTTON_DOWN_time_event_0,
	Sc_prefix_sc_prefix_Button_A_ST_BUTTON_RISING_time_event_0,
	Sc_prefix_sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_ON_time_event_0,
	Sc_prefix_sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_OFF_time_event_0
} Sc_prefixEventID;

/*
 * Struct that represents a single event.
 */
typedef struct {
	Sc_prefixEventID name;
} sc_prefix_event;

/*
 * Queue that holds the raised events.
 */
typedef struct sc_prefix_eventqueue_s {
	sc_prefix_event *events;
	sc_integer capacity;
	sc_integer pop_index;
	sc_integer push_index;
	sc_integer size;
} sc_prefix_eventqueue;

/*! Enumeration of all states */ 
typedef enum
{
	Sc_prefix_last_state,
	Sc_prefix_Button_A_ST_BUTTON_UP,
	Sc_prefix_Button_A_ST_BUTTON_FALLING,
	Sc_prefix_Button_A_ST_BUTTON_DOWN,
	Sc_prefix_Button_A_ST_BUTTON_RISING,
	Sc_prefix_System_ST_SYSTEM_IDLE,
	Sc_prefix_System_ST_SYSTEM_ACTIVE,
	Sc_prefix_Led_A_ST_LED_OFF,
	Sc_prefix_Led_A_ST_LED_ON,
	Sc_prefix_Led_A_ST_LED_BLINK,
	Sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_ON,
	Sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_OFF
} Sc_prefixStates;





/* Declaration of constants for scope Sc_prefixIface. */
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_BTN_A;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_BTN_B;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_BTN_C;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_BTN_UP;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_LED_A;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_LED_B;
extern const uint32_t SC_PREFIX_SC_PREFIXIFACE_LED_C;


/*! Type declaration of the data structure for the Sc_prefixInternal interface scope. */
struct Sc_prefixInternal
{
	uint32_t vi_button;
	sc_boolean ev_button_a_down_raised;
	sc_boolean ev_button_a_up_raised;
	uint32_t vi_system;
	sc_boolean ev_led_a_blink_raised;
	sc_boolean ev_led_a_on_raised;
	sc_boolean ev_led_a_off_raised;
};



/*! Type declaration of the data structure for the Sc_prefixTimeEvents interface scope. */
struct Sc_prefixTimeEvents
{
	sc_boolean sc_prefix_Button_A_ST_BUTTON_UP_tev0_raised;
	sc_boolean sc_prefix_Button_A_ST_BUTTON_FALLING_tev0_raised;
	sc_boolean sc_prefix_Button_A_ST_BUTTON_DOWN_tev0_raised;
	sc_boolean sc_prefix_Button_A_ST_BUTTON_RISING_tev0_raised;
	sc_boolean sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_ON_tev0_raised;
	sc_boolean sc_prefix_Led_A_ST_LED_BLINK_r1_ST_LED_OFF_tev0_raised;
};






/*! 
 * Type declaration of the data structure for the Sc_prefix state machine.
 * This data structure has to be allocated by the client code. 
 */
struct Sc_prefix
{
	Sc_prefixStates stateConfVector[SC_PREFIX_MAX_ORTHOGONAL_STATES];
	Sc_prefixInternal internal;
	Sc_prefixTimeEvents timeEvents;
	sc_boolean isExecuting;
	sc_integer stateConfVectorPosition;
	sc_prefix_eventqueue internal_event_queue;
	sc_prefix_event internal_buffer[SC_PREFIX_INTERNAL_EVENTQUEUE_BUFFERSIZE];
	sc_prefix_eventqueue in_event_queue;
	sc_prefix_event in_buffer[SC_PREFIX_IN_EVENTQUEUE_BUFFERSIZE];
};



/*! Initializes the Sc_prefix state machine data structures. Must be called before first usage.*/
extern void sc_prefix_init(Sc_prefix* handle);


/*! Activates the state machine. */
extern void sc_prefix_enter(Sc_prefix* handle);

/*! Deactivates the state machine. */
extern void sc_prefix_exit(Sc_prefix* handle);

/*! 
Can be used by the client code to trigger a run to completion step without raising an event.
*/
extern void sc_prefix_trigger_without_event(Sc_prefix* handle);


/*! Raises a time event. */
extern void sc_prefix_raise_time_event(Sc_prefix* handle, sc_eventid evid);

/*! Gets the value of the variable 'BTN_A' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_bTN_A(const Sc_prefix* handle);
/*! Gets the value of the variable 'BTN_B' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_bTN_B(const Sc_prefix* handle);
/*! Gets the value of the variable 'BTN_C' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_bTN_C(const Sc_prefix* handle);
/*! Gets the value of the variable 'BTN_UP' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_bTN_UP(const Sc_prefix* handle);
/*! Gets the value of the variable 'LED_A' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_lED_A(const Sc_prefix* handle);
/*! Gets the value of the variable 'LED_B' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_lED_B(const Sc_prefix* handle);
/*! Gets the value of the variable 'LED_C' that is defined in the default interface scope. */ 
extern uint32_t sc_prefix_get_lED_C(const Sc_prefix* handle);

/*!
 * Checks whether the state machine is active (until 2.4.1 this method was used for states).
 * A state machine is active if it was entered. It is inactive if it has not been entered at all or if it has been exited.
 */
extern sc_boolean sc_prefix_is_active(const Sc_prefix* handle);

/*!
 * Checks if all active states are final. 
 * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
 */
extern sc_boolean sc_prefix_is_final(const Sc_prefix* handle);

/*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
extern sc_boolean sc_prefix_is_state_active(const Sc_prefix* handle, Sc_prefixStates state);


#ifdef __cplusplus
}
#endif 

#endif /* SC_PREFIX_H_ */
