GigETransportLayer.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2008-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Thomas Koeller, Hartmut Nebelung
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Definition of the GigE-specific transport layer interface extension
  10. */
  11. #ifndef TRANSPORTLAYER_GIGE_H
  12. #define TRANSPORTLAYER_GIGE_H
  13. #if _MSC_VER>1000
  14. #pragma once
  15. #endif // _MSC_VER>1000
  16. #include <pylon/TransportLayer.h>
  17. #include "PylonGigE.h"
  18. namespace Pylon
  19. {
  20. /*!
  21. \ingroup Pylon_TransportLayer
  22. \brief Lists possible status codes returned by IGigETransportLayer::IssueActionCommand or IGigETransportLayer::IssueScheduledActionCommand.
  23. */
  24. enum EGigEActionCommandStatus
  25. {
  26. /**
  27. \brief The device acknowledged the command.
  28. */
  29. GigEActionCommandStatus_Ok = 0,
  30. /**
  31. \brief The device is not synchronized to a master clock to be used as time reference.
  32. Typically used when scheduled action commands cannot be scheduled for
  33. a future time since the reference time coming from IEEE 1588 is not locked.
  34. The action command has been ignored by the device.
  35. */
  36. GigEActionCommandStatus_NoRefTime = 0xE1018013,
  37. /**
  38. \brief Returned when the scheduled action commands queue is full and the device cannot accept the additional request.
  39. The action command has been discarded by the device.
  40. */
  41. GigEActionCommandStatus_Overflow = 0xE1018015,
  42. /**
  43. \brief The requested scheduled action command was requested at a point in time that is in the past.
  44. If the time tag of the scheduled action command is in the past (relative to the device timestamp), and if it is a valid action
  45. command, then the device will execute this action command immediately and return \c GigEActionCommandStatus_ActionLate.
  46. This status code is used as an indicator to the application requesting the action command that a mis-synchronization might have
  47. occurred.
  48. */
  49. GigEActionCommandStatus_ActionLate = 0xE1018016
  50. };
  51. /*!
  52. \ingroup Pylon_TransportLayer
  53. \brief Optional result structure of IGigETransportLayer::IssueActionCommand and IGigETransportLayer::IssueScheduledActionCommand.
  54. */
  55. struct GigEActionCommandResult
  56. {
  57. /// IP address of the device.
  58. char DeviceAddress[12 + 3 + 1];
  59. /// GigE Vision status code returned by the device. See Pylon::EGigEActionCommandStatus for more information.
  60. int32_t Status;
  61. };
  62. /*!
  63. \ingroup Pylon_TransportLayer
  64. \interface IGigETransportLayer
  65. \brief Extends the ITransportLayer interface by GigE Vision specific
  66. functionality.
  67. */
  68. interface PUBLIC_INTERFACE IGigETransportLayer : public ITransportLayer
  69. {
  70. //! \brief Enumerates all available Basler GigE Vision devices
  71. /*!
  72. In contrast to the ITransportLayer::EnumerateDevices method,
  73. devices having a subnet configured that is different from the subnet of the
  74. application will be listed.
  75. All Basler GigE Vision devices will be listed, including the Basler blaze,
  76. which is usually not considered by the GigE transport layer.
  77. */
  78. virtual int EnumerateAllDevices( DeviceInfoList_t&, bool addToList = false ) = 0;
  79. //! \brief "Force" a static IP address configuration in a device identified by its MAC Address
  80. /**
  81. This applies to all Basler GigE Vision devices, including the Basler blaze, which isn't
  82. usually considered by the GigE transport layer.
  83. \note When calling this function, there must be no opened camera object for
  84. the device to be reconfigured!
  85. \param MacAddress MAC address as a string, no delimiters are used. e.g., 003053061a58
  86. \param IpAddress Temporary IP address, "dot notation", e.g., 192.168.1.2
  87. \param SubnetMask Temporary SubnetMask, "dot notation", e.g. 255.255.255.0
  88. \param DefaultGateway Temporary DefaultGateway, "dot notation", e.g., 192.168.1.1
  89. */
  90. virtual void ForceIp( const String_t& MacAddress,
  91. const String_t& IpAddress,
  92. const String_t& SubnetMask,
  93. const String_t& DefaultGateway ) = 0;
  94. //! \brief Let a device restart the IP configuration cycle
  95. /**
  96. \note This function fails when the device is open, i.e., a control channel is established
  97. \param MacAddress MAC address as a string, no delimiters are used, e.g., 003053061a58
  98. */
  99. virtual void RestartIpConfiguration( const String_t& MacAddress ) = 0;
  100. //! \brief Announce that a remote device is going to be used
  101. /*!
  102. This applies to all Basler GigE Vision devices, including the Basler blaze, which isn't
  103. usually considered by the GigE transport layer.
  104. \note This device must be reachable, a route is configured.
  105. \param IpAddress address of device in "dot notation"
  106. \param pInfo This optional parameter holds the full device info if found
  107. */
  108. virtual bool AnnounceRemoteDevice( const String_t& IpAddress, CDeviceInfo* pInfo = NULL ) = 0;
  109. //! \brief Stop using remote device.
  110. /*! \param IpAddress address of device in "dot notation" */
  111. virtual bool RenounceRemoteDevice( const String_t& IpAddress ) = 0;
  112. //! \brief Broadcast a new IP configuration
  113. /**
  114. All Basler GigE Vision devices can be configured, including the Basler blaze, which
  115. isn't usually considered by the GigE transport layer.
  116. When configuring a blaze camera, some options may not be supported. Please check
  117. the camera documentation for more information.
  118. \param MacAddress MAC address as a string, no delimiters are used. e.g., 003053061a58
  119. \param EnablePersistentIp If true, a persistent Ip address will be set
  120. \param EnableDhcp If true, DHCP is enabled
  121. \param IpAddress Device's new IP address, "dot notation", e.g., 192.168.1.2
  122. \param SubnetMask Device's new SubnetMask, "dot notation", e.g. 255.255.255.0
  123. \param DefaultGateway Device's new DefaultGateway, "dot notation", e.g., 192.168.1.1
  124. \param UserdefinedName Device's new UserdefinedName, maximal 16 character
  125. \return true if configuration was successfully written
  126. */
  127. virtual bool BroadcastIpConfiguration( const String_t& MacAddress,
  128. bool EnablePersistentIp,
  129. bool EnableDhcp,
  130. const String_t& IpAddress,
  131. const String_t& SubnetMask,
  132. const String_t& DefaultGateway,
  133. const String_t& UserdefinedName ) = 0;
  134. //! \brief Issue a broadcast action command.
  135. /**
  136. \param[in] deviceKey The device key addresses devices managed by an application.
  137. The device key is only known to the application controlling its camera devices
  138. and it ensures that only this application can trigger the camera devices.
  139. Therefore the device key cannot be read from a device.
  140. An exact match of the send \c deviceKey and the device key stored in a device
  141. is required for executing an action.
  142. \param[in] groupKey The group key is used to create groups of devices or actions.
  143. An exact match of the send \c groupKey and the group key stored in a device
  144. for an action is required for executing an action.
  145. \param[in] groupMask The groupMask is a bit mask that allows to send an action to a subgroup
  146. of the devices addressed by the \c deviceKey \c groupKey pair.
  147. The result of a bitwise AND operation of \c groupMask and the group mask
  148. stored in a device for an action must be non-zero for executing an action.
  149. \param[in] broadcastAddress BroadcastAddress in dot notation where the command will be broadcast to,
  150. e.g. 255.255.255.255 (all adapters, default),
  151. 192.168.1.255 (all devices in a single subnet 192.168.1.xxx),
  152. 192.168.1.38 (single device).
  153. See the note below.
  154. \param[in] timeoutMs Optional: Time in milliseconds the call is waiting for acknowledges of the addressed devices.
  155. Waiting for acknowledges is stopped if \c pNumResults have been received.
  156. This parameter can be 0 if a check of action command results is not required.
  157. \param[in,out] pNumResults Optional: The number of results in the \c results array.
  158. The value passed should be equal to the expected number of devices that acknowledge the command.
  159. Returns the number of received results.
  160. This parameter is ignored if \c timeoutMs is 0.
  161. Thus this parameter can be NULL if \c timeoutMs is 0.
  162. \param[out] results Optional: An Array with \c *pNumResults elements to hold the action command result status.
  163. The buffer is filled beginning from the start. Remaining results are
  164. not changed if less results are received than result items available.
  165. This parameter is ignored if \c timeoutMs is 0.
  166. Thus this parameter can be NULL if \c timeoutMs is 0.
  167. \return Returns true if *pNumResults have been received and the \c Status of all results is \c GigEActionCommandStatus_Ok.
  168. Returns true if no results have been requested.
  169. The action command feature lets you trigger actions in multiple devices (e.g. cameras) at roughly
  170. the same time or at a defined point in time (scheduled action command) by using a single broadcast protocol message (without extra cabling). Action
  171. commands are used in cameras in the same way as for example the digital input lines.
  172. \note The request is sent via all existing network adapters. If a network adapter has more than one IP address, the request is sent separately for each address.
  173. This is not executed simultaneously but consecutively, IP address by IP address. That's why additional latency is added to the execution time.
  174. Directed broadcasts (192.168.1.255) or unicasts (192.168.1.38) are only sent if the request subnet matches the subnet of the IP address, i.e., if no gateway or routing are required.
  175. See \ref sample_Grab_UsingActionCommand and Pylon::CActionTriggerConfiguration for more information.
  176. \pre
  177. <ul>
  178. <li> IP4 addresses must be used.
  179. <li> \c groupMask must not be 0.
  180. <li> \c pNumResult, \c *pNumResult and \c results must not be 0 if a \c timeoutMs value other than 0 is passed.
  181. </ul>
  182. \error
  183. Throws an exception if the preconditions are not met. Throws C++ exceptions.
  184. \threading
  185. The method is thread-safe.
  186. */
  187. virtual bool IssueActionCommand( uint32_t deviceKey,
  188. uint32_t groupKey,
  189. uint32_t groupMask,
  190. const String_t &broadcastAddress = "255.255.255.255",
  191. uint32_t timeoutMs = 0,
  192. uint32_t *pNumResults = 0,
  193. GigEActionCommandResult results[] = NULL ) = 0;
  194. //! \brief Issue a scheduled action command via broadcast.
  195. /**
  196. \copydetails IGigETransportLayer::IssueActionCommand
  197. \param[in] actionTimeNs Time in nanoseconds when the action is to be executed.
  198. The actual value depends on the used master clock.
  199. A master clock value can be obtained for instance for a set of
  200. synchronized camera devices by reading the timestamp value
  201. (GevTimestampValue) after latching the timestamp value
  202. (GevTimestampControlLatch) from one camera device of the set
  203. \pre \c actionTimeNs must be smaller than or equal INT64_MAX.
  204. */
  205. virtual bool IssueScheduledActionCommand( uint32_t deviceKey,
  206. uint32_t groupKey,
  207. uint32_t groupMask,
  208. uint64_t actionTimeNs,
  209. const String_t &broadcastAddress = "255.255.255.255",
  210. uint32_t timeoutMs = 0,
  211. uint32_t *pNumResults = 0,
  212. GigEActionCommandResult results[] = NULL
  213. ) = 0;
  214. };
  215. } // namespace Pylon
  216. #endif // TRANSPORTLAYER_GIGE_H