using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FLY.Modbus
{
    /// <summary>
    /// 读写操作 回调函数
    /// </summary>
    public interface IModbusRegister
    {
        /// <summary>
        /// 设置Modbus的值，会改变相应命名数据的值，并产生通知
        /// </summary>
        /// <param name="area">coil or register</param>
        /// <param name="addr">地址</param>
        /// <param name="val">值，类型为ushort[]或bool[]</param>
        /// <returns></returns>
        void SetModbusData(PLCAddressArea area, int addr, object val);

        /// <summary>
        /// 获取Modbus的数据值
        /// </summary>
        /// <param name="area">coil or register</param>
        /// <param name="addr">地址</param>
        /// <param name="num">数量</param>
        /// <returns>类型为ushort[]或bool[]</returns>
        object GetModbusData(PLCAddressArea area, int addr, int num);
    }

    /// <summary>
    /// PLC 地址空间， 线圈 or 寄存器
    /// </summary>
    public enum PLCAddressArea
    {
        /// <summary>
        /// 线圈
        /// </summary>
        Coil,
        /// <summary>
        /// 寄存器
        /// </summary>
        Register
    }
}
