CGH_Printer.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. #pragma once
  2. #pragma execution_character_set("utf-8")
  3. #include <QtWidgets/QMainWindow>
  4. #include <QTimer>
  5. #include <QList>
  6. #include "ui_CGH_Printer.h"
  7. //#include "CGH_CheckStateThread.h"
  8. #include "CGH_Shutter.h"
  9. #include "PrintThread.h"
  10. #include "PI_GCS2_DLL.h"
  11. #include "CGH_ProjectView.h"
  12. #include "CGH_Project.h"
  13. #include <QDesktopWidget>
  14. #include <QCameraInfo>
  15. #include <QCamera>
  16. #include <QCameraImageCapture>
  17. #include <QCameraViewfinder>
  18. #include <QCloseEvent>
  19. #include <functional>
  20. #include "CGH_Shutter.h"
  21. const BOOL SERVO_ON = TRUE;
  22. const BOOL SERVO_OFF = FALSE;
  23. const BOOL ENABLE = TRUE;
  24. const BOOL UNABLE = FALSE;
  25. const int BufferSize = 2048;
  26. class PrintThread;
  27. // class CGH_CoordinateThread;
  28. class CGH_Printer : public QMainWindow
  29. {
  30. Q_OBJECT
  31. public:
  32. CGH_Printer(QWidget* parent = Q_NULLPTR);
  33. // 变量初始化函数
  34. void initVariables();
  35. // 配置初始化函数
  36. void initConfigure();
  37. // 信号与槽绑定的初始化函数
  38. void initSlots();
  39. // 配置文件加载函数
  40. void ReadConfigure();
  41. // 工程文件加载函数
  42. void loadHistory();
  43. // 获取SLM当前状态
  44. bool get_SLMState() {
  45. return curSLMState;
  46. }
  47. // 获取Shutter当前状态
  48. bool get_ShutterState() {
  49. return curShutterState;
  50. }
  51. // 获取TransTable当前状态
  52. bool get_TransTableState() {
  53. return curTransTableState;
  54. }
  55. // 获取CCD当前状态
  56. bool get_CCDState() {
  57. return curCCDState;
  58. }
  59. // 获取ControllerID
  60. int get_ControllerID() {
  61. return ControllerID;
  62. }
  63. // 添加工程文件
  64. void addProject(CGH_Project* pj);
  65. void addProject(const string& name);
  66. // 获取CCD数量函数
  67. int GetCamerasNum() {
  68. m_pCameraInfos = QCameraInfo::availableCameras();
  69. return m_pCameraInfos.size();
  70. }
  71. // 获取显示器数量函数
  72. /*int GetSLMNum() {
  73. return SLM_Num;
  74. }*/
  75. // 设备
  76. void ComboDevice();
  77. // 格式和帧率
  78. void ComboFormatandFramerate();
  79. // 开启相机
  80. void OpenCamera();
  81. // 关闭相机
  82. void CloseCamera();
  83. // SLM显示弹窗设置
  84. void SLMDisplay();
  85. /***平移台相关函数***/
  86. // 平移台连接
  87. void PITransTableInit();
  88. // 平移台运动等待
  89. // bool WaitForMotionDone(int ID, std::string axis);
  90. // 工作状态
  91. void BusyState();
  92. void ReadyState();
  93. // 读取平移台配置
  94. void ReadTransTableConfigue();
  95. // 格式转换
  96. string numberToString(int n, int l = 3);
  97. string formatTime(long ss);
  98. // 打印变量获取
  99. double Get_PrintLSpacing() {
  100. return PrintLSpacing;
  101. }
  102. double Get_PrintCSpacing() {
  103. return PrintCSpacing;
  104. }
  105. int Get_PrintLine() {
  106. return PrintLine;
  107. }
  108. int Get_PrintColumn() {
  109. return PrintColumn;
  110. }
  111. string Get_PrintPrefix() {
  112. return PrintPrefix;
  113. }
  114. int Get_PrintExpose() {
  115. return PrintExpose;
  116. }
  117. int Get_PrintQuiet() {
  118. return PrintQuiet;
  119. }
  120. string Get_PrintResource() {
  121. return PrintResource;
  122. }
  123. vector<int> Get_Devices() {
  124. return Devices;
  125. }
  126. string Get_sAxis() {
  127. return sAxis;
  128. }
  129. bool Get_PRINTSTOP() {
  130. return PRINTSTOP;
  131. }
  132. signals:
  133. //void isDone(int);
  134. //void isDone(string);
  135. public slots:
  136. void timerUpdate();
  137. // void StateUpdate(int);
  138. void CoordinateUpdate();
  139. void NewProject();
  140. void ModifyProject();
  141. void DeleteProject();
  142. void PrintTemp();
  143. void Print();
  144. void PrintProgress();
  145. void Preview();
  146. void Snapshot();
  147. void ChangeDevice();
  148. void ChangeFormat();
  149. // 全息图加载
  150. void CGHLoad();
  151. // 工作状态检测
  152. void WorkStateUpdate();
  153. void ExposeUpdate();
  154. void WorkTimeUpdate();
  155. void PrintOKUpdate();
  156. void PrintCancelUpdate();
  157. // ***电控平移台*** //
  158. // 平移台前移
  159. void MoveUp();
  160. // 平移台后移
  161. void MoveDown();
  162. // 平移台左移
  163. void MoveLeft();
  164. // 平移台右移
  165. void MoveRight();
  166. // 平移台急停
  167. void TranstableStop();
  168. // 平移台回零
  169. void MoveZero();
  170. // 上料
  171. // ***电子快门*** //
  172. // 电子快门曝光
  173. void Expose();
  174. // 电子快门停止
  175. void ShutterStop();
  176. // 上料
  177. void Feed();
  178. // 下料
  179. void Underfeed();
  180. // 暂时保存配置
  181. void TempSaved();
  182. // 永久保存配置
  183. void PermSaved();
  184. // 打印过程中更新空间光调制器
  185. void SLMUpdate(const QString& tempCGH);
  186. // 打印过程中更新打印进度
  187. void PrintUpdate(int tempLL, int tempCC);
  188. void PrintStop();
  189. private:
  190. Ui::CGH_PrinterClass ui;
  191. // 关闭程序
  192. void closeEvent(QCloseEvent* event);
  193. // 配置相关变量
  194. string absPath, absConfigurePath, absProjectPath, absCapturePath, absResourcesPath;// 绝对路径
  195. string relConfigurePath, relProjectPath, relCapturePath, relResourcesPath;// 相对路径
  196. string ProjectType, ConfigureName;
  197. // SLM显示
  198. QDesktopWidget* Desktop;
  199. QLabel* labelPrint;
  200. // 定时器对象
  201. QTimer* timer_calendar;
  202. QTimer* timer_WorkState;
  203. QTimer* timer_Expose;
  204. QTimer* timer_Work;
  205. // CGH_CheckStateThread* CheckState;// 硬件状态检测线程对象
  206. // CGH_CoordinateThread* Coordinate;// 平移台坐标更新线程对象
  207. PrintThread* m_Printer;
  208. // CCD相关变量
  209. QList<QCameraInfo> m_pCameraInfos;
  210. QCameraImageCapture* m_pCameraCapture;
  211. QCamera* m_pCamera;
  212. QCameraViewfinder* m_pViewfinder;
  213. int m_pCameraIndex;
  214. BOOL m_pCameraOpen;
  215. // 硬件连接状态检测相关变量
  216. QImage* icon_Red;
  217. QImage* icon_Green;
  218. bool curSLMState; // SLM当前连接状态
  219. bool curShutterState;// 电子快门当前连接状态
  220. bool curTransTableState;// 平移台当前连接状态
  221. bool curCCDState;// CCD当前连接状态
  222. bool curShutterWorkState;// 电子快门当前工作状态
  223. // 平移台相关变量
  224. int ControllerID;
  225. int DeviceNum;
  226. char* ControllerIDN;
  227. vector<int> Devices;
  228. string sAxis;
  229. // 电子快门相关变量
  230. // QElapsedTimer* t1;
  231. CGH_Shutter* MyShutter;
  232. QList<QString> error_messages{};
  233. // 平移台轴坐标实时更新
  234. double CoordinateX = 0;
  235. double CoordinateY = 0;
  236. QButtonGroup* pButtonGroup; // 创建按钮组
  237. // 工作变量
  238. string PrintName;// 文件名
  239. double PrintLSpacing, PrintCSpacing;// 横向、纵向
  240. int PrintLine, PrintColumn;// 行、列
  241. string PrintPrefix;// 前缀
  242. int PrintExpose, PrintQuiet;// 曝光、静台
  243. string PrintResource;// 资源
  244. int PrintLL, PrintCC;// 打印进度行、列
  245. int CurProgress, FulProgress;// 当前打印进度和总打印进度
  246. clock_t timePrintStart, timePrintCur;// 打印开始时间和当前时间
  247. long Printtimed;//已打印时间
  248. // 配置变量
  249. double AccX, DecX, MaxvX;
  250. double AccY, DecY, MaxvY;
  251. const unsigned int Acc = 0xB;
  252. const unsigned int Dec = 0xC;
  253. const unsigned int Maxv = 0x49;
  254. const char *szPassword = "100";
  255. bool PRINTSTOP;
  256. };