|
@@ -38,6 +38,9 @@ using System.Numerics;
|
|
|
using MathNet.Numerics.RootFinding;
|
|
|
using HslCommunication.Enthernet;
|
|
|
using BZFAStandardLib;
|
|
|
+using MainForm.ClassFile;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
+using static MainForm.ClassFile.XiaomiAPI.XiaomiMqttClient_Extend;
|
|
|
|
|
|
/*
|
|
|
* 注:本源码对外提供,所以有些地方使用中文命名方法及变量
|
|
@@ -99,6 +102,11 @@ namespace MainForm
|
|
|
|
|
|
private int IntervalAlarm = 1000; //ms 数据(报警)查询与设备运行信息
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 设备报警数据
|
|
|
+ /// </summary>
|
|
|
+ uint[] _FaultDatas;
|
|
|
+
|
|
|
// 软件状态
|
|
|
private bool IsRun = true;
|
|
|
|
|
@@ -165,41 +173,67 @@ namespace MainForm
|
|
|
try
|
|
|
{
|
|
|
AddMessage(LogType.Info, "开始初始化程序");
|
|
|
- InitalDicAlarm(); // 实例化报警字典
|
|
|
|
|
|
//组建plc对象字典
|
|
|
//plc1Alarm = new ModbusClientHelper(GlobalContext.Machine1Address, GlobalContext.MachinePort);
|
|
|
//plc1Alarm = new Inovance_EIP(GlobalContext.PCAddress, GlobalContext.Machine1Address);
|
|
|
|
|
|
if (GlobalContext.IsUsePLC1)
|
|
|
- FunsEip.Add(1,
|
|
|
- new Inovance_EIP(GlobalContext.PC1Address, GlobalContext.Machine1Address)); //OP10 壳体清洁上料装备
|
|
|
- if (GlobalContext.IsUsePLC2)
|
|
|
- //Funs.Add(2, new ModbusClientHelper(GlobalContext.Machine2Address, GlobalContext.MachinePort, 2001)); // FCT(板测),
|
|
|
- FunsEip.Add(2,
|
|
|
- new Inovance_EIP(GlobalContext.PC2Address, GlobalContext.Machine2Address)); //OP20 顶盖上料设备
|
|
|
- if (GlobalContext.IsUsePLC3)
|
|
|
- FunsEip.Add(3,
|
|
|
- new Inovance_EIP(GlobalContext.PC3Address, GlobalContext.Machine3Address)); //OP30 点胶设备
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 1;
|
|
|
+ GlobalContext.IsUseStationName = "[OP10]壳体清洁上料";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC1Address, GlobalContext.Machine1Address)); //OP10 壳体清洁上料装备
|
|
|
+ }
|
|
|
+ if (GlobalContext.IsUsePLC2)
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 2;
|
|
|
+ GlobalContext.IsUseStationName = "[OP20]上盖板上料装备";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC2Address, GlobalContext.Machine2Address)); //OP20 顶盖上料设备
|
|
|
+ }
|
|
|
+ if (GlobalContext.IsUsePLC3)
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 3;
|
|
|
+ GlobalContext.IsUseStationName = "[OP30]点散热胶装备";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC3Address, GlobalContext.Machine3Address)); //OP30 点胶设备
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC4)
|
|
|
- FunsEip.Add(4,
|
|
|
- new Inovance_EIP(GlobalContext.PC4Address, GlobalContext.Machine4Address)); //OP40 3D胶线检测
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 4;
|
|
|
+ GlobalContext.IsUseStationName = "[OP40]胶线检测";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC4Address, GlobalContext.Machine4Address)); //OP40 3D胶线检测
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC5)
|
|
|
- FunsEip.Add(5,
|
|
|
- new Inovance_EIP(GlobalContext.PC5Address, GlobalContext.Machine5Address)); //OP50 ADD PCB板上料
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 5;
|
|
|
+ GlobalContext.IsUseStationName = "[OP50]ADD板上料组装装备";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC5Address, GlobalContext.Machine5Address)); //OP50 ADD PCB板上料
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC6)
|
|
|
- FunsEip.Add(6,
|
|
|
- new Inovance_EIP(GlobalContext.PC6Address, GlobalContext.Machine6Address)); //OP60 顶盖装配
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 6;
|
|
|
+ GlobalContext.IsUseStationName = "[OP60]组上盖板";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC6Address, GlobalContext.Machine6Address)); //OP60 顶盖装配
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC7)
|
|
|
- FunsEip.Add(7,
|
|
|
- new Inovance_EIP(GlobalContext.PC7Address, GlobalContext.Machine7Address)); //OP70 锁螺丝
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 7;
|
|
|
+ GlobalContext.IsUseStationName = "[OP70]上盖板锁螺丝";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC7Address, GlobalContext.Machine7Address)); //OP70 锁螺丝
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC8)
|
|
|
- FunsEip.Add(8,
|
|
|
- new Inovance_EIP(GlobalContext.PC8Address,
|
|
|
- GlobalContext.Machine8Address)); //OP80 3D螺丝高度检测,NG出料站
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 8;
|
|
|
+ GlobalContext.IsUseStationName = "[OP80]NG下料";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC8Address, GlobalContext.Machine8Address)); //OP80 3D螺丝高度检测,NG出料站
|
|
|
+ }
|
|
|
if (GlobalContext.IsUsePLC9)
|
|
|
- FunsEip.Add(9,
|
|
|
- new Inovance_EIP(GlobalContext.PC9Address, GlobalContext.Machine9Address)); //OP90 下料站
|
|
|
+ {
|
|
|
+ GlobalContext.IsUsePLCNow = 9;
|
|
|
+ GlobalContext.IsUseStationName = "[OP90]半成品下料";
|
|
|
+ FunsEip.Add(GlobalContext.IsUsePLCNow, new Inovance_EIP(GlobalContext.PC9Address, GlobalContext.Machine9Address)); //OP90 下料站
|
|
|
+ }
|
|
|
+ (bool,string)DicResult=InitalDicAlarm(); // 实例化报警字典
|
|
|
+ AddMessage(LogType.Info, DicResult.Item2);
|
|
|
|
|
|
foreach (Inovance_EIP plcEIP in FunsEip.Values)
|
|
|
{
|
|
@@ -727,17 +761,13 @@ namespace MainForm
|
|
|
private string _DeviceStates2 = "未知状态";
|
|
|
private string _DeviceStates_Old2 = "未知状态";
|
|
|
|
|
|
+ private object dicAlarms_Cur_PLC1_Old;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取设备报警数据与获取设备运行信息
|
|
|
/// </summary>
|
|
|
private async void ReadAlarmAllPLC()
|
|
|
{
|
|
|
- // [S1] Tray盘上料装备(板测)
|
|
|
- // [S2] FCT(板测)
|
|
|
- // [S3] 值板机
|
|
|
- // [S4] 取放桁架
|
|
|
- // [S5] Tray盘下料装备
|
|
|
- /// 上位机心跳
|
|
|
/// 获取设备报警数据与状态信息
|
|
|
string stationNameStr = "获取设备报警数据与状态信息";
|
|
|
// 已连接到PLC
|
|
@@ -745,6 +775,91 @@ namespace MainForm
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ DateTime dtNow = DateTime.Now;
|
|
|
+
|
|
|
+ #region 报警数据
|
|
|
+ try
|
|
|
+ {
|
|
|
+ List<DeviceAlarm_Cur> deviceAlarm_Curs = new List<DeviceAlarm_Cur>(); // 同步到报警页面用传输载体
|
|
|
+
|
|
|
+ _FaultDatas=new uint[] { 4,0,0,10};
|
|
|
+
|
|
|
+
|
|
|
+ bool isNeedUpdUI = false; // 是否需要更新历史报警UI
|
|
|
+ //解析报警信息
|
|
|
+ List<(int, int)> AlarmIndexList = new List<(int, int)>();//收集所有报警信息的位置
|
|
|
+ if (_FaultDatas.Length>0)
|
|
|
+ {
|
|
|
+ string binaryString = "";
|
|
|
+ for (int i = 0; i <= _FaultDatas.Length-1; i++)
|
|
|
+ {
|
|
|
+ var num = 0;
|
|
|
+ if (_FaultDatas[i]>0)
|
|
|
+ {
|
|
|
+ binaryString = Convert.ToString(_FaultDatas[i], 2);
|
|
|
+ for (int j = binaryString.Length - 1; j >= 0; j--)
|
|
|
+ {
|
|
|
+ num++;
|
|
|
+ char s = binaryString[j];
|
|
|
+ if (binaryString[j]=='1')
|
|
|
+ {
|
|
|
+ AlarmIndexList.Add((i, num-1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 同步“设备报警信息”到“设备报警临时字典DicAlarms_Cur”
|
|
|
+ var dicAlarms_Cur_PLC1 = DicAlarms_Cur[GlobalContext.IsUseStationName];
|
|
|
+ int AlarmsLine = 0;//记录总循环行数
|
|
|
+ foreach ((int index, int row) in AlarmIndexList)
|
|
|
+ {
|
|
|
+ var tempDic = dicAlarms_Cur_PLC1.Where(x => x.group_index == index).ToList();
|
|
|
+ for (int i = 0; i < tempDic.Count -1; i++) // 读取
|
|
|
+ {
|
|
|
+ if (tempDic[i].group_index == index && i == row)
|
|
|
+ {
|
|
|
+ dicAlarms_Cur_PLC1[AlarmsLine].报警数据 = new AlarmData()
|
|
|
+ {
|
|
|
+ GUID = Guid.NewGuid().ToString(),
|
|
|
+ LineName = GlobalContext.IsUseStationName, // 工站
|
|
|
+ PlcStation = tempDic[i].plcName, // 工站全称;[S1]
|
|
|
+ Type1 = tempDic[i].type1, // 故障层级1
|
|
|
+ Type2 = tempDic[i].type2, // 故障层级2
|
|
|
+ Type3 = tempDic[i].type3, // 故障层级3
|
|
|
+ Type4 = tempDic[i].type4, // 故障层级4
|
|
|
+ AlarmType = tempDic[i].fault_code, // 报警类型
|
|
|
+ AlarmDesc = tempDic[i].fault_name, // 报警内容
|
|
|
+ StartTime = dtNow // 开始时间
|
|
|
+ };
|
|
|
+ }
|
|
|
+ AlarmsLine += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //FaultLogRequest request = new FaultLogRequest();
|
|
|
+ //request.station = mesStation; // 工位
|
|
|
+ //request.fault_name = xmFaultName; // 故障名称(同数据字典中的事件名称)
|
|
|
+ //request.fault_code = xmFaultCode2; // 故障编码(A,B,C,D,E)
|
|
|
+ //request.fault_cmpnt = xmFaultCmpnt; // 故障部件
|
|
|
+ //request.fault_desc = xmFaultDesc; // 故障描述
|
|
|
+ //request.fault_tm = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // 故障发生时间 2022-06-01 14:27:57.283
|
|
|
+ // // 上传
|
|
|
+ //(int, string) iotResult = XiaomiMqttClient_Extend.Write_FaultLog(request, type1, type2, type3, request.fault_cmpnt, deciveCode);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ string str = ex.StackTrace;
|
|
|
+ AddMessage_Station(stationNameStr, LogType.Error, $"{stationNameStr}_获取报警数据出错!错误信息:" + ex.Message.ToString() + "异常位置:" + str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
+ }
|
|
|
+ #endregion 报警数据
|
|
|
+
|
|
|
+
|
|
|
+ #region 设备状态
|
|
|
//if (!GlobalContext._IsCon_plc1Alarm)
|
|
|
//{
|
|
|
// UpdatePLCMonitor(1, -2, 0);
|
|
@@ -867,6 +982,9 @@ namespace MainForm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
//if (plc1Alarm.IsConnected) // 检查PLC是否已连接上
|
|
|
//{
|
|
|
|
|
@@ -2084,6 +2202,158 @@ namespace MainForm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 实例化报警字典
|
|
|
+ /// </summary>
|
|
|
+ private (bool, string) InitalDicAlarm()
|
|
|
+ {
|
|
|
+ #region 加载报警表
|
|
|
+ string excelPath = "";
|
|
|
+ switch (GlobalContext.IsUsePLCNow)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_10_壳体清洁上料.xlsx";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_20_上盖板上料装备.xlsx";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_30_点散热胶装备.xlsx";
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_40_胶线检测.xlsx";
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_50_ADD板上料组装装备.xlsx";
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_60_组上盖板.xlsx";
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_70_上盖板锁螺丝.xlsx";
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_80_NG下料.xlsx";
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ excelPath = AppDomain.CurrentDomain.BaseDirectory + "DBFile\\小米-IoT报警字典_90_半成品下料.xlsx";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return (false, $"不支持当前PLC[{GlobalContext.IsUsePLCNow}]的报警点位表!请在设置页切换到正确的plc后重启该软件!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!File.Exists(excelPath))
|
|
|
+ return (false, $"未找到当前PLC[{GlobalContext.IsUsePLCNow}]的报警点位表!请检查文件路径:'{excelPath}'。");
|
|
|
+
|
|
|
+ DataTable DtModel = NPOIHelper.ReadExcel(excelPath);
|
|
|
+ if (DtModel == null || DtModel.Rows.Count < 1)
|
|
|
+ return (false, $"报警点位表未包含任何报警数据!请检查‘{excelPath}’文件!");
|
|
|
+
|
|
|
+ // 检查列名
|
|
|
+ List<string> isNeedParms = new List<string>() {"设备分类名称","设备分类编码","分类层级1","分类层级2","分类层级3" ,"分类层级4","事件名称"
|
|
|
+ ,"事件ID","描述","标签","PLC地址","工位"}; // 必须要有的列
|
|
|
+
|
|
|
+ // 指定列名 + 检查列是否完整
|
|
|
+ DataRow dtRowName = DtModel.Rows[0];
|
|
|
+ int count = DtModel.Columns.Count;
|
|
|
+ for (int i = 0; i < count; i++)
|
|
|
+ {
|
|
|
+ string columeName = dtRowName[i]?.ToString();
|
|
|
+ if (!string.IsNullOrEmpty(columeName))
|
|
|
+ DtModel.Columns[i].ColumnName = columeName;
|
|
|
+
|
|
|
+ if ((!string.IsNullOrEmpty(columeName)) && isNeedParms.Count > 0 && isNeedParms.Contains(columeName))
|
|
|
+ isNeedParms.Remove(columeName);
|
|
|
+ }
|
|
|
+ DtModel.Rows.RemoveAt(0);
|
|
|
+
|
|
|
+ if (isNeedParms.Count > 0)
|
|
|
+ {
|
|
|
+ string msg1 = string.Join(",", isNeedParms);
|
|
|
+ return (false, $"报警点位表未包含列:{msg1}!请检查‘{excelPath}’文件!");
|
|
|
+ }
|
|
|
+ #endregion 加载报警表
|
|
|
+
|
|
|
+ List<Alarm> keyValues1 = new List<Alarm>();
|
|
|
+ for (int i = 0; i < DtModel.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ Alarm alarm = new Alarm();
|
|
|
+ alarm.plcName = DtModel.Rows[i]["设备分类名称"]?.ToString(); // 设备名;
|
|
|
+ string type1Str = DtModel.Rows[i]["分类层级1"]?.ToString(); // 分类层级1;
|
|
|
+ alarm.type1CH = type1Str; // 分类层级1 中文
|
|
|
+ alarm.type1 = type1Str; // 分类层级1
|
|
|
+ if (!string.IsNullOrEmpty(type1Str) && type1Str.Contains("\n"))
|
|
|
+ {
|
|
|
+ string[] type1Strs = type1Str.Split('\n');
|
|
|
+ if (type1Strs.Length >= 2)
|
|
|
+ {
|
|
|
+ alarm.type1CH = type1Strs[0].Trim(); // 分类层级1 中文
|
|
|
+ alarm.type1 = type1Strs[1].Trim(); // 分类层级1
|
|
|
+ if (string.IsNullOrEmpty(alarm.type1))
|
|
|
+ alarm.type1 = alarm.type1CH;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string type2Str = DtModel.Rows[i]["分类层级2"]?.ToString(); // 分类层级2;电气控制 electric_control
|
|
|
+ alarm.type2CH = type2Str; // 分类层级2 中文
|
|
|
+ alarm.type2 = type2Str; // 分类层级2
|
|
|
+ if (!string.IsNullOrEmpty(type2Str) && type2Str.Contains("\n"))
|
|
|
+ {
|
|
|
+ string[] type2Strs = type2Str.Split('\n');
|
|
|
+ if (type2Strs.Length >= 2)
|
|
|
+ {
|
|
|
+ alarm.type2CH = type2Strs[0].Trim(); // 分类层级2 中文
|
|
|
+ alarm.type2 = type2Strs[1].Trim(); // 分类层级2
|
|
|
+ if (string.IsNullOrEmpty(alarm.type2))
|
|
|
+ alarm.type2 = alarm.type2CH;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string type3Str = DtModel.Rows[i]["分类层级3"]?.ToString(); // 分类层级3;故障 Fault
|
|
|
+ alarm.type3CH = type3Str; // 分类层级3 中文
|
|
|
+ alarm.type3 = type3Str; // 分类层级3
|
|
|
+ if (!string.IsNullOrEmpty(type3Str) && type3Str.Contains("\n"))
|
|
|
+ {
|
|
|
+ string[] type3Strs = type3Str.Split('\n');
|
|
|
+ if (type3Strs.Length >= 2)
|
|
|
+ {
|
|
|
+ alarm.type3CH = type3Strs[0].Trim(); // 分类层级3 中文
|
|
|
+ alarm.type3 = type3Strs[1].Trim(); // 分类层级3
|
|
|
+ if (string.IsNullOrEmpty(alarm.type3))
|
|
|
+ alarm.type3 = alarm.type3CH;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string faultStr = DtModel.Rows[i]["分类层级4"]?.ToString(); // 故障部件;overall_module
|
|
|
+ alarm.type4 = faultStr; // 分类层级4 中文
|
|
|
+ alarm.type4CH = faultStr; // 分类层级4
|
|
|
+ if (!string.IsNullOrEmpty(faultStr) && faultStr.Contains("\n"))
|
|
|
+ {
|
|
|
+ string[] faultStrs = faultStr.Split('\n');
|
|
|
+ if (faultStrs.Length >= 2)
|
|
|
+ {
|
|
|
+ alarm.type4CH = faultStrs[0].Trim(); // 故障部件;overall_module
|
|
|
+ alarm.type4 = faultStrs[1].Trim(); // 故障部件
|
|
|
+ if (string.IsNullOrEmpty(alarm.type4))
|
|
|
+ alarm.type4 = alarm.type4CH;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alarm.fault_code = DtModel.Rows[i]["事件ID"]?.ToString(); // 故障编码;A40001
|
|
|
+ alarm.fault_name = DtModel.Rows[i]["事件名称"]?.ToString(); // 故障名称;AL[1000]_系统_HMI急停故障
|
|
|
+ alarm.fault_desc = alarm.fault_name; // 故障描述;AL[1000]_系统_HMI急停故障
|
|
|
+ string plcAdress = DtModel.Rows[i]["PLC地址"]?.ToString();
|
|
|
+ alarm.PLC地址 = plcAdress;
|
|
|
+ plcAdress = plcAdress.Replace("fault_codes[", "");
|
|
|
+ plcAdress = plcAdress.Replace("]", "");
|
|
|
+ alarm.group_index = Convert.ToInt32(plcAdress.Split(".")[0]);
|
|
|
+
|
|
|
+ keyValues1.Add(alarm);
|
|
|
+
|
|
|
+ }
|
|
|
+ DicAlarms_Cur.Add(GlobalContext.IsUseStationName, keyValues1); // 这里使用线体代替工位
|
|
|
+ return (true, "报警字典表初始化成功!");
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region S1
|
|
@@ -2149,11 +2419,14 @@ namespace MainForm
|
|
|
xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7)
|
|
|
? XiaomiDeviceState.Unknown
|
|
|
: (XiaomiDeviceState)xmDeviceStateInt;
|
|
|
-
|
|
|
- s1PLCData["a1OEEPartNo"] =
|
|
|
- stPLC_MesData.BarcodeSet.strProductBarcode; // 物料码(物料码还未绑定载具SN时必填)
|
|
|
- s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
- s1PLCData["a1OEEType"] = stPLC_MesData.iotData.BeatAction; // 节拍
|
|
|
+ // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s1PLCData["a1OEEPartNo"] = stPLC_MesData.BarcodeSet.strProductBarcode;
|
|
|
+ // 载具SN
|
|
|
+ s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode;
|
|
|
+ // 节拍
|
|
|
+ s1PLCData["a1OEEType"] = stPLC_MesData.iotData.BeatAction;
|
|
|
+ //报警信息
|
|
|
+ _FaultDatas = stPLC_MesData.iotData.fault_codes;
|
|
|
}
|
|
|
|
|
|
#endregion 一次性读取所有数据
|
|
@@ -2903,45 +3176,21 @@ namespace MainForm
|
|
|
string tagAgvCommName = "agvCommFrmPC";
|
|
|
string tagBarsetName = "BarcodeSet";
|
|
|
|
|
|
+ //s1PLCSignal_Old.Add("a1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
|
+ s3PLCSignal_Old.Add("a3OEEType_left", 0); // 节拍类型(plc写入)
|
|
|
+ s3PLCSignal_Old.Add("a3OEEType_right", 0); // 节拍类型(plc写入)
|
|
|
+
|
|
|
+ // PLC数据字典 赋值
|
|
|
+ s3PLCData.Add("a3OEEType_left", 0); // 节拍类型(plc写入)
|
|
|
+ s3PLCData.Add("a3OEEPartNo_left", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s3PLCData.Add("a3OEEVehicleCode_left", ""); // 载具SN
|
|
|
+ s3PLCData.Add("a3OEEType_right", 0); // 节拍类型(plc写入)
|
|
|
+ s3PLCData.Add("a3OEEPartNo_right", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s3PLCData.Add("a3OEEVehicleCode_right", ""); // 载具SN
|
|
|
+
|
|
|
OP30_MesData_t stPLC_MesData; //PLC的MES数据
|
|
|
(int, string) result;
|
|
|
|
|
|
- #region 创建字典
|
|
|
-
|
|
|
- // 触发信号字典 赋值
|
|
|
- s3PLCSignal_Old.Add("c1PLC_FLAG_Check", 0); // PLC_FLAG 进站校验
|
|
|
- s3PLCSignal_Old.Add("c1PLC_FLAG_Unbind", 0); // PLC_FLAG 二穴载具解绑
|
|
|
- s3PLCSignal_Old.Add("c1PLC_FLAG_Bind", 0); // PLC_FLAG 二穴载具绑定
|
|
|
- s3PLCSignal_Old.Add("c1PLC_FLAG", 0); // PLC_FLAG 出站接口
|
|
|
- s3PLCSignal_Old.Add("c1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
|
-
|
|
|
- // PLC数据字典 赋值
|
|
|
- s3PLCData.Add("c1PLC_FLAG_Check", 0); // PLC_FLAG 进站校验
|
|
|
- s3PLCData.Add("c1MES_FLAG_Check", 0); // MES_FLAG
|
|
|
- s3PLCData.Add("c1ProductSN_Check", ""); // 产品SN(二穴载具SN)
|
|
|
- s3PLCData.Add("c1PLC_FLAG_Unbind", 0); // PLC_FLAG 二穴载具解绑
|
|
|
- s3PLCData.Add("c1MES_FLAG_Unbind", 0); // MES_FLAG
|
|
|
- //s3PLCData.Add("c1ProductSN_Check", ""); // 产品SN(二穴载具SN)
|
|
|
- s3PLCData.Add("c1VehicleCavity_Unbind", 0); // 二穴载具穴位号(产品取自二穴载具哪个穴位)
|
|
|
- s3PLCData.Add("c1PLC_FLAG_Bind", 0); // PLC_FLAG 二穴载具绑定
|
|
|
- s3PLCData.Add("c1MES_FLAG_Bind", 0); // MES_FLAG
|
|
|
- //s3PLCData.Add("c1ProductSN_Check", ""); // 产品SN(二穴载具SN)
|
|
|
- s3PLCData.Add("c1CavityReverse_Bind", 0); // 是否是两个穴位交换
|
|
|
- s3PLCData.Add("c1VehicleCavityFr_Bind", 0); // 来源穴位号(产品取自二穴载具哪个穴位)
|
|
|
- s3PLCData.Add("c1VehicleCavityTo_Bind", 0); // 目标载具穴位号(产品放到二穴载具哪个穴位)
|
|
|
- s3PLCData.Add("c1PLC_FLAG", 0); // PLC_FLAG 出站接口
|
|
|
- s3PLCData.Add("c1MES_FLAG", 0); // MES_FLAG
|
|
|
- s3PLCData.Add("c1ProductSN", ""); // 产品SN(一穴载具SN)
|
|
|
- //s3PLCData.Add("c1ProductSN_Check", ""); // 二穴载具SN(产品取自哪个二穴载具)
|
|
|
- s3PLCData.Add("c1VehicleCavity", 0); // 二穴载具穴位号(产品取自二穴载具哪个穴位)
|
|
|
- s3PLCData.Add("c1Result", 0); // 产品结果
|
|
|
- s3PLCData.Add("c1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
|
- s3PLCData.Add("c1OEEMES_FLAG", 0); // MES_FLAG
|
|
|
- s3PLCData.Add("c1OEEProductSN", ""); // 产品SN(载具SN)
|
|
|
- s3PLCData.Add("c1OEEType", 0); // 节拍类型(plc写入)
|
|
|
-
|
|
|
- #endregion 创建字典
|
|
|
-
|
|
|
while (true)
|
|
|
{
|
|
|
try
|
|
@@ -2972,16 +3221,19 @@ namespace MainForm
|
|
|
else
|
|
|
{
|
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
|
- //int xmDeviceStateInt_L = stPLC_MesData.Left.iotData.machineState;
|
|
|
- //int xmDeviceStateInt_R = stPLC_MesData.Right.iotData.machineState;
|
|
|
- int xmDeviceStateInt_L = 1;
|
|
|
- int xmDeviceStateInt_R = 2;
|
|
|
+ int xmDeviceStateInt_L = stPLC_MesData.Left.iotData.machineState;
|
|
|
+ int xmDeviceStateInt_R = stPLC_MesData.Right.iotData.machineState;
|
|
|
xmDeviceStateData.left = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7)
|
|
|
? XiaomiDeviceState.Unknown
|
|
|
: (XiaomiDeviceState)xmDeviceStateInt_L;
|
|
|
xmDeviceStateData.right = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7)
|
|
|
? XiaomiDeviceState.Unknown
|
|
|
: (XiaomiDeviceState)xmDeviceStateInt_R;
|
|
|
+ s1PLCData["a1OEEPartNo"] =stPLC_MesData.Left.BarcodeSet.strProductBarcode; // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.Left.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
+ s1PLCData["a1OEEType"] = stPLC_MesData.Left.iotData.BeatAction; // 节拍
|
|
|
+ s1PLCData["a1OEEVehicleCode_right"] = stPLC_MesData.Right.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
+ s1PLCData["a1OEEType_right"] = stPLC_MesData.Right.iotData.BeatAction; // 节拍
|
|
|
}
|
|
|
|
|
|
#endregion 一次性读取所有数据
|
|
@@ -3105,6 +3357,90 @@ namespace MainForm
|
|
|
|
|
|
#endregion 右边出站
|
|
|
|
|
|
+ #region 节拍接口
|
|
|
+ try
|
|
|
+ {
|
|
|
+ #region 左工位 节拍
|
|
|
+ int a30EEType_left = (int)s3PLCData["a30EEType_left"];
|
|
|
+ int a30EETypeGOld_left = (int)s3PLCSignal_Old["a30EEType_left"];
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
+ if (a30EEType_left == 1)
|
|
|
+ {
|
|
|
+ a30EETypeGOld_left = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a30EEType_left != a30EETypeGOld_left)
|
|
|
+ {
|
|
|
+ stationNameStr = stationNameStr + "_Left";
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
+ if ((a30EETypeGOld_left == 1 && a30EEType_left != 2) || (a30EETypeGOld_left == 3 && a30EEType_left != 4) ||
|
|
|
+ (a30EETypeGOld_left == 5 && a30EEType_left != 6))
|
|
|
+ {
|
|
|
+ //写入PLC
|
|
|
+ stPLC_MesData.Left.iotData.beatReturn = 2; //NG
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
|
|
|
+ AddMessage(LogType.Info,
|
|
|
+ stationNameStr +
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a30EEType_left}],未上传节拍[{a30EETypeGOld_left}]的结束信号,请检查;总用时" +
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
+ "ms");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Task.Run(() =>
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName,
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
+ }
|
|
|
+ s3PLCSignal_Old["a30EEType_left"] = s3PLCData["a30EEType_left"];
|
|
|
+ }
|
|
|
+ #endregion 左工位 节拍
|
|
|
+
|
|
|
+ #region 右工位 节拍
|
|
|
+ int a30EEType_right = (int)s3PLCData["a30EEType_right"];
|
|
|
+ int a30EETypeGOld_right = (int)s3PLCSignal_Old["a30EEType_right"];
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
+ if (a30EEType_right == 1)
|
|
|
+ {
|
|
|
+ a30EETypeGOld_right = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a30EEType_right != a30EETypeGOld_right)
|
|
|
+ {
|
|
|
+ stationNameStr = stationNameStr + "_Right";
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
+ if ((a30EETypeGOld_right == 1 && a30EEType_right != 2) || (a30EETypeGOld_right == 3 && a30EEType_right != 4) ||
|
|
|
+ (a30EETypeGOld_right == 5 && a30EEType_right != 6))
|
|
|
+ {
|
|
|
+ //写入PLC
|
|
|
+ stPLC_MesData.Right.iotData.beatReturn = 2; //NG
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
|
|
|
+ AddMessage(LogType.Info,
|
|
|
+ stationNameStr +
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a30EEType_right}],未上传节拍[{a30EETypeGOld_right}]的结束信号,请检查;总用时" +
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
+ "ms");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Task.Run(() =>
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName,
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
+ }
|
|
|
+ s3PLCSignal_Old["a30EEType_right"] = s3PLCData["a30EEType_right"];
|
|
|
+ }
|
|
|
+ #endregion 右工位 节拍
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ string str = ex.StackTrace;
|
|
|
+ AddMessage_Station(stationNameStr, LogType.Error,
|
|
|
+ $"PLC{plcNo}_{stationNameStr} 上传出站数据出错!错误信息:" + ex.Message + "异常位置:" +
|
|
|
+ str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
UpdatePLCMonitor(1, plcNo, 1); // 更新PLC状态的UI // 更新PLC状态的UI
|
|
|
|
|
@@ -4861,6 +5197,8 @@ namespace MainForm
|
|
|
#endregion
|
|
|
|
|
|
#region S7
|
|
|
+ private Dictionary<string, object> s7PLCSignal_Old = new Dictionary<string, object>();
|
|
|
+ private Dictionary<string, object> s7PLCData = new Dictionary<string, object>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// [S7] 锁螺丝设备
|
|
@@ -4876,8 +5214,22 @@ namespace MainForm
|
|
|
string tagAgvCommName = "agvCommFrmPC";
|
|
|
string tagBarsetName = "BarcodeSet";
|
|
|
string tagScrewDataset = "screwDataset";
|
|
|
+
|
|
|
+ //s1PLCSignal_Old.Add("a1OEEPLC_FLAG", 0); // PLC_FLAG 节拍接口
|
|
|
+ s7PLCSignal_Old.Add("a7OEEType_left", 0); // 节拍类型(plc写入)
|
|
|
+ s7PLCSignal_Old.Add("a7OEEType_right", 0); // 节拍类型(plc写入)
|
|
|
+
|
|
|
+ // PLC数据字典 赋值
|
|
|
+ s7PLCData.Add("a7OEEType_left", 0); // 节拍类型(plc写入)
|
|
|
+ s7PLCData.Add("a7OEEPartNo_left", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s7PLCData.Add("a7OEEVehicleCode_left", ""); // 载具SN
|
|
|
+ s7PLCData.Add("a7OEEType_right", 0); // 节拍类型(plc写入)
|
|
|
+ s7PLCData.Add("a7OEEPartNo_right", ""); // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s7PLCData.Add("a7OEEVehicleCode_right", ""); // 载具SN
|
|
|
+
|
|
|
OP70_MesData_t stPLC_MesData; //PLC的MES数据
|
|
|
(int, string) result;
|
|
|
+
|
|
|
AtlasScrew atlasScrewLeft = new AtlasScrew(GlobalContext.AtlasAddressLeft, GlobalContext.AtlasAddressPort,
|
|
|
3000, 3000, "Left");
|
|
|
atlasScrewLeft.Initial();
|
|
@@ -4885,6 +5237,7 @@ namespace MainForm
|
|
|
3000, 3000, "Right");
|
|
|
atlasScrewRight.Initial();
|
|
|
|
|
|
+
|
|
|
while (true)
|
|
|
{
|
|
|
try
|
|
@@ -4915,6 +5268,20 @@ namespace MainForm
|
|
|
else
|
|
|
{
|
|
|
//richTextBox1.AppendText("\n" + "读取成功");
|
|
|
+
|
|
|
+ int xmDeviceStateInt_L = stPLC_MesData.Left.iotData.machineState;
|
|
|
+ int xmDeviceStateInt_R = stPLC_MesData.Right.iotData.machineState;
|
|
|
+ xmDeviceStateData.left = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7)
|
|
|
+ ? XiaomiDeviceState.Unknown
|
|
|
+ : (XiaomiDeviceState)xmDeviceStateInt_L;
|
|
|
+ xmDeviceStateData.right = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7)
|
|
|
+ ? XiaomiDeviceState.Unknown
|
|
|
+ : (XiaomiDeviceState)xmDeviceStateInt_R;
|
|
|
+ s7PLCData["a7OEEPartNo"] =stPLC_MesData.Left.BarcodeSet.strProductBarcode; // 物料码(物料码还未绑定载具SN时必填)
|
|
|
+ s7PLCData["a7OEEVehicleCode"] = stPLC_MesData.Left.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
+ s7PLCData["a7OEEType"] = stPLC_MesData.Left.iotData.BeatAction; // 节拍
|
|
|
+ s7PLCData["a7OEEVehicleCode_right"] = stPLC_MesData.Right.BarcodeSet.strCarrierBarcode; // 载具SN
|
|
|
+ s7PLCData["a7OEEType_right"] = stPLC_MesData.Right.iotData.BeatAction; // 节拍
|
|
|
}
|
|
|
|
|
|
#endregion 一次性读取所有数据
|
|
@@ -5041,6 +5408,90 @@ namespace MainForm
|
|
|
|
|
|
#endregion 右边出站
|
|
|
|
|
|
+ #region 节拍接口
|
|
|
+ try
|
|
|
+ {
|
|
|
+ #region 左工位 节拍
|
|
|
+ int a70EEType_left = (int)s7PLCData["a70EEType_left"];
|
|
|
+ int a70EETypeGOld_left = (int)s7PLCSignal_Old["a70EEType_left"];
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
+ if (a70EEType_left == 1)
|
|
|
+ {
|
|
|
+ a70EETypeGOld_left = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a70EEType_left != a70EETypeGOld_left)
|
|
|
+ {
|
|
|
+ stationNameStr = stationNameStr + "_Left";
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
+ if ((a70EETypeGOld_left == 1 && a70EEType_left != 2) || (a70EETypeGOld_left == 3 && a70EEType_left != 4) ||
|
|
|
+ (a70EETypeGOld_left == 5 && a70EEType_left != 6))
|
|
|
+ {
|
|
|
+ //写入PLC
|
|
|
+ stPLC_MesData.Left.iotData.beatReturn = 2; //NG
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
|
|
|
+ AddMessage(LogType.Info,
|
|
|
+ stationNameStr +
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a70EEType_left}],未上传节拍[{a70EETypeGOld_left}]的结束信号,请检查;总用时" +
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
+ "ms");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Task.Run(() =>
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName,
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
+ }
|
|
|
+ s7PLCSignal_Old["a70EEType_left"] = s7PLCData["a70EEType_left"];
|
|
|
+ }
|
|
|
+ #endregion 左工位 节拍
|
|
|
+
|
|
|
+ #region 右工位 节拍
|
|
|
+ int a70EEType_right = (int)s7PLCData["a70EEType_right"];
|
|
|
+ int a70EETypeGOld_right = (int)s7PLCSignal_Old["a70EEType_right"];
|
|
|
+ //若设备紧急复原后节拍重置
|
|
|
+ if (a70EEType_right == 1)
|
|
|
+ {
|
|
|
+ a70EETypeGOld_right = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a70EEType_right != a70EETypeGOld_right)
|
|
|
+ {
|
|
|
+ stationNameStr = stationNameStr + "_Right";
|
|
|
+ //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
|
|
|
+ if ((a70EETypeGOld_right == 1 && a70EEType_right != 2) || (a70EETypeGOld_right == 3 && a70EEType_right != 4) ||
|
|
|
+ (a70EETypeGOld_right == 5 && a70EEType_right != 6))
|
|
|
+ {
|
|
|
+ //写入PLC
|
|
|
+ stPLC_MesData.Right.iotData.beatReturn = 2; //NG
|
|
|
+ WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
|
|
|
+ AddMessage(LogType.Info,
|
|
|
+ stationNameStr +
|
|
|
+ $"_节拍接口-- 设备本次上传节拍[{a70EEType_right}],未上传节拍[{a70EETypeGOld_right}]的结束信号,请检查;总用时" +
|
|
|
+ stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds +
|
|
|
+ "ms");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Task.Run(() =>
|
|
|
+ S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName,
|
|
|
+ stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
|
|
|
+ }
|
|
|
+ s7PLCSignal_Old["a70EEType_right"] = s7PLCData["a70EEType_right"];
|
|
|
+ }
|
|
|
+ #endregion 右工位 节拍
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ string str = ex.StackTrace;
|
|
|
+ AddMessage_Station(stationNameStr, LogType.Error,
|
|
|
+ $"PLC{plcNo}_{stationNameStr} 上传出站数据出错!错误信息:" + ex.Message + "异常位置:" +
|
|
|
+ str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
UpdatePLCMonitor(1, plcNo, 1); // 更新PLC状态的UI // 更新PLC状态的UI
|
|
|
|
|
@@ -13133,139 +13584,6 @@ namespace MainForm
|
|
|
|
|
|
#endregion 日志
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 实例化报警字典
|
|
|
- /// </summary>
|
|
|
- private void InitalDicAlarm()
|
|
|
- {
|
|
|
- #region 第一个工站(这里未区分工位,所以下面出现的‘工位代码’使用‘线别代码’代替)
|
|
|
-
|
|
|
- List<Alarm> keyValues1 = new List<Alarm>
|
|
|
- {
|
|
|
- #region 第一组报警(电机)
|
|
|
-
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "料盘搬运_Y轴电机故障", 关联的PLC地址 = 5100 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "壳体取料_X轴电机故障", 关联的PLC地址 = 5101 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "壳体取料_Z轴电机故障", 关联的PLC地址 = 5102 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "载具搬运_X轴电机故障", 关联的PLC地址 = 5103 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "镭射_X轴电机故障", 关联的PLC地址 = 5104 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "上相机_X轴电机故障", 关联的PLC地址 = 5105 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "上相机_Z轴电机故障", 关联的PLC地址 = 5106 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "下相机_X轴电机故障", 关联的PLC地址 = 5107 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "下料_Y轴电机故障", 关联的PLC地址 = 5108 },
|
|
|
- new Alarm { 报警类型 = "电机故障", 报警详情 = "下料_X轴电机故障", 关联的PLC地址 = 5109 },
|
|
|
-
|
|
|
- #endregion 第一组报警(电机)
|
|
|
-
|
|
|
- #region 第二组报警(气缸)
|
|
|
-
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "上料仓分料进退气缸故障", 关联的PLC地址 = 5200 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "上料仓分料升降气缸故障", 关联的PLC地址 = 5201 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "上料仓顶升气缸故障", 关联的PLC地址 = 5202 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "壳体取料夹爪气缸故障", 关联的PLC地址 = 5203 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "下料仓顶升气缸故障", 关联的PLC地址 = 5204 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "壳体上料平移气缸故障", 关联的PLC地址 = 5205 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "壳体上料升降气缸故障", 关联的PLC地址 = 5206 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "壳体上料夹爪气缸故障", 关联的PLC地址 = 5207 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "壳体上料旋转气缸故障", 关联的PLC地址 = 5208 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "胶圈组装平移气缸故障", 关联的PLC地址 = 5209 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "胶圈组装升降气缸故障", 关联的PLC地址 = 5210 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "胶圈组装夹爪气缸故障", 关联的PLC地址 = 5211 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "胶圈组装撑开气缸故障", 关联的PLC地址 = 5212 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "载具定位气缸1故障", 关联的PLC地址 = 5213 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "载具定位气缸2故障", 关联的PLC地址 = 5214 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "载具下料移载气缸故障", 关联的PLC地址 = 5215 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "载具侧推气缸故障", 关联的PLC地址 = 5216 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "载具回流气缸故障", 关联的PLC地址 = 5217 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位2压料气缸故障", 关联的PLC地址 = 5218 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位2电测气缸故障", 关联的PLC地址 = 5219 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位2气密气缸故障", 关联的PLC地址 = 5220 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位3下压气缸故障", 关联的PLC地址 = 5221 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位3上顶气缸故障", 关联的PLC地址 = 5222 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位5相机升降气缸故障", 关联的PLC地址 = 5223 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "下料模组升降气缸故障", 关联的PLC地址 = 5224 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "下料模组夹爪气缸1故障", 关联的PLC地址 = 5225 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "下料模组夹爪气缸2故障", 关联的PLC地址 = 5226 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "机械手夹爪气缸故障", 关联的PLC地址 = 5227 },
|
|
|
- new Alarm { 报警类型 = "气缸故障", 报警详情 = "工位4:镭射压料气缸故障", 关联的PLC地址 = 5228 },
|
|
|
-
|
|
|
- #endregion 第二组报警(气缸)
|
|
|
-
|
|
|
- #region 第三组报警(其他故障)
|
|
|
-
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "上料处缺料报警", 关联的PLC地址 = 5300 },
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "震盘缺料报警", 关联的PLC地址 = 5301 },
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "成品仓料满报警", 关联的PLC地址 = 5302 },
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "检测拍照超时报警", 关联的PLC地址 = 5303 },
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "检测拍照NG报警", 关联的PLC地址 = 5304 },
|
|
|
- new Alarm { 报警类型 = "其他故障", 报警详情 = "玻璃门打开报警", 关联的PLC地址 = 5305 },
|
|
|
-
|
|
|
- #endregion 第三组报警(其他故障)
|
|
|
- };
|
|
|
|
|
|
- DicAlarms_Cur.Add(GlobalContext.LineCode, keyValues1); // 这里使用线体代替工位
|
|
|
-
|
|
|
- #endregion 第一个工站(这里使用线体代替工位)
|
|
|
-
|
|
|
- # region 第二个工站-原来的写法(废弃)
|
|
|
-
|
|
|
- //keyValues = new Dictionary<int, AlarmData[]>();
|
|
|
- ////1
|
|
|
- //dicAlarmName = new Dictionary<int, Alarm>();
|
|
|
- //dicAlarmName.Add(0, new Alarm { Name = "M01衬套组模组X电机报警" });
|
|
|
- //dicAlarmName.Add(1, new Alarm { Name = "M02衬套组模组Y电机报警" });
|
|
|
- //dicAlarmName.Add(2, new Alarm { Name = "M03衬套组模组Z电机报警" });
|
|
|
- //dicAlarmName.Add(3, new Alarm { Name = "M04衬套组模组U电机报警" });
|
|
|
- //dicAlarmName.Add(4, new Alarm { Name = "M05外流线皮带电机报警" });
|
|
|
- //alarmDatas = new AlarmData[dicAlarmName.Count];
|
|
|
- //for (int i = 0; i < dicAlarmName.Count; i++)
|
|
|
- //{
|
|
|
- // alarmDatas[i] = new AlarmData();
|
|
|
- // alarmDatas[i].Equipment_code = GlobalContext.LineCode + "-2";
|
|
|
- // alarmDatas[i].AlarmDesc = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmName = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmType = 1;
|
|
|
- //}
|
|
|
- //keyValues.Add(1, alarmDatas);
|
|
|
- ////2
|
|
|
- //dicAlarmName = new Dictionary<int, Alarm>();
|
|
|
- //dicAlarmName.Add(0, new Alarm { Name = "C01定位气缸故障" });
|
|
|
- //dicAlarmName.Add(1, new Alarm { Name = "C02左推料气缸故障" });
|
|
|
- //dicAlarmName.Add(2, new Alarm { Name = "C03右推料气缸故障" });
|
|
|
- //dicAlarmName.Add(3, new Alarm { Name = "C04左压料气缸故障" });
|
|
|
- //dicAlarmName.Add(4, new Alarm { Name = "C05右压料气缸故障" });
|
|
|
- //dicAlarmName.Add(5, new Alarm { Name = "C06切料气缸故障" });
|
|
|
- //dicAlarmName.Add(6, new Alarm { Name = "C07左入料吹气气缸故障" });
|
|
|
- //dicAlarmName.Add(7, new Alarm { Name = "C08右入料吹气气缸故障" });
|
|
|
- //alarmDatas = new AlarmData[dicAlarmName.Count];
|
|
|
- //for (int i = 0; i < dicAlarmName.Count; i++)
|
|
|
- //{
|
|
|
- // alarmDatas[i] = new AlarmData();
|
|
|
- // alarmDatas[i].Equipment_code = GlobalContext.LineCode + "-2";
|
|
|
- // alarmDatas[i].AlarmDesc = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmName = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmType = 2;
|
|
|
- //}
|
|
|
- //keyValues.Add(2, alarmDatas);
|
|
|
- ////3
|
|
|
- //dicAlarmName = new Dictionary<int, Alarm>();
|
|
|
- //dicAlarmName.Add(0, new Alarm { Name = "安全门报警" });
|
|
|
- //dicAlarmName.Add(1, new Alarm { Name = "联机通信故障" });
|
|
|
- //dicAlarmName.Add(2, new Alarm { Name = "连续NG报警" });
|
|
|
- //dicAlarmName.Add(3, new Alarm { Name = "合格率低于设定值报警" });
|
|
|
- //alarmDatas = new AlarmData[dicAlarmName.Count];
|
|
|
- //for (int i = 0; i < dicAlarmName.Count; i++)
|
|
|
- //{
|
|
|
- // alarmDatas[i] = new AlarmData();
|
|
|
- // alarmDatas[i].Equipment_code = GlobalContext.LineCode + "-3";
|
|
|
- // alarmDatas[i].AlarmDesc = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmName = dicAlarmName[i].Name;
|
|
|
- // alarmDatas[i].AlarmType = 3;
|
|
|
- //}
|
|
|
- //keyValues.Add(3, alarmDatas);
|
|
|
- //DicAlarms.Add(2, keyValues);
|
|
|
-
|
|
|
- #endregion 第二个工站-原来的写法(废弃)
|
|
|
- }
|
|
|
}
|
|
|
}
|