Prev: Preparing the application files
Next: Identifying and classifying states and pseudostates
The events in the
my state machine have been identified in the state diagram in Figure 1. Note that events consist really of two parts. The part of the event called the signal conveys the type of the occurrence (what happened). For example, the ONE signal conveys the arrival of a press key '1'. An event can also contain additional quantitative information about the occurrence in form of event parameters. In
my state machine, all signals are accompanied by the parameter (ts) that contain the quantitative information as to timestamp. In RKH, events are represented as instances of the RKH_EVT_T structure provided by the framework. Specifically, the RKH_EVT_T structure contains the member
e, to represent the signal of that event. Event parameters are added in the process of inheritance .
Because events are explicitly shared among most of the application components, it is convenient to declare them in the separate header file "my.h", which is shown below.
RKH supports the simple mechanism of direct event posting supported through the functions rkh_sma_post_fifo() and rkh_sma_post_lifo(), where the producer of an event directly posts the event to the event queue of the consumer active object (SMA). In RKH, any part of the system can produce events, not necessarily only the SMAs. For example, interrupt service routines (ISRs) or device drivers can also produce events. On the other hand, only SMAs can consume events, because only SMAs have event queues. The following listing provides examples of posting dynamic and static events from the interrupt service routines (ISRs) of the
ahsm demo application version for the win32 single thread, "bsp.c" file.
tsparameter of the event is assigned.