23 #ifndef __PLUGINS_PANTILT_SONY_VISCA_H_ 24 #define __PLUGINS_PANTILT_SONY_VISCA_H_ 26 #include <core/exception.h> 28 #ifdef TIMETRACKER_VISCA 29 # warning Visca time tracker enabled 30 # include <utils/timetracker.h> 68 static const unsigned int VISCA_ZOOM_VALUE_WIDE = 0x0000;
70 static const unsigned int VISCA_ZOOM_VALUE_1X = 0x0E6D;
72 static const unsigned int VISCA_ZOOM_VALUE_2X = 0x188E;
74 static const unsigned int VISCA_ZOOM_VALUE_3X = 0x2507;
76 static const unsigned int VISCA_ZOOM_VALUE_4X = 0x2B82;
78 static const unsigned int VISCA_ZOOM_VALUE_5X = 0x3130;
80 static const unsigned int VISCA_ZOOM_VALUE_6X = 0x352E;
82 static const unsigned int VISCA_ZOOM_VALUE_7X = 0x385D;
84 static const unsigned int VISCA_ZOOM_VALUE_8X = 0x3B48;
86 static const unsigned int VISCA_ZOOM_VALUE_9X = 0x3E01;
88 static const unsigned int VISCA_ZOOM_VALUE_10X = 0x4000;
90 static const unsigned int VISCA_ZOOM_VALUE_DIG_20X = 0x5000;
92 static const unsigned int VISCA_ZOOM_VALUE_DIG_30X = 0x6000;
94 static const unsigned int VISCA_ZOOM_VALUE_DIG_40X = 0x7000;
96 Visca(
const char *device_file,
unsigned int def_timeout_ms = 10,
97 bool blocking =
true);
108 void set_power(
bool powered);
113 void recv(
unsigned int timeout_ms = 0xFFFFFFFF);
114 void recv_ack(
unsigned int *socket = NULL);
115 void send_with_reply();
116 void send_nonblocking(
unsigned int *socket = NULL);
117 void cancel_command(
unsigned int socket);
118 bool data_available();
122 void reset_pan_tilt();
130 void start_get_pan_tilt();
131 void set_pan_tilt(
int pan,
int tilt);
132 void get_pan_tilt(
int &pan,
int &tilt);
133 void set_pan_tilt_limit(
int pan_left,
int pan_right,
int tilt_up,
int tilt_down);
134 void reset_pan_tilt_limit();
135 void set_pan_tilt_speed(
unsigned char pan_speed,
unsigned char tilt_speed);
136 void get_pan_tilt_speed(
unsigned char &pan_speed,
unsigned char &tilt_speed);
138 bool is_nonblocking_finished(
unsigned int item)
const;
142 void set_zoom(
unsigned int zoom);
143 void get_zoom(
unsigned int &zoom);
144 void set_zoom_speed_tele(
unsigned int speed);
145 void set_zoom_speed_wide(
unsigned int speed);
146 void set_zoom_digital_enabled(
bool enabled);
150 void apply_effect(
unsigned char effect);
151 void apply_effect_pastel();
152 void apply_effect_neg_art();
153 void apply_effect_sepia();
154 void apply_effect_bnw();
155 void apply_effect_solarize();
156 void apply_effect_mosaic();
157 void apply_effect_slim();
158 void apply_effect_stretch();
160 unsigned int get_white_balance_mode();
163 void set_mirror(
bool mirror);
167 static const unsigned int VISCA_RUNINQ_NONE = 0;
168 static const unsigned int VISCA_RUNINQ_PANTILT = 1;
171 static const unsigned char VISCA_BUS_0 = 0;
172 static const unsigned char VISCA_BUS_1 = 1;
173 static const unsigned char VISCA_BUS_2 = 2;
174 static const unsigned char VISCA_BUS_3 = 3;
175 static const unsigned char VISCA_BUS_4 = 4;
176 static const unsigned char VISCA_BUS_5 = 5;
177 static const unsigned char VISCA_BUS_6 = 6;
178 static const unsigned char VISCA_BUS_7 = 7;
179 static const unsigned char VISCA_BUS_BROADCAST = 8;
182 static const unsigned char VISCA_COMMAND = 0x01;
183 static const unsigned char VISCA_CANCEL = 0x20;
184 static const unsigned char VISCA_INQUIRY = 0x09;
185 static const unsigned char VISCA_TERMINATOR = 0xFF;
188 static const unsigned char VISCA_RESPONSE_CLEAR = 0x40;
189 static const unsigned char VISCA_RESPONSE_ADDRESS = 0x30;
190 static const unsigned char VISCA_RESPONSE_ACK = 0x40;
191 static const unsigned char VISCA_RESPONSE_COMPLETED = 0x50;
192 static const unsigned char VISCA_RESPONSE_ERROR = 0x60;
195 static const unsigned char VISCA_ERROR_LENGTH = 0x01;
196 static const unsigned char VISCA_ERROR_SYNTAX = 0x02;
197 static const unsigned char VISCA_ERROR_BUFFERFULL = 0x03;
198 static const unsigned char VISCA_ERROR_CANCELLED = 0x04;
199 static const unsigned char VISCA_ERROR_NOSOCKET = 0x05;
200 static const unsigned char VISCA_ERROR_NOTEXECABLE = 0x41;
204 static const unsigned char VISCA_CATEGORY_INTERFACE = 0x00;
205 static const unsigned char VISCA_CATEGORY_CAMERA1 = 0x04;
206 static const unsigned char VISCA_CATEGORY_PAN_TILTER = 0x06;
207 static const unsigned char VISCA_CATEGORY_CAMERA2 = 0x07;
209 static const unsigned char VISCA_POWER = 0x00;
210 static const unsigned char VISCA_POWER_ON = 0x02;
211 static const unsigned char VISCA_POWER_OFF = 0x03;
212 static const unsigned char VISCA_DEVICE_INFO = 0x02;
213 static const unsigned char VISCA_KEYLOCK = 0x17;
214 static const unsigned char VISCA_ID = 0x22;
215 static const unsigned char VISCA_ZOOM = 0x07;
216 static const unsigned char VISCA_ZOOM_STOP = 0x00;
217 static const unsigned char VISCA_ZOOM_TELE = 0x02;
218 static const unsigned char VISCA_ZOOM_WIDE = 0x03;
219 static const unsigned char VISCA_ZOOM_TELE_SPEED = 0x20;
220 static const unsigned char VISCA_ZOOM_WIDE_SPEED = 0x30;
221 static const unsigned char VISCA_ZOOM_VALUE = 0x47;
222 static const unsigned char VISCA_ZOOM_FOCUS_VALUE = 0x47;
223 static const unsigned char VISCA_DZOOM = 0x06;
224 static const unsigned char VISCA_DZOOM_ON = 0x02;
225 static const unsigned char VISCA_DZOOM_OFF = 0x03;
226 static const unsigned char VISCA_FOCUS = 0x08;
227 static const unsigned char VISCA_FOCUS_STOP = 0x00;
228 static const unsigned char VISCA_FOCUS_FAR = 0x02;
229 static const unsigned char VISCA_FOCUS_NEAR = 0x03;
230 static const unsigned char VISCA_FOCUS_FAR_SPEED = 0x20;
231 static const unsigned char VISCA_FOCUS_NEAR_SPEED = 0x30;
232 static const unsigned char VISCA_FOCUS_VALUE = 0x48;
233 static const unsigned char VISCA_FOCUS_AUTO = 0x38;
234 static const unsigned char VISCA_FOCUS_AUTO_MAN = 0x10;
235 static const unsigned char VISCA_FOCUS_ONE_PUSH = 0x18;
236 static const unsigned char VISCA_FOCUS_ONE_PUSH_TRIG = 0x01;
237 static const unsigned char VISCA_FOCUS_ONE_PUSH_INF = 0x02;
238 static const unsigned char VISCA_FOCUS_AUTO_SENSE = 0x58;
239 static const unsigned char VISCA_FOCUS_AUTO_SENSE_HIGH = 0x02;
240 static const unsigned char VISCA_FOCUS_AUTO_SENSE_LOW = 0x03;
241 static const unsigned char VISCA_FOCUS_NEAR_LIMIT = 0x28;
242 static const unsigned char VISCA_WB = 0x35;
243 static const unsigned char VISCA_WB_AUTO = 0x00;
244 static const unsigned char VISCA_WB_INDOOR = 0x01;
245 static const unsigned char VISCA_WB_OUTDOOR = 0x02;
246 static const unsigned char VISCA_WB_ONE_PUSH = 0x03;
247 static const unsigned char VISCA_WB_ATW = 0x04;
248 static const unsigned char VISCA_WB_MANUAL = 0x05;
249 static const unsigned char VISCA_WB_ONE_PUSH_TRIG = 0x05;
250 static const unsigned char VISCA_RGAIN = 0x03;
251 static const unsigned char VISCA_RGAIN_VALUE = 0x43;
252 static const unsigned char VISCA_BGAIN = 0x04;
253 static const unsigned char VISCA_BGAIN_VALUE = 0x44;
254 static const unsigned char VISCA_AUTO_EXP = 0x39;
255 static const unsigned char VISCA_AUTO_EXP_FULL_AUTO = 0x00;
256 static const unsigned char VISCA_AUTO_EXP_MANUAL = 0x03;
257 static const unsigned char VISCA_AUTO_EXP_SHUTTER_PRIORITY = 0x0A;
258 static const unsigned char VISCA_AUTO_EXP_IRIS_PRIORITY = 0x0B;
259 static const unsigned char VISCA_AUTO_EXP_GAIN_PRIORITY = 0x0C;
260 static const unsigned char VISCA_AUTO_EXP_BRIGHT = 0x0D;
261 static const unsigned char VISCA_AUTO_EXP_SHUTTER_AUTO = 0x1A;
262 static const unsigned char VISCA_AUTO_EXP_IRIS_AUTO = 0x1B;
263 static const unsigned char VISCA_AUTO_EXP_GAIN_AUTO = 0x1C;
264 static const unsigned char VISCA_SLOW_SHUTTER = 0x5A;
265 static const unsigned char VISCA_SLOW_SHUTTER_AUTO = 0x02;
266 static const unsigned char VISCA_SLOW_SHUTTER_MANUAL = 0x03;
267 static const unsigned char VISCA_SHUTTER = 0x0A;
268 static const unsigned char VISCA_SHUTTER_VALUE = 0x4A;
269 static const unsigned char VISCA_IRIS = 0x0B;
270 static const unsigned char VISCA_IRIS_VALUE = 0x4B;
271 static const unsigned char VISCA_GAIN = 0x0C;
272 static const unsigned char VISCA_GAIN_VALUE = 0x4C;
273 static const unsigned char VISCA_BRIGHT = 0x0D;
274 static const unsigned char VISCA_BRIGHT_VALUE = 0x4D;
275 static const unsigned char VISCA_EXP_COMP = 0x0E;
276 static const unsigned char VISCA_EXP_COMP_POWER = 0x3E;
277 static const unsigned char VISCA_EXP_COMP_VALUE = 0x4E;
278 static const unsigned char VISCA_BACKLIGHT_COMP = 0x33;
279 static const unsigned char VISCA_APERTURE = 0x02;
280 static const unsigned char VISCA_APERTURE_VALUE = 0x42;
281 static const unsigned char VISCA_ZERO_LUX = 0x01;
282 static const unsigned char VISCA_IR_LED = 0x31;
283 static const unsigned char VISCA_WIDE_MODE = 0x60;
284 static const unsigned char VISCA_WIDE_MODE_OFF = 0x00;
285 static const unsigned char VISCA_WIDE_MODE_CINEMA = 0x01;
286 static const unsigned char VISCA_WIDE_MODE_16_9 = 0x02;
287 static const unsigned char VISCA_MIRROR = 0x61;
288 static const unsigned char VISCA_MIRROR_ON = 0x02;
289 static const unsigned char VISCA_MIRROR_OFF = 0x03;
290 static const unsigned char VISCA_FREEZE = 0x62;
291 static const unsigned char VISCA_PICTURE_EFFECT = 0x63;
292 static const unsigned char VISCA_PICTURE_EFFECT_OFF = 0x00;
293 static const unsigned char VISCA_PICTURE_EFFECT_PASTEL = 0x01;
294 static const unsigned char VISCA_PICTURE_EFFECT_NEGATIVE = 0x02;
295 static const unsigned char VISCA_PICTURE_EFFECT_SEPIA = 0x03;
296 static const unsigned char VISCA_PICTURE_EFFECT_BW = 0x04;
297 static const unsigned char VISCA_PICTURE_EFFECT_SOLARIZE = 0x05;
298 static const unsigned char VISCA_PICTURE_EFFECT_MOSAIC = 0x06;
299 static const unsigned char VISCA_PICTURE_EFFECT_SLIM = 0x07;
300 static const unsigned char VISCA_PICTURE_EFFECT_STRETCH = 0x08;
301 static const unsigned char VISCA_DIGITAL_EFFECT = 0x64;
302 static const unsigned char VISCA_DIGITAL_EFFECT_OFF = 0x00;
303 static const unsigned char VISCA_DIGITAL_EFFECT_STILL = 0x01;
304 static const unsigned char VISCA_DIGITAL_EFFECT_FLASH = 0x02;
305 static const unsigned char VISCA_DIGITAL_EFFECT_LUMI = 0x03;
306 static const unsigned char VISCA_DIGITAL_EFFECT_TRAIL = 0x04;
307 static const unsigned char VISCA_DIGITAL_EFFECT_LEVEL = 0x65;
308 static const unsigned char VISCA_MEMORY = 0x3F;
309 static const unsigned char VISCA_MEMORY_RESET = 0x00;
310 static const unsigned char VISCA_MEMORY_SET = 0x01;
311 static const unsigned char VISCA_MEMORY_RECALL = 0x02;
312 static const unsigned char VISCA_DISPLAY = 0x15;
313 static const unsigned char VISCA_DISPLAY_TOGGLE = 0x10;
314 static const unsigned char VISCA_DATE_TIME_SET = 0x70;
315 static const unsigned char VISCA_DATE_DISPLAY = 0x71;
316 static const unsigned char VISCA_TIME_DISPLAY = 0x72;
317 static const unsigned char VISCA_TITLE_DISPLAY = 0x74;
318 static const unsigned char VISCA_TITLE_DISPLAY_CLEAR = 0x00;
319 static const unsigned char VISCA_TITLE_SET = 0x73;
320 static const unsigned char VISCA_TITLE_SET_PARAMS = 0x00;
321 static const unsigned char VISCA_TITLE_SET_PART1 = 0x01;
322 static const unsigned char VISCA_TITLE_SET_PART2 = 0x02;
323 static const unsigned char VISCA_IRRECEIVE = 0x08;
324 static const unsigned char VISCA_IRRECEIVE_ON = 0x02;
325 static const unsigned char VISCA_IRRECEIVE_OFF = 0x03;
326 static const unsigned char VISCA_IRRECEIVE_ONOFF = 0x10;
327 static const unsigned char VISCA_PT_DRIVE = 0x01;
328 static const unsigned char VISCA_PT_DRIVE_HORIZ_LEFT = 0x01;
329 static const unsigned char VISCA_PT_DRIVE_HORIZ_RIGHT = 0x02;
330 static const unsigned char VISCA_PT_DRIVE_HORIZ_STOP = 0x03;
331 static const unsigned char VISCA_PT_DRIVE_VERT_UP = 0x01;
332 static const unsigned char VISCA_PT_DRIVE_VERT_DOWN = 0x02;
333 static const unsigned char VISCA_PT_DRIVE_VERT_STOP = 0x03;
334 static const unsigned char VISCA_PT_ABSOLUTE_POSITION = 0x02;
335 static const unsigned char VISCA_PT_RELATIVE_POSITION = 0x03;
336 static const unsigned char VISCA_PT_HOME = 0x04;
337 static const unsigned char VISCA_PT_RESET = 0x05;
338 static const unsigned char VISCA_PT_LIMITSET = 0x07;
339 static const unsigned char VISCA_PT_LIMITSET_SET = 0x00;
340 static const unsigned char VISCA_PT_LIMITSET_CLEAR = 0x01;
341 static const unsigned char VISCA_PT_LIMITSET_SET_UR = 0x01;
342 static const unsigned char VISCA_PT_LIMITSET_SET_DL = 0x00;
343 static const unsigned char VISCA_PT_DATASCREEN = 0x06;
344 static const unsigned char VISCA_PT_DATASCREEN_ON = 0x02;
345 static const unsigned char VISCA_PT_DATASCREEN_OFF = 0x03;
346 static const unsigned char VISCA_PT_DATASCREEN_ONOFF = 0x10;
347 static const unsigned char VISCA_PT_VIDEOSYSTEM_INQ = 0x23;
348 static const unsigned char VISCA_PT_MODE_INQ = 0x10;
349 static const unsigned char VISCA_PT_MAXSPEED_INQ = 0x11;
350 static const unsigned char VISCA_PT_POSITION_INQ = 0x12;
351 static const unsigned char VISCA_PT_DATASCREEN_INQ = 0x06;
355 static const unsigned char VISCA_WIDE_CON_LENS = 0x26;
356 static const unsigned char VISCA_WIDE_CON_LENS_SET = 0x00;
358 static const unsigned char VISCA_AT_MODE = 0x01;
359 static const unsigned char VISCA_AT_ONOFF = 0x10;
360 static const unsigned char VISCA_AT_AE = 0x02;
361 static const unsigned char VISCA_AT_AUTOZOOM = 0x03;
362 static const unsigned char VISCA_ATMD_FRAMEDISPLAY = 0x04;
363 static const unsigned char VISCA_AT_FRAMEOFFSET = 0x05;
364 static const unsigned char VISCA_ATMD_STARTSTOP = 0x06;
365 static const unsigned char VISCA_AT_CHASE = 0x07;
366 static const unsigned char VISCA_AT_CHASE_NEXT = 0x10;
368 static const unsigned char VISCA_MD_MODE = 0x08;
369 static const unsigned char VISCA_MD_ONOFF = 0x10;
370 static const unsigned char VISCA_MD_FRAME = 0x09;
371 static const unsigned char VISCA_MD_DETECT = 0x0A;
373 static const unsigned char VISCA_MD_ADJUST = 0x00;
374 static const unsigned char VISCA_MD_ADJUST_YLEVEL = 0x0B;
375 static const unsigned char VISCA_MD_ADJUST_HUELEVEL = 0x0C;
376 static const unsigned char VISCA_MD_ADJUST_SIZE = 0x0D;
377 static const unsigned char VISCA_MD_ADJUST_DISPTIME = 0x0F;
378 static const unsigned char VISCA_MD_ADJUST_REFTIME = 0x0B;
379 static const unsigned char VISCA_MD_ADJUST_REFMODE = 0x10;
381 static const unsigned char VISCA_AT_ENTRY = 0x15;
382 static const unsigned char VISCA_AT_LOSTINFO = 0x20;
383 static const unsigned char VISCA_MD_LOSTINFO = 0x21;
384 static const unsigned char VISCA_ATMD_LOSTINFO1 = 0x20;
385 static const unsigned char VISCA_ATMD_LOSTINFO2 = 0x07;
387 static const unsigned char VISCA_MD_MEASURE_MODE_1 = 0x27;
388 static const unsigned char VISCA_MD_MEASURE_MODE_2 = 0x28;
390 static const unsigned char VISCA_ATMD_MODE = 0x22;
391 static const unsigned char VISCA_AT_MODE_QUERY = 0x23;
392 static const unsigned char VISCA_MD_MODE_QUERY = 0x24;
393 static const unsigned char VISCA_MD_REFTIME_QUERY = 0x11;
394 static const unsigned char VISCA_AT_POSITION = 0x20;
395 static const unsigned char VISCA_MD_POSITION = 0x21;
397 void recv_packet(
unsigned int timeout_ms);
398 void handle_response();
399 void finish_nonblocking(
unsigned int socket);
404 unsigned int __default_timeout_ms;
406 unsigned int __inquire;
408 unsigned char __recipient;
409 unsigned char __sender;
411 unsigned char __obuffer[16];
412 unsigned char __ibuffer[1024];
413 int __obuffer_length;
414 int __ibuffer_length;
417 bool __nonblocking_running[2];
418 unsigned int __nonblocking_sockets[2];
420 unsigned char __pan_speed;
421 unsigned char __tilt_speed;
423 #ifdef TIMETRACKER_VISCA 425 unsigned int __ttc_pantilt_get_send;
426 unsigned int __ttc_pantilt_get_read;
427 unsigned int __ttc_pantilt_get_handle;
428 unsigned int __ttc_pantilt_get_interpret;
static const unsigned int VISCA_WHITEBALANCE_ATW
ATW white balance preset.
static const unsigned int NONBLOCKING_PANTILT
Non-blocking pan/tilt item.
static const unsigned int MAX_TILT_SPEED
Number of non-blocking items.
static const unsigned int VISCA_WHITEBALANCE_MANUAL
Manual white balance.
static const unsigned int NONBLOCKING_ZOOM
Non-blocking zoom item.
int _errno
Error number, should be used if the error was caused by a method that supplies errno.
Visca inquire running exception.
static const unsigned int VISCA_WHITEBALANCE_INDOOR
Indoor white balance preset.
static const unsigned int NONBLOCKING_NUM
Number of non-blocking items.
static const unsigned int VISCA_WHITEBALANCE_OUTDOOR
Outdoor white balance preset.
Base class for exceptions in Fawkes.
static const unsigned int VISCA_WHITEBLANCE_AUTO
Automatic white balance.
Visca control protocol implementation over a serial line.
static const unsigned int MAX_PAN_SPEED
Number of non-blocking items.
ViscaException(const char *msg)
Constructor.
static const unsigned int VISCA_WHITEBALANCE_ONE_PUSH
One push white balance preset.