COSA
An Object-Oriented Platform for Arduino Programming
Event Class Reference

#include <Event.hh>

Collaboration diagram for Event:
Collaboration graph

Classes

class  Handler
 

Public Types

enum  {
  NULL_TYPE = 0, FALLING_TYPE, RISING_TYPE, CHANGE_TYPE,
  SAMPLE_REQUEST_TYPE, SAMPLE_COMPLETED_TYPE, WATCHDOG_TYPE, TIMEOUT_TYPE,
  BEGIN_TYPE, END_TYPE, RUN_TYPE, CONNECT_TYPE,
  DISCONNECT_TYPE, RECEIVE_REQUEST_TYPE, RECEIVE_COMPLETED_TYPE, SEND_REQUEST_TYPE,
  SEND_COMPLETED_TYPE, OPEN_TYPE, CLOSE_TYPE, READ_REQUEST_TYPE,
  READ_COMPLETED_TYPE, WRITE_REQUEST_TYPE, WRITE_COMPLETED_TYPE, COMMAND_REQUEST_TYPE,
  COMMAND_COMPLETED_TYPE, SERVICE_REQUEST_TYPE, SERVICE_RESPONSE_TYPE, USER_TYPE = 64,
  ERROR_TYPE = 255
}
 

Public Member Functions

 Event (int8_t type=NULL_TYPE, Handler *target=NULL, uint16_t value=0)
 
uint8_t type () const
 
Handlertarget () const
 
uint16_t value () const
 
void * env () const
 
void dispatch ()
 

Static Public Member Functions

static bool push (uint8_t type, Handler *target, uint16_t value=0)
 
static bool push (uint8_t type, Handler *target, void *env)
 
static bool service (uint32_t ms=0L)
 

Static Public Attributes

static const uint8_t QUEUE_MAX = COSA_EVENT_QUEUE_MAX
 
static Queue< Event, QUEUE_MAXqueue
 

Detailed Description

Event data structure with type, source and value.

Definition at line 39 of file Event.hh.

Member Enumeration Documentation

anonymous enum

Event types are added here. Typical mapping from interrupts to events. Note that the event is not a global numbering scheme. Instead depends on the receiving/sending party, the protocol.

Enumerator
NULL_TYPE 
FALLING_TYPE 
RISING_TYPE 
CHANGE_TYPE 
SAMPLE_REQUEST_TYPE 
SAMPLE_COMPLETED_TYPE 
WATCHDOG_TYPE 
TIMEOUT_TYPE 
BEGIN_TYPE 
END_TYPE 
RUN_TYPE 
CONNECT_TYPE 
DISCONNECT_TYPE 
RECEIVE_REQUEST_TYPE 
RECEIVE_COMPLETED_TYPE 
SEND_REQUEST_TYPE 
SEND_COMPLETED_TYPE 
OPEN_TYPE 
CLOSE_TYPE 
READ_REQUEST_TYPE 
READ_COMPLETED_TYPE 
WRITE_REQUEST_TYPE 
WRITE_COMPLETED_TYPE 
COMMAND_REQUEST_TYPE 
COMMAND_COMPLETED_TYPE 
SERVICE_REQUEST_TYPE 
SERVICE_RESPONSE_TYPE 
USER_TYPE 
ERROR_TYPE 

Definition at line 53 of file Event.hh.

Constructor & Destructor Documentation

Event::Event ( int8_t  type = NULL_TYPE,
Handler target = NULL,
uint16_t  value = 0 
)
inline

Construct event with given type, target and value.

Parameters
[in]typeevent identity (default NULL_TYPE(0)).
[in]targetevent receiver (default NULL(0)).
[in]valueevent value (default zero(0)).

Definition at line 121 of file Event.hh.

Member Function Documentation

void Event::dispatch ( )
inline

Dispatch event handler for target object.

Definition at line 166 of file Event.hh.

void* Event::env ( ) const
inline

Return event environment pointer.

Returns
pointer.

Definition at line 158 of file Event.hh.

static bool Event::push ( uint8_t  type,
Handler target,
uint16_t  value = 0 
)
inlinestatic

Push an event with given type, source and value into the event queue. Return true(1) if successful otherwise false(0).

Parameters
[in]typeevent identity.
[in]targetevent target.
[in]valueevent value.
Returns
bool.

Definition at line 180 of file Event.hh.

static bool Event::push ( uint8_t  type,
Handler target,
void *  env 
)
inlinestatic

Push an event with given type, source and value into the event queue. Return true(1) if successful otherwise false(0).

Parameters
[in]typeevent identity.
[in]targetevent target.
[in]envevent environment pointer.
Returns
bool.

Definition at line 195 of file Event.hh.

bool Event::service ( uint32_t  ms = 0L)
static

Service events and wait at most given number of milliseconds. The value zero(0) indicates that call should block until an event.

Parameters
[in]msmaximum wait time (Default blocking).
Returns
true(1) if an event was dispatched otherwise false(0).

Definition at line 27 of file Event.cpp.

Handler* Event::target ( ) const
inline

Return event target.

Returns
pointer.

Definition at line 140 of file Event.hh.

uint8_t Event::type ( ) const
inline

Return event type.

Returns
type.

Definition at line 131 of file Event.hh.

uint16_t Event::value ( ) const
inline

Return event value.

Returns
value.

Definition at line 149 of file Event.hh.

Member Data Documentation

Queue< Event, Event::QUEUE_MAX > Event::queue
static

Event queue of size QUEUE_MAX.

Definition at line 204 of file Event.hh.

const uint8_t Event::QUEUE_MAX = COSA_EVENT_QUEUE_MAX
static

Size of event queue. Adjust depending on application. Must be Power(2). Class Queue will statically check this.

Definition at line 45 of file Event.hh.


The documentation for this class was generated from the following files: