camera_interface
CamTypes.h
Go to the documentation of this file.
1 /*
2  * File: CamTypes.h
3  * Author: developer
4  *
5  * Created on February 11, 2010, 12:37 AM
6  */
7 
8 #ifndef _CAMTYPES_H
9 #define _CAMTYPES_H
10 
11 #ifndef __orogen
12 #include <string>
13 #include <stdexcept>
14 #endif
15 
16 namespace camera
17 {
18  // grab modes
19  //
20 
21  //integer camera attributes
22  namespace int_attrib
23  {
24  enum CamAttrib
25  {
30  TotalBytesPerFrame, //read only
103  };
104  }
105 
106  //double camera attributes
107  namespace double_attrib
108  {
110  {
113  };
114  }
115 
116  //string camera attributes
117  namespace str_attrib
118  {
120  {
131  };
132  }
133 
134  //enum camera attributes
135  namespace enum_attrib
136  {
138  {
249  };
250  }
251 
252 
253  //
254  // IP configuration mode for ethernet cameras.
255  //
256  enum IpConfig
257  {
259  IpConfigPersistent = 1, // Use persistent IP settings
260  IpConfigDhcp = 2, // Use DHCP, fallback to AutoIP
261  IpConfigAutoIp = 4 // Use AutoIP only
262  };
263 
264  struct IPSettings
265  {
266  // IP configuration mode: persistent, DHCP & AutoIp, or AutoIp only.
268  // IP configuration mode supported by the camera
269  unsigned long config_mode_support;
270 
271  // Current IP configuration. Ignored for PvCameraIpSettingsChange().
272  // All values are in network byte order (i.e. big endian).
273  unsigned long current_ip_address;
274  unsigned long current_ip_subnet;
275  unsigned long current_ip_gateway;
276 
277  // Persistent IP configuration. See "ConfigMode" to enable persistent
278  // IP settings. All values are in network byte order.
279  unsigned long persisten_ip_addr;
280  unsigned long persistent_ip_subnet;
281  unsigned long persistent_ip_gateway;
282 
283  #ifndef __orogen
285  {
288  current_ip_address = 0;
289  current_ip_subnet = 0;
290  current_ip_gateway = 0;
291  persisten_ip_addr = 0;
294  };
295 
296  bool matches(const IPSettings &other)const
297  {
298  if (config_mode != 0 && other.config_mode != 0 &&
299  config_mode != other.config_mode)
300  return false;
301  if (config_mode_support != 0 && other.config_mode_support != 0 &&
303  return false;
304  if (current_ip_address != 0 && other.current_ip_address != 0 &&
306  return false;
307  if (current_ip_subnet != 0 && other.current_ip_subnet != 0 &&
309  return false;
310  if (current_ip_gateway != 0 && other.current_ip_gateway != 0 &&
312  return false;
313  if (persisten_ip_addr != 0 && other.persisten_ip_addr != 0 &&
315  return false;
316  if (persistent_ip_subnet != 0 && other.persistent_ip_subnet!= 0 &&
318  return false;
319  if (persistent_ip_gateway != 0 && other.persistent_ip_gateway != 0 &&
321  return false;
322  return true;
323  };
324  #endif
325  };
326 
327  #ifndef __orogen
328  //
329  // Camera interface type (i.e. firewire, ethernet):
330  //
332  {
337  };
338 
339 
340  static inline std::string enumInterfaceToStr(InterfaceType i)
341  {
342  switch(i)
343  {
344  case InterfaceUnknown:
345  return "InterfaceUnknown";
346  case InterfaceFirewire:
347  return "InterfaceFirewire";
348  case InterfaceEthernet:
349  return "InterfaceEthernet";
350  case InterfaceUSB:
351  return "InterfaceUSB";
352  default:
353  throw std::runtime_error("no Interface enum value found");
354 
355  }
356  return "";
357  }
358 
359  //
360  // Camera information type.
361  //
362  struct CamInfo
363  {
364  unsigned long unique_id ; // Unique value for each camera
365  std::string serial_string; // Camera's serial number
366  unsigned long part_number; // Camera part number
367  unsigned long part_version; // Camera part version
368  unsigned long permitted_access; // A combination of tPvAccessFlags
369  unsigned long interface_id; // Unique value for each interface
370  // or bus
371  std::string device; // Camera device on OS (for USB)
372  InterfaceType interface_type; // Interface type; see
373  // tPvInterface
374  std::string display_name; // People-friendly camera name
375  bool reachable; // indicates if the camera is
376  // reachable (same sub net)
377  IPSettings ip_settings; // ip settings for ethernet
378  // cameras
380  {
381  unique_id = 0;
382  part_number = 0;
383  part_version = 0;
384  permitted_access = 0;
385  interface_id = 0;
387  reachable = false;
388  };
389 
390  bool matches(const CamInfo &other)const
391  {
392  if (unique_id != 0 && other.unique_id != 0 &&
393  unique_id != other.unique_id)
394  return false;
395  if (part_number != 0 && other.part_number != 0 &&
396  part_number != other.part_number)
397  return false;
398  if (part_version != 0 && other.part_version != 0 &&
399  part_version != other.part_version)
400  return false;
401  if (permitted_access != 0 && other.permitted_access != 0 &&
403  return false;
404  if (interface_id != 0 && other.interface_id != 0 &&
405  interface_id != other.interface_id)
406  return false;
407  if (interface_type != 0 && other.interface_type != 0 &&
409  return false;
410  if (serial_string.size() != 0 && other.serial_string.size() != 0 &&
411  serial_string != other.serial_string)
412  return false;
413  if (device.size() != 0 && other.device.size() != 0 &&
414  device != other.device)
415  return false;
416  if (display_name.size() != 0 && other.display_name.size() != 0 &&
417  display_name != other.display_name)
418  return false;
419  // if (reachable && !other.reachable)
420  // return false;
421  if(!ip_settings.matches(other.ip_settings))
422  return false;
423  return true;
424  };
425  };
426  #endif
427 
428  //
429  // grab modes
430  //
431  enum GrabMode
432  {
437  };
438 
439  //
440  // Camera access modes.
441  //
443  {
444  Monitor, //listen only
445  Master, //full control
446  MasterMulticast //full control + enables multicast for ethernet cameras
447  };
448 
449 }
450 
451 #endif /* _CAMTYPES_H */
452 
Definition: CamTypes.h:207
Definition: CamTypes.h:334
Definition: CamTypes.h:129
Definition: CamTypes.h:28
Definition: CamTypes.h:127
CamAttrib
Definition: CamTypes.h:119
Definition: CamTypes.h:35
Definition: CamTypes.h:98
Definition: CamTypes.h:67
Definition: CamTypes.h:336
Definition: CamTypes.h:199
Definition: CamTypes.h:126
Definition: CamTypes.h:66
unsigned long current_ip_address
Definition: CamTypes.h:273
Definition: CamTypes.h:121
Definition: CamTypes.h:259
Definition: CamTypes.h:69
Definition: CamTypes.h:238
Definition: CamTypes.h:99
Definition: CamTypes.h:260
Definition: CamTypes.h:258
Definition: CamTypes.h:204
AccessMode
Definition: CamTypes.h:442
CamInfo()
Definition: CamTypes.h:379
Definition: CamTypes.h:88
unsigned long current_ip_gateway
Definition: CamTypes.h:275
Definition: CamTypes.h:95
Definition: CamTypes.h:203
Definition: CamTypes.h:71
Definition: CamTypes.h:226
CamAttrib
Definition: CamTypes.h:109
Definition: CamTypes.h:125
Definition: CamTypes.h:152
IpConfig
Definition: CamTypes.h:256
unsigned long permitted_access
Definition: CamTypes.h:368
unsigned long persisten_ip_addr
Definition: CamTypes.h:279
Definition: CamTypes.h:54
GrabMode
Definition: CamTypes.h:431
Definition: CamTypes.h:27
unsigned long part_number
Definition: CamTypes.h:366
Definition: CamTypes.h:92
CamAttrib
Definition: CamTypes.h:24
Definition: CamTypes.h:72
Definition: CamTypes.h:240
CamAttrib
Definition: CamTypes.h:137
unsigned long unique_id
Definition: CamTypes.h:364
InterfaceType
Definition: CamTypes.h:331
Definition: CamTypes.h:63
Definition: CamTypes.h:435
Definition: CamTypes.h:446
bool matches(const IPSettings &other) const
Definition: CamTypes.h:296
Definition: CamTypes.h:79
IPSettings()
Definition: CamTypes.h:284
Definition: CamTypes.h:62
unsigned long current_ip_subnet
Definition: CamTypes.h:274
Definition: CamTypes.h:444
Definition: CamTypes.h:245
Definition: CamTypes.h:190
Definition: CamTypes.h:41
Definition: CamTypes.h:93
Definition: CamTypes.h:58
Definition: CamTypes.h:189
std::string device
Definition: CamTypes.h:371
Definition: CamTypes.h:64
Definition: CamTypes.h:362
Definition: CamTypes.h:86
Definition: CamTypes.h:77
Definition: CamTypes.h:61
Definition: CamTypes.h:153
Definition: CamTypes.h:193
Definition: CamTypes.h:49
Definition: CamTypes.h:59
Definition: CamTypes.h:147
Definition: CamTypes.h:214
Definition: CamTypes.h:192
Definition: CamTypes.h:128
Definition: CamTypes.h:445
Definition: CamTypes.h:335
Definition: CamTypes.h:46
Definition: CamTypes.h:433
Definition: CamTypes.h:51
Definition: CamTypes.h:436
Definition: CamTypes.h:80
Definition: CamTypes.h:65
Definition: CamTypes.h:194
IpConfig config_mode
Definition: CamTypes.h:267
Definition: CamTypes.h:212
Definition: CamTypes.h:211
Definition: CamTypes.h:130
Definition: CamTypes.h:102
Definition: CamTypes.h:209
Definition: CamTypes.h:78
Definition: CamTypes.h:44
Definition: CamTypes.h:111
Definition: CamTypes.h:36
Definition: CamTypes.h:45
Definition: CamTypes.h:146
unsigned long interface_id
Definition: CamTypes.h:369
Definition: CamTypes.h:47
std::string display_name
Definition: CamTypes.h:374
bool reachable
Definition: CamTypes.h:375
bool matches(const CamInfo &other) const
Definition: CamTypes.h:390
Definition: CamTypes.h:82
unsigned long config_mode_support
Definition: CamTypes.h:269
Definition: CamTypes.h:101
Definition: CamTypes.h:210
Definition: CamTypes.h:246
unsigned long persistent_ip_subnet
Definition: CamTypes.h:280
Definition: CamTypes.h:123
Definition: CamTypes.h:55
Definition: CamTypes.h:73
InterfaceType interface_type
Definition: CamTypes.h:372
Definition: CamTypes.h:75
Definition: CamTypes.h:195
Definition: CamTypes.h:333
Definition: CamTypes.h:149
Definition: CamTypes.h:76
Definition: CamTypes.h:124
Definition: CamTypes.h:205
Definition: CamTypes.h:68
Definition: CamTypes.h:81
Definition: CamTypes.h:261
Definition: CamTypes.h:112
IPSettings ip_settings
Definition: CamTypes.h:377
Definition: CamTypes.h:57
Definition: CamTypes.h:122
Definition: CamTypes.h:97
unsigned long persistent_ip_gateway
Definition: CamTypes.h:281
Definition: CamTypes.h:191
Definition: CamTypes.h:96
Definition: CamTypes.h:94
Definition: CamTypes.h:264
Definition: CamTypes.h:43
Definition: CamTypes.h:91
Definition: CamTypes.h:26
Definition: CamTypes.h:198
Definition: CamTypes.h:83
Definition: CamTypes.h:38
Definition: CamTypes.h:29
Definition: CamTypes.h:34
unsigned long part_version
Definition: CamTypes.h:367
Definition: CamTypes.h:434
Definition: CamTypes.h:48
std::string serial_string
Definition: CamTypes.h:365
Definition: CamTypes.h:56
Definition: CamTypes.h:50