Revision 736
Major changes to wireless, but still more work to do.
sensor_matrix.h | ||
---|---|---|
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 |
* |
... | ... | |
57 | 60 |
typedef struct |
58 | 61 |
{ |
59 | 62 |
/** |
60 |
* The size of the sensor matrix.
|
|
61 |
**/ |
|
62 |
int size;
|
|
63 |
* The number of robots in the token ring.
|
|
64 |
**/
|
|
65 |
int numJoined;
|
|
63 | 66 |
/** |
64 | 67 |
* The matrix. Each row represents the readings of one |
65 | 68 |
* robot. |
66 | 69 |
**/ |
67 |
int** matrix;
|
|
70 |
unsigned char matrix[MAXIMUM_XBEE_ID][MAXIMUM_XBEE_ID];
|
|
68 | 71 |
/** |
69 | 72 |
* The element representing a robot is true if that robot |
70 | 73 |
* is in the token ring and false otherwise. |
71 | 74 |
**/ |
72 |
//TODO: if these values are just to be used to represent boolean values, why are they int? |
|
73 |
// They could be made char and the code should still be fine, and if you want to save more |
|
74 |
// memory, they could be made into bit vectors but that would increase the complexity of |
|
75 |
// the code to set and read from them. |
|
76 |
int* joined; |
|
77 |
/** |
|
78 |
* The number of robots in the token ring. |
|
79 |
**/ |
|
80 |
//TODO: int is probably > 2 bytes. Unless we are going to have more than 255 robots, |
|
81 |
// this could be made a char. It would only save 1 byte, but on embedded systems, every |
|
82 |
// byte counts |
|
83 |
int numJoined; |
|
75 |
unsigned char joined[MAXIMUM_XBEE_ID]; |
|
84 | 76 |
} SensorMatrix; |
85 | 77 |
|
86 | 78 |
/**@brief Create a sensor matrix **/ |
87 |
SensorMatrix* sensor_matrix_create(void); |
|
88 |
/**@brief Destroy a sensor matrix **/ |
|
89 |
void sensor_matrix_destroy(SensorMatrix* m); |
|
90 |
/**@brief Add a robot to a sensor matrix **/ |
|
91 |
void sensor_matrix_add_robot(SensorMatrix* m, int id); |
|
92 |
/**@brief Remove a robot from a sensor matrix **/ |
|
93 |
void sensor_matrix_remove_robot(SensorMatrix* m, int id); |
|
79 |
void sensor_matrix_create(void); |
|
94 | 80 |
/**@brief Set a reading in a sensor matrix **/ |
95 |
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); |
|
96 | 82 |
/**@brief Get a reading in a sensor matrix **/ |
97 |
int sensor_matrix_get_reading(SensorMatrix* m, int observer, int robot);
|
|
83 |
int sensor_matrix_get_reading(int observer, int robot); |
|
98 | 84 |
/**@brief Set whether the robot is in the token ring **/ |
99 |
void sensor_matrix_set_in_ring(SensorMatrix* m, int robot, int in);
|
|
85 |
void sensor_matrix_set_in_ring(int robot, int in); |
|
100 | 86 |
/**@brief Get whether the robot is in the sensor ring **/ |
101 |
int sensor_matrix_get_in_ring(SensorMatrix* m, int robot); |
|
102 |
/**@brief Get the size of the sensor matrix **/ |
|
103 |
int sensor_matrix_get_size(SensorMatrix* m); |
|
87 |
int sensor_matrix_get_in_ring(int robot); |
|
104 | 88 |
/**@brief Get the number of robots which have joined the token ring **/ |
105 |
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); |
|
106 | 92 |
|
107 | 93 |
/** @} **/ //end defgroup |
108 | 94 |
|
109 | 95 |
|
110 | 96 |
#endif |
97 |
|
Also available in: Unified diff