using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Khd.Core.Plc { /// /// Plc帮助类 /// public static class StaticPlcHelper { /// /// 进行高低位转换后,写入Plc地址 /// /// plc /// 写入地址 /// 值 /// 长度 public static void WriteToPoint(this Plc.S7.Plc plc,string address,string valueString,string len) { var value = GetValue(len, valueString); plc.Write(address, value); } /// /// 电气写入点位高低位转换 /// /// 点位地址位长度 /// 写入数值 /// private static object GetValue(string len, string value) { if (len == "2") { return Convert.ToInt16(value); } if (len == "4") { return Convert.ToInt32(value); } return 0; } } }