]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - include/states.h
Commit a new cvs repo.
[CanFestival-3.git] / include / states.h
1 /*
2 This file is part of CanFestival, a library implementing CanOpen Stack. 
3
4 Copyright (C): Edouard TISSERANT and Francis DUPIN
5
6 See COPYING file for copyrights details.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23 #ifndef __states_h__
24 #define __states_h__
25
26 #include <applicfg.h>
27
28 ///The nodes states 
29 //-----------------
30 /// values are choosen so, that they can be sent directly
31 /// for heartbeat messages...
32 /// Must be coded on 7 bits only
33 /* Should not be modified */
34 enum enum_nodeState {
35   Initialisation  = 0x00, 
36   Disconnected    = 0x01,
37   Connecting      = 0x02,
38   Preparing       = 0x02,
39   Stopped         = 0x04,
40   Operational     = 0x05,
41   Pre_operational = 0x7F,
42   Unknown_state   = 0x0F
43 };
44
45 typedef enum enum_nodeState e_nodeState;
46
47 typedef struct
48 {
49         UNS8 csBoot_Up;
50         UNS8 csSDO;
51         UNS8 csEmergency;
52         UNS8 csSYNC;
53         UNS8 csHeartbeat;
54         UNS8 csPDO;
55 } s_state_communication;
56
57 /** Function that user app must provide
58  * 
59  */
60 typedef void (*initialisation_t)(void);
61 typedef void (*preOperational_t)(void);
62 typedef void (*operational_t)(void);
63 typedef void (*stopped_t)(void);
64
65 #include "data.h"
66
67 /************************* prototypes ******************************/
68
69 /** Called by driver/app when receiving messages
70 */
71 void canDispatch(CO_Data* d, Message *m);
72
73 /** Returns the state of the node 
74 */
75 e_nodeState getState (CO_Data* d);
76
77 /** Change the state of the node 
78 */
79 UNS8 setState (CO_Data* d, e_nodeState newState);
80
81 /** Returns the nodId 
82 */
83 UNS8 getNodeId (CO_Data* d);
84
85 /** Define the node ID. Initialize the object dictionary
86 */
87 void setNodeId (CO_Data* d, UNS8 nodeId);
88
89 /** Some stuff to do when the node enter in reset mode
90  *
91  */
92 //void initResetMode (CO_Data* d);
93
94
95 /** Some stuff to do when the node enter in pre-operational mode
96  *
97  */
98 void initPreOperationalMode (CO_Data* d);
99
100 #endif