00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _MOTE_SENSIX_H_
00036 #define _MOTE_SENSIX_H_
00037
00038 #include "mote_types.h"
00039
00040
00041 #define SPATIAL_SERIES_TIMEOUT 10000
00042
00043 enum { ID_BYTE_LEN = 4, };
00044
00045
00046 typedef struct _functor {
00047 byte_t bits;
00048 enum {
00049 functor_used = 1,
00050 functor_pass_thru = 2,
00051 functor_running = 4,
00052 functor_hi_thresh = 8,
00053 functor_lo_thresh = 16,
00054 functor_peer_req = 32,
00055 functor_data_ready = 64,
00056 } F_BITS;
00057
00058 byte_t requestor[ID_BYTE_LEN];
00059 byte_t req_octet;
00060 byte_t priority;
00061
00062 byte_t f_type;
00063 byte_t f_id;
00064 uint_t f_e;
00065 uint_t f_t;
00066 int_t (*function)(struct _functor*);
00067 int_t (*function_done)(struct _functor*);
00068 struct _functor *collector;
00069 struct _functor *parent;
00070
00071 byte_t sensor;
00072 int_t threshold;
00073 int_t alt_threshold;
00074 uint_t rate;
00075 uint_t duration;
00076
00077 byte_t task_id;
00079
00080 uint_t size;
00081 struct _res {
00082 byte_t octet;
00083 byte_t id[ID_BYTE_LEN];
00084 int_t data;
00085 } results[MAX_RESULTS];
00086
00087 int_t result;
00088
00089 uint_t node_idx;
00090 } functor;
00091
00092 struct _state;
00093
00094
00095 struct _state *get_state(uint_t node);
00096 functor *get_functor(uint_t, uint_t);
00097 void start_discovery(uint_t);
00098 void discover_ancestors(uint_t);
00099 void discover_siblings(uint_t);
00100 int_t initialize(uint_t, uint_t);
00101 void add_capability(byte_t, uint_t);
00102
00103 int_t f_apply(functor*);
00104 int_t f_dataready(functor*);
00105 int_t f_cancel(functor*);
00106
00107 functor *allocate_functor(uint_t);
00108 void init_functor(functor*, uint_t);
00109 void free_functor(functor*);
00110
00111 int_t f_sense(functor*);
00112 int_t f_peak_sense(functor*);
00113
00114 int_t f_time_series(functor*);
00115 int_t f_spatial_series(functor*);
00116
00117 int_t f_recite(functor*);
00118 int_t f_sum(functor*);
00119 int_t f_delta(functor*);
00120 int_t f_mean(functor*);
00121 int_t f_sigma(functor*);
00122
00123 int_t f_lambda(functor*);
00124
00125
00126 uint_t energy_diff(uint_t, uint_t);
00127 uint_t time_diff(uint_t, uint_t);
00128
00129
00130 #endif // _MOTE_SENSIX_H_