SR7LinkFunc.cs 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. /**************************************************************************
  2. * File Name: SR7LinkFunc.cs
  3. * Created Date: 2025-04-01
  4. * Version: 1.0.0
  5. * Description: 将SR7lnik sdk库转成C#可用接口
  6. * Convert the SR7lnik SDK library into a C# usable interface
  7. *
  8. * Change Log:
  9. * Date Author Description
  10. * ---------- --------- ----------------------------------------------
  11. * 2025-04-01 GK Add
  12. **************************************************************************/
  13. using System;
  14. using System.Diagnostics;
  15. using System.IO;
  16. using System.Runtime.InteropServices;
  17. namespace SR7Link
  18. {
  19. #region Structure
  20. /// <summary>
  21. /// IP 结构体 / IP structure
  22. /// </summary>
  23. [StructLayout(LayoutKind.Sequential)]
  24. public struct SR7IF_ETHERNET_CONFIG
  25. {
  26. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
  27. public byte[] abyIpAddress;
  28. }
  29. /// <summary>
  30. /// 目标设置结构体 / Target setting structure
  31. /// </summary>
  32. public struct SR_TARGET_SETTING
  33. {
  34. public byte byType; // 类型 / Type
  35. public byte byCategory; // 类别 / Category
  36. public byte byItem; // 项目 / Item
  37. public byte reserve; // 保留 / Reserved
  38. public byte byTarget1; // 目标1 / Target 1
  39. public byte byTarget2; // 目标2 / Target 2
  40. public byte byTarget3; // 目标3 / Target 3
  41. public byte byTarget4; // 目标4 / Target 4
  42. };
  43. /// <summary>
  44. /// 回调信息结构体 / Callback information structure
  45. /// </summary>
  46. public struct SR7IF_STR_CALLBACK_INFO
  47. {
  48. /// <summary>
  49. /// x方向数据数量 / Number of data points in x direction
  50. /// </summary>
  51. public int xPoints; // x方向数据数量 / Number of data points in x direction
  52. /// <summary>
  53. /// 批处理数量 / Batch quantity
  54. /// </summary>
  55. public int BatchPoints; // 批处理数量 / Batch quantity
  56. /// <summary>
  57. /// 批处理次数 / Number of batches
  58. /// </summary>
  59. public int BatchTimes; // 批处理次数 / Number of batches
  60. /// <summary>
  61. /// x方向点间距 / Point spacing in x direction
  62. /// </summary>
  63. public double xPixth; // x方向点间距 / Point spacing in x direction
  64. /// <summary>
  65. /// 批处理开始编码器值 / Batch start encoder value
  66. /// </summary>
  67. public int startEncoder; // 批处理开始编码器值 / Batch start encoder value
  68. /// <summary>
  69. /// 相机头数量 / Number of camera heads
  70. /// </summary>
  71. public int HeadNumber; // 相机头数量 / Number of camera heads
  72. /// <summary>
  73. /// 0:正常批处理 / 0: Normal batch processing
  74. /// </summary>
  75. public int returnStatus; // 0:正常批处理 / 0: Normal batch processing
  76. }
  77. /// <summary>
  78. /// 异步回调结构体 / Asynchronous callback structure
  79. /// </summary>
  80. public struct AsyncCallBackInfo
  81. {
  82. public int dev; // 本次回调控制器编号 / The controller number of this callback
  83. public int profileIndex; // 本次回调起始行号 / The starting line number of this callback
  84. public int profileNum; // 本次回调帧数量 / The number of frames in this callback
  85. public int profileWidth; // 本次回调宽度 / The width of this callback
  86. public uint BatchTimes; // 本次回调批处理序号 / The batch number of this callback
  87. public int bGray; // 本次回调是否开启灰度 / Whether this callback is grayscale enabled
  88. public int bCamB; // 本次回调相机b是否在线 / Whether camera B is online in this callback
  89. public int ProfileBits; // 本次回调数据类型0:32bit;1:16bit / The data type of this callback is 0:32bit; 1:16bit
  90. public IntPtr pProfileDataA; // 相机a数据地址 / Camera A data address
  91. public IntPtr pProfileDataB; // 相机b数据地址 / Camera B data address
  92. public IntPtr pProfileDataA16Bit; // 相机A16Bit数据地址 / Camera A 16Bit data address
  93. public IntPtr pProfileDataB16Bit; // 相机B16Bit数据地址 / Camera B 16Bit data address
  94. public IntPtr pGrayDataA; // 相机A灰度图 / Camera A grayscale image
  95. public IntPtr pGrayDataB; // 相机B灰度图 / Camera B grayscale image
  96. public IntPtr pEncoderDataA; // 相机A编码器数据 / Camera A encoder data
  97. public IntPtr pEncoderDataB; // 相机B编码器数据 / Camera B encoder data
  98. };
  99. #endregion
  100. #region Method
  101. /// <summary>
  102. /// 回调函数-高速数据通信的回调函数接口 / Callback function - callback function interface for high-speed data communication
  103. /// </summary>
  104. /// <param name="buffer">指向储存概要数据的缓冲区的指针 / Pointer to a buffer to store summary data</param>
  105. /// <param name="size">每个单元(行)的字节数量 / The number of bytes per cell (row)</param>
  106. /// <param name="count">存储在pBuffer中的内存的单元数量 / The number of cells of memory stored in pBuffer</param>
  107. /// <param name="notify">中断或批量结束等中断的通知 / Notification of interruptions such as interruption or batch end</param>
  108. /// <param name="user">用户自定义信息 / User-defined information</param>
  109. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  110. public delegate void HighSpeedDataCallBack(IntPtr buffer, uint size, uint count, uint notify, uint user);
  111. /// <summary>
  112. /// 异步回调回调函数 / Asynchronous callback function
  113. /// </summary>
  114. /// <param name="info">保留 / Reserved</param>
  115. /// <param name="SR7IF_Data">回调相关信息 / Callback related information</param>
  116. /// <param name="pUserData">返回用户注册传入的指针 / Returns the pointer passed by user registration</param>
  117. /// <param name="state">本次回调状态 / Current callback status
  118. /// (0x01 << 0) : 批处理批处理正常结束 / Batch processing ended normally
  119. /// (0x01 << 1) : 批处理软件溢出 / Batch software overflow
  120. /// (0x01 << 2) : 批处理硬件溢出 / Batch hardware overflow
  121. /// (0x01 << 3) : 网络异常,接收断开 / Network abnormality, reception disconnected
  122. /// (0x01 << 4) : 其他错误 / Other errors
  123. /// </param>
  124. /// <param name="dwDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  125. /// <returns>
  126. /// &lt;0: 失败 / Fail
  127. /// =0: 成功 / Success
  128. /// </returns>
  129. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  130. public delegate void SR7IF_AsyncCALLBACK(IntPtr SR7IF_Data, IntPtr pUserData, uint state, int dwDeviceId);
  131. /// <summary>
  132. /// 异步错误回调 / Asynchronous error callback
  133. /// </summary>
  134. /// <param name="DeviciId">设备ID / Device ID</param>
  135. /// <param name="ErrCode">错误码 / Error code</param>
  136. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  137. public delegate void SR7IF_AsyncErrCallBack(int DeviciId, int ErrCode);
  138. /// <summary>
  139. /// 回调函数-无限循环回调函数接口 / Callback function - infinite loop callback function interface
  140. /// </summary>
  141. /// <param name="pProfileBuffer">返回轮廓数据 / Return contour data</param>
  142. /// <param name="pIntensityBuffer">返回灰度数据 / Return grayscale data</param>
  143. /// <param name="pEncoder">返回编码器数据 / Return encoder data</param>
  144. /// <param name="dwSize">数据宽度 / Data width</param>
  145. /// <param name="dwCount">批处理点数 / Batch points</param>
  146. /// <param name="dwRet">返回值,待使用 / Return value, to be used</param>
  147. /// <param name="dwDeviceId">相应的控制器(0-63) / Corresponding controller (0-63)</param>
  148. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  149. public delegate void SR7IF_RollDataCallback(IntPtr pProfileBuffer, IntPtr pIntensityBuffer, IntPtr pEncoder, int dwSize, int dwCount, int dwRet, int dwDeviceId);
  150. /// <summary>
  151. /// 高速数据通信的回调函数接口 / Callback function interface for high-speed data communication
  152. /// </summary>
  153. /// <param name="data">指向储存概要数据的缓冲区的指针 / Pointer to the buffer where the summary data is stored</param>
  154. /// <param name="ProfileCompressType">Ethernet 压缩类型0:32bit,1:16bit / Ethernet compression type 0:32bit, 1:16bit</param>
  155. /// <param name="xPoints">一行轮廓的点数 / The number of points in a line of contours</param>
  156. /// <param name="dwCount">当前回调返回行数 / The current callback returns the number of rows</param>
  157. /// <param name="dwNotify">回调状态0:回调中,1:回调结束 / Callback status 0: callback in progress, 1: callback completed</param>
  158. /// <param name="dwDeviceId">被调用函数DeviceID号 / DeviceID number of the called function</param>
  159. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  160. public delegate void SR7IF_ProfileCALLBACK(IntPtr data, byte ProfileCompressType, int xPoints, int dwCount, int dwNotify, int dwDeviceId);
  161. /// <summary>
  162. /// 批处理一次性回调 / Batch one-time callback
  163. /// </summary>
  164. /// <param name="info">信息 / Information</param>
  165. /// <param name="DataObj">数据对象 / Data object</param>
  166. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  167. public delegate void SR7IF_BatchOneTimeCallBack(IntPtr info, IntPtr DataObj);
  168. /// <summary>
  169. /// 相机异常回调 / Camera exception callback
  170. /// </summary>
  171. /// <param name="dwDeviceId">设备ID / Device ID</param>
  172. /// <param name="cmd">命令 / Command</param>
  173. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  174. public delegate void ErrConnectCallBack(int dwDeviceId, int cmd);
  175. /// <summary>
  176. /// Function definitions 接口函数定义 / Interface function definition
  177. /// </summary>
  178. internal class SR7LinkFunc
  179. {
  180. internal static UInt32 ProgramSettingSize
  181. {
  182. get { return 10932; }
  183. }
  184. /// <summary>
  185. /// 连接相机 / Connect camera
  186. /// </summary>
  187. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  188. /// <param name="pEthernetConfig">(网口)通信设定 / (Network port) Communication settings</param>
  189. /// <returns>
  190. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  191. /// </returns>
  192. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  193. internal static extern int SR7IF_EthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig);
  194. /// <summary>
  195. /// 连接相机ext / Connect camera ext
  196. /// </summary>
  197. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  198. /// <param name="pEthernetConfig">(网口)通信设定 / (Network port) Communication settings</param>
  199. /// <param name="Timeout">超时时间,默认为2000ms / Timeout, default is 2000ms</param>
  200. /// <param name="fun">TCP连接函数 / TCP connection function</param>
  201. /// <returns>
  202. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  203. /// </returns>
  204. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  205. internal static extern int SR7IF_EthernetOpenExt(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int Timeout = 2000, ErrConnectCallBack fun = null);
  206. /// <summary>
  207. /// 断开相机连接 / Disconnect the camera
  208. /// </summary>
  209. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  210. /// <returns>
  211. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  212. /// </returns>
  213. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  214. internal static extern int SR7IF_CommClose(int lDeviceId);
  215. /// <summary>
  216. /// 开始批处理,立即执行批处理程序 / Start batch processing and execute the batch program immediately
  217. /// </summary>
  218. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  219. /// <param name="Timeout">非循环获取时,超时时间(单位ms); 循环模式该参数可设置为-1 / Timeout in milliseconds for non-loop mode; set to -1 for loop mode</param>
  220. /// <returns>
  221. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  222. /// </returns>
  223. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  224. internal static extern int SR7IF_StartMeasure(int lDeviceId, int Timeout);
  225. /// <summary>
  226. /// 开始批处理,硬件IO触发开始批处理,具体查看硬件手册 / Start batch processing, triggered by hardware IO. Refer to the hardware manual for details.
  227. /// </summary>
  228. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  229. /// <param name="Timeout">非循环获取时,超时时间(单位ms); 循环模式该参数可设置为-1 / Timeout in milliseconds for non-loop mode; set to -1 for loop mode</param>
  230. /// <param name="restart">预留,设为0 / Reserved, set to 0</param>
  231. /// <returns>
  232. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  233. /// </returns>
  234. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  235. internal static extern int SR7IF_StartIOTriggerMeasure(int lDeviceId, int Timeout, int restart);
  236. /// <summary>
  237. /// 停止批处理---停止扫描 / Stop batch processing - stop scanning
  238. /// </summary>
  239. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  240. /// <returns>
  241. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  242. /// </returns>
  243. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  244. internal static extern int SR7IF_StopMeasure(int lDeviceId);
  245. /// <summary>
  246. /// 阻塞方式获取数据---等待数据接收完成 / Get data in blocking mode - wait until data reception is complete
  247. /// </summary>
  248. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  249. /// <param name="DataObj">返回数据指针 / Pointer to the returned data</param>
  250. /// <returns>
  251. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  252. /// </returns>
  253. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  254. internal static extern int SR7IF_ReceiveData(int lDeviceId, IntPtr DataObj);
  255. /// <summary>
  256. /// 获取当前编码器值 / Get the current encoder value
  257. /// </summary>
  258. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  259. /// <param name="DataObj">返回数据指针 / Pointer to the returned data</param>
  260. /// <returns>
  261. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  262. /// </returns>
  263. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  264. internal static extern int SR7IF_GetCurrentEncoder(int lDeviceId, IntPtr DataObj);
  265. /// <summary>
  266. /// 获取当前批处理设定行数 / Get the number of preset lines for batch processing
  267. /// </summary>
  268. /// <param name="lDeviceId">设备号0-63 / Device ID, ranging from 0 to 63</param>
  269. /// <param name="DataObj">预留设置为null / Reserved, set to null</param>
  270. /// <returns>
  271. /// 返回实际批处理行数 / Returns the actual number of batch processing lines
  272. /// </returns>
  273. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  274. internal static extern int SR7IF_ProfilePointSetCount(int lDeviceId, IntPtr DataObj);
  275. /// <summary>
  276. /// 获取批处理实际获取行数 / Get the actual number of lines obtained in batch processing
  277. /// </summary>
  278. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  279. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  280. /// <returns>
  281. /// 返回实际批处理行数 / Returns the actual number of batch processing lines
  282. /// </returns>
  283. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  284. internal static extern int SR7IF_ProfilePointCount(int lDeviceId, IntPtr DataObj);
  285. /// <summary>
  286. /// 获取数据宽度 / Get the data width
  287. /// </summary>
  288. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
  289. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  290. /// <returns>
  291. /// 返回数据宽度(单位像素) / Returns the data width (in pixels)
  292. /// </returns>
  293. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  294. internal static extern int SR7IF_ProfileDataWidth(int lDeviceId, IntPtr DataObj);
  295. /// <summary>
  296. /// 本次上电后控制器运行的时间 / The running time of the controller since the last power-on
  297. /// </summary>
  298. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  299. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  300. /// <param name="TimeStamp">返回运行的时间(单位秒) / Returns the running time (in seconds)</param>
  301. /// <returns>
  302. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  303. /// </returns>
  304. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  305. internal static extern int SR7IF_GetTimeStamp(int lDeviceId, IntPtr DataObj, int TimeStamp);
  306. /// <summary>
  307. /// 批处理状态查询 / Batch processing status query
  308. /// </summary>
  309. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  310. /// <param name="Status">批处理状态 1:正在批处理 0:批处理结束 / Batch status 1: batch processing in progress 0: batch processing ended</param>
  311. /// <returns>
  312. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  313. /// </returns>
  314. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  315. internal static extern int SR7IF_GetBatchStatus(int lDeviceId, int Status);
  316. /// <summary>
  317. /// 设置控制器网络参数 / Set controller network parameters
  318. /// </summary>
  319. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  320. /// <param name="ip">IP地址 / IP address</param>
  321. /// <param name="netmask">子网掩码 / Subnet mask</param>
  322. /// <param name="gateway">默认网关 / Default gateway</param>
  323. /// <returns>
  324. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  325. /// </returns>
  326. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  327. internal static extern int SR7IF_SetNetworkParam(int lDeviceId, IntPtr ip, IntPtr netmask, IntPtr gateway);
  328. /// <summary>
  329. /// 续传功能使能 / Resume function enable
  330. /// 设置相机在一次批处理过程中,可以通过IO控制来暂停或继续批处理 / Set the camera to pause or resume batch processing through IO control during a batch process
  331. /// IO控制使用控制器11脚和14脚配合使用,其中11脚开启电平控制模式,14脚控制暂停和继续批处理 / IO control uses pin 11 and pin 14 of the controller, where pin 11 enables level control mode and pin 14 controls pause and resume of batch processing
  332. /// </summary>
  333. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  334. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  335. /// <param name="Enable">功能使能0:关闭 1:使能 / Function enable 0: disable 1: enable</param>
  336. /// <returns>
  337. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  338. /// </returns>
  339. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  340. internal static extern int SR7IF_SetBatchCtrlByIO(int lDeviceId, IntPtr DataObj, int Enable);
  341. /// <summary>
  342. /// 获取z向测量范围上下限 / Get the upper and lower limits of the z-direction measurement range
  343. /// </summary>
  344. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  345. /// <param name="up">上限(mm) / Upper limit (mm)</param>
  346. /// <param name="down">下限(mm) / Lower limit (mm)</param>
  347. /// <returns>
  348. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  349. /// </returns>
  350. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  351. internal static extern int SR7IF_GetMeasuringRangeZ(int lDeviceId, double up, double down);
  352. /// <summary>
  353. /// 获取编码器值64bit / Get 64-bit encoder value
  354. /// </summary>
  355. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  356. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  357. /// <param name="Encoder">返回数据指针 / Return data pointer</param>
  358. /// <returns>
  359. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  360. /// </returns>
  361. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  362. internal static extern int SR7IF_GetBatchEncoder64Bit(int lDeviceId, IntPtr DataObj, IntPtr Encoder);
  363. /// <summary>
  364. /// 获取激光器宽度数据(仅支持SRI设备) / Get laser width data (only supports SRI devices)
  365. /// </summary>
  366. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  367. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  368. /// <param name="widthData">返回数据指针,双相机为A/B行交替数据 / Return data pointer, dual cameras are A/B row alternate data</param>
  369. /// <param name="GetCnt">获取数据长度 / Get data length</param>
  370. /// <returns>
  371. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  372. /// </returns>
  373. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  374. internal static extern int SR7IF_GetLaserWidthData(int lDeviceId, IntPtr DataObj, IntPtr widthData, int GetCnt = 0);
  375. /// <summary>
  376. /// 设置有效数据范围(获取数据模式:批处理一次回调一次) / Set valid data range (data acquisition mode: one callback per batch)
  377. /// </summary>
  378. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  379. /// <param name="Left">左侧裁剪数量 / Number of left crops</param>
  380. /// <param name="Right">右侧裁剪数量 / Number of right crops</param>
  381. /// <returns>
  382. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  383. /// </returns>
  384. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  385. internal static extern int SR7IF_SetBatchOneTimeDataValidRange(int lDeviceId, int Left, int Right);
  386. /// <summary>
  387. /// 获取数据x方向间距 / Get data x-direction spacing
  388. /// </summary>
  389. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  390. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  391. /// <returns>
  392. /// 返回数据x方向间距(mm) / Returns the x-direction spacing of the data (mm)
  393. /// </returns>
  394. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  395. internal static extern double SR7IF_ProfileData_XPitch(int lDeviceId, IntPtr DataObj);
  396. /// <summary>
  397. /// 获取编码器值 / Get encoder value
  398. /// </summary>
  399. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  400. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  401. /// <param name="Encoder">返回数据指针 / Return data pointer</param>
  402. /// <returns>
  403. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  404. /// </returns>
  405. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  406. internal static extern int SR7IF_GetEncoder(int lDeviceId, IntPtr DataObj, IntPtr Encoder);
  407. /// <summary>
  408. /// 非阻塞方式获取编码器值 / Get encoder value in non-blocking mode
  409. /// </summary>
  410. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  411. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  412. /// <param name="Encoder">返回数据指针 / Return data pointer</param>
  413. /// <param name="GetCnt">获取数据长度 / Get data length</param>
  414. /// <returns>
  415. /// >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
  416. /// </returns>
  417. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  418. internal static extern int SR7IF_GetEncoderContiune(int lDeviceId, IntPtr DataObj, IntPtr Encoder, int GetCnt);
  419. /// <summary>
  420. /// 阻塞方式获取轮廓数据 / Get profile data in blocking mode
  421. /// </summary>
  422. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  423. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  424. /// <param name="Profile">返回数据指针 / Return data pointer</param>
  425. /// <returns>
  426. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  427. /// </returns>
  428. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  429. internal static extern int SR7IF_GetProfileData(int lDeviceId, IntPtr DataObj, IntPtr Profile);
  430. /// <summary>
  431. /// 非阻塞方式获取轮廓数据 / Get profile data in non-blocking mode
  432. /// </summary>
  433. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  434. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  435. /// <param name="Profile">返回数据指针 / Return data pointer</param>
  436. /// <param name="GetCnt">获取数据长度 / Get data length</param>
  437. /// <returns>
  438. /// >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
  439. /// </returns>
  440. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  441. internal static extern int SR7IF_GetProfileContiuneData(int lDeviceId, IntPtr DataObj, IntPtr Profile, int GetCnt);
  442. /// <summary>
  443. /// 无终止循环获取数据 / Get data in infinite loop mode
  444. /// </summary>
  445. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  446. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  447. /// <param name="Profile">返回轮廓数据指针 / Return profile data pointer</param>
  448. /// <param name="Intensity">返回亮度数据指针 / Return intensity data pointer</param>
  449. /// <param name="Encoder">返回编码器数据指针 / Return encoder data pointer</param>
  450. /// <param name="FrameId">返回帧编号数据指针 / Return frame ID data pointer</param>
  451. /// <param name="FrameLoss">返回批处理过快掉帧数量数据指针 / Return the number of frames lost due to too fast batch processing</param>
  452. /// <param name="GetCnt">获取数据长度 / Get data length</param>
  453. /// <returns>
  454. /// >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
  455. /// </returns>
  456. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  457. internal static extern int SR7IF_GetBatchRollData(int lDeviceId, IntPtr DataObj, IntPtr Profile, IntPtr Intensity, IntPtr Encoder, IntPtr FrameId, IntPtr FrameLoss, int GetCnt);
  458. /// <summary>
  459. /// 无终止循环设定终止行数(该设置断电不保存) / Set the termination line number for infinite loop (this setting is not saved after power off)
  460. /// </summary>
  461. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  462. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  463. /// <param name="points">设定行数,范围(0:无终止循环。≥15000:设定终止行数,其他无效) / Set the number of lines, range (0: infinite loop. ≥15000: set termination line number, others invalid)</param>
  464. /// <returns>
  465. /// =0: 设置成功 小于0: 设置失败 / =0: setting successful less than 0: setting failed
  466. /// </returns>
  467. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  468. internal static extern int SR7IF_SetBatchRollProfilePoint(int lDeviceId, IntPtr DataObj, uint points);
  469. /// <summary>
  470. /// 无终止循环回调方式 / Infinite loop callback mode
  471. /// </summary>
  472. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  473. /// <param name="pCallBack">回调函数 / Callback function</param>
  474. /// <param name="dwProfileCnt">单次回调行数:范围0-15000 / Number of lines per callback: range 0-15000</param>
  475. /// <param name="Timeout">获取档次回调行数超时时间,单位ms <0:关闭超时 / Timeout for getting callback lines, in ms <0: disable timeout</param>
  476. /// <returns>
  477. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  478. /// </returns>
  479. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  480. internal static extern int SR7IF_RollDataCallbackInitalize(int lDeviceId, SR7IF_RollDataCallback pCallBack, int dwProfileCnt, int Timeout);
  481. /// <summary>
  482. /// 阻塞方式获取亮度数据 / Get intensity data in blocking mode
  483. /// </summary>
  484. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  485. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  486. /// <param name="Intensity">返回数据指针 / Return data pointer</param>
  487. /// <returns>
  488. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  489. /// </returns>
  490. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  491. internal static extern int SR7IF_GetIntensityData(int lDeviceId, IntPtr DataObj, IntPtr Intensity);
  492. /// <summary>
  493. /// 非阻塞获取亮度数据 / Get intensity data in non-blocking mode
  494. /// </summary>
  495. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  496. /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
  497. /// <param name="Intensity">返回数据指针 / Return data pointer</param>
  498. /// <param name="GetCnt">获取数据长度 / Get data length</param>
  499. /// <returns>
  500. /// >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
  501. /// </returns>
  502. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  503. internal static extern int SR7IF_GetIntensityContiuneData(int lDeviceId, IntPtr DataObj, IntPtr Intensity, int GetCnt);
  504. /// <summary>
  505. /// 无终止循环获取数据异常计算值 / Get abnormal calculation value of infinite loop data
  506. /// </summary>
  507. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  508. /// <param name="EthErrCnt">返回网络传输导致错误的数量 / Returns the number of errors caused by network transmission</param>
  509. /// <param name="UserErrCnt">返回用户获取导致错误的数量 / Returns the number of errors caused by user acquisition</param>
  510. /// <returns>
  511. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  512. /// </returns>
  513. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  514. internal static extern int SR7IF_GetBatchRollError(int lDeviceId, IntPtr EthErrCnt, IntPtr UserErrCnt);
  515. /// <summary>
  516. /// 获取系统错误信息 / Get system error information
  517. /// </summary>
  518. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  519. /// <param name="EthErrCnt">返回错误码数量 / Returns the number of error codes</param>
  520. /// <param name="UserErrCnt">返回错误码指针 / Returns the error code pointer</param>
  521. /// <returns>
  522. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  523. /// </returns>
  524. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  525. internal static extern int SR7IF_GetError(int lDeviceId, IntPtr pbyErrCnt, IntPtr pwErrCode);
  526. /// <summary>
  527. /// 初始化以太网高速数据通信 / Initialize Ethernet high-speed data communication
  528. /// </summary>
  529. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  530. /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
  531. /// <param name="wHighSpeedPortNo">Ethernet 通信端口设定 / Ethernet communication port settings</param>
  532. /// <param name="pCallBack">高速通信中数据接收的回调函数 / Callback function for data reception in high-speed communication</param>
  533. /// <param name="dwProfileCnt">回调函数被调用的频率. 范围1-256 / Frequency at which the callback function is called. Range 1-256</param>
  534. /// <param name="dwThreadId">线程号 / Thread number</param>
  535. /// <returns>
  536. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  537. /// </returns>
  538. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  539. internal static extern int SR7IF_HighSpeedDataEthernetCommunicationInitalize(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int wHighSpeedPortNo,
  540. HighSpeedDataCallBack pCallBack, uint dwProfileCnt, uint dwThreadId);
  541. /// <summary>
  542. /// 初始化以太网高速数据通信 / Initialize Ethernet high-speed data communication
  543. /// </summary>
  544. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  545. /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
  546. /// <param name="pCallBack">回调函数 / Callback function</param>
  547. /// <param name="dwProfileCnt">范围1-15000 / Range 1-15000</param>
  548. /// <returns>
  549. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  550. /// </returns>
  551. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  552. internal static extern int SR7IF_HighSpeedDataCallBackInitalize(int lDeviceId, [MarshalAs(UnmanagedType.LPStr)] string pEthernetConfig, SR7IF_ProfileCALLBACK pCallBack, int dwProfileCnt);
  553. /// <summary>
  554. /// 高速回调开始批处理 / High-speed callback start batch processing
  555. /// </summary>
  556. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  557. /// <param name="ImmediateBatch">0:立即开始批处理 非0:等待外部开始批处理 / 0: start batch immediately non-zero: wait for external start batch</param>
  558. /// <returns>
  559. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  560. /// </returns>
  561. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  562. internal static extern int SR7IF_StartMeasureWithHighSpeedCallback(int lDeviceId, int ImmediateBatch);
  563. /// <summary>
  564. /// 高速回调停止批处理 / High-speed callback stop batch processing
  565. /// </summary>
  566. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  567. /// <param name="instantStop">0:数据传输完成 1:立即停止,抛弃剩余未传完数据 / 0: data transmission completed 1: stop immediately, discard remaining untransmitted data</param>
  568. /// <returns>
  569. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  570. /// </returns>
  571. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  572. internal static extern int SR7IF_StopMeasureWithHighSpeedCallback(int lDeviceId, int instantStop);
  573. /// <summary>
  574. /// 高速回调获取32位高度数据 / High-speed callback get 32-bit height data
  575. /// </summary>
  576. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  577. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  578. /// <param name="Profile">接收数据指针,单点数据大小为4Bytes / Receive data pointer, single point data size is 4Bytes</param>
  579. /// <returns>
  580. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  581. /// </returns>
  582. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  583. internal static extern int SR7IF_GetProfilePointData32bit(IntPtr DataObj, int head, int[] Profile);
  584. /// <summary>
  585. /// 高速回调获取16位高度数据 / High-speed callback get 16-bit height data
  586. /// </summary>
  587. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  588. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  589. /// <param name="Profile">接收数据指针,单点数据大小为2Bytes / Receive data pointer, single point data size is 2Bytes</param>
  590. /// <param name="Scale">压缩比例 / Compression ratio</param>
  591. /// <returns>
  592. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  593. /// </returns>
  594. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  595. internal static extern int SR7IF_GetProfilePointData16bit(IntPtr DataObj, int head, IntPtr Profile, double Scale);
  596. /// <summary>
  597. /// 高速回调获取灰度数据 / High-speed callback get grayscale data
  598. /// </summary>
  599. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  600. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  601. /// <param name="Profile">接收数据指针 / Receive data pointer</param>
  602. /// <returns>
  603. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  604. /// </returns>
  605. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  606. internal static extern int SR7IF_GetHighSpeedIntensityData(IntPtr DataObj, int head, byte[] Intensity);
  607. /// <summary>
  608. /// 高速回调获取16位灰度图 / High-speed callback get 16-bit grayscale image
  609. /// </summary>
  610. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  611. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  612. /// <param name="Profile">接收数据指针,单点数据大小为2Bytes / Receive data pointer, single point data size is 2Bytes</param>
  613. /// <param name="Scale">压缩比例 / Compression ratio</param>
  614. /// <returns>
  615. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  616. /// </returns>
  617. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  618. internal static extern int SR7IF_GetGrayData16Bit(IntPtr DataObj, int head, IntPtr Profile, double Scale);
  619. /// <summary>
  620. /// 高速回调获取编码器数据 / High-speed callback get encoder data
  621. /// </summary>
  622. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  623. /// <param name="pEncoder">接收数据指针 / Receive data pointer</param>
  624. /// <returns>
  625. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  626. /// </returns>
  627. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  628. internal static extern int SR7IF_GetHighSpeedEncoderContiune(IntPtr DataObj, int[] pEncoder);
  629. /// <summary>
  630. /// 获取库版本号 / Get library version number
  631. /// </summary>
  632. /// <returns>
  633. /// 返回版本信息 / Returns version information
  634. /// </returns>
  635. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  636. internal static extern IntPtr SR7IF_GetVersion();
  637. /// <summary>
  638. /// 获取相机型号 / Get camera model
  639. /// </summary>
  640. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  641. /// <returns>
  642. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  643. /// </returns>
  644. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  645. internal static extern IntPtr SR7IF_GetModels(int lDeviceId);
  646. /// <summary>
  647. /// 获取相机头序列号 / Get camera head serial number
  648. /// </summary>
  649. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  650. /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
  651. /// <returns>
  652. /// 成功:返回相机头序列号,失败:相机头不存在或参数错误 / Success: returns camera head serial number, failure: camera head does not exist or parameter error
  653. /// </returns>
  654. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  655. internal static extern IntPtr SR7IF_GetHeaderSerial(int lDeviceId, int Head);
  656. /// <summary>
  657. /// 获取传感头B是否在线 / Get whether sensor head B is online
  658. /// </summary>
  659. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  660. /// <returns>
  661. /// 0:在线; 小于0:不在线 / 0: online; less than 0: offline
  662. /// </returns>
  663. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  664. internal static extern int SR7IF_GetOnlineCameraB(int lDeviceId);
  665. /// <summary>
  666. /// 切换相机配置的参数 / Switch camera configuration parameters
  667. /// </summary>
  668. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  669. /// <param name="No">任务参数列表编号 0 - 63 / Task parameter list number 0 - 63</param>
  670. /// <returns>
  671. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  672. /// </returns>
  673. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  674. internal static extern int SR7IF_SwitchProgram(int lDeviceId, int No);
  675. /// <summary>
  676. /// 设置输出端口电平 / Set output port level
  677. /// </summary>
  678. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  679. /// <param name="Port">输出端口号,范围为0-7 / Output port number, ranging from 0 to 7</param>
  680. /// <param name="Level">输出电平值 / Output level value</param>
  681. /// <returns>
  682. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  683. /// </returns>
  684. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  685. internal static extern int SR7IF_SetOutputPortLevel(uint lDeviceId, uint Port, bool Level);
  686. /// <summary>
  687. /// 读取输入端口电平 / Read input port level
  688. /// </summary>
  689. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  690. /// <param name="Port">输入端口号,范围为0-7 / Input port number, ranging from 0 to 7</param>
  691. /// <param name="Level">读取输入电平 / Read input level</param>
  692. /// <returns>
  693. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  694. /// </returns>
  695. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  696. internal static extern int SR7IF_GetInputPortLevel(uint lDeviceId, uint Port, IntPtr Level);
  697. /// <summary>
  698. /// 参数设定 / Parameter setting
  699. /// </summary>
  700. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  701. /// <param name="Depth">设置的值的级别 / Level of the value to be set</param>
  702. /// <param name="Type">设置类型 / Setting type</param>
  703. /// <param name="Category">设置种类 / Setting category</param>
  704. /// <param name="Item">设置项目 / Setting item</param>
  705. /// <param name="Target">根据发送/接收的设定,可能需要进行相应的指定。无需设定时,指定为0 / Depending on the send/receive settings, it may need to be specified accordingly. When no setting is needed, specify as 0</param>
  706. /// <param name="pData">设置数据 / Setting data</param>
  707. /// <param name="DataSize">设置数据的长度 / Length of setting data</param>
  708. /// <returns>
  709. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  710. /// </returns>
  711. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  712. internal static extern int SR7IF_SetSetting(uint lDeviceId, int Depth, int Type, int Category, int Item, int[] Target, IntPtr pData, int DataSize);
  713. /// <summary>
  714. /// 参数获取 / Parameter acquisition
  715. /// </summary>
  716. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  717. /// <param name="Type">设置类型 / Setting type</param>
  718. /// <param name="Category">设置种类 / Setting category</param>
  719. /// <param name="Item">设置项目 / Setting item</param>
  720. /// <param name="Target">根据发送/接收的设定,可能需要进行相应的指定。无需设定时,指定为0 / Depending on the send/receive settings, it may need to be specified accordingly. When no setting is needed, specify as 0</param>
  721. /// <param name="pData">设置数据 / Setting data</param>
  722. /// <param name="DataSize">设置数据的长度 / Length of setting data</param>
  723. /// <returns>
  724. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  725. /// </returns>
  726. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  727. internal static extern int SR7IF_GetSetting(uint lDeviceId, int Type, int Category, int Item, int[] Target, IntPtr pData, int DataSize);
  728. /// <summary>
  729. /// 获取当前一条轮廓(非批处理下) / Get current single profile (not in batch mode)
  730. /// </summary>
  731. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  732. /// <param name="pProfileData">返回轮廓的指针 / Pointer to return profile</param>
  733. /// <param name="pEncoder">返回编码器的指针 / Pointer to return encoder</param>
  734. /// <returns>
  735. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  736. /// </returns>
  737. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  738. internal static extern int SR7IF_GetSingleProfile(uint lDeviceId, [Out] int[] pProfileData, [Out] uint[] pEncoder);
  739. ///
  740. /// \brief SR7IF_GetSingleProfile3DMode 获取一条轮廓数据(非批处理下 3D模式)
  741. /// \param lDeviceId 设备ID号,范围为0-63.
  742. /// \param pProfileData 返回轮廓的指针.
  743. /// \return
  744. /// <0: 失败.
  745. /// =0: 成功.
  746. ///
  747. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  748. internal static extern int SR7IF_GetSingleProfile3DMode(uint lDeviceId, [Out] int[] pProfileData);
  749. /// <summary>
  750. /// 将导出的参数导入到系统中 / Import exported parameters into the system
  751. /// </summary>
  752. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  753. /// <param name="pSettingdata">导入参数表指针 / Pointer to import parameter table</param>
  754. /// <param name="size">导入参数表的大小 / Size of import parameter table</param>
  755. /// <returns>
  756. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  757. /// </returns>
  758. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  759. internal static extern int SR7IF_LoadParameters(uint lDeviceId, IntPtr pSettingdata, UInt32 size);
  760. /// <summary>
  761. /// 返回产品剩余天数 / Return product remaining days
  762. /// </summary>
  763. /// <param name="lDeviceId">设备ID号 / Device ID number</param>
  764. /// <param name="RemainDay">返回剩余天数 / Returns remaining days</param>
  765. /// <returns>
  766. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  767. /// </returns>
  768. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  769. internal static extern int SR7IF_GetLicenseKey(uint lDeviceId, IntPtr RemainDay);
  770. /// <summary>
  771. /// 将系统参数导出,注意只导出当前任务的参数 / Export system parameters, note that only the parameters of the current task are exported
  772. /// </summary>
  773. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  774. /// <param name="size">返回参数表的大小 / Returns the size of the parameter table</param>
  775. /// <returns>
  776. /// NULL:失败. 其他:成功 / NULL: failure. Others: success
  777. /// </returns>
  778. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  779. internal static extern IntPtr SR7IF_ExportParameters(int lDeviceId, IntPtr size);
  780. /// <summary>
  781. /// 3D显示 / 3D display
  782. /// </summary>
  783. /// <param name="_BatchData">批处理数据 / Batch data</param>
  784. /// <param name="x_true_step">x方向间矩/mm / x-direction spacing/mm</param>
  785. /// <param name="y_true_step">y方向间距/mm / y-direction spacing/mm</param>
  786. /// <param name="x_Point_num">x方向数据个数 / Number of data points in x direction</param>
  787. /// <param name="y_batchPoint_num">批处理行数 / Number of batch lines</param>
  788. /// <param name="z_scale">z方向缩放系数 / z-direction scaling factor</param>
  789. /// <param name="Ho">z方向最大值 / Maximum value in z direction</param>
  790. /// <param name="Lo">z方向最小值 / Minimum value in z direction</param>
  791. [DllImport("SR3dexe.dll", CallingConvention = CallingConvention.Cdecl)]
  792. internal static extern void SR_3D_EXE_Show(IntPtr _BatchData,
  793. double x_true_step,
  794. double y_true_step,
  795. int x_Point_num,
  796. int y_batchPoint_num,
  797. double z_scale,
  798. double Ho,
  799. double Lo
  800. );
  801. /// <summary>
  802. /// 设置回调函数,建议获取数据后另外开启线程进行处理(批处理一次回调一次) / Set callback function, it is recommended to open another thread for processing after obtaining data (one callback per batch)
  803. /// </summary>
  804. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  805. /// <param name="size">回调函数 / Callback function</param>
  806. /// <returns>
  807. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  808. /// </returns>
  809. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  810. internal static extern int SR7IF_SetBatchOneTimeDataHandler(int lDeviceId, SR7IF_BatchOneTimeCallBack CallFunc);
  811. /// <summary>
  812. /// 开始批处理 (批处理一次回调一次) / Start batch processing (one callback per batch)
  813. /// </summary>
  814. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  815. /// <param name="ImmediateBatch">0:立即开始批处理 1:等待外部开始批处理 / 0: start batch immediately 1: wait for external start batch</param>
  816. /// <returns>
  817. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  818. /// </returns>
  819. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  820. internal static extern int SR7IF_StartMeasureWithCallback(int lDeviceId, int ImmediateBatch);
  821. /// <summary>
  822. /// 批处理软件触发开始(批处理一次回调一次) / Batch software trigger start (one callback per batch)
  823. /// </summary>
  824. /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  825. /// <returns>
  826. /// 0:成功; 小于0:失败 / 0: success; less than 0: failure
  827. /// </returns>
  828. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  829. internal static extern int SR7IF_TriggerOneBatch(int lDeviceId);
  830. /// <summary>
  831. /// 批处理轮廓获取(批处理一次回调一次) / Batch profile acquisition (one callback per batch)
  832. /// </summary>
  833. /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  834. /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
  835. /// <returns>
  836. /// 返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
  837. /// </returns>
  838. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  839. internal static extern IntPtr SR7IF_GetBatchProfilePoint(IntPtr DataObj, int Head);
  840. /// <summary>
  841. /// 批处理亮度获取(批处理一次回调一次) / Batch intensity acquisition (one callback per batch)
  842. /// </summary>
  843. /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  844. /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
  845. /// <returns>
  846. /// 返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
  847. /// </returns>
  848. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  849. internal static extern IntPtr SR7IF_GetBatchIntensityPoint(IntPtr DataObj, int Head);
  850. /// <summary>
  851. /// 批处理编码器获取(批处理一次回调一次) / Batch encoder acquisition (one callback per batch)
  852. /// </summary>
  853. /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
  854. /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
  855. /// <returns>
  856. /// 返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
  857. /// </returns>
  858. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  859. internal static extern IntPtr SR7IF_GetBatchEncoderPoint(IntPtr DataObj, int Head);
  860. /// <summary>
  861. /// 查找在线设备 / Search for online devices
  862. /// </summary>
  863. /// <param name="ReadNum">搜索到的设备个数 / Number of devices found</param>
  864. /// <param name="timeOut">搜索超时时间 / Search timeout</param>
  865. /// <returns>
  866. /// 返回已搜索到的设备的 IP 地址指针 / Returns the IP address pointer of the found devices
  867. /// </returns>
  868. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  869. internal static extern IntPtr SR7IF_SearchOnline(IntPtr ReadNum, int timeOut);
  870. /// <summary>
  871. /// 异步回调连接函数 / Asynchronous callback connection function
  872. /// </summary>
  873. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  874. /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
  875. /// <param name="timeOut">搜索时间(ms),最小值100 / Search time (ms), minimum 100</param>
  876. /// <param name="fun">掉线回调函数 / Disconnection callback function</param>
  877. /// <returns>
  878. /// &lt;0: 失败 / Fail
  879. /// =0: 成功 / Success
  880. /// </returns>
  881. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  882. internal static extern int SR7IF_AsyncEthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int timeOut = 2000, SR7IF_AsyncErrCallBack errCallBackFunc = null);
  883. /// <summary>
  884. /// 初始化异步回调数据通信 / Initialize asynchronous callback data communication
  885. /// </summary>
  886. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  887. /// <param name="pCallBack">回调函数 / Callback function</param>
  888. /// <param name="pUserData">用户注册传入指针 / Pointer passed by user registration</param>
  889. /// <param name="ProfileBits">0:返回32位高度数据。1:返回16位高度数据 / 0: return 32-bit height data. 1: return 16-bit height data</param>
  890. /// <param name="mMaxLine">指定行数返回数据 / Specify the number of lines to return data</param>
  891. /// <returns>
  892. /// &lt;0: 失败 / Fail
  893. /// =0: 成功 / Success
  894. /// </returns>
  895. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  896. internal static extern int SR7IF_AsyncCallBackInitalize(int lDeviceId, SR7IF_AsyncCALLBACK pCallBack, IntPtr pUserData, uint ProfileBits = 0, uint mMaxLine = 0xFFFFFFFF);
  897. /// <summary>
  898. /// 异步回调软触发 / Asynchronous callback soft trigger
  899. /// </summary>
  900. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  901. /// <returns>
  902. /// &lt;0: 失败 / Fail
  903. /// =0: 成功 / Success
  904. /// </returns>
  905. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  906. internal static extern int SR7IF_AsyncSoftStartBatch(int lDeviceId);
  907. /// <summary>
  908. /// 异步回调停止批处理 / Asynchronous callback stop batch processing
  909. /// </summary>
  910. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  911. /// <returns>
  912. /// &lt;0: 失败 / Fail
  913. /// =0: 成功 / Success
  914. /// </returns>
  915. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  916. internal static extern int SR7IF_AsyncSoftStopBatch(int lDeviceId);
  917. /// <summary>
  918. /// 异步回调获取16位高度数据 / Asynchronous callback get 16-bit height data
  919. /// </summary>
  920. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  921. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  922. /// <returns>
  923. /// 数据指针 / Data pointer
  924. /// </returns>
  925. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  926. internal static extern IntPtr SR7IF_GetAsyncProfilePointData16Bit(IntPtr DataObj, int Head);
  927. /// <summary>
  928. /// 异步回调获取32位高度数据 / Asynchronous callback get 32-bit height data
  929. /// </summary>
  930. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  931. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  932. /// <returns>
  933. /// 数据指针 / Data pointer
  934. /// </returns>
  935. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  936. internal static extern IntPtr SR7IF_GetAsyncProfilePointData(IntPtr DataObj, int Head);
  937. /// <summary>
  938. /// 异步回调获取灰度数据 / Asynchronous callback get grayscale data
  939. /// </summary>
  940. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  941. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  942. /// <returns>
  943. /// 数据指针 / Data pointer
  944. /// </returns>
  945. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  946. internal static extern IntPtr SR7IF_GetAsyncIntensityContiuneData(IntPtr DataObj, int Head);
  947. /// <summary>
  948. /// 异步回调获取编码器数据 / Asynchronous callback get encoder data
  949. /// </summary>
  950. /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
  951. /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
  952. /// <returns>
  953. /// 数据指针 / Data pointer
  954. /// </returns>
  955. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  956. internal static extern IntPtr SR7IF_GetAsyncEncoderContiune(IntPtr DataObj, int Head);
  957. /// <summary>
  958. /// 获取16bit高度数据物理单位 / Get 16bit height data physical unit
  959. /// </summary>
  960. /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
  961. /// <param name="Scale">单位(mm) / Unit (mm)</param>
  962. /// <returns>
  963. /// 0:成功,&lt;0: 失败 / 0: success, &lt;0: failure
  964. /// </returns>
  965. [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
  966. internal static extern int SR7IF_Get16BitScale(int lDeviceId, IntPtr Scale);
  967. internal static int SR7IF_CommClose(uint controllerID)
  968. {
  969. throw new NotImplementedException();
  970. }
  971. }
  972. #endregion
  973. }