RedisClientReadFromCoreServerAsync 方法 (Socket, Byte, Boolean, Boolean) |
将数据报文发送指定的网络通道上,根据当前指定的
INetMessage类型,返回一条完整的数据指令
Sends a data message to the specified network channel, and returns a complete data command according to the currently specified
INetMessage type
命名空间:
HslCommunication.Enthernet.Redis
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public override Task<OperateResult<byte[]>> ReadFromCoreServerAsync(
Socket socket,
byte[] send,
bool hasResponseData = true,
bool usePackHeader = true
)
Public Overrides Function ReadFromCoreServerAsync (
socket As Socket,
send As Byte(),
Optional hasResponseData As Boolean = true,
Optional usePackHeader As Boolean = true
) As Task(Of OperateResult(Of Byte()))
public:
virtual Task<OperateResult<array<unsigned char>^>^>^ ReadFromCoreServerAsync(
Socket^ socket,
array<unsigned char>^ send,
bool hasResponseData = true,
bool usePackHeader = true
) override
abstract ReadFromCoreServerAsync :
socket : Socket *
send : byte[] *
?hasResponseData : bool *
?usePackHeader : bool
(* Defaults:
let _hasResponseData = defaultArg hasResponseData true
let _usePackHeader = defaultArg usePackHeader true
*)
-> Task<OperateResult<byte[]>>
override ReadFromCoreServerAsync :
socket : Socket *
send : byte[] *
?hasResponseData : bool *
?usePackHeader : bool
(* Defaults:
let _hasResponseData = defaultArg hasResponseData true
let _usePackHeader = defaultArg usePackHeader true
*)
-> Task<OperateResult<byte[]>>
参数
- socket
- 类型:System.Net.SocketsSocket
指定的套接字 - send
- 类型:SystemByte
发送的完整的报文信息 - hasResponseData (Optional)
- 类型:SystemBoolean
是否有等待的数据返回,默认为 true - usePackHeader (Optional)
- 类型:SystemBoolean
[缺少 "M:HslCommunication.Enthernet.Redis.RedisClient.ReadFromCoreServerAsync(System.Net.Sockets.Socket,System.Byte[],System.Boolean,System.Boolean)" 的 <param name="usePackHeader"/> 文档]
返回值
类型:
TaskOperateResultByte接收的完整的报文信息
备注
无锁的基于套接字直接进行叠加协议的操作。
示例
假设你有一个自己的socket连接了设备,本组件可以直接基于该socket实现modbus读取,三菱读取,西门子读取等等操作,前提是该服务器支持多协议,虽然这个需求听上去比较变态,但本组件支持这样的操作。
ModbusTcpNet modbus = new ModbusTcpNet( );
MelsecMcNet melsec = new MelsecMcNet( );
SiemensS7Net siemens = new SiemensS7Net( SiemensPLCS.S1200 );
PipeTcpNet pipe = new PipeTcpNet( "192.168.0.100", 1000 );
pipe.OpenCommunication( );
OperateResult<byte[]> read_modbus = modbus.ReadFromCoreServer( pipe, SoftBasic.HexStringToBytes( "00 00 00 00 00 06 00 03 00 00 00 03" ), hasResponseData: true, usePackAndUnpack: true );
OperateResult<byte[]> read_melsec = melsec.ReadFromCoreServer( pipe, SoftBasic.HexStringToBytes( "50 00 00 FF FF 03 00 0D 00 0A 00 01 14 01 00 64 00 00 90 01 00 10" ), hasResponseData: true, usePackAndUnpack: true );
OperateResult<byte[]> read_siemens = siemens.ReadFromCoreServer( pipe, SoftBasic.HexStringToBytes( "03 00 00 24 02 F0 80 32 01 00 00 00 01 00 0E 00 05 05 01 12 0A 10 02 00 01 00 00 83 00 03 20 00 04 00 08 3B" ), hasResponseData: true, usePackAndUnpack: true );
pipe.CloseCommunication( );
参见