123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- #pragma once
- #pragma execution_character_set("utf-8")
- #include <QtWidgets/QMainWindow>
- #include <QTimer>
- #include <QList>
- #include "ui_CGH_Printer.h"
- //#include "LoopThread.h"
- //#include "CGH_CheckStateThread.h"
- #include "CGH_Shutter.h"
- #include "PrintThread.h"
- #include "PI_GCS2_DLL.h"
- #include "CGH_ProjectView.h"
- #include "CGH_Project.h"
- #include <QDesktopWidget>
- #include <QCameraInfo>
- #include <QCamera>
- #include <QCameraImageCapture>
- #include <QCameraViewfinder>
- #include <QCloseEvent>
- #include <functional>
- #include "CGH_Shutter.h"
- const BOOL SERVO_ON = TRUE;
- const BOOL SERVO_OFF = FALSE;
- const BOOL ENABLE = TRUE;
- const BOOL UNABLE = FALSE;
- const int BufferSize = 2048;
- class PrintThread;
- class LoopThread;
- // class CGH_CoordinateThread;
- class CGH_Printer : public QMainWindow
- {
- Q_OBJECT
- public:
- CGH_Printer(QWidget* parent = Q_NULLPTR);
- // 变量初始化函数
- void initVariables();
- // 配置初始化函数
- void initConfigure();
- // 信号与槽绑定的初始化函数
- void initSlots();
- // 配置文件加载函数
- void ReadConfigure();
- // 工程文件加载函数
- void loadHistory();
- // 获取SLM当前状态
- bool get_SLMState() {
- return curSLMState;
- }
- // 获取Shutter当前状态
- bool get_ShutterState() {
- return curShutterState;
- }
- // 获取TransTable当前状态
- bool get_TransTableState() {
- return curTransTableState;
- }
- // 获取CCD当前状态
- bool get_CCDState() {
- return curCCDState;
- }
- // 获取ControllerID
- int get_ControllerID() {
- return ControllerID;
- }
- // 添加工程文件
- void addProject(CGH_Project* pj);
- void addProject(const string& name);
- // 获取CCD数量函数
- int GetCamerasNum() {
- m_pCameraInfos = QCameraInfo::availableCameras();
- return m_pCameraInfos.size();
- }
- // 获取显示器数量函数
- /*int GetSLMNum() {
- return SLM_Num;
- }*/
- // 设备
- void ComboDevice();
- // 格式和帧率
- void ComboFormatandFramerate();
- // 开启相机
- void OpenCamera();
- // 关闭相机
- void CloseCamera();
- // SLM显示弹窗设置
- void SLMDisplay();
-
- /***平移台相关函数***/
- // 平移台连接
- void PITransTableInit();
- // 平移台运动等待
- // bool WaitForMotionDone(int ID, std::string axis);
- // 工作状态
- void BusyState();
- void ReadyState();
- // 读取平移台配置
- void ReadTransTableConfigue();
-
- // 格式转换
- string numberToString(int n, int l = 3);
- string formatTime(long ss);
- // 打印变量获取
- double Get_PrintLSpacing() {
- return PrintLSpacing;
- }
- double Get_PrintCSpacing() {
- return PrintCSpacing;
- }
- int Get_PrintLine() {
- return PrintLine;
- }
- int Get_PrintColumn() {
- return PrintColumn;
- }
- string Get_PrintPrefix() {
- return PrintPrefix;
- }
- int Get_PrintExpose() {
- return PrintExpose;
- }
- int Get_PrintQuiet() {
- return PrintQuiet;
- }
- string Get_PrintResource() {
- return PrintResource;
- }
- vector<int> Get_Devices() {
- return Devices;
- }
- string Get_sAxis() {
- return sAxis;
- }
- bool Get_PRINTSTOP() {
- return PRINTSTOP;
- }
- signals:
- //void isDone(int);
- //void isDone(string);
- void sendCGH(QString CGHName);//传递全息图地址到子线程中
- void sendtime(int EXtime);//传递时间到子线程中
- public slots:
- void timerUpdate();
- // void StateUpdate(int);
- void CoordinateUpdate();
- void NewProject();
- void ModifyProject();
- void DeleteProject();
- void PrintTemp();
- void Print();
- void PrintProgress();
- void Preview();
- void Snapshot();
- void ChangeDevice();
- void ChangeFormat();
- // 全息图加载
- void CGHLoad();
- void CGHLoad_loop();
- // 工作状态检测
- void WorkStateUpdate();
- void ExposeUpdate();
- void WorkTimeUpdate();
- void PrintOKUpdate();
- void PrintCancelUpdate();
- // ***电控平移台*** //
-
- // 平移台前移
- void MoveUp();
- // 平移台后移
- void MoveDown();
- // 平移台左移
- void MoveLeft();
- // 平移台右移
- void MoveRight();
- // 平移台急停
- void TranstableStop();
- // 平移台回零
- void MoveZero();
- // 上料
- // ***电子快门*** //
-
- // 电子快门曝光
- void Expose();
- void Expose_1();
- void Expose_2();
- void Expose_3();
- void Expose_loop();
- // 电子快门停止
- void ShutterStop();
- void ShutterStop_1();
- void ShutterStop_2();
- void ShutterStop_3();
- // 上料
- void Feed();
- // 下料
- void Underfeed();
- // 暂时保存配置
- void TempSaved();
- // 永久保存配置
- void PermSaved();
- // 打印过程中更新空间光调制器
- void SLMUpdate(const QString& tempCGH);
- void SLMUpdate_loop();//图片定时器的槽函数
- // 打印过程中更新打印进度
- void PrintUpdate(int tempLL, int tempCC);
- void PrintStop();
- private:
- Ui::CGH_PrinterClass ui;
- // 关闭程序
- void closeEvent(QCloseEvent* event);
- // 配置相关变量
- string absPath, absConfigurePath, absProjectPath, absCapturePath, absResourcesPath;// 绝对路径
- string relConfigurePath, relProjectPath, relCapturePath, relResourcesPath;// 相对路径
- string ProjectType, ConfigureName;
- QString loopCGH;//定义加载循环图片的变量
- // SLM显示
- QDesktopWidget* Desktop;
- QLabel* labelPrint;
- // 定时器对象
- QTimer* timer_calendar;
- QTimer* timer_WorkState;
- QTimer* timer_Expose;
- QTimer* timer_Work;
- QTimer* timer_loop;
- // CGH_CheckStateThread* CheckState;// 硬件状态检测线程对象
- // CGH_CoordinateThread* Coordinate;// 平移台坐标更新线程对象
- PrintThread* m_Printer;
- LoopThread* m_LoopThread;
- // CCD相关变量
- QList<QCameraInfo> m_pCameraInfos;
- QCameraImageCapture* m_pCameraCapture;
- QCamera* m_pCamera;
- QCameraViewfinder* m_pViewfinder;
- int m_pCameraIndex;
- BOOL m_pCameraOpen;
- // 硬件连接状态检测相关变量
- QImage* icon_Red;
- QImage* icon_Green;
- bool curSLMState; // SLM当前连接状态
- bool curShutterState;// 电子快门当前连接状态
- bool curTransTableState;// 平移台当前连接状态
- bool curCCDState;// CCD当前连接状态
- bool curShutterWorkState;// 电子快门当前工作状态
- // 平移台相关变量
- int ControllerID;
- int DeviceNum;
- char* ControllerIDN;
- vector<int> Devices;
- string sAxis;
- // 电子快门相关变量
- // QElapsedTimer* t1;
- CGH_Shutter* MyShutter;
- QList<QString> error_messages{};
- // 平移台轴坐标实时更新
- double CoordinateX = 0;
- double CoordinateY = 0;
- QButtonGroup* pButtonGroup; // 创建按钮组
- // 工作变量
- string PrintName;// 文件名
- double PrintLSpacing, PrintCSpacing;// 横向、纵向
- int PrintLine, PrintColumn;// 行、列
- string PrintPrefix;// 前缀
- int PrintExpose, PrintQuiet;// 曝光、静台
- string PrintResource;// 资源
- int PrintLL, PrintCC;// 打印进度行、列
- int CurProgress, FulProgress;// 当前打印进度和总打印进度
- clock_t timePrintStart, timePrintCur;// 打印开始时间和当前时间
- long Printtimed;//已打印时间
- // 配置变量
- double AccX, DecX, MaxvX;
- double AccY, DecY, MaxvY;
- const unsigned int Acc = 0xB;
- const unsigned int Dec = 0xC;
- const unsigned int Maxv = 0x49;
- const char *szPassword = "100";
- bool PRINTSTOP;
- };
|