LAPTOP-SNT8I5JK\Boounion
2025-09-05 63a4a159a2dd300eafcb5b62124923fa21544217
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include "Context.h"
#include <string>
#include "CPath.h"
#include "CJobDataA.h"
#include "CJobDataB.h"
#include "CJobDataC.h"
#include "CJobDataS.h"
#include "ServoCommo.h"
#include "ProcessJob.h"
#include "CParam.h"
 
 
namespace SERVO {
    /// PJ ÉúÃüÖÜÆÚ£¨Ìù½ü E40 ³£¼û״̬£©
    enum class GlsState : uint8_t {
        NoState = 0,
        Queued,
        InProcess,
        Paused,
        Completed,
        Aborted,
        Failed
    };
 
    class CGlass : public CContext
    {
    public:
        CGlass();
        virtual ~CGlass();
        void reset();
 
    public:
        virtual std::string& getClassName();
        virtual std::string toString();
        short getCassetteSequenceNo() { return m_jobDataS.getCassetteSequenceNo(); }
        short getJobSequenceNo() { return m_jobDataS.getJobSequenceNo(); }
        MaterialsType getType();
        void setType(MaterialsType type);
        void setID(const char* pszID);
        std::string& getID();
        void setOriginPort(int port, int slot);
        void getOrginPort(int& port, int& slot);
        BOOL isScheduledForProcessing();
        void setScheduledForProcessing(BOOL bProcessing);
        CProcessJob* getProcessJob();
        void setProcessJob(CProcessJob* pProcessJob);
        CPath* getPathWithEq(unsigned int nEqId, unsigned int nUnit);
        CPath* getPath();
        void addPath(unsigned int nEqId, unsigned int nUnit);
        void serialize(CArchive& ar);
        void setJobDataS(CJobDataS* pJobDataS);
        void updateJobDataS(CJobDataS* pJobDataS);
        CJobDataS* getJobDataS();
        BOOL setBuddy(CGlass* pGlass);
        BOOL forceSetBuddy(CGlass* pGlass);
        CGlass* getBuddy();
        std::string& getBuddyId();
        int processEnd(unsigned int nEqId, unsigned int nUnit);
        BOOL isProcessed(unsigned int nEqId, unsigned int nUnit);
        int setInspResult(unsigned int nEqId, unsigned int nUnit, InspResult result);
        InspResult getInspResult(unsigned int nEqId, unsigned int nUnit);
 
    public:
        // ÐÂÔö״̬
        GlsState state() const noexcept { return m_state; }
        std::string getStateText();
        GlsState m_state{ GlsState::NoState };
        static void clampString(std::string& s, size_t maxLen);
        static std::string trimCopy(std::string s);
        std::string m_failReason;
 
        // ¡ª¡ª ×´Ì¬»ú£¨´øÊØÎÀ£©¡ª¡ª
        bool queue();           // NoState -> Queued
        bool start();           // Queued -> InProcess
        bool pause();           // InProcess -> Paused
        bool resume();          // Paused -> InProcess
        bool complete();        // InProcess -> Completed
        bool abort();           // Any (δÖÕ̬) -> Aborted
        bool fail(std::string reason); // ÈÎÒâ̬ -> Failed£¨¼Ç¼ʧ°ÜÔ­Òò£©
 
        // Ê±¼ä´Á
        std::optional<std::chrono::system_clock::time_point> m_tQueued;
        std::optional<std::chrono::system_clock::time_point> m_tStart;
        std::optional<std::chrono::system_clock::time_point> m_tEnd;
 
        // Ê±¼ä´Á£¨¿ÉÓÃÓÚ±¨±í/×·ËÝ£©
        std::optional<std::chrono::system_clock::time_point> tQueued() const { return m_tQueued; }
        std::optional<std::chrono::system_clock::time_point> tStart()  const { return m_tStart; }
        std::optional<std::chrono::system_clock::time_point> tEnd()    const { return m_tEnd; }
        void markQueued();
        void markStart();
        void markEnd();
 
        // ¹¤ÒÕ²ÎÊý
        void addParams(std::vector<CParam>& params);
        std::vector<CParam>& getParams();
 
    private:
        MaterialsType m_type;
        std::string m_strID;
        CPath* m_pPath;
        CJobDataS m_jobDataS;
        CGlass* m_pBuddy;
        std::string m_strBuddyId;
        int m_nOriginPort;
        int m_nOriginSlot;
        BOOL m_bScheduledForProcessing;            /* ÊÇ·ñ½«¼Ó¹¤´¦Àí */
        CProcessJob* m_pProcessJob;
        std::vector<CParam> m_params;            // ¹¤ÒÕ²ÎÊý
    };
}