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