ElectricClamp.cs 2.0 KB
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlineStore.DeviceLibrary
{
    public class ElectricClamp
    {
        private static int subType = 0;
        public static bool needClamp = false;
        public ElectricClamp(int subType)
        {
            //this.subType = subType;
        }
        public static void Clamp(StoreMoveInfo moveInfo = null)
        {
            needClamp = true;
            if (!IsBusy)
            {
                IOManager.IOMove(IO_Type.Clamp_SetPos0, IO_VALUE.LOW, subType);
                IOManager.IOMove(IO_Type.Clamp_SetPos1, IO_VALUE.HIGH, subType);
                IOManager.IOMove(IO_Type.Clamp_DoAction, IO_VALUE.HIGH, subType);
            }
            if (moveInfo != null)
                moveInfo.WaitList.Add(WaitResultInfo.WaitElectricClamp());
        }
        public static bool Release(StoreMoveInfo moveInfo = null)
        {
            needClamp = false;
            if (!IsBusy)
            {
                IOManager.IOMove(IO_Type.Clamp_SetPos0, IO_VALUE.HIGH, subType);
                IOManager.IOMove(IO_Type.Clamp_SetPos1, IO_VALUE.LOW, subType);
                IOManager.IOMove(IO_Type.Clamp_DoAction, IO_VALUE.HIGH, subType);
                moveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
                return true;
            }
            else
            {
                return false;
                if (moveInfo != null)
                    moveInfo.WaitList.Add(WaitResultInfo.WaitElectricClamp());
            }
        }
        public static bool IsBusy {
            get {
                return IOManager.IOValue(IO_Type.Clamp_Busy, subType).Equals(IO_VALUE.HIGH);
            }
        }
        public static bool IsClamp {
            get
            {
                return IOManager.IOValue(IO_Type.Clamp_OnPosition, subType).Equals(IO_VALUE.HIGH);
            }
        }
    }
}