namespace SlnMesnac.Plc
{
    public abstract class PlcAbsractFactory
    {
        /// <summary>
        /// 是否连接
        /// </summary>
        public abstract bool IsConnected { get; set; }
        
        /// <summary>
        /// 建立连接
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public abstract bool Connect(string ip, int port);
        
        /// <summary>
        /// 断开连接
        /// </summary>
        /// <returns></returns>
        public abstract bool DisConnect();
        
        /// <summary>
        /// 根据地址读取指定长度数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        public abstract byte[] readValueByAddress(string address,int len);
        
        /// <summary>
        /// 通过PLC地址读取int16类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract int readInt16ByAddress(string address);


        /// <summary>
        /// 通过PLC地址读取int32类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract int readInt32ByAddress(string address);


        /// <summary>
        /// 通过PLC地址写入int16类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public abstract bool writeInt16ByAddress(string address,int value);

        /// <summary>
        /// 通过PLC地址写入int32类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public abstract bool writeInt32ByAddress(string address, int value);

        /// <summary>
        /// 通过PLC地址读取string类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract string readStringByAddress(string address, ushort length);

        /// <summary>
        /// 通过PLC地址写入String类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="SFC"></param>
        /// <returns></returns>
        public abstract bool writeStringByAddress(string address, string value);

        /// <summary>
        /// 通过PLC地址读取Bool类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract bool readBoolByAddress(string address);

        /// <summary>
        /// 通过PLC地址读取心跳结果
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract bool readHeartByAddress(string address);


        /// <summary>
        /// 通过PLC地址写入Bool类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public abstract bool writeBoolByAddress(string address, bool value);

        /// <summary>
        /// 通过PLC地址写入Double类型数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public abstract bool writeDoubleByAddress(string address, int value);
    }
}