using Aitex.Core.RT.OperationCenter;
using MECF.Framework.Common.OperationCenter;

namespace SicModules.PMs
{
    public partial class PMModule
    {

        private void InitInterlock()
        {
            OP.AddCheck($"{Module}.{Name}.Disconnect", new CheckPlcConnect(this));

            //OP.AddCheck($"{Module}.{Name}.Pump", new CheckPump(this));

        }

        private class CheckPlcConnect : IInterlockChecker
        {
            private PMModule _pm;
            public CheckPlcConnect(PMModule pm)
            {
                _pm = pm;
            }

            public bool CanDo(out string reason, object[] args)
            {
                if (_pm.IsBusy)
                {
                    reason = $"{_pm.Module} is in {_pm.StringFsmStatus} status, can not disconnect, should be idle";
                    return false;
                }

                reason = string.Empty;
                return true;
            }
        }
 
    }
}
