| | |
| | | /// </summary> |
| | | /// <param name="orderName">IOç¹åç§°</param> |
| | | /// <returns></returns> |
| | | public override DataType ReadByOrder<DataType>(string orderName) |
| | | public override DataType ReadByOrder<DataType>(string orderName, string Method = null) |
| | | { |
| | | var item = itemGroups.Where(t => t.name.Equals(orderName)).FirstOrDefault(); |
| | | if (Method != null) { item = itemGroups.Where(t => t.name.Equals(orderName) && t.Methods.Equals(Method)).FirstOrDefault(); } |
| | | if (item == null) |
| | | { |
| | | throw new Exception($"PLC{PLCName},æªå®ä¹æä»¤{orderName}"); |
| | |
| | | else if (typeof(DataType) == typeof(string))//å符串 |
| | | { |
| | | var str = GetContent(siemensPLCClient.ReadString(item.dbAddress, (ushort)item.dataLen), item).ToString(); |
| | | str = str.Replace("\0", ""); |
| | | str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", ""); |
| | | return (DataType)(str as object); |
| | | } |
| | | else |
| | |
| | | /// </summary> |
| | | /// <param name="orderName"></param> |
| | | /// <exception cref="Exception"></exception> |
| | | public override bool WriteByOrder(string orderName, object value) |
| | | public override bool WriteByOrder(string orderName, object value, string Method = null) |
| | | { |
| | | lock (_lockWrite) |
| | | { |
| | | var item = itemGroups.Where(t => t.name.Equals(orderName)).FirstOrDefault(); |
| | | if (Method != null) { item = itemGroups.Where(t => t.name.Equals(orderName) && t.Methods.Equals(Method)).FirstOrDefault(); } |
| | | if (item == null) |
| | | { |
| | | throw new Exception($"PLC{PLCName},æªå®ä¹æä»¤{orderName}"); |