/// <summary> /// 查询PLC位地址状态 /// </summary> /// <param name="listip"></param> /// <param name="Value"></param> public static bool PLC_QueryBit(int listip, string Value) { //%01$RC021 string strValue = SocketHelper.SendAddress(SocketHelper.socketList[listip].socket, PLCAddressHelper.RAddressReadConvert(Value)); return(PLCAddressHelper.ValueInfo(strValue)); }
/// <summary> /// 查询PLC 例如温度, /// </summary> /// <param name="ListIp">list索引的ip</param> /// <param name="Address">PLC读取的寄存器</param> /// <returns></returns> public static Double TimeAddress(int ListIp, int Address) { string DataInfo = ""; string ss = ""; string strValue = SocketHelper.SendAddress(SocketHelper.socketList[ListIp].socket, PLCAddressHelper.DTAddressReadConvert(Address)); strValue = strValue.Replace("\r", ""); string highOrder = ""; string lowOrder = ""; if (!string.IsNullOrEmpty(strValue))//未读到了正确数据 { ss = HexStr(strValue); } for (int i = 0; i < ss.Length / 4; i++) { highOrder = ss.Substring((i * 4), 2); //高位数据 09100910 lowOrder = ss.Substring((i * 4) + 2, 2); //低位数据 DataInfo = HexToTen(lowOrder + highOrder).ToString(); } return(Convert.ToDouble(DataInfo)); }