include/states.h
changeset 528 0a30e161d63c
parent 381 854c43cdc24a
child 529 c171e11707c5
equal deleted inserted replaced
527:7d5c74cc8f91 528:0a30e161d63c
    18 You should have received a copy of the GNU Lesser General Public
    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
    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
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    21 */
    21 */
    22 
    22 
       
    23 /** @defgroup statemachine State Machine
       
    24  *  @ingroup userapi
       
    25  */
       
    26  
    23 #ifndef __states_h__
    27 #ifndef __states_h__
    24 #define __states_h__
    28 #define __states_h__
    25 
    29 
    26 #include <applicfg.h>
    30 #include <applicfg.h>
    27 
    31 
    54 	INTEGER8 csHeartbeat;
    58 	INTEGER8 csHeartbeat;
    55 	INTEGER8 csPDO;
    59 	INTEGER8 csPDO;
    56 	INTEGER8 csLSS;
    60 	INTEGER8 csLSS;
    57 } s_state_communication;
    61 } s_state_communication;
    58 
    62 
    59 /** Function that user app can overload
    63 /** 
       
    64  * @brief Function that user app can overload
    60  * 
    65  * 
    61  */
    66  */
    62 typedef void (*initialisation_t)(CO_Data*);
    67 typedef void (*initialisation_t)(CO_Data*);
    63 typedef void (*preOperational_t)(CO_Data*);
    68 typedef void (*preOperational_t)(CO_Data*);
    64 typedef void (*operational_t)(CO_Data*);
    69 typedef void (*operational_t)(CO_Data*);
    65 typedef void (*stopped_t)(CO_Data*);
    70 typedef void (*stopped_t)(CO_Data*);
    66 
    71 
    67 void _initialisation(CO_Data*);
    72 /** 
    68 void _preOperational(CO_Data*);
    73  * @brief Function that user app can overload
    69 void _operational(CO_Data*);
    74  * @param *d Pointer on a CAN object data structure
    70 void _stopped(CO_Data*);
    75  */
       
    76 void _initialisation(CO_Data* d);
       
    77 
       
    78 /** 
       
    79  * @brief Function that user app can overload
       
    80  * @param *d Pointer on a CAN object data structure
       
    81  */
       
    82 void _preOperational(CO_Data* d);
       
    83 
       
    84 /** 
       
    85  * @brief Function that user app can overload
       
    86  * @param *d Pointer on a CAN object data structure
       
    87  */
       
    88 void _operational(CO_Data* d);
       
    89 
       
    90 /** 
       
    91  * @brief Function that user app can overload
       
    92  * @param *d Pointer on a CAN object data structure
       
    93  */
       
    94 void _stopped(CO_Data* d);
    71 
    95 
    72 #include "data.h"
    96 #include "data.h"
    73 
    97 
    74 /************************* prototypes ******************************/
    98 /************************* prototypes ******************************/
    75 
    99 
    76 /** Called by driver/app when receiving messages
   100 /** 
    77 */
   101  * @brief Called by driver/app when receiving messages
       
   102  * @param *d Pointer on a CAN object data structure
       
   103  * @param *m Pointer on a CAN message structure
       
   104  */
    78 void canDispatch(CO_Data* d, Message *m);
   105 void canDispatch(CO_Data* d, Message *m);
    79 
   106 
    80 /** Returns the state of the node 
   107 /** 
    81 */
   108  * @ingroup statemachine
       
   109  * @brief Returns the state of the node
       
   110  * @param *d Pointer on a CAN object data structure
       
   111  * @return The node state
       
   112  */
    82 e_nodeState getState (CO_Data* d);
   113 e_nodeState getState (CO_Data* d);
    83 
   114 
    84 /** Change the state of the node 
   115 /** 
    85 */
   116  * @ingroup statemachine
       
   117  * @brief Change the state of the node 
       
   118  * @param *d Pointer on a CAN object data structure
       
   119  * @param newState The state to assign
       
   120  * @return 
       
   121  */
    86 UNS8 setState (CO_Data* d, e_nodeState newState);
   122 UNS8 setState (CO_Data* d, e_nodeState newState);
    87 
   123 
    88 /** Returns the nodId 
   124 /**
    89 */
   125  * @ingroup statemachine 
       
   126  * @brief Returns the nodId 
       
   127  * @param *d Pointer on a CAN object data structure
       
   128  * @return
       
   129  */
    90 UNS8 getNodeId (CO_Data* d);
   130 UNS8 getNodeId (CO_Data* d);
    91 
   131 
    92 /** Define the node ID. Initialize the object dictionary
   132 /** 
    93 */
   133  * @ingroup statemachine
       
   134  * @brief Define the node ID. Initialize the object dictionary
       
   135  * @param *d Pointer on a CAN object data structure
       
   136  * @param nodeId The node ID to assign
       
   137  */
    94 void setNodeId (CO_Data* d, UNS8 nodeId);
   138 void setNodeId (CO_Data* d, UNS8 nodeId);
    95 
   139 
    96 /** Some stuff to do when the node enter in reset mode
   140 /** 
    97  *
   141  * @brief Some stuff to do when the node enter in pre-operational mode
    98  */
   142  * @param *d Pointer on a CAN object data structure
    99 /* void initResetMode (CO_Data* d); */
       
   100 
       
   101 
       
   102 /** Some stuff to do when the node enter in pre-operational mode
       
   103  *
       
   104  */
   143  */
   105 void initPreOperationalMode (CO_Data* d);
   144 void initPreOperationalMode (CO_Data* d);
   106 
   145 
   107 #endif
   146 #endif