00001
00009 #ifndef _NODEDEF_
00010 #define _NODEDEF_
00011
00012
00013 #include <stdio.h>
00014 #include <math.h>
00015 #include <BITE.h>
00016
00017
00018 #define NB_EMISSIONS 8//16
00019 #define NB_REEMISSIONS 16
00020 #define IT_IS_A_BASE 1
00021
00022
00023 #define MAX_ENVOIS 3
00024 #define DISTANCE_MAX 100 //nodes in a perimeter^2 which messages are accepted
00025 #define DISTANCE_MAX2 100 //to choose the ones that are kept in the neighborhood table
00026
00027
00028 #ifdef VOISINAGE_FIXE
00029 #ifdef NOEUD
00030 #define NB_VOISINS NB_NOEUDS_FIXE-1
00031 #elif AVION
00032 #define NB_VOISINS NB_NOEUDS_FIXE
00033 #else
00034 #define NB_VOISINS NB_NOEUDS_FIXE-1
00035 #endif
00036 #else
00037 #define NB_VOISINS 8
00038 #endif
00039
00040
00041 #define DISTANCE_RADIO(x, y) ((long)(((signed int)x - (signed int)Id_x)*((signed int)x - (signed int)Id_x) + ((signed int)y - (signed int)Id_y)*((signed int)y - (signed int)Id_y)) <= DISTANCE_MAX)
00042
00043
00044
00045
00046 typedef struct
00047 {
00048 unsigned char id_x ;
00049 unsigned char id_y ;
00050 int energie;
00051 int info_noeud;
00052 char ack_REQvois ;
00053 } voisin ;
00054
00055 typedef struct
00056 {
00057 unsigned int id_x ;
00058 unsigned int id_y ;
00059 unsigned int NumTrame;
00060 } reemission ;
00061
00062 typedef struct
00063 {
00064 unsigned int id_x : 8;
00065 unsigned int id_y : 8;
00066 unsigned int num_frame : 8;
00067 unsigned int nb_envois : 8;
00068
00069 } voisin2;
00070
00071 typedef struct
00072 {
00073 unsigned int x, y ;
00074 } noeud ;
00075
00076
00077 typedef struct
00078 {
00079 int id_noeud;
00080 noeud coord;
00081 int id_capteur;
00082 unsigned int temperature;
00083 int energie;
00084 int flagMAJ;
00085 unsigned int inertie;
00086 int flagMAJInertie;
00087 int info_noeud;
00088 } t_node_info;
00089
00090 typedef struct
00091 {
00092 unsigned char id_x ;
00093 unsigned char id_y ;
00094 unsigned int coherence_temporelle ;
00095 unsigned int numero_cible ;
00096 int distance ;
00097 } distances_capteur ;
00098
00099
00100
00101
00102 extern const UINT16 Id_x ;
00103 extern const UINT16 Id_y ;
00104
00105 extern unsigned int noReemission;
00106 extern voisin Tab_voisinage [NB_VOISINS] ;
00107 extern voisin *Ptr_voisinage ;
00108 extern voisin2 Tab_emissions[NB_EMISSIONS];
00109 extern voisin2 *Ptr_nb_emissions;
00110
00111 extern reemission Tab_reemission [NB_REEMISSIONS] ;
00112 extern reemission *Ptr_reemission_lit;
00113 extern reemission *Ptr_reemission_ecrit;
00114
00115
00116
00117
00118
00119 extern unsigned int ED2 ;
00120
00121
00122
00123
00124 extern UINT16 Nb_top ;
00125
00126
00127 extern unsigned int Numero_ack ;
00128
00129 #ifdef VOISINAGE_FIXE
00130 #ifdef NOEUD
00131 #define NB_VOISINS NB_NOEUDS_FIXE-1
00132 #elif AVION
00133 #define NB_VOISINS NB_NOEUDS_FIXE
00134 #else
00135 #define NB_VOISINS NB_NOEUDS_FIXE-1
00136 #endif
00137 #else
00138 #define NB_VOISINS 8
00139 #endif
00140
00141
00142
00143
00144
00145
00146 #define DISTANCE(x, y) (long)(((signed int)x - (signed int)Id_x)*((signed int)x - (signed int)Id_x) + ((signed int)y - (signed int)Id_y)*((signed int)y - (signed int)Id_y))
00147 #define TAB_VOIS_PAS_PLEINE() (Ptr_voisinage < Tab_voisinage + NB_VOISINS)
00148 #define TAB_EMISSION_PAS_PLEINE() (Ptr_nb_emissions <Tab_emissions + NB_EMISSIONS)
00149 #define TAB_EMISSION_OVERFLOW() ((Ptr_nb_emissions >Tab_emissions + NB_EMISSIONS)||(ptr_nb_emissions_cour>Tab_emissions + NB_EMISSIONS))//a revoir
00150 #define TAB_BASE_PAS_PLEINE()(Ptr_bases<Tab_bases+NB_BASES)
00151
00152
00153
00154
00155
00156
00157
00158
00159 voisin* RechercheMoinsBonVois(unsigned int mon_x, unsigned int mon_y);
00160
00161
00162 #ifdef VOISINAGE_FIXE
00163 #define NB_NOEUDS NB_NOEUDS_FIXE
00164 #else
00165 #define NB_NOEUDS 10
00166 #endif
00167 #define NB_DISTANCES 8
00168 #if defined(BASE)
00169
00170
00171
00172
00173
00174
00175 extern t_node_info Tab_noeuds[NB_NOEUDS];
00176 extern t_node_info *Ptr_noeuds;
00177
00178
00179
00180 extern distances_capteur Tab_distances [NB_DISTANCES] ;
00181 extern distances_capteur* Ptr_distances ;
00182
00183 #elif defined(NOEUD)
00184 #define NB_BASES 1
00185 extern noeud Tab_bases [NB_BASES] ;
00186 extern noeud *Ptr_bases ;
00187
00188 #endif
00189 #endif