using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Device.Unit;
using MECF.Framework.Common.Equipment;

namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TMs
{
    public class TM : BaseDevice, IDevice, ITM
    {
        public virtual double ChamberPressure { get; }
        public virtual double ForelinePressure { get; }

        public virtual double PM1Pressure2 { get; }

        public virtual double PM2Pressure2 { get; }

        public TM(string module ) : base(module, module, module, module)
        {
         }
 

        public virtual bool Initialize()
        {
            DATA.Subscribe($"{Name}.IsAtm", () => { return CheckAtm(); });
            DATA.Subscribe($"{Name}.IsVacuum", () => { return CheckVacuum(); });
            DATA.Subscribe($"{Name}.PM1Pressure2", () => PM1Pressure2);
            DATA.Subscribe($"{Name}.PM2Pressure2", () => PM2Pressure2);
            //DATA.Subscribe($"{Name}.ForelinePressure", () => ForelinePressure);

            return true;
        }


        public virtual bool CheckAtm()
        {
            return false;
        }

        public virtual bool CheckVacuum()
        {
            return false;
        }

        public virtual bool CheckIsPumping()
        {
            return false;
        }

        public virtual bool SetFastVentValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetBufferVentValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetSlowVentValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetFastPumpValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetSlowPumpValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetTurboPumpIsoValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetTmToUnLoadVent(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetTmToLLVent(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetTurboPumpBackingValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }
        public virtual bool SetMfcVentValve(bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }
        public virtual bool SetAllValvesClose(out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetVentMfc(double flow, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool SetVentMfcFullFlow(out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool CheckTurboPumpStable()
        {
            return true;
        }

        public virtual bool CheckTurboPumpOn()
        {
            return true;
        }
        public virtual bool CheckTurboPumpOff()
        {
            return true;
        }
        public virtual bool CheckTurboPumpError()
        {
            return true;
        }
        public virtual bool TurboPumpOn()
        {
            return true;
        }
        public virtual bool TurboPumpOff()
        {
            return true;
        }
        public virtual IoSlitValve GetSlitValve(ModuleName module)
        {
            return null;
        }

        public virtual bool SetSlitValve(ModuleName module, bool isOpen, out string reason)
        {
            reason = string.Empty;
            return true;
        }

        public virtual bool CheckSlitValveOpen(ModuleName module)
        {
            return true;
        }

        public virtual bool CheckSlitValveClose(ModuleName module)
        {
            return true;
        }

        public virtual bool CheckIsoValveClose()
        {
            return true;
        }

        public virtual bool CheckIsoValveOpen()
        {
            return true;
        }

        public virtual void Monitor()
        {

        }

        public virtual void Terminate()
        {

        }

        public virtual void Reset()
        {

        }

    }
}
