BatchAxisController.cs 2.3 KB
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineStore.DeviceLibrary
{
    /// <summary>
    /// 批量上下料 轴,检测料盘检测信号处理
    /// </summary>
    public class BatchAxisController
    {
      
        private static  bool IsStop = false;
        private static  System.Timers.Timer checkTimer = null;
        private static string TargetIoType = IO_Type.TrayCheck_LoadMaterial;
        public static bool StartCheck(string targetIo)
        {
            if (checkTimer == null)
            {
                checkTimer = new System.Timers.Timer();
                checkTimer.AutoReset = true;
                checkTimer.Interval += 50;
                checkTimer.Elapsed += CheckTimer_Elapsed;
                checkTimer.Enabled = false;
            }
            TargetIoType = targetIo;
            checkTimer.Start(); 
            return true;
        }
         
        public static bool StopCheck()
        {
            if (!(checkTimer == null))
            {
                checkTimer.Stop();
            }
            return true;
        }
        private static  bool IsInProcess = false;
        private static void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (IsInProcess) { return; }
            IsInProcess = true;
            bool result = false;
            if (KND.IOValue(TargetIoType).Equals(IO_VALUE.HIGH))
            { 
                LogUtil.info("批量上料轴,检测到【" + TargetIoType + "】信号,可以停止运动"); 
                result = true;
            }
            //else if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1))
            //{ 
            //    LogUtil.info("批量上料轴,检测到正极限信号,可以停止运动");
            //    result = true; 
            //}
            if (result)
            {
                //AutoAxisIsMove = 0;
                LogUtil.debug("批量上料轴, 停止运动");
                ACServerManager.SuddenStop(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue());
                StopCheck();
            }
            IsInProcess = false;
        }
    }
}