CGH_Printer.h 7.1 KB

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