using System;

namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.UPS
{
    public class ITAUPS : UPSBase
    {
        public ITAUPS(string module, string name, string scRoot):base(module, name, scRoot)
        {
            Oids.Add("InputVoltage", ".1.3.6.1.4.1.13400.2.54.2.2.1.0");//输入电压，输入电压为0说明使用UPS，要除10
            Oids.Add("BatteryVoltage", ".1.3.6.1.4.1.13400.2.54.2.5.1.0");//电池当前电压，要除10
            Oids.Add("BatteryRemainsTime", ".1.3.6.1.4.1.13400.2.54.2.5.7.0");//输入电压，输入电压为0说明使用UPS，要除10
            Oids.Add("upsOutputSource", ".1.3.6.1.4.1.13400.2.54.2.1.2.0");//当前输出源
            Oids.Add("BatteryUnderResidue", ".1.3.6.1.4.1.13400.2.54.2.5.10.0");//电量剩余百分比，直接用数值
        }

        public override void ParseOutputSource(string value)
        {

            if (value == "0") //UPS No Output 
            {
                UPSPowerAlarm = true;
            }
            else if (value == "1") // UPS On Main
            {
                UPSPowerAlarm = false;
            }
            else if (value == "2") //UPS On Battery
            {
                UPSPowerAlarm = true;
            }
        }

        public override void ParseBatteryRemainsTime(string value)
        {
            BatteryRemainsTime = Convert.ToInt32(value) / 10;
        }

        public override void ParseBatteryVoltage(string value)
        {
            BatteryVoltage = Convert.ToSingle(value) / 10;
        }

        public override void ParseInputVoltage(string value)
        {
            InputVoltage = Convert.ToSingle(value) / 10;
        }
    }
}

