123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace MECF.Framework.RT.Core.IoProviders.Common.Net
- {
- /// <summary>
- /// 所有的和设备或是交互类统一读写标准
- /// </summary>
- /// <remarks>
- /// Modbus类,PLC类均实现了本接口,可以基于本接口实现统一所有的不同种类的设备的数据交互
- /// </remarks>
- /// <example>
- /// 此处举例实现modbus,三菱,西门子三种设备的统一的数据交互
- /// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Core\IReadWriteNet.cs" region="IReadWriteNetExample" title="IReadWriteNet示例" />
- /// </example>
- public interface IReadWriteNet
- {
- #region Read Support
-
- /// <summary>
- /// 批量读取底层的数据信息,需要指定地址和长度,具体的结果取决于实现
- /// </summary>
- /// <param name="address">数据地址</param>
- /// <param name="length">数据长度</param>
- /// <returns>带有成功标识的byte[]数组</returns>
- OperateResult<byte[]> Read( string address, ushort length );
- /// <summary>
- /// 读取16位的有符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的short数据</returns>
- OperateResult<short> ReadInt16( string address );
- /// <summary>
- /// 读取16位的有符号整型数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">读取的数组长度</param>
- /// <returns>带有成功标识的short数组</returns>
- OperateResult<short[]> ReadInt16( string address, ushort length );
- /// <summary>
- /// 读取16位的无符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的ushort数据</returns>
- OperateResult<ushort> ReadUInt16( string address );
- /// <summary>
- /// 读取16位的无符号整型数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">读取的数组长度</param>
- /// <returns>带有成功标识的ushort数组</returns>
- OperateResult<ushort[]> ReadUInt16( string address, ushort length );
- /// <summary>
- /// 读取32位的有符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的int数据</returns>
- OperateResult<int> ReadInt32( string address );
- /// <summary>
- /// 读取32位有符号整型的数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<int[]> ReadInt32( string address, ushort length );
- /// <summary>
- /// 读取32位的无符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的uint数据</returns>
- OperateResult<uint> ReadUInt32( string address );
- /// <summary>
- /// 读取设备的uint类型的数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<uint[]> ReadUInt32( string address, ushort length );
- /// <summary>
- /// 读取64位的有符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的long数据</returns>
- OperateResult<long> ReadInt64( string address );
- /// <summary>
- /// 读取64位的有符号整型数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<long[]> ReadInt64( string address, ushort length );
- /// <summary>
- /// 读取64位的无符号整型
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的ulong数据</returns>
- OperateResult<ulong> ReadUInt64( string address );
- /// <summary>
- /// 读取64位的无符号整型的数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<ulong[]> ReadUInt64( string address, ushort length );
- /// <summary>
- /// 读取单浮点精度的数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的float数据</returns>
- OperateResult<float> ReadFloat( string address );
- /// <summary>
- /// 读取单浮点精度的数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<float[]> ReadFloat( string address, ushort length );
- /// <summary>
- /// 读取双浮点精度的数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的double数据</returns>
- OperateResult<double> ReadDouble( string address );
- /// <summary>
- /// 读取双浮点精度的数据的数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数组长度</param>
- /// <returns>带成功标志的结果数据对象</returns>
- OperateResult<double[]> ReadDouble( string address, ushort length );
- /// <summary>
- /// 读取字符串数据,
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="length">数据长度</param>
- /// <returns>带有成功标识的string数据</returns>
- OperateResult<string> ReadString( string address, ushort length );
- /// <summary>
- /// 读取自定义的数据类型,需要继承自IDataTransfer接口
- /// </summary>
- /// <typeparam name="T">自定义的类型</typeparam>
- /// <param name="address">起始地址</param>
- /// <returns>带有成功标识的自定义类型数据</returns>
- OperateResult<T> ReadCustomer<T>( string address ) where T : IDataTransfer, new();
- #endregion
- #region Write Support
-
- /// <summary>
- /// 写入byte数组数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, byte[] value );
- /// <summary>
- /// 写入short数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, short value );
- /// <summary>
- /// 写入short数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="values">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, short[] values );
- /// <summary>
- /// 写入int数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, int value );
- /// <summary>
- /// 写入int[]数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="values">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, int[] values );
- /// <summary>
- /// 写入long数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, long value );
- /// <summary>
- /// 写入long数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="values">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, long[] values );
- /// <summary>
- /// 写入float数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, float value );
- /// <summary>
- /// 写入float数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="values">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, float[] values );
- /// <summary>
- /// 写入double数据
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, double value );
- /// <summary>
- /// 写入double数组
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="values">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, double[] values );
- /// <summary>
- /// 写入字符串信息,编码为ASCII
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, string value );
- /// <summary>
- /// 写入指定长度的字符串信息,编码为ASCII
- /// </summary>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <param name="length">字符串的长度</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult Write( string address, string value, int length );
- /// <summary>
- /// 写入自定义类型的数据,该类型必须继承自IDataTransfer接口
- /// </summary>
- /// <typeparam name="T">类型对象</typeparam>
- /// <param name="address">起始地址</param>
- /// <param name="value">写入值</param>
- /// <returns>带有成功标识的结果类对象</returns>
- OperateResult WriteCustomer<T>( string address, T value ) where T : IDataTransfer, new();
- #endregion
- }
- }
|