22 #include "event-driven/vtsHelper.h" 31 #define IS_SKIN(x) x&0x01000000 32 #define IS_SAMPLE(x) x&0x00804000 33 #define IS_SSA(x) x&0x00004000 34 #define IS_SSV(x) x&0x00800000 35 #define IS_IMUSAMPLE(x) x&0x02000000 36 #define IS_AUDIO(x) x&0x04000000 42 template<
typename V = vEvent>
using event = std::shared_ptr<V>;
44 template<
typename V1,
typename V2>
inline event<V1> as_event(event<V2> orig_event) {
45 return std::dynamic_pointer_cast<V1>(orig_event);
48 template<
typename V1,
typename V2>
inline event<V1> is_event(event<V2> orig_event) {
49 return std::static_pointer_cast<V1>(orig_event);
52 template<
typename V> event<V>
inline make_event(
void) {
53 return std::make_shared<V>();
57 template<
typename V>
inline V* read_as(
const event<> &orig_event) {
58 return (V *)orig_event.get();
62 template<
typename V1,
typename V2> event<V1> make_event(event<V2> orig_event) {
63 return std::make_shared<V1>(*(orig_event.get()));
66 using vQueue = std::deque< event<vEvent> >;
69 void qsort(vQueue &q,
bool respectWraps =
false);
72 event<> createEvent(
const std::string &type);
75 unsigned int packetSize(
const std::string &type);
78 enum { VLEFT = 0, VRIGHT = 1 } ;
85 static const std::string tag;
86 unsigned int stamp:31;
91 virtual event<> clone();
92 virtual void encode(yarp::os::Bottle &b)
const;
93 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
94 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
95 virtual void decode(
const int32_t *&data);
96 virtual yarp::os::Property getContent()
const;
97 virtual std::string getType()
const;
98 virtual int getChannel()
const;
99 virtual void setChannel();
106 static const std::string tag;
110 uint32_t _coded_data;
112 unsigned int polarity:1;
114 unsigned int _xfill:2;
116 unsigned int _yfill:2;
117 unsigned int channel:1;
120 unsigned int _fill:7;
128 virtual event<> clone();
129 virtual void encode(yarp::os::Bottle &b)
const;
130 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
131 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
132 virtual void decode(
const int32_t *&data);
133 virtual yarp::os::Property getContent()
const;
134 virtual std::string getType()
const;
135 virtual int getChannel()
const;
136 virtual void setChannel(
const int channel);
144 static const std::string tag;
150 unsigned int polarity:1;
151 unsigned int taxel:10;
152 unsigned int _reserved1:2;
153 unsigned int cross_base:1;
154 unsigned int _sample:1;
155 unsigned int _error:1;
156 unsigned int body_part:3;
157 unsigned int _reserved2:3;
168 virtual event<> clone();
169 virtual void encode(yarp::os::Bottle &b)
const;
170 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
171 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
172 virtual void decode(
const int32_t *&data);
173 virtual yarp::os::Property getContent()
const;
174 virtual std::string getType()
const;
182 static const std::string tag;
185 unsigned int value:16;
191 virtual event<> clone();
192 virtual void encode(yarp::os::Bottle &b)
const;
193 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
194 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
195 virtual void decode(
const int32_t *&data);
196 virtual yarp::os::Property getContent()
const;
197 virtual std::string getType()
const;
205 static const std::string tag;
219 virtual event<> clone();
220 virtual void encode(yarp::os::Bottle &b)
const;
221 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
222 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
223 virtual void decode(
const int32_t *&data);
224 virtual yarp::os::Property getContent()
const;
225 virtual std::string getType()
const;
227 int getDeath()
const;
234 static const std::string tag;
241 virtual event<> clone();
242 virtual void encode(yarp::os::Bottle &b)
const;
243 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
244 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
245 virtual void decode(
const int32_t *&data);
246 virtual yarp::os::Property getContent()
const;
247 virtual std::string getType()
const;
254 static const std::string tag;
268 virtual event<> clone();
269 virtual void encode(yarp::os::Bottle &b)
const;
270 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
271 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
272 virtual void decode(
const int32_t *&data);
273 virtual yarp::os::Property getContent()
const;
274 virtual std::string getType()
const;
281 static const std::string tag;
285 uint32_t _coded_data;
288 unsigned int sensor:4;
290 unsigned int channel:1;
296 const static unsigned int _max_value = 32768;
302 virtual event<> clone();
303 virtual void encode(yarp::os::Bottle &b)
const;
304 virtual void encode(std::vector<int32_t> &b,
unsigned int &pos)
const;
305 virtual bool decode(
const yarp::os::Bottle &packet,
size_t &pos);
306 virtual void decode(
const int32_t *&data);
307 virtual yarp::os::Property getContent()
const;
308 virtual std::string getType()
const;
309 virtual int getChannel()
const {
return channel;}
310 virtual void setChannel(
const int channel) { this->channel = channel;}
314 template <
class T>
size_t countEvents(
const T &q) {
return q.size(); }
318 template <
typename T>
inline int countTime(
const T &q,
int &p_time)
320 if(!p_time) p_time = q.front().stamp;
321 int dt = q.back().stamp - q.front().stamp;
322 p_time = q.back().stamp;
327 template <>
inline int countTime<vQueue> (
const vQueue &q,
int &p_time)
329 if(!p_time) p_time = q.front()->stamp;
330 int dt = q.back()->stamp - q.front()->stamp;
331 p_time = q.back()->stamp;
336 template <>
inline int countTime< std::vector<int32_t> > (
const std::vector<int32_t> &q,
int &p_time)
an AddressEvent with a velocity in visual space
Definition: vCodec.h:202
an event with a pixel location, camera number and polarity
Definition: vCodec.h:103
static unsigned int max_stamp
the maximum value of the timestamp before a wrap occurs
Definition: vtsHelper.h:39
an event with a taxel location, body-part and polarity
Definition: vCodec.h:179
base event class which defines the time the event occurs
Definition: vCodec.h:82
an AddressEvent with an ID or class label
Definition: vCodec.h:231
an event with a taxel location, body-part and polarity
Definition: vCodec.h:141
a LabelledAE with parameters that define a 2D gaussian
Definition: vCodec.h:251
an event with a pixel location, camera number and polarity
Definition: vCodec.h:278