You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/Tool/Model/HmiPointInfo.cs

415 lines
13 KiB
C#

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
{
/// <summary>
/// DInt 供料电机速度
/// </summary>
public static readonly string feeding_motor_speed = "feeding_motor_speed";
public static Int32 GetFeedingMotorSpeed => GetValue(feeding_motor_speed);
/// <summary>
/// DInt 层合电机速度
/// </summary>
public static readonly string Laminated_motor_speed = "Laminated_motor_speed";
public static Int32 GetLaminatedMotorSpeed => GetValue(Laminated_motor_speed);
/// <summary>
/// DInt 毛毡带电机速度
/// </summary>
public static readonly string Felt_belt_motor_speed = "Felt_belt_motor_speed";
public static Int32 GetFeltBeltMotorSpeed => GetValue(Felt_belt_motor_speed);
/// <summary>
/// DInt 收料电机1速度
/// </summary>
public static readonly string Receiving_Electric_motor_speed = "Receiving_Electric_motor_speed";
public static Int32 GeReceivingMotorSpeed => GetValue(Receiving_Electric_motor_speed);
/// <summary>
/// 层合生产数量
/// </summary>
public static readonly string Product_counter2 = "Product_counter2";
public static Int32 GetProduct_counter2 => GetValue(Product_counter2);
/// <summary>
/// 裁切1生产数量
/// </summary>
public static readonly string CQ_Chip1_counter = "CQ_Chip1_counter";
public static Int32 GetCQ_Chip1_counter => GetValue(CQ_Chip1_counter);
/// <summary>
/// 裁切2生产数量
/// </summary>
public static readonly string CQ_Chip2_counter = "CQ_Chip2_counter";
public static Int32 GetCQ_Chip2_counter => GetValue(CQ_Chip2_counter);
/// <summary>
/// 裁刀1温度
/// </summary>
public static readonly string QDWD1SS = "QDWD1SS";
public static Int32 GetQDWD1SS => GetValue(QDWD1SS);
/// <summary>
/// 裁刀1温度
/// </summary>
public static readonly string QDWD2SS = "QDWD2SS";
public static Int32 GetQDWD2SS => GetValue(QDWD2SS);
/// <summary>
/// 设备内部温度
/// </summary>
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);
/// <summary>
/// 计划的数量
/// </summary>
public static readonly string Product_counter_CH = "Product_counter_CH";
/// <summary>
/// 安全级别
/// </summary>
public static readonly string Safety_level = "Safety_level";
/// <summary>
/// 1盘料选择0卷料选择
/// </summary>
public static readonly string CH_Mode_selection = "CH_Mode_selection";
/// <summary>
/// 裁刀1屏蔽
/// </summary>
public static readonly string HMI_Cutting1_pass = "HMI_Cutting1_pass";
/// <summary>
/// 裁刀2屏蔽
/// </summary>
public static readonly string HMI_Cutting2_pass = "HMI_Cutting2_pass";
/// <summary>
/// 裁刀1屏蔽
/// </summary>
public static readonly string Cutting1_passad = "Cutting1_passad";
/// <summary>
/// 裁刀2屏蔽
/// </summary>
public static readonly string Cutting2_passad = "Cutting2_passad";
/// <summary>
/// 切刀1到达使用上限清除计数按钮
/// </summary>
public static readonly string CQ_QD1_counter_reset = "CQ_QD1_counter_reset";
/// <summary>
/// 切刀2到达使用上限清除计数按钮
/// </summary>
public static readonly string CQ_QD2_counter_reset = "CQ_QD2_counter_reset";
/// <summary>
/// 毛毡带到达使用上限清除计数按钮
/// </summary>
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<string, string> BufDictionary = new Dictionary<string, string>();
public static (bool, string) GetBufA()
{
string key = "CHIP0_OK_For_SWJ";
string kye = "READ_CHIP0.BUF";
var plc = PlcConnect.Instance;
var result =plc.ReadInt32(key);
if (result.IsSuccess && result.Content==1)
{
OperateResult<ushort, byte[]> read = plc.ReadTag(kye, ushort.Parse("23"));
if (read.IsSuccess)
{
var stringBuilder = read.Content2.ToHexString();
if (stringBuilder.Length > 22)
{
stringBuilder = stringBuilder.Substring(22);
plc.Write(key, Int32.Parse("0"));
return (true,stringBuilder);
}
}
}
return (false, "");
}
public static (bool, string) GetBufB()
{
string key = "CHIP1_OK_For_SWJ";
string kye = "READ_CHIP1.BUF";
var plc = PlcConnect.Instance;
var result = plc.ReadInt32(key);
if (result.IsSuccess && result.Content == 1)
{
OperateResult<ushort, byte[]> read = plc.ReadTag(kye, ushort.Parse("23"));
if (read.IsSuccess)
{
var stringBuilder = read.Content2.ToHexString();
if (stringBuilder.Length > 22)
{
stringBuilder = stringBuilder.Substring(22);
plc.Write(key, Int32.Parse("0"));
return (true, stringBuilder);
}
}
}
return (false, "");
}
public static (bool, string) GetBufC()
{
var plc = PlcConnect.Instance;
string kye = "READ_CHIP2.BUF";
string stringBuilder = "";
OperateResult<ushort, byte[]> read = plc.ReadTag(kye, ushort.Parse("25"));
if (read.IsSuccess)
{
stringBuilder = read.Content2.ToHexString();
if (stringBuilder.StartsWith("024E6F52", StringComparison.OrdinalIgnoreCase))
{
return (false, "");
}
if (stringBuilder.Length > 2)
{
stringBuilder = stringBuilder.Substring(2);
return (true, stringBuilder);
}
}
return (false, "");
}
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<ushort, byte[]> 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);
}
}
}
}