HSerial.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 20.11
  3. * Usage: Interface to C++
  4. *
  5. * Software by: MVTec Software GmbH, www.mvtec.com
  6. ***********************************************************/
  7. #ifndef HCPP_HSERIAL
  8. #define HCPP_HSERIAL
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a connection via a serial port.
  12. class LIntExport HSerial : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HSerial():HHandle() {}
  17. // Copy constructor
  18. HSerial(const HSerial& source) : HHandle(source) {}
  19. // Copy constructor
  20. HSerial(const HHandle& handle);
  21. // Create HSerial from handle, taking ownership
  22. explicit HSerial(Hlong handle);
  23. bool operator==(const HHandle& obj) const
  24. {
  25. return HHandleBase::operator==(obj);
  26. }
  27. bool operator!=(const HHandle& obj) const
  28. {
  29. return HHandleBase::operator!=(obj);
  30. }
  31. protected:
  32. // Verify matching semantic type ('serial')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. /*****************************************************************************
  36. * Operator-based class constructors
  37. *****************************************************************************/
  38. // open_serial: Open a serial device.
  39. explicit HSerial(const HString& PortName);
  40. // open_serial: Open a serial device.
  41. explicit HSerial(const char* PortName);
  42. #ifdef _WIN32
  43. // open_serial: Open a serial device.
  44. explicit HSerial(const wchar_t* PortName);
  45. #endif
  46. /***************************************************************************
  47. * Operators *
  48. ***************************************************************************/
  49. // Clear the buffer of a serial connection.
  50. void ClearSerial(const HString& Channel) const;
  51. // Clear the buffer of a serial connection.
  52. void ClearSerial(const char* Channel) const;
  53. #ifdef _WIN32
  54. // Clear the buffer of a serial connection.
  55. void ClearSerial(const wchar_t* Channel) const;
  56. #endif
  57. // Write to a serial connection.
  58. void WriteSerial(const HTuple& Data) const;
  59. // Write to a serial connection.
  60. void WriteSerial(Hlong Data) const;
  61. // Read from a serial device.
  62. HTuple ReadSerial(Hlong NumCharacters) const;
  63. // Get the parameters of a serial device.
  64. Hlong GetSerialParam(Hlong* DataBits, HString* FlowControl, HString* Parity, Hlong* StopBits, Hlong* TotalTimeOut, Hlong* InterCharTimeOut) const;
  65. // Set the parameters of a serial device.
  66. void SetSerialParam(const HTuple& BaudRate, const HTuple& DataBits, const HString& FlowControl, const HString& Parity, const HTuple& StopBits, const HTuple& TotalTimeOut, const HTuple& InterCharTimeOut) const;
  67. // Set the parameters of a serial device.
  68. void SetSerialParam(Hlong BaudRate, Hlong DataBits, const HString& FlowControl, const HString& Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const;
  69. // Set the parameters of a serial device.
  70. void SetSerialParam(Hlong BaudRate, Hlong DataBits, const char* FlowControl, const char* Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const;
  71. #ifdef _WIN32
  72. // Set the parameters of a serial device.
  73. void SetSerialParam(Hlong BaudRate, Hlong DataBits, const wchar_t* FlowControl, const wchar_t* Parity, Hlong StopBits, Hlong TotalTimeOut, Hlong InterCharTimeOut) const;
  74. #endif
  75. // Close a serial device.
  76. void CloseSerial() const;
  77. // Open a serial device.
  78. void OpenSerial(const HString& PortName);
  79. // Open a serial device.
  80. void OpenSerial(const char* PortName);
  81. #ifdef _WIN32
  82. // Open a serial device.
  83. void OpenSerial(const wchar_t* PortName);
  84. #endif
  85. };
  86. // forward declarations and types for internal array implementation
  87. template<class T> class HSmartPtr;
  88. template<class T> class HHandleBaseArrayRef;
  89. typedef HHandleBaseArrayRef<HSerial> HSerialArrayRef;
  90. typedef HSmartPtr< HSerialArrayRef > HSerialArrayPtr;
  91. // Represents multiple tool instances
  92. class LIntExport HSerialArray : public HHandleBaseArray
  93. {
  94. public:
  95. // Create empty array
  96. HSerialArray();
  97. // Create array from native array of tool instances
  98. HSerialArray(HSerial* classes, Hlong length);
  99. // Copy constructor
  100. HSerialArray(const HSerialArray &tool_array);
  101. // Destructor
  102. virtual ~HSerialArray();
  103. // Assignment operator
  104. HSerialArray &operator=(const HSerialArray &tool_array);
  105. // Clears array and all tool instances
  106. virtual void Clear();
  107. // Get array of native tool instances
  108. const HSerial* Tools() const;
  109. // Get number of tools
  110. virtual Hlong Length() const;
  111. // Create tool array from tuple of handles
  112. virtual void SetFromTuple(const HTuple& handles);
  113. // Get tuple of handles for tool array
  114. virtual HTuple ConvertToTuple() const;
  115. protected:
  116. // Smart pointer to internal data container
  117. HSerialArrayPtr *mArrayPtr;
  118. };
  119. }
  120. #endif