public ProjectProductionRealTimeManager()
        {
            this._currentProductionSpeed = 0;
            this._isRealTimeProductionDataCollator = false;
            this._isPLCMachineHalting = -1;
            this._isPLCDisconnect = true;
            this._isPause = false;
            this._isOpenVirtualMachine = false;
            this.ProjectFinishType = CommonDefine.ProjectFinishType.Empty;
            this._currentProjectStatus = CustEnum.ProjectStatus.INITIAL;

            this._realTimeProductionDataUpdateTimer = new Timer();

            this._realTimeProductionDataUpdateTimer.Enabled = true;
            this._realTimeProductionDataUpdateTimer.Interval = 1000;
            this._realTimeProductionDataUpdateTimer.Elapsed += new ElapsedEventHandler(RealTimeProductionDataUpdateTimer_Elapsed);

            this.SignalLightControler = new SignalLightControler();

            this.SignalLightControler.ExceptionEvent += new EventHandler<EventBaseInfo<Exception>>(SignalLightControler_ExceptionEvent);
        }
 /// <summary>
 /// 檢查是否停機超時
 /// </summary>
 /// <param name="timeHaltBegin">停機開始時間</param>
 /// <param name="iForecastTime">預計需時</param>
 /// <param name="iDinnerTime">用餐時間</param>
 private void StopOverTimeCheck(DateTime? timeHaltBegin, int iForecastTime, int iDinnerTime)
 {
     if (timeHaltBegin == null)
     {
         return;
     }
     if (iForecastTime > 0)
     {
         DateTime dtNow = DateTime.Now;
         int iHaveStopedTime = (int)(dtNow - timeHaltBegin.Value).TotalSeconds - iDinnerTime;//已停機時間
         int iHaltOverTime = iForecastTime - iHaveStopedTime;//停機超時時間
         if (iHaltOverTime < 0)
         {
             if (this.m_statusProj != CustEnum.ProjectStatus.PROD_STOP_OT)
             {
                 this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP_OT;
                 if (m_CurrentHaltLogicStatus == EnmHaltLogicStatus.Running)
                 {
                     //當停機超時時間大於零,且當前狀態為非生產中停機狀態,則通知中心已超時
                     base.OnMachineHaltStatusChanged(CustEnum.ProjectStatus.PROD_STOP_OT);
                 }
             }
         }
         else
         {
             if (this.m_statusProj != CustEnum.ProjectStatus.PROD_STOP)
             {
                 this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP;
                 if (m_CurrentHaltLogicStatus == EnmHaltLogicStatus.Running)
                 {
                     base.OnMachineHaltStatusChanged(CustEnum.ProjectStatus.PROD_STOP);
                 }
             }
         }
     }
     else
     {
         if (this.m_statusProj != CustEnum.ProjectStatus.PROD_STOP)
         {
             this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP;
             if (m_CurrentHaltLogicStatus == EnmHaltLogicStatus.Running)
             {
                 base.OnMachineHaltStatusChanged(CustEnum.ProjectStatus.PROD_STOP);
             }
         }
     }
 }
        /// <summary>
        /// 恢復歷史停機記錄
        /// </summary>
        void RegainHistoryMachineHaltRecord(ProjectMachineHaltRecord recHalt)
        {
            base.CurrentMachineHaltRecord = recHalt;

            this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP;//當前狀態轉為生產停機狀態
            base.OnMachineHaltStatusChanged(this.m_statusProj);

            base.OnRecordEdit(recHalt);//通知界面編輯

            StartTimer_CheckOT();
        }
        /// <summary>
        /// 定時處理停機記錄的邏輯
        /// </summary>
        void m_tmrProjMacHalt_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (m_blnIsRunningHalt)
            {
                return;
            }
            m_blnIsRunningHalt = true;

            if (m_CurrentHaltLogicStatus != EnmHaltLogicStatus.Running)
            {
                m_CurrentHaltLogicStatus = EnmHaltLogicStatus.Running;
            }

            int iHaltTaskMaxCount = base.ProjectMachineHaltLogicTime * 60;//時間間隔值(秒)

            if (m_iTmrCounter_Task < iHaltTaskMaxCount)//需要達到停機記錄時間間隔時,方可進行下一步操作
            {
                m_iTmrCounter_Task++;
            }
            else//到達停機記錄創建時間間隔
            {
                if (base.CurrentMachineHaltRecord == null)
                {
                    if (base.MachineHaltRecords == null)
                    {
                        base.MachineHaltRecords = new List<ProjectMachineHaltRecord>();
                    }

                    ProjectMachineHaltRecord recHalt = CreateNewHaltRec(true);
                    if (recHalt != null)
                    {
                        base.CurrentMachineHaltRecord = recHalt;

                        base.MachineHaltRecords.Add(recHalt);//將新的停機記錄添加到當前品檢記錄列表

                        base.OnProductionChanged(recHalt);//通知中心更新

                        this.m_statusProj = CustEnum.ProjectStatus.PROD_STOP;//當前狀態轉為生產停機狀態
                        base.OnMachineHaltStatusChanged(this.m_statusProj);

                        base.OnRecordEdit(recHalt);//通知界面編輯

                        m_tmrProjMacHalt.Stop();
                        m_iTmrCounter_Task = 0;

                        StartTimer_CheckOT();
                    }
                    else
                    {
                        base.OnException(mc_ControllerName, "m_tmrProjMacHalt_Elapsed", "無法創建新的停機記錄。" + DateTime.Now.ToString());
                    }

                }
                else
                {
                    m_tmrProjMacHalt.Stop();
                    m_iTmrCounter_Task = 0;
                }

                m_iTmrCounter_Task = 0;//將時間置零,準備下次操作
            }

            m_blnIsRunningHalt = false;
        }
 /// <summary>
 /// 初始化參數
 /// </summary>
 void InitParams()
 {
     m_dtHaltBegin = null;
     m_statusProj = CustEnum.ProjectStatus.PROD_STOP;
     m_iTmrCounter_Task = 0;
     m_CurrentHaltLogicStatus = EnmHaltLogicStatus.None;
     m_dtPause = null;
     m_blnIsRunningHalt = false;
     m_blnIsCheckingHaltOverTime = false;
 }
 /// <summary>
 /// 重置
 /// </summary>
 public override void Reset()
 {
     this._currentProjectStatus = CustEnum.ProjectStatus.INITIAL;
 }
        /// <summary>
        /// 生產工程狀態設置
        /// </summary>
        /// <param name="projectStatus">工程狀態</param>
        public override void ProductionProjectStatusSetting(CustEnum.ProjectStatus projectStatus)
        {
            if (this._currentProjectStatus != projectStatus)
            {
                if (projectStatus != CustEnum.ProjectStatus.INITIAL)
                {
                    this._currentProjectStatus = projectStatus;
                }

                this.SetSingnalLightStatus(projectStatus);

                this.OnMachineProductionStatusChange(projectStatus);
            }
        }