Browse Source

add Measure and ThreadStatus

HaoShuang 5 years ago
parent
commit
da928f5516
2 changed files with 225 additions and 0 deletions
  1. 93 0
      MeasureThread/Measure.cs
  2. 132 0
      MeasureThread/ThreadStatus.cs

+ 93 - 0
MeasureThread/Measure.cs

@@ -0,0 +1,93 @@
+//时间:20200610
+//作者:郝爽
+//功能:测量线程
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SmartSEMControl;
+using MeasureData;
+
+namespace MeasureThread
+{
+    public class Measure
+    {
+        //全局只有一个fatorySEM
+        static FactoryHardware factorySEM = FactoryHardware.Instance;
+        ISEMControl iSEM = factorySEM.ISEM;
+
+        //测量文件
+        private MeasureFile m_measureFile;
+        public MeasureFile MeasureFile
+        {
+            get { return this.m_measureFile; }
+            set { this.m_measureFile = value; }
+        }
+
+        //测量的切割孔
+        private List<MeasureData.CutHole> m_cutHoles;
+        public List<MeasureData.CutHole> cutHoles
+        {
+            get { return this.m_cutHoles; }
+            set { this.m_cutHoles = value; }
+        }
+
+        //工作文件夹
+        private string m_WorkingFolder;
+        public string WorkingFolder
+        {
+            get { return this.m_WorkingFolder; }
+            set { this.m_WorkingFolder = value; }
+        }
+
+        //线程状态
+        private ThreadState m_ThreadStatus;
+        public ThreadState ThreadStatus
+        {
+            get { return this.m_ThreadStatus; }
+            set { this.m_ThreadStatus = value; }
+        }
+
+        //// SEM data general
+        //CSEMDataGnrPtr m_pSEMDataGnr;
+
+        ////MeasureAppFormName
+        //CString m_strMAppFormName;
+
+        //HWND m_hWnd;
+
+        //COTSHardwareMgrPtr m_pHardwareMgr;
+
+        //构造函数
+        public Measure()
+        {
+        }
+
+        //初始化测量业务
+        public bool InitMeas(MeasureFile a_measureFile, List<CutHole> a_listMeasuableHoles)
+        {
+            return false;
+        }
+
+        //初始化测量业务
+        public bool InitMeas(MeasureFile a_measureFile)
+        {
+            return false;
+        }
+
+        //第一个孔的测试过程
+        public void FirstHole()
+        {
+            
+        }
+
+        //非第一个孔的测试过程
+        public void OtherHole()
+        {
+        }
+
+    }
+}

+ 132 - 0
MeasureThread/ThreadStatus.cs

@@ -0,0 +1,132 @@
+//时间:20200611
+//作者:郝爽
+//功能:测量状态
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MeasureThread
+{
+    //测试结果
+    public enum ThreadState
+    {
+        Ready,     //就绪
+        InProcess, //进行中
+        Waiting,   //等待,半自动化测试过程的状态
+        Failed,    //失败
+        Success    //成功
+    }
+
+    //计算时间类型
+    public enum THREAD_TIME_TYPE
+    {
+        START = 1,
+        STOPPED = 2,
+    }
+
+    public class ThreadStatus
+    {
+        //线程状态
+        private ThreadState m_threadState;
+        public ThreadState STATE
+        {
+            get { return this.m_threadState; }
+            set { this.m_threadState = value; }
+        }
+
+        //线程开始的时间
+        private DateTime m_startTime;
+        public DateTime StartTime
+        {
+            get { return this.m_startTime; }
+            set { this.m_startTime = value; }
+        }
+
+        //线程结束的时间
+        private DateTime m_endTime;
+        public DateTime EndTime
+        {
+            get { return this.m_endTime; }
+            set { this.m_endTime = value; }
+        }
+
+        //线程使用的时间
+        private TimeSpan m_UsedTime;
+        public TimeSpan UsedTime
+        {
+            get { return this.m_UsedTime; }
+            set { this.m_UsedTime = value; }
+        }
+
+        //线程当前开始的时间
+        private DateTime m_CurrentStartTime;
+        public DateTime CurrentStartTime
+        {
+            get { return this.m_CurrentStartTime; }
+            set { this.m_CurrentStartTime = value; }
+        }
+
+        //构造函数
+        public ThreadStatus()
+        {
+            Init();
+        }
+
+        public void Init()
+        {
+            m_threadState = ThreadState.Ready;
+            m_startTime = new DateTime();
+            m_endTime = new DateTime();
+            m_CurrentStartTime = new DateTime();
+            m_UsedTime = m_endTime - m_startTime;
+        }
+
+        // 计算时间
+        public bool ComputeTime(THREAD_TIME_TYPE a_nType)
+        {
+            if (a_nType == THREAD_TIME_TYPE.START)
+            {
+                if (m_startTime == new DateTime())
+                {
+                    m_startTime = DateTime.Now;
+                    m_CurrentStartTime = m_startTime;
+                }
+                else
+                {
+                    m_CurrentStartTime = DateTime.Now;
+                }
+                m_endTime = DateTime.Now;
+            }
+            else if (a_nType == THREAD_TIME_TYPE.STOPPED)
+            {
+                // set current time as end time
+                m_endTime = DateTime.Now;
+
+                // compute used time
+                TimeSpan timeUsed = new TimeSpan();
+
+                if (m_CurrentStartTime == m_startTime)
+                {
+                    // first compute time
+                    timeUsed = m_endTime - m_startTime;
+                }
+                else
+                {
+                    // not the first compute time
+                    timeUsed = m_UsedTime + ( m_endTime - m_CurrentStartTime);
+                }
+
+                m_UsedTime = timeUsed;
+            }
+            else
+            {
+                return false;
+            }
+
+            return true;
+
+        }
+    }
+}