MelsecFxSerialReadBool 方法 (String, UInt16) |
命名空间: HslCommunication.Profinet.Melsec
MelsecFxSerial melsecFx = new MelsecFxSerial( ); melsecFx.SerialPortInni( sp => { sp.PortName = "COM1"; sp.BaudRate = 9600; sp.DataBits = 7; sp.StopBits = System.IO.Ports.StopBits.One; sp.Parity = System.IO.Ports.Parity.Even; } ); melsecFx.Open( ); // 以下是简单的读取,没有仔细校验的方式 bool X1 = melsecFx.ReadBool( "X1" ).Content; bool[] X1_10 = melsecFx.ReadBool( "X1", 10 ).Content; // 如果需要判断是否读取成功 OperateResult<bool> R_X1 = melsecFx.ReadBool( "X1" ); if (R_X1.IsSuccess) { // success bool value = R_X1.Content; } else { // failed } OperateResult<bool[]> R_X1_10 = melsecFx.ReadBool( "X1", 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 }