TRC Library for FTC (2011) 2011
TRC Library Code Project

C:/Users/Michael/Ftc/2011/code/trclib/sm.h File Reference

Go to the source code of this file.

Data Structures

struct  WAIT_EVT
struct  SM

Defines

#define _SM_H
#define MOD_ID   MOD_SM
#define SMF_READY   0x0100
#define SMF_TIMEOUT   0x0200
#define SMF_MASK   0x00ff
#define SMF_WAIT_ALL   0x0001
#define SMF_CLEAR_EVENTS   0x0002
#define SMSTATE_DISABLED   0
#define SMSTATE_STARTED   1
#define EVTTYPE_NONE   0
#define MAX_WAIT_EVENTS   4
#define IsSMDisabled(s)   (s.currState == SMSTATE_DISABLED)
#define IsSMEnabled(s)   (s.currState != SMSTATE_DISABLED)
#define IsSMTimedOut(s)   (s.smFlags & SMF_TIMEOUT)

Functions

void SMClearAllEvents (__out SM &sm)
void SMInit (__out SM &sm)
void SMStart (__out SM &sm)
void SMStop (__out SM &sm)
bool SMIsReady (__out SM &sm)
bool SMAddWaitEvent (__inout SM &sm, __in int evtType, __in int evtID, __in int evtData)
void SMWaitEvents (__inout SM &sm, __in int nextState, __in int timeout, __in int flags)
void SMSetEvent (__inout SM &sm, __in int evtType, __in int evtID, __in int evtData, __in int evtParam1, __in int evtParam2)

Define Documentation

#define _SM_H

Definition at line 16 of file sm.h.

#define EVTTYPE_NONE   0

Definition at line 37 of file sm.h.

#define IsSMDisabled (   s)    (s.currState == SMSTATE_DISABLED)

Definition at line 46 of file sm.h.

#define IsSMEnabled (   s)    (s.currState != SMSTATE_DISABLED)

Definition at line 47 of file sm.h.

#define IsSMTimedOut (   s)    (s.smFlags & SMF_TIMEOUT)

Definition at line 48 of file sm.h.

#define MAX_WAIT_EVENTS   4

Definition at line 40 of file sm.h.

#define MOD_ID   MOD_SM

Definition at line 23 of file sm.h.

#define SMF_CLEAR_EVENTS   0x0002

Definition at line 32 of file sm.h.

#define SMF_MASK   0x00ff

Definition at line 30 of file sm.h.

#define SMF_READY   0x0100

Definition at line 28 of file sm.h.

#define SMF_TIMEOUT   0x0200

Definition at line 29 of file sm.h.

#define SMF_WAIT_ALL   0x0001

Definition at line 31 of file sm.h.

#define SMSTATE_DISABLED   0

Definition at line 34 of file sm.h.

#define SMSTATE_STARTED   1

Definition at line 35 of file sm.h.


Function Documentation

bool SMAddWaitEvent ( __inout SM sm,
__in int  evtType,
__in int  evtID,
__in int  evtData 
)

This function adds a wait event to the state machine.

Parameters:
smPoints to the SM structure.
evtTypeSpecifies the event type to wait for.
evtIDSpecifies the event ID to wait for.
evtDataSpecifies the event data to wait for.
Returns:
Success: Returns true.
Failure: Returns false.

Definition at line 221 of file sm.h.

void SMClearAllEvents ( __out SM sm)

This function clears all wait events in the state machine.

Parameters:
smPoints to the SM structure.

Definition at line 80 of file sm.h.

void SMInit ( __out SM sm)

This function initializes the state machine.

Parameters:
smPoints to the SM structure to be initialized.

Definition at line 111 of file sm.h.

bool SMIsReady ( __out SM sm)

This function checks if the state machine is ready or timed out.

Parameters:
smPoints to the SM structure to be initialized.

Definition at line 181 of file sm.h.

void SMSetEvent ( __inout SM sm,
__in int  evtType,
__in int  evtID,
__in int  evtData,
__in int  evtParam1,
__in int  evtParam2 
)

This function is called when an event has occurred. It will determine if the state machine is waiting for the event and will advance the state machine to the next state if necessary.

Parameters:
smPoints to the SM structure.
evtTypeSpecifies the event type.
evtIDSpecifies the event ID.
evtDataSpecifies the event data.
evtParam1Specifies the event parameter 1.
evtParam2Specifies the event parameter 2.

Definition at line 307 of file sm.h.

void SMStart ( __out SM sm)

This function starts the state machine.

Parameters:
smPoints to the SM structure to be initialized.

Definition at line 135 of file sm.h.

void SMStop ( __out SM sm)

This function stops the state machine.

Parameters:
smPoints to the SM structure to be initialized.

Definition at line 161 of file sm.h.

void SMWaitEvents ( __inout SM sm,
__in int  nextState,
__in int  timeout,
__in int  flags 
)

This function sets the wait event mode and the next state to advance to when the wait is fulfilled.

Parameters:
smPoints to the SM structure.
nextStateSpecifies the next state to advance to.
timeoutSpecifies the timeout value in msec for the wait. If 0, it will wait indefinitely for the events.
flagsSpecifies the SMF flags.

Definition at line 262 of file sm.h.

 All Data Structures Files Functions Variables Defines