Revision 743
Fixed compilation errors.
sensor_matrix.h | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (c) 2007 Colony Project |
3 |
*
|
|
3 |
* |
|
4 | 4 |
* Permission is hereby granted, free of charge, to any person |
5 | 5 |
* obtaining a copy of this software and associated documentation |
6 | 6 |
* files (the "Software"), to deal in the Software without |
... | ... | |
9 | 9 |
* copies of the Software, and to permit persons to whom the |
10 | 10 |
* Software is furnished to do so, subject to the following |
11 | 11 |
* conditions: |
12 |
*
|
|
12 |
* |
|
13 | 13 |
* The above copyright notice and this permission notice shall be |
14 | 14 |
* included in all copies or substantial portions of the Software. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
18 | 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
... | ... | |
46 | 46 |
* @{ |
47 | 47 |
**/ |
48 | 48 |
|
49 |
#define MAXIMUM_XBEE_ID 0x10 |
|
50 |
#define READING_UNKNOWN 0xFF |
|
51 |
|
|
49 | 52 |
/** |
50 | 53 |
* @struct SensorMatrix |
51 | 54 |
* |
52 | 55 |
* A sensor matrix. |
53 | 56 |
**/ |
57 |
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct |
|
58 |
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size. |
|
59 |
// Thus, pointers should be first, followed by int, followed by char. |
|
54 | 60 |
typedef struct |
55 | 61 |
{ |
56 | 62 |
/** |
57 |
* The size of the sensor matrix.
|
|
58 |
**/ |
|
59 |
int size;
|
|
63 |
* The number of robots in the token ring.
|
|
64 |
**/
|
|
65 |
int numJoined;
|
|
60 | 66 |
/** |
61 | 67 |
* The matrix. Each row represents the readings of one |
62 | 68 |
* robot. |
63 | 69 |
**/ |
64 |
int** matrix;
|
|
70 |
unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
|
|
65 | 71 |
/** |
66 | 72 |
* The element representing a robot is true if that robot |
67 | 73 |
* is in the token ring and false otherwise. |
68 | 74 |
**/ |
69 |
int* joined; |
|
70 |
/** |
|
71 |
* The number of robots in the token ring. |
|
72 |
**/ |
|
73 |
int numJoined; |
|
75 |
unsigned char joined[MAXIMUM_XBEE_ID]; |
|
74 | 76 |
} SensorMatrix; |
75 | 77 |
|
76 | 78 |
/**@brief Create a sensor matrix **/ |
77 |
SensorMatrix* sensor_matrix_create(void); |
|
78 |
/**@brief Destroy a sensor matrix **/ |
|
79 |
void sensor_matrix_destroy(SensorMatrix* m); |
|
80 |
/**@brief Add a robot to a sensor matrix **/ |
|
81 |
void sensor_matrix_add_robot(SensorMatrix* m, int id); |
|
82 |
/**@brief Remove a robot from a sensor matrix **/ |
|
83 |
void sensor_matrix_remove_robot(SensorMatrix* m, int id); |
|
79 |
void sensor_matrix_create(void); |
|
84 | 80 |
/**@brief Set a reading in a sensor matrix **/ |
85 |
void sensor_matrix_set_reading(SensorMatrix* m, int observer, int robot, int reading);
|
|
81 |
void sensor_matrix_set_reading(int observer, int robot, int reading); |
|
86 | 82 |
/**@brief Get a reading in a sensor matrix **/ |
87 |
int sensor_matrix_get_reading(SensorMatrix* m, int observer, int robot);
|
|
83 |
int sensor_matrix_get_reading(int observer, int robot); |
|
88 | 84 |
/**@brief Set whether the robot is in the token ring **/ |
89 |
void sensor_matrix_set_in_ring(SensorMatrix* m, int robot, int in);
|
|
85 |
void sensor_matrix_set_in_ring(int robot, int in); |
|
90 | 86 |
/**@brief Get whether the robot is in the sensor ring **/ |
91 |
int sensor_matrix_get_in_ring(SensorMatrix* m, int robot); |
|
92 |
/**@brief Get the size of the sensor matrix **/ |
|
93 |
int sensor_matrix_get_size(SensorMatrix* m); |
|
87 |
int sensor_matrix_get_in_ring(int robot); |
|
94 | 88 |
/**@brief Get the number of robots which have joined the token ring **/ |
95 |
int sensor_matrix_get_joined(SensorMatrix* m); |
|
89 |
int sensor_matrix_get_joined(void); |
|
90 |
/**@brief Get the maximum size of the sensor matrix **/ |
|
91 |
int sensor_matrix_get_size(void); |
|
96 | 92 |
|
97 | 93 |
/** @} **/ //end defgroup |
98 | 94 |
|
99 | 95 |
|
100 | 96 |
#endif |
97 |
|
Also available in: Unified diff