点击或拖拽改变大小

OmronHostLinkOverTcpReadBool 方法 (String, UInt16)

从欧姆龙PLC中批量读取位软元件,地址格式为"D100.0","C100.0","W100.0","H100.0","A100.0"
Read bit devices in batches from Omron PLC with address format "D100.0", "C100.0", "W100.0", "H100.0", "A100.0"

命名空间:  HslCommunication.Profinet.Omron
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法
public override OperateResult<bool[]> ReadBool(
	string address,
	ushort length
)

参数

address
类型:SystemString
读取地址,格式为"D100","C100","W100","H100","A100"
length
类型:SystemUInt16
读取的长度

返回值

类型:OperateResultBoolean
带成功标志的结果数据对象

实现

IReadWriteNetReadBool(String, UInt16)
IReadWriteNetReadBool(String, UInt16)
示例
ReadBool示例
OmronFinsNet omronFinsNet = new OmronFinsNet( "192.168.1.110", 9600 );

// 以下是简单的读取,没有仔细校验的方式
bool X1 = omronFinsNet.ReadBool( "D100.1" ).Content;
bool[] X1_10 = omronFinsNet.ReadBool( "D100.1", 10 ).Content;

// 如果需要判断是否读取成功
OperateResult<bool> R_X1 = omronFinsNet.ReadBool( "D100.1" );
if (R_X1.IsSuccess)
{
    // success
    bool value = R_X1.Content;
}
else
{
    // failed
}


OperateResult<bool[]> R_X1_10 = omronFinsNet.ReadBool( "D100.1", 10 );
if (R_X1_10.IsSuccess)
{
    // success
    bool x1 = R_X1_10.Content[0];
    bool x2 = R_X1_10.Content[1];
    bool x3 = R_X1_10.Content[2];
    bool x4 = R_X1_10.Content[3];
    bool x5 = R_X1_10.Content[4];
    bool x6 = R_X1_10.Content[5];
    bool x7 = R_X1_10.Content[6];
    bool x8 = R_X1_10.Content[7];
    bool x9 = R_X1_10.Content[8];
    bool xa = R_X1_10.Content[9];
}
else
{
    // failed
}
参见