DLT645With1997ReadString 方法 (String, UInt16, Encoding) |
使用指定的编码,读取字符串数据
Reads string data using the specified encoding
命名空间:
HslCommunication.Instrument.DLT
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 public override OperateResult<string> ReadString(
string address,
ushort length,
Encoding encoding
)
Public Overrides Function ReadString (
address As String,
length As UShort,
encoding As Encoding
) As OperateResult(Of String)
public:
virtual OperateResult<String^>^ ReadString(
String^ address,
unsigned short length,
Encoding^ encoding
) override
abstract ReadString :
address : string *
length : uint16 *
encoding : Encoding -> OperateResult<string>
override ReadString :
address : string *
length : uint16 *
encoding : Encoding -> OperateResult<string>
参数
- address
- 类型:SystemString
起始地址 - length
- 类型:SystemUInt16
数据长度 - encoding
- 类型:System.TextEncoding
指定的自定义的编码
返回值
类型:
OperateResultString带有成功标识的string数据
实现
IReadWriteNetReadString(String, UInt16, Encoding)IReadWriteNetReadString(String, UInt16, Encoding)备注
地址可以携带地址域信息,例如 "s=2;B6-11" 或是 "s=100000;B6-11",关于数据域信息,需要查找手册,例如:B6-30 表示: (当前)正向有功总电能
示例
以下为三菱的连接对象示例,其他的设备读写情况参照下面的代码:
MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
string d100_value = melsec_net.ReadString( "D100", 5 ).Content;
OperateResult<string> R_d100_value = melsec_net.ReadString( "D100", 5, Encoding.Unicode );
if (R_d100_value.IsSuccess)
{
string value = R_d100_value.Content;
}
else
{
}
参见