CIOIIDeviceDefines.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*****************************************************************************
  2. * CIOIIDeviceDefines.h
  3. *****************************************************************************
  4. *
  5. * Project: HALCON/libhalcon
  6. * Description: Defines for the integration interface for IO Devices
  7. *
  8. * (c) 2013-2020 by MVTec Software GmbH
  9. * www.mvtec.com
  10. *
  11. *****************************************************************************
  12. *
  13. *
  14. *****************************************************************************/
  15. #ifndef CIO_IIDEVICE_DEFINES_H
  16. #define CIO_IIDEVICE_DEFINES_H
  17. #ifndef HC_NO_IOIINTERFACE
  18. # define HIOII_VERSION 1300
  19. # define HIOGET_IOII_VERSION(IOI_VERSION) ((IOI_VERSION) >> 16)
  20. # define HIOGET_IOII_HMAJOR(IOI_VERSION) \
  21. (HIOGET_IOII_VERSION(IOI_VERSION) / 100)
  22. # define HIOGET_IOII_HMINOR(IOI_VERSION) \
  23. (HIOGET_IOII_VERSION(IOI_VERSION) % 100)
  24. # define HIOGET_IOI_REVISION(IOI_VERSION) (((IOI_VERSION) >> 8) & 0xFF)
  25. # define HIOGET_IOI_BUILD(IOI_VERSION) ((IOI_VERSION)&0xFF)
  26. # define HIOI_VERSION(IOI_REVISION, IOI_BUILD) \
  27. (((HIOII_VERSION) << 16) | ((IOI_REVISION) << 8) | (IOI_BUILD))
  28. # if !defined HIOI_PREFIX
  29. # if defined H_PARALLEL
  30. # define HIOI_PREFIX "hio"
  31. # else
  32. # define HIOI_PREFIX "seqhio"
  33. # endif
  34. # endif
  35. # if !defined HIOI_SUFFIX
  36. # if defined HC_LARGE_IMAGES
  37. # define HIOI_SUFFIX "xl"
  38. # else
  39. # define HIOI_SUFFIX ""
  40. # endif
  41. # endif
  42. # if defined(__cplusplus)
  43. extern "C" {
  44. # endif
  45. # ifndef HC_NO_STRUCT_MEMBER_ALIGNMENT
  46. /* sets the struct member alignment to avoid problems if
  47. * the settings of the user differ to those of the HALCON
  48. * version. (8 is the default alignment, generally) */
  49. # pragma pack(push, 8)
  50. # endif
  51. /* HIOInstance holds the general data of a (virtual) device instance */
  52. typedef struct _HIOInstance
  53. {
  54. struct _HIOClass* ioclass; /* backward reference to the interface
  55. * class handle */
  56. char* H_RESTRICT name; /* name of opened device */
  57. void* iochnl_list; /* list of opened device channels */
  58. void* H_RESTRICT usrinst; /* holds the device specific data, set by
  59. * the device interface. */
  60. } HIOInstance;
  61. /* HIOChannel holds the general data of a (virtual) channel */
  62. typedef struct _HIOChannel
  63. {
  64. char* H_RESTRICT name; /* name of opened channels */
  65. struct _HIOInstance* ioinst; /* backward reference to the interface
  66. * device instance */
  67. void* H_RESTRICT usrchnl; /* holds the channel specific data, set by
  68. * the device interface. */
  69. } HIOChannel;
  70. /* HIOClass holds the class information of a io device interface */
  71. typedef struct _HIOClass
  72. {
  73. /* -------------------------- internal ---------------------------------- */
  74. char* interface_name; /* name of io class */
  75. void* lib_handle; /* handle of interface library */
  76. INT4 interface_version; /* current HALCON io device interface version */
  77. INT4 flags; /* interface flags */
  78. void* ioinst_list; /* list of instantiated device interfaces */
  79. Hphandle handle; /* pointer to (shared) HALCON handle */
  80. HBOOL keep_open; /* If true, do not close the interface if no */
  81. /* instances are open. */
  82. /* ----------------- interface-specific functions ----------------------- */
  83. Herror (*Cleanup)(Hproc_handle ph, struct _HIOClass* ioclass);
  84. Herror (*QueryInterface)(Hproc_handle ph);
  85. Herror (*OpenDevice)(Hproc_handle ph, HIOInstance* const* ioinst,
  86. INT4_8* inst_num);
  87. Herror (*CloseDevice)(Hproc_handle ph, HIOInstance* const* ioinst,
  88. INT4_8 inst_num);
  89. Herror (*SetDeviceParam)(Hproc_handle ph, HIOInstance* H_RESTRICT ioinst);
  90. Herror (*GetDeviceParam)(Hproc_handle ph, HIOInstance const* ioinst);
  91. Herror (*QueryDevice)(Hproc_handle ph, HIOInstance const* ioinst);
  92. Herror (*OpenChannel)(Hproc_handle ph, HIOInstance const* ioinst,
  93. HIOChannel* const* iochnls, INT4_8* chnlnum);
  94. Herror (*CloseChannel)(Hproc_handle ph, HIOChannel* const* iochnls,
  95. INT4_8 chnlnum);
  96. Herror (*SetChannelParam)(Hproc_handle ph, HIOChannel* const* iochnls,
  97. INT4_8 chnlnum);
  98. Herror (*GetChannelParam)(Hproc_handle ph, HIOChannel const* const* iochnls,
  99. INT4_8 chnlnum);
  100. Herror (*ReadChannel)(Hproc_handle ph, HIOChannel const* const* iochnls,
  101. INT4_8 chnlnum);
  102. Herror (*WriteChannel)(Hproc_handle ph, HIOChannel* const* iochnls,
  103. INT4_8 chnlnum);
  104. /* These are optional */
  105. Herror (*ControlInterface)(Hproc_handle ph);
  106. Herror (*ControlDevice)(Hproc_handle ph, HIOInstance const* ioinst);
  107. Herror (*ControlChannel)(Hproc_handle ph, HIOChannel* const* iochnls,
  108. INT4_8 chnlnum);
  109. } HIOClass;
  110. typedef Herror (*HIOI_INIT_FUNC)(Hproc_handle, HIOClass*);
  111. # define HIOI_INIT_NAME "HIOIInit"
  112. # define HIOI_FLAGS_NAME "HIOIFlags"
  113. /*
  114. * Special IO interface flags. Tp set the flags, the interface should export
  115. * the symbol HIOI_FLAGS_NAME, which must be an INT4.
  116. *
  117. * The following flags are defined:
  118. *
  119. * HIO_FLAG_THREAD_INIT: if set, the interface cleanup function is called
  120. * from the same thread as the init function.
  121. */
  122. # define HIO_FLAG_THREAD_INIT (1 << 0)
  123. # ifndef HC_NO_STRUCT_MEMBER_ALIGNMENT
  124. # pragma pack(pop)
  125. # endif
  126. # if defined(__cplusplus)
  127. }
  128. # endif
  129. #endif /* ifndef HC_NO_IOIINTERFACE */
  130. #endif /* ifndef CIO_IIDEVICE_DEFINES_H */