Out-of-office display, GFX
Main Page
Modules
Classes
Files
Examples
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Groups
stateMachine
stateMachine.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2013 Andreas Misje
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
27
#ifndef STATEMACHINE_H
28
#define STATEMACHINE_H
29
30
#include <stddef.h>
31
#include <stdbool.h>
32
43
struct
event
44
{
46
int
type
;
54
void
*
data
;
55
};
56
57
struct
state
;
58
109
struct
transition
110
{
112
int
eventType
;
121
void
*
condition
;
135
bool ( *
guard
)(
void
*
condition
,
struct
event
*
event
);
144
void ( *
action
)(
struct
event
*
event
);
152
struct
state
*
nextState
;
153
};
154
232
struct
state
233
{
237
struct
state
*
parentState
;
242
struct
state
*
entryState
;
246
struct
transition
*
transitions
;
250
size_t
numTransitions
;
255
void
*
data
;
266
void ( *
entryAction
)(
void
*stateData,
struct
event
*
event
);
277
void ( *
exitAction
)(
void
*stateData,
struct
event
*
event
);
278
};
279
285
struct
stateMachine
286
{
288
struct
state
*
currentState
;
295
struct
state
*
previousState
;
300
struct
state
*
errorState
;
301
};
302
320
void
stateM_init
(
struct
stateMachine
*
stateMachine
,
321
struct
state
*initialState,
struct
state
*errorState );
322
326
enum
stateM_handleEventRetVals
327
{
329
stateM_errArg
= -2,
337
stateM_errorStateReached
,
339
stateM_stateChanged
,
341
stateM_stateLoopSelf
,
347
stateM_noStateChange
,
349
stateM_finalStateReached
,
350
};
351
365
int
stateM_handleEvent
(
struct
stateMachine
*
stateMachine
,
366
struct
event
*
event
);
367
376
struct
state
*
stateM_currentState
(
struct
stateMachine
*
stateMachine
);
377
387
struct
state
*
stateM_previousState
(
struct
stateMachine
*
stateMachine
);
388
398
bool
stateM_stopped
(
struct
stateMachine
*
stateMachine
);
399
400
#endif // STATEMACHINE_H
401
Generated on Mon Jul 8 2013 01:04:59 for Out-of-office display, GFX by
1.8.1.2