using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using HslCommunication; namespace Tool.Model { public class HmiPointInfo { /// /// DInt 供料电机速度 /// public static readonly string feeding_motor_speed = "feeding_motor_speed"; public static Int32 GetFeedingMotorSpeed => GetValue(feeding_motor_speed); /// /// DInt 层合电机速度 /// public static readonly string Laminated_motor_speed = "Laminated_motor_speed"; public static Int32 GetLaminatedMotorSpeed => GetValue(Laminated_motor_speed); /// /// DInt 毛毡带电机速度 /// public static readonly string Felt_belt_motor_speed = "Felt_belt_motor_speed"; public static Int32 GetFeltBeltMotorSpeed => GetValue(Felt_belt_motor_speed); /// /// DInt 收料电机1速度 /// public static readonly string Receiving_Electric_motor_speed = "Receiving_Electric_motor_speed"; public static Int32 GeReceivingMotorSpeed => GetValue(Receiving_Electric_motor_speed); /// /// 层合生产数量 /// public static readonly string Product_counter2 = "Product_counter2"; public static Int32 GetProduct_counter2 => GetValue(Product_counter2); /// /// 裁切1生产数量 /// public static readonly string CQ_Chip1_counter = "CQ_Chip1_counter"; public static Int32 GetCQ_Chip1_counter => GetValue(CQ_Chip1_counter); /// /// 裁切2生产数量 /// public static readonly string CQ_Chip2_counter = "CQ_Chip2_counter"; public static Int32 GetCQ_Chip2_counter => GetValue(CQ_Chip2_counter); /// /// 裁刀1温度 /// public static readonly string QDWD1SS = "QDWD1SS"; public static Int32 GetQDWD1SS => GetValue(QDWD1SS); /// /// 裁刀1温度 /// public static readonly string QDWD2SS = "QDWD2SS"; public static Int32 GetQDWD2SS => GetValue(QDWD2SS); /// /// 设备内部温度 /// public static readonly string SWSS = "SWSS"; public static Int32 GetSWSS => GetValue(SWSS); private static Int32 GetValue(string key) { var plc = PlcConnect.Instance; var result = plc.ReadInt32(key); return result.IsSuccess ? result.Content : 0; } private static Boolean GetBoolValue(string key) { var plc = PlcConnect.Instance; var result = plc.ReadBool(key); return result.Content; } public static readonly string CUTTING_SET_TEMPERATURE1_1 = "CUTTING_SET_TEMPERATURE1_1"; public static Int32 GetCUTTING_SET_TEMPERATURE1_1 => GetValue(CUTTING_SET_TEMPERATURE1_1); public static readonly string CUTTING_SET_TEMPERATURE1_2 = "CUTTING_SET_TEMPERATURE1_2"; public static Int32 GetCUTTING_SET_TEMPERATURE1_2 => GetValue(CUTTING_SET_TEMPERATURE1_2); public static readonly string CUTTING_SET_TEMPERATURE1_3 = "CUTTING_SET_TEMPERATURE1_3"; public static Int32 GetCUTTING_SET_TEMPERATURE1_3 => GetValue(CUTTING_SET_TEMPERATURE1_3); public static readonly string CUTTING_SET_TEMPERATURE1_4 = "CUTTING_SET_TEMPERATURE1_4"; public static Int32 GetCUTTING_SET_TEMPERATURE1_4 => GetValue(CUTTING_SET_TEMPERATURE1_4); public static readonly string CUTTING_SET_TEMPERATURE2_1 = "CUTTING_SET_TEMPERATURE2_1"; public static Int32 GetCUTTING_SET_TEMPERATURE2_1 => GetValue(CUTTING_SET_TEMPERATURE2_1); public static readonly string CUTTING_SET_TEMPERATURE2_2 = "CUTTING_SET_TEMPERATURE2_2"; public static Int32 GetCUTTING_SET_TEMPERATURE2_2 => GetValue(CUTTING_SET_TEMPERATURE2_2); public static readonly string CUTTING_SET_TEMPERATURE2_3 = "CUTTING_SET_TEMPERATURE2_3"; public static Int32 GetCUTTING_SET_TEMPERATURE2_3 => GetValue(CUTTING_SET_TEMPERATURE2_3); public static readonly string CUTTING_SET_TEMPERATURE2_4 = "CUTTING_SET_TEMPERATURE2_4"; public static Int32 GetCUTTING_SET_TEMPERATURE2_4 => GetValue(CUTTING_SET_TEMPERATURE2_4); public static readonly string CUTTING_SET_TIME1_1 = "CUTTING_SET_TIME1_1"; public static Int32 GetCUTTING_SET_TIME1_1 => GetValue(CUTTING_SET_TIME1_1); public static readonly string CUTTING_SET_TIME1_2 = "CUTTING_SET_TIME1_2"; public static Int32 GetCUTTING_SET_TIME1_2 => GetValue(CUTTING_SET_TIME1_2); public static readonly string CUTTING_SET_TIME1_3 = "CUTTING_SET_TIME1_3"; public static Int32 GetCUTTING_SET_TIME1_3 => GetValue(CUTTING_SET_TIME1_3); public static readonly string CUTTING_SET_TIME1_4 = "CUTTING_SET_TIME1_4"; public static Int32 GetCUTTING_SET_TIME1_4 => GetValue(CUTTING_SET_TIME1_4); public static readonly string CUTTING_SET_TIME2_1 = "CUTTING_SET_TIME2_1"; public static Int32 GetCUTTING_SET_TIME2_1 => GetValue(CUTTING_SET_TIME2_1); public static readonly string CUTTING_SET_TIME2_2 = "CUTTING_SET_TIME2_2"; public static Int32 GetCUTTING_SET_TIME2_2 => GetValue(CUTTING_SET_TIME2_2); public static readonly string CUTTING_SET_TIME2_3 = "CUTTING_SET_TIME2_3"; public static Int32 GetCUTTING_SET_TIME2_3 => GetValue(CUTTING_SET_TIME2_3); public static readonly string CUTTING_SET_TIME2_4 = "CUTTING_SET_TIME2_4"; public static Int32 GetCUTTING_SET_TIME2_4 => GetValue(CUTTING_SET_TIME2_4); /// /// 计划的数量 /// public static readonly string Product_counter_CH = "Product_counter_CH"; /// /// 安全级别 /// public static readonly string Safety_level = "Safety_level"; /// /// 1盘料选择,0卷料选择 /// public static readonly string CH_Mode_selection = "CH_Mode_selection"; /// /// 裁刀1屏蔽 /// public static readonly string HMI_Cutting1_pass = "HMI_Cutting1_pass"; /// /// 裁刀2屏蔽 /// public static readonly string HMI_Cutting2_pass = "HMI_Cutting2_pass"; /// /// 裁刀1屏蔽 /// public static readonly string Cutting1_passad = "Cutting1_passad"; /// /// 裁刀2屏蔽 /// public static readonly string Cutting2_passad = "Cutting2_passad"; /// /// 切刀1到达使用上限清除计数按钮 /// public static readonly string CQ_QD1_counter_reset = "CQ_QD1_counter_reset"; /// /// 切刀2到达使用上限清除计数按钮 /// public static readonly string CQ_QD2_counter_reset = "CQ_QD2_counter_reset"; /// /// 毛毡带到达使用上限清除计数按钮 /// public static readonly string CQ_MZD_counter_reset = "CQ_MZD_counter_reset"; public static String GetStateText() { string text = ""; var plc = PlcConnect.Instance; var result = plc.ReadInt32("status_indicator"); if (result.IsSuccess) { var context = result.Content; switch (context) { case 0: text = "异常停机"; break; case 1: text = "手动模式"; break; case 2: text = "自动模式"; break; case 3: text = "自动运行中"; break; case 4: text = "停止"; break; case 5: text = "安全回路异常"; break; } } return text; } public static Dictionary BufDictionary=new Dictionary(); public static (bool,string) GetBufA() { return GetBufABC("A"); } public static (bool, string) GetBufB() { return GetBufABC("B"); } public static (bool, string) GetBufC() { return GetBufABC("C"); } public static (bool, string) GetBufABC(string key2) { string[] str = new string[] { "READ_CHIP0.BUF", "READ_CHIP1.BUF", "READ_CHIP2.BUF" }; string kye = ""; switch (key2) { case "A": kye = str[0]; break; case "B": kye = str[1]; break; case "C": kye = str[2]; break; } var plc = PlcConnect.Instance; string stringBuilder = ""; OperateResult read = plc.ReadTag(kye, ushort.Parse("25")); if (read.IsSuccess) { stringBuilder = read.Content2.ToHexString(); } if (stringBuilder.Trim().Length == 0) { return (false, stringBuilder); } if (stringBuilder.StartsWith("000000000") || stringBuilder.StartsWith("024E6F52".ToLower())) { return (false, stringBuilder); } if (BufDictionary.TryGetValue(key2, out var val)) { if (val == stringBuilder) { return (false, stringBuilder); } else { BufDictionary[key2] = stringBuilder; return (true, stringBuilder); } } else { BufDictionary[key2] = stringBuilder; return (true, stringBuilder); } } } }