CInterface.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. #pragma once
  2. #include <vector>
  3. #include <string>
  4. #ifdef INTERFACE_DLL
  5. #define INTERFACE_API __declspec(dllexport)
  6. #else
  7. #define INTERFACE_API
  8. #endif
  9. using namespace std;
  10. // 图像数据类型,指向内存中的图像二进制数据
  11. typedef unsigned char* ImageDataPtr;
  12. typedef struct
  13. {
  14. double x;
  15. double y;
  16. }XY_DOUBLE_STRUCT;
  17. typedef struct
  18. {
  19. long x;
  20. long y;
  21. }XY_LONG_STRUCT;
  22. typedef struct
  23. {
  24. double x;
  25. double y;
  26. double a; //角度
  27. }X_Y_ANGLE_STRUCT;
  28. enum DEVICE_STATUS
  29. {
  30. IDLE,//停机待机
  31. RUNING,//生产
  32. CALIB,//校准
  33. WARN,//报警
  34. FAULT, //故障
  35. DIAGNOSE//诊断
  36. };
  37. enum CONNECT_STATUS
  38. {
  39. NO_CONNECT,//未连接
  40. CONNECT_ING,//连接中
  41. CONNECT_OK,//连接成功
  42. };
  43. typedef struct
  44. {
  45. string name; //设备名称
  46. string type; //设备类型
  47. DEVICE_STATUS deveicStatus; //设备状态
  48. string product; //产品批号
  49. CONNECT_STATUS connectStatus; //连接状态
  50. }DEVICE_INFO_STRUCT;
  51. enum MATERIAL_TYPE
  52. {
  53. MATERIAL_WAFER,//晶圆
  54. MATERIAL_WAFFLE,//华夫盒
  55. MATERIAL_BOX,//料盒
  56. MATERIAL_BOND //载具物料
  57. };
  58. typedef struct
  59. {
  60. int iCameraId; // 相机Id
  61. string name; // 相机名称
  62. MATERIAL_TYPE eType; //物料类型
  63. }CameraInfo;
  64. enum ImageFormat
  65. {
  66. GRAY8 = 0, // 灰度图,色值0~255 Format_Grayscale8
  67. RGB888, // 每个像素 24 位,顺序是 0xRRGGBB,没有 Alpha 通道 Format_RGB888
  68. ARGB8888, // 带有 Alpha 通道的 32 位像素格式,顺序是 0xAARRGGBB
  69. RGB32, // 每个像素 32 位,其中包含了 RGB 颜色信息,顺序通常是 0xAARRGGBB(最高字节为 Alpha 通道,但被忽略,因为 Alpha 通道总是视为 0xFF)
  70. YUV422, // YUV4:2:2
  71. };
  72. /**
  73. * @brief 存储图像信息的结构
  74. */
  75. typedef struct
  76. {
  77. int width; // 图像宽度
  78. int height; // 图像高度
  79. int channel; // 图像通道数
  80. ImageFormat format; // 图像格式
  81. ImageDataPtr data; // 图像数据
  82. }ImageInfo;
  83. enum PICK_DIE_STATUS {
  84. DIE_EXIST,/*原来的*/
  85. PICK_ING,/*正在取*/
  86. NO_EXIST,/*已取走*/
  87. SKIP_DIE,/*跳过的点*/
  88. EDGE_DIE /*边缘无效*/
  89. };
  90. typedef struct
  91. {
  92. int nDieMatrixId; //晶圆矩阵Id
  93. int nDieRow; //固晶点在矩阵中所在行
  94. int nDieCol; //固晶点在矩阵中所在列
  95. int iDieIndex; //所在Point点ID
  96. bool bDisable; //不可用点,等同于无效点
  97. PICK_DIE_STATUS eStatus; //晶片状态
  98. XY_DOUBLE_STRUCT stPosition; //程序设置的位置
  99. } WAFER_MATRIX_POINT_INFO_STRUCT;
  100. typedef struct _WAFFLE_MATRIX_POINT_STRUCT
  101. {
  102. int nPackMatrixId; //华夫盒矩阵 Id 第个Id表示一种晶圆
  103. int nPackRow; //华夫盒矩阵行数
  104. int nPackCol; //华夫盒矩阵列数
  105. int nDieMatrixId; //晶圆矩阵Id
  106. int nDieRow; //固晶点在矩阵中所在行
  107. int nDieCol; //固晶点在矩阵中所在列
  108. int iDieIndex; //当前Point在pcb中的序号
  109. bool bDisable; //不可用晶片
  110. PICK_DIE_STATUS eStatus; //晶片状态
  111. XY_DOUBLE_STRUCT stPosition; //程序设置的位置
  112. } WAFFLE_MATRIX_POINT_STRUCT; //固晶点
  113. typedef struct _BOND_INDEX_STRUCT
  114. {
  115. //UINT iProductId = 1; //固晶点所在产品Id
  116. int iPcbMatId = 1; //固晶点所在PCB Id
  117. int iPcbRow = 1; //固晶点在PCB中所在行
  118. int iPcbCol = 1; //固晶点在PCB中所在列
  119. int iPtMatId = 1; //固晶点所在Pt矩阵Id
  120. int iPtRow = 1; //固晶点在矩阵中所在行
  121. int iPtCol = 1; //固晶点在矩阵中所在列
  122. int iIndex = 1; //当前Point在整个Bond矩阵中的序号
  123. } BOND_MATRIX_POINT_INFO_STRUCT; //固晶点
  124. enum DIE_STATUS {
  125. NO_PICK = 0, /*未取晶*/
  126. WAF_PICK_DONE, /*已从晶片台取晶*/
  127. TRANSFER_BOND_DONE, /*已将晶片放到中转台*/
  128. TRANSFER_PICK_DONE, /*已从中转台取晶*/
  129. LOOKUP_CALIB_DONE, /*已上视校准*/
  130. BOND_DONE, /*已固晶*/
  131. BOND_DEL /*不固晶点*/
  132. };
  133. //过程产生的关联数据
  134. typedef struct
  135. {
  136. //流程过程中的状态数据,不保存到数据库中
  137. DIE_STATUS bDieStatus; //固晶状态
  138. bool bAlnStatus; //对点状态,是否已对点
  139. bool bIsCheck; //是否固后检测完成
  140. X_Y_ANGLE_STRUCT stLookUpOffset; //上视拍照偏差结果
  141. XY_DOUBLE_STRUCT stSetBondPosition; //程序设置的固晶位置
  142. XY_DOUBLE_STRUCT stAlnBondPosition; //对点后的固晶位置
  143. XY_DOUBLE_STRUCT stAlnOffset; //固晶点对点偏移
  144. double dAlnAngle; //对点角度
  145. XY_DOUBLE_STRUCT stCheckOffset; //固后检测结果
  146. double dCheckAngle; //固后检测角度
  147. } BOND_STATUS_STRUCT;
  148. typedef struct
  149. {
  150. BOND_MATRIX_POINT_INFO_STRUCT stIndex;
  151. BOND_STATUS_STRUCT stBondStatus;
  152. //PROCESS_INFO_STRUCT stBondInfo;
  153. } POINT_INFO_STRUCT;
  154. typedef struct
  155. {
  156. int iCurrLayers; //当前工作层
  157. int iLayersTotal; //总层数
  158. int iTopLev; //最上层高度
  159. int iBottomLev; //最下层高度
  160. XY_DOUBLE_STRUCT stPos; //料盒位置;
  161. int iStatas[32]; //每层状态,0表示空,1表示有料。
  162. int iLength; //料盒长度
  163. int iLeight; //料盒高度
  164. int iWall; //侧壁厚
  165. int iTopWall; //上壁厚
  166. int iBelowWall; //下壁厚
  167. }MATERIAL_BOX_STRUCT;
  168. typedef struct
  169. {
  170. int Lot; //批次号
  171. int PtIndex; //固晶点编号
  172. int Attribute; //0表示正常数据;1表示接手动允许数据;2表示跳过数据。其它无意义
  173. int X_Offset; //X方向偏差
  174. int X_RefMin; //X方向参考范围小值
  175. int X_RefMax; //X方向参考范围大值
  176. int Y_Offset; //Y方向偏差
  177. int Y_RefMin; //Y方向参考范围小值
  178. int Y_RefMax; //Y方向参考范围大值
  179. int Theta_Offset; //Theta方向偏差
  180. int Theta_RefMin; //Theta方向参考范围小值
  181. int Theta_RefMax; //Theta方向参考范围大值
  182. long Time; //加工时间
  183. } CPK_LIST_STRUCT;
  184. typedef struct _CONFIG_BASE_STRUCT
  185. {
  186. int iGroupId;
  187. string strName;
  188. string strDescribe;
  189. int iUserGrade;
  190. int iChangeFlag;
  191. string strValue;
  192. string strType;
  193. string strDefult;
  194. string strLowerLimit;
  195. string strUpperLimit;
  196. string strUnit;
  197. }CONFIG_BASE_STRUCT;
  198. enum LogLevel
  199. {
  200. Info,
  201. Error,
  202. Warn,
  203. Debug,
  204. Fatal,
  205. };
  206. typedef struct
  207. {
  208. LogLevel iLevel; //告警级别
  209. int iId; //告警Id
  210. string strInfo; //告警信息
  211. long lTime; //告警时间
  212. }ALARM_LIST_STRUCT;
  213. typedef struct
  214. {
  215. int iBlackNum; //阻塞次数
  216. int iId; //告警Id
  217. string strInfo; //告警信息
  218. long lTime; //告警时间
  219. }ERROR_STATISTIC_STRUCT;
  220. class INTERFACE_API CInterface
  221. {
  222. public:
  223. /// <summary>
  224. /// 获取设备信息
  225. /// </summary>
  226. /// <returns></returns>
  227. long GetDeviceInfo(DEVICE_INFO_STRUCT &info);
  228. /// <summary>
  229. /// 设置红光
  230. /// </summary>
  231. /// <param name="iCameraId">相机Id</param>
  232. /// <param name="LightValue">灯光值</param>
  233. /// <returns>成功返回0,否则返回错误码</returns>
  234. long SetRedLight(int iCameraId,int LightValue);
  235. /// <summary>
  236. /// 设置绿光
  237. /// </summary>
  238. /// <param name="LightValue">灯光值</param>
  239. /// <returns>成功返回0,否则返回错误码</returns>
  240. long SetGreenLight(int iCameraId, int LightValue);
  241. /// <summary>
  242. /// 设置蓝光
  243. /// </summary>
  244. /// <param name="iCameraId">相机Id</param>
  245. /// <param name="LightValue">灯光值</param>
  246. /// <returns>成功返回0,否则返回错误码</returns>
  247. long SetBlueLight(int iCameraId, int LightValue);
  248. /// <summary>
  249. /// 设置点光
  250. /// </summary>
  251. /// <param name="iCameraId">相机Id</param>
  252. /// <param name="LightValue">灯光值</param>
  253. /// <returns>成功返回0,否则返回错误码</returns>
  254. long SetPointLight(int iCameraId, int LightValue);
  255. /// <summary>
  256. /// 获取灯光值
  257. /// </summary>
  258. /// <param name="iCameraId">相机Id</param>
  259. /// <param name="redLightValue">红光。值为-1时,表示没有该灯</param>
  260. /// <param name="greenLightValue">绿光。值为-1时,表示没有该灯</param>
  261. /// <param name="blueLightValue">蓝光。值为-1时,表示没有该灯</param>
  262. /// <param name="pointLightValue">点光。值为-1时,表示没有该灯</param>
  263. /// <returns>成功返回0,否则返回错误码</returns>
  264. long GetLight(int iCameraId, int &redLightValue, int &greenLightValue, int &blueLightValue,int &pointLightValue);
  265. /// <summary>
  266. /// 获取相机图像。调用后会阻塞,直到有新的相机图像时才返回
  267. /// </summary>
  268. /// <param name="iCameraId">相机Id</param>
  269. /// <param name="image"></param>
  270. /// <returns>成功返回0,否则返回错误码</returns>
  271. long GrabImage(int iCameraId, ImageInfo& image);
  272. /// <summary>
  273. /// 获取CPK数据信息
  274. /// </summary>
  275. /// <param name="CpkList">CPK数据</param>
  276. /// <returns>成功返回0,否则返回错误码</returns>
  277. long GetCpkList(std::vector<CPK_LIST_STRUCT> &CpkList);
  278. /// <summary>
  279. /// 读取表中指定GroupId的配置信息
  280. /// </summary>
  281. /// <param name="iGroupId">组Id</param>
  282. /// <param name="strTableName">表名</param>
  283. /// <param name="vecConfig">返回的配置信息</param>
  284. /// <returns>成功返回0,否则返回错误码</returns>
  285. long LoadConfigDB(string strTableName, vector<int> iGroupId, vector<CONFIG_BASE_STRUCT>& vecConfig);
  286. /// <summary>
  287. /// 保存配置信息
  288. /// </summary>
  289. /// <param name="strTableName">表名</param>
  290. /// <param name="vecConfig">要保存的配置信息</param>
  291. /// <returns>成功返回0,否则返回错误码</returns>
  292. long SaveConfigDB(string strTableName, vector<CONFIG_BASE_STRUCT> vecConfig);
  293. /// <summary>
  294. /// 获取相机列表
  295. /// </summary>
  296. /// <param name="vecCamera">相机列表</param>
  297. /// <returns>成功返回0,否则返回错误码</returns>
  298. long GetCameraList(vector<CameraInfo>& vecCamera);
  299. /// <summary>
  300. /// 获取告警信息
  301. /// </summary>
  302. /// <param name="alarmList">告警列表</param>
  303. /// <returns>成功返回0,否则返回错误码</returns>
  304. long GetAlarmList(vector<ALARM_LIST_STRUCT>& alarmList);
  305. /// <summary>
  306. /// 相机移动某个位置
  307. /// </summary>
  308. /// <param name="iCameraId">相机Id</param>
  309. /// <param name="x">图像中的X像素坐标</param>
  310. /// <param name="y">图像中的y像素坐标</param>
  311. /// <returns>成功返回0,否则返回错误码</returns>
  312. long CameraMove(int iCameraId, double x, double y);
  313. /// <summary>
  314. /// 相机移动到某个位置
  315. /// </summary>
  316. /// <param name="iCameraId">相机Id</param>
  317. /// <param name="x">图像中的X像素坐标</param>
  318. /// <param name="y">图像中的y像素坐标</param>
  319. /// <returns>成功返回0,否则返回错误码</returns>
  320. long CameraMoveTo(int iCameraId, double x, double y);
  321. /// <summary>
  322. /// 像素值转为物理位置坐标
  323. /// </summary>
  324. /// <param name="iCameraId">相机Id</param>
  325. /// <param name="inX">图像中的X像素坐标X</param>
  326. /// <param name="inY">图像中的Y像素坐标</param>
  327. /// <param name="outX">转换后的物理X坐标。单位微米</param>
  328. /// <param name="outY">转换后的物理Y坐标。单位微米</param>
  329. /// <returns>成功返回0,否则返回错误码</returns>
  330. long PixelToPos(int iCameraId, double inX, double inY,double &outX,double &outY);
  331. #pragma region 晶圆接口
  332. /// <summary>
  333. /// 获取所有晶圆信息
  334. /// </summary>
  335. /// <param name="stPointInfo">晶圆信息</param>
  336. /// <returns>成功返回0,否则返回错误码</returns>
  337. long GetWaferAllPointInfo(vector<WAFER_MATRIX_POINT_INFO_STRUCT>& stPointInfo);
  338. /// <summary>
  339. /// 获取晶环尺寸
  340. /// </summary>
  341. /// <param name="iSize">获取到的尺寸</param>
  342. /// <returns>成功返回0,否则返回错误码</returns>
  343. long GetWaferSize(int& iSize);
  344. /// <summary>
  345. /// 获取晶圆尺寸
  346. /// </summary>
  347. /// <param name="iLong">长</param>
  348. /// <param name="iWide">宽</param>
  349. /// <returns>成功返回0,否则返回错误码</returns>
  350. long GetDieSize(int &iLong,int &iWide);
  351. /// <summary>
  352. /// 移动到指定的点
  353. /// </summary>
  354. /// <param name="iDieIndex"></param>
  355. /// <returns>成功返回0,否则返回错误码</returns>
  356. long MoveWaferToPoint(int iDieIndex);
  357. /// <summary>
  358. /// 从底层获取模板图片
  359. /// </summary>
  360. /// <param name="image">获取到的图片</param>
  361. /// <returns>成功返回0,否则返回错误码</returns>
  362. long GetWaferRefImage(ImageInfo& image);
  363. /// <summary>
  364. /// 获取晶圆台角度
  365. /// </summary>
  366. /// <param name="angle">获取到的角度</param>
  367. /// <returns>成功返回0,否则返回错误码</returns>
  368. long GetWaferTableAngle(double &angle);
  369. /// <summary>
  370. /// 设置矩形边界
  371. /// </summary>
  372. /// <param name="nDieMatrixId">矩阵Id</param>
  373. /// <param name="row1">左上角行号</param>
  374. /// <param name="col1">左上角列号</param>
  375. /// <param name="row2">右下角行号</param>
  376. /// <param name="col2">右下触目列号</param>
  377. /// <returns></returns>
  378. long SetWaferRectBorder(int nDieMatrixId,int row1,int col1,int row2,int col2);
  379. #pragma endregion
  380. #pragma region 华夫盒接口
  381. /// <summary>
  382. /// 获取所有晶圆信息
  383. /// </summary>
  384. /// <param name="stPointInfo">晶圆信息</param>
  385. /// <returns>成功返回0,否则返回错误码</returns>
  386. long GetWafflePackAllPointInfo(vector<WAFFLE_MATRIX_POINT_STRUCT>& stPointInfo);
  387. /// <summary>
  388. /// 移动到指定的点
  389. /// </summary>
  390. /// <param name="iDieIndex"></param>
  391. /// <returns>成功返回0,否则返回错误码</returns>
  392. long MoveWafflePackToPoint(int iDieIndex);
  393. /// <summary>
  394. /// 从底层获取模板图片
  395. /// </summary>
  396. /// <param name="image">获取到的图片</param>
  397. /// <returns>成功返回0,否则返回错误码</returns>
  398. long GetWafflePackRefImage(ImageInfo& image);
  399. /// <summary>
  400. /// 设置矩形边界
  401. /// </summary>
  402. /// <param name="nPackMatrixId">华夫盒矩阵 Id</param>
  403. /// <param name="nDieMatrixId">矩阵Id</param>
  404. /// <param name="row1">左上角行号</param>
  405. /// <param name="col1">左上角列号</param>
  406. /// <param name="row2">右下角行号</param>
  407. /// <param name="col2">右下触目列号</param>
  408. /// <returns></returns>
  409. long SetWafflePackRectBorder(int nPackMatrixId,int nDieMatrixId, int row1, int col1, int row2, int col2);
  410. #pragma endregion
  411. #pragma region 载具物料接口
  412. /// <summary>
  413. /// 获取所有晶圆信息
  414. /// </summary>
  415. /// <param name="stPointInfo">晶圆信息</param>
  416. /// <returns>成功返回0,否则返回错误码</returns>
  417. long GetBondAllPointInfo(vector<POINT_INFO_STRUCT>& stPointInfo);
  418. /// <summary>
  419. /// 移动到指定的点
  420. /// </summary>
  421. /// <param name="iDieIndex"></param>
  422. /// <returns>成功返回0,否则返回错误码</returns>
  423. long MoveBondToPoint(int iDieIndex);
  424. /// <summary>
  425. /// 从底层获取模板图片
  426. /// </summary>
  427. /// <param name="image">获取到的图片</param>
  428. /// <returns>成功返回0,否则返回错误码</returns>
  429. long GetBondRefImage(ImageInfo& image);
  430. /// <summary>
  431. /// 设置矩形边界
  432. /// </summary>
  433. /// <param name="nPackMatrixId">华夫盒矩阵 Id</param>
  434. /// <param name="nDieMatrixId">矩阵Id</param>
  435. /// <param name="row1">左上角行号</param>
  436. /// <param name="col1">左上角列号</param>
  437. /// <param name="row2">右下角行号</param>
  438. /// <param name="col2">右下触目列号</param>
  439. /// <returns></returns>
  440. long SetBondRectBorder(int nPackMatrixId, int nDieMatrixId, int row1, int col1, int row2, int col2);
  441. #pragma endregion
  442. #pragma region 料盒类
  443. /// <summary>
  444. /// 获取所有料盒信息
  445. /// </summary>
  446. /// <param name="stPointInfo">晶圆信息</param>
  447. /// <returns>成功返回0,否则返回错误码</returns>
  448. long GetMaterialBoxAllPointInfo(MATERIAL_BOX_STRUCT& stPointInfo);
  449. /// <summary>
  450. /// 移动到指定的层
  451. /// </summary>
  452. /// <param name="iLayers"></param>
  453. /// <returns>成功返回0,否则返回错误码</returns>
  454. long MoveMaterialBoxToiLayers(int iLayers);
  455. #pragma endregion
  456. //long GetErrorStatistic(long sTime,long eTime,vector<ALARM_LIST_STRUCT>& alarmList);
  457. };