Beispiel #1
0
        /// <summary>
        ///  獲取PLC生產信息
        /// </summary>
        void GetPLCProdctionQty()
        {
            PLCProductionDataArgs prodArg = null;

            try
            {
                lock (m_objSyncRoot)
                {
                    int l_iRealCounter = 0;//PLC實際總計數,未減去清零后的計數
                    int l_iCurrentCounter = 0;//當次實際生產的數量

                    //啤機沒有生產速度的返回數據

                    float l_MachineSpeed = GetMachineSpeed();//機台速度

                    l_iRealCounter = GetMachineProdCounter();//獲取機台實際計數

                    string strLogMsg = string.Empty;

                    //獲取上次PLC清零后保存在txt中的計數
                    int l_iCounterAfterClear = EquipmentGeneral.ReadHistoryProdCounter();

                    if (l_iRealCounter >= 0 && l_iRealCounter >= l_iCounterAfterClear)/*PLC數量大於等於清零后的數量*/
                    {
                        l_iCurrentCounter = l_iRealCounter - l_iCounterAfterClear;
                    }
                    else
                    {
                        strLogMsg += "產量:" + ("PLC計數異常").PadRight(10) + Environment.NewLine;
                        strLogMsg += "PLC計數:" + l_iRealCounter.ToString().PadRight(10) + Environment.NewLine;
                        strLogMsg += "PLC清零后第一次計數:" + l_iCounterAfterClear.ToString().PadRight(10) + Environment.NewLine;

                        base.OnException(mc_strClassName, "GetPLCProdctionQty", new Exception(strLogMsg));

                        return;
                    }

                    EnmPLCStatus status = StopFacade(l_iCurrentCounter, this.m_iCurrentProdQty);

                    this.m_iCurrentProdQty = l_iCurrentCounter;

                    prodArg = new PLCProductionDataArgs();
                    prodArg.CurrentPLCStatus = status;
                    prodArg.MachineSpeed = l_MachineSpeed;
                    prodArg.ProductionQty = l_iCurrentCounter;
                    prodArg.RealProdQty = l_iRealCounter;

                    strLogMsg += "產量:" + l_iCurrentCounter.ToString().PadRight(10);
                    strLogMsg += "PLC計數:" + l_iRealCounter.ToString().PadRight(10);
                    base.WriteLog(strLogMsg);

                    if (prodArg.CurrentPLCStatus == EnmPLCStatus.Normal)
                    {
                        base.OnProductionDataRead(prodArg);
                    }
                    else if (prodArg.CurrentPLCStatus == EnmPLCStatus.Halt)
                    {
                        base.OnHaltReminding();
                    }
                    else
                    {
                        base.OnException(mc_strClassName, "GetPLCProdctionQty", "判斷停機狀態時出現異常,無法判斷狀態。");
                    }
                }
            }
            catch (Exception ex)
            {
                base.PLCOnline = false;
                base.OnException(mc_strClassName, "GetPLCProdctionQty", ex);
            }
        }
 /// <summary>
 /// PLC返回生產數據讀數
 /// </summary>
 /// <param name="args">生產數據</param>
 public void OnProductionDataRead(PLCProductionDataArgs args)
 {
     if (this.ProductionDataReadEvent != null)
     {
         this.ProductionDataReadEvent(this, args);
     }
 }
Beispiel #3
0
 /// <summary>
 ///  获取PLC关闭的响应参数
 /// </summary>
 /// <returns></returns>
 private PLCProductionDataArgs GetPLCCloseArgs()
 {
     PLCProductionDataArgs args = new PLCProductionDataArgs();
     args.CurrentPLCStatus = EnmPLCStatus.Halt;
     args.MachineSpeed = 0;
     args.ProductionQty = 0;
     return args;
 }