From 27a86a8a1da0366d64df907b713ab8f1753714f8 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 25 六月 2024 18:22:11 +0800 Subject: [PATCH] 添加VK4、VK5的通信处理逻辑(VK4、VK5)开发完成 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs | 138 +++++++++++++++++----- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs | 7 + 代码管理/大屏/src/views/centerRight4.vue | 2 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs | 7 + 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs | 192 ++++++++++++++++++++++++++++++++ 5 files changed, 310 insertions(+), 36 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs" new file mode 100644 index 0000000..5cdec05 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/equipment/info_interaction.cs" @@ -0,0 +1,192 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using WIDESEA_Comm.LogInfo; +using WIDESEA_Core.EFDbContext; +using WIDESEA_WCS.IRepositories; +using WIDESEA_WCS.Repositories; +using WIDESEA_WCS.WCSClient; +using WIDESEA_WMS.IRepositories; +using WIDESEA_WMS.Repositories; +using static WIDESEA_Comm.Wheel_trace; +using static WIDESEA_WCS.GantryDB; + +namespace WIDESEA_WCS +{ + public class info_interaction + { + + /// <summary> + /// 杞﹁疆鍙傛暟浜や簰 + /// </summary> + /// <param name="client"></param> + public static void wheeldata(PLCClient client) + { + VOLContext context = new VOLContext(); + Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context); + var groups = client.itemGroups.Where(x => x.opratortype == "wheeldata").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList(); + foreach (var key in groups) + { + try + { + DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on"); + if (group != null) + { + var oi_on = DBExtension.Read(group, client); + if (Convert.ToByte(oi_on) == 1) + { + var o_wp_type = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_type"), client); + var geometry = geometry_DataRepository.Find(x => x.TypeId == Convert.ToInt32(o_wp_type)).FirstOrDefault(); + if (geometry == null) + { + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + throw new Exception($"{key.Key}鏈壘鍒扮被鍨媨o_wp_type}鐨勮溅杞弬鏁癨n鍐欏叆杈婇亾淇℃伅锛歩_status锛�2,oi_on锛�0"); + } + else + { + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_a").dbAddress, (float)geometry.a);//杞﹁疆鍙傛暟a + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_b").dbAddress, (float)geometry.b);//杞﹁疆鍙傛暟b + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_c").dbAddress, (float)geometry.c);//杞﹁疆鍙傛暟c + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_d").dbAddress, (float)geometry.d);//杞﹁疆鍙傛暟d + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_e").dbAddress, (float)geometry.e);//杞﹁疆鍙傛暟e + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_f").dbAddress, (float)geometry.f);//杞﹁疆鍙傛暟f + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_g").dbAddress, (float)geometry.g);//杞﹁疆鍙傛暟g + client.Write(key.FirstOrDefault(x => x.name == "i_parameter_h").dbAddress, (float)geometry.h);//杞﹁疆鍙傛暟h + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + #region 鏃ュ織璁板綍 + WriteLog.Write_Log(key.Key + "杈婇亾", "鐢宠鏌ヨ杞﹁疆淇℃伅", "", $"璇诲彇杈婇亾淇℃伅锛歕n杞瀷ID锛歿o_wp_type}\n\n鍐欏叆杈婇亾淇℃伅锛歕ni_status锛�1" + $"\n" + + $"a锛歿(float)geometry.a}\n" + + $"b锛歿(float)geometry.b}\n" + + $"c锛歿(float)geometry.c}\n" + + $"d锛歿(float)geometry.d}\n" + + $"e锛歿(float)geometry.e}\n" + + $"f锛歿(float)geometry.f}\n" + + $"g锛歿(float)geometry.g}\n" + + $"h锛歿(float)geometry.h}\n" + + $"oi_on锛�0"); + #endregion + } + } + } + } + catch (Exception ex) + { + WriteLog.Write_Log(key.Key + "杈婇亾", "鐢宠鏌ヨ杞﹁疆淇℃伅", "", ex.Message); + } + } + } + + /// <summary> + /// 鎵爜鏋� + /// </summary> + /// <param name="client"></param> + public static void scan(PLCClient client) + { + VOLContext context = new VOLContext(); + Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context); + var groups = client.itemGroups.Where(x => x.opratortype == "scan").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList(); + foreach (var key in groups) + { + try + { + DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on"); + if (group != null) + { + var oi_on = DBExtension.Read(group, client); + if (Convert.ToByte(oi_on) == 1) + { + var o_wp_type = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_type"), client); + var o_wp_id = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_id"), client); + var geometry = geometry_DataRepository.Find(x => x.TypeId == Convert.ToInt32(o_wp_type)).FirstOrDefault(); + if (geometry == null) + { + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + throw new Exception($"{key.Key}鏈壘鍒扮被鍨媨o_wp_type}鐨勮溅杞弬鏁癨n鍐欏叆杈婇亾淇℃伅锛歩_status锛�2,oi_on锛�0"); + } + var Work = workinfoRepository.Find(x => x.SN == o_wp_id && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (Work == null) + { + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)3);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + throw new Exception($"{key.Key}鏈壘鍒癝N锛歿o_wp_id}鐨勫伐鍗曚俊鎭痋n鍐欏叆杈婇亾淇℃伅锛歩_status锛�3,oi_on锛�0"); + } + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "i_direction").dbAddress, (byte)2);//鍘诲悜榛樿鍐�2 + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + WriteLog.Write_Log(key.Key + "杈婇亾", "鎵爜鏋�", "", "鍐欏叆杈婇亾淇℃伅锛歕ni_status锛�1,i_direction锛�2,oi_on锛�0"); + } + } + } + catch (Exception ex) + { + WriteLog.Write_Log(key.Key + "杈婇亾", "鎵爜鏋�", "", ex.Message); + } + } + } + + /// <summary> + /// 璐存爣鏈轰氦浜� + /// </summary> + /// <param name="client"></param> + public static void labeller(PLCClient client) + { + VOLContext context = new VOLContext(); + Idt_geometry_dataRepository geometry_DataRepository = new dt_geometry_dataRepository(context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context); + var groups = client.itemGroups.Where(x => x.opratortype == "labeller").OrderBy(x => x.Methods).ThenBy(x => x.name).GroupBy(x => x.Methods).ToList(); + foreach (var key in groups) + { + try + { + DBItemGroup group = key.FirstOrDefault(x => x.name == "oi_on"); + if (group != null) + { + var oi_on = DBExtension.Read(group, client); + if (Convert.ToByte(oi_on) == 1) + { + var o_wp_id = DBExtension.Read(key.FirstOrDefault(x => x.name == "o_wp_id"), client); + if (string.IsNullOrEmpty(o_wp_id.ToString())) + { + var Work = workinfoRepository.Find(x => x.SN == o_wp_id && x.processCode == "17").OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (Work == null) + { + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)2);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + throw new Exception($"{key.Key}鏈壘鍒癝N锛歿o_wp_id}鐨勫伐鍗曚俊鎭痋n鍐欏叆杈婇亾淇℃伅锛歩_status锛�2,oi_on锛�0"); + } + client.Write(key.FirstOrDefault(x => x.name == "i_job_id").dbAddress, Work.jobID);//宸ュ崟缂栧彿 + client.Write(key.FirstOrDefault(x => x.name == "i_heat_id").dbAddress, Work.heatID);//鐐変唬鍙� + client.Write(key.FirstOrDefault(x => x.name == "i_billet_id").dbAddress, Work.billetID.ToString());//閽㈠澂鍙� + client.Write(key.FirstOrDefault(x => x.name == "i_batch_id").dbAddress, Work.heatBatchID);//鐑鐞嗘壒娆� + client.Write(key.FirstOrDefault(x => x.name == "i_drawing_id").dbAddress, Work.drawingNo);//鍥惧彿 + client.Write(key.FirstOrDefault(x => x.name == "i_status").dbAddress, (byte)1);//鐘舵�� + client.Write(key.FirstOrDefault(x => x.name == "oi_on").dbAddress, (byte)0);//鐢宠澶嶄綅 + WriteLog.Write_Log(key.Key + "杈婇亾", "璐存爣鏈�", "SN鍙凤細" + o_wp_id.ToString(), + $"鍐欏叆杈婇亾淇℃伅锛歕n" + + $"i_job_id锛歿Work.jobID}\n" + + $"i_heat_id锛歿Work.heatID}\n" + + $"i_billet_id锛歿Work.billetID}\n" + + $"i_batch_id锛歿Work.heatBatchID}\n" + + $"i_drawing_id锛歿Work.drawingNo}\n" + + $"i_status锛歿(byte)1}\n" + + $"oi_on锛歿(byte)0}"); + } + } + } + } + catch (Exception ex) + { + WriteLog.Write_Log(key.Key + "杈婇亾", "璐存爣鏈�", "", ex.Message); + } + } + } + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs" index 3e7898c..dbafe1e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/One_two_unitJob.cs" @@ -105,61 +105,133 @@ VOLContext context = new VOLContext(); Idt_plcinfodetailRepository repository = new dt_plcinfodetailRepository(context); List<dt_plcinfodetail> plcinfodetail = new List<dt_plcinfodetail>(); - for (int i = 1; i <= 1; i++) + string name = "VK5"; + for (int i = 1; i <= 2; i++) { dt_plcinfodetail dt_Plcinfodetail1 = new dt_plcinfodetail() { plcdetail_id = Guid.NewGuid(), - plcdetail_iotype = "VK5", - plcdetail_db = "DB630", - plcdetail_value = ((i - 1 + 28 + 10 + 10) * 24).ToString(), - plcdetail_valtype = "string", - plcdetail_len = 20, - plcdetail_name = "R_wheel_SN", - plcdetail_opratortype = "wheel", - plcdetail_remark = "璇诲彇杞﹁疆SN鍙�", - plcdetail_number = "鏈烘鎵�3", + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (0 + (i - 1) * 144).ToString(), + plcdetail_valtype = "byte", + plcdetail_name = "oi_on", + plcdetail_opratortype = "labeller", + plcdetail_remark = "鐢宠", + plcdetail_number = i + "鍗曞厓", }; plcinfodetail.Add(dt_Plcinfodetail1); dt_plcinfodetail dt_Plcinfodetail2 = new dt_plcinfodetail() { plcdetail_id = Guid.NewGuid(), - plcdetail_iotype = "VK5", - plcdetail_db = "DB630", - plcdetail_value = (20 + (i - 1 + 28 + 10 + 10) * 24).ToString(), - plcdetail_valtype = "int16", - plcdetail_name = "R_wheel_type", - plcdetail_opratortype = "wheel", - plcdetail_remark = "璇诲彇杞﹁疆绫诲瀷", - plcdetail_number = "鏈烘鎵�3", + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (2 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "o_wp_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "杞﹁疆SN鍙�", + plcdetail_number = i + "鍗曞厓", }; plcinfodetail.Add(dt_Plcinfodetail2); dt_plcinfodetail dt_Plcinfodetail3 = new dt_plcinfodetail() { plcdetail_id = Guid.NewGuid(), - plcdetail_iotype = "VK5", - plcdetail_db = "DB630", - plcdetail_value = (22 + (i - 1 + 28 + 10 + 10) * 24).ToString(), - plcdetail_valtype = "byte", - plcdetail_name = "R_part_status", - plcdetail_opratortype = "wheel", - plcdetail_remark = "璇诲彇杞﹁疆鐘舵��", - plcdetail_number = "鏈烘鎵�3", + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (24 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_job_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "宸ュ崟缂栧彿", + plcdetail_number = i + "鍗曞厓", }; plcinfodetail.Add(dt_Plcinfodetail3); dt_plcinfodetail dt_Plcinfodetail4 = new dt_plcinfodetail() { plcdetail_id = Guid.NewGuid(), - plcdetail_iotype = "VK5", - plcdetail_db = "DB630", - plcdetail_value = (23 + (i - 1 + 28 + 10 + 10) * 24).ToString(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (22 + (i - 1) * 144).ToString(), plcdetail_valtype = "byte", - plcdetail_name = "R_part_process", - plcdetail_opratortype = "wheel", - plcdetail_remark = "璇诲彇杞﹁疆宸ヨ壓", - plcdetail_number = "鏈烘鎵�3", + plcdetail_name = "i_status", + plcdetail_opratortype = "labeller", + plcdetail_remark = "鐘舵��", + plcdetail_number = i + "鍗曞厓", }; plcinfodetail.Add(dt_Plcinfodetail4); + dt_plcinfodetail dt_Plcinfodetail5 = new dt_plcinfodetail() + { + plcdetail_id = Guid.NewGuid(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (44 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_heat_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "鐐変唬鍙�", + plcdetail_number = i + "鍗曞厓", + }; + plcinfodetail.Add(dt_Plcinfodetail5); + dt_plcinfodetail dt_Plcinfodetail6 = new dt_plcinfodetail() + { + plcdetail_id = Guid.NewGuid(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (64 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_billet_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "閽㈠澂鍙�", + plcdetail_number = i + "鍗曞厓", + }; + plcinfodetail.Add(dt_Plcinfodetail6); + dt_plcinfodetail dt_Plcinfodetail7 = new dt_plcinfodetail() + { + plcdetail_id = Guid.NewGuid(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (84 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_batch_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "鐑鐞嗘壒娆�", + plcdetail_number = i + "鍗曞厓", + }; + plcinfodetail.Add(dt_Plcinfodetail7); + dt_plcinfodetail dt_Plcinfodetail8 = new dt_plcinfodetail() + { + plcdetail_id = Guid.NewGuid(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (104 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_drawing_id", + plcdetail_opratortype = "labeller", + plcdetail_remark = "鍥惧彿", + plcdetail_number = i + "鍗曞厓", + }; + plcinfodetail.Add(dt_Plcinfodetail8); + dt_plcinfodetail dt_Plcinfodetail9 = new dt_plcinfodetail() + { + plcdetail_id = Guid.NewGuid(), + plcdetail_iotype = name, + plcdetail_db = "DB603", + plcdetail_value = (124 + (i - 1) * 144).ToString(), + plcdetail_len = 20, + plcdetail_valtype = "string", + plcdetail_name = "i_wheel_type", + plcdetail_opratortype = "labeller", + plcdetail_remark = "i_wheel_type", + plcdetail_number = i + "鍗曞厓", + }; + plcinfodetail.Add(dt_Plcinfodetail9); } repository.AddRange(plcinfodetail, true); } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs" index c96c3c0..3ca6c7a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK4Job.cs" @@ -39,7 +39,12 @@ client.Connect(); return; } - #region MyRegion + #region 淇℃伅浜や簰 + info_interaction.wheeldata(client); + info_interaction.scan(client); + info_interaction.labeller(client); + #endregion + #region 杞﹁疆淇℃伅杩芥函 Wheel_info_trace.Wheel_online(client); Wheel_info_trace.Wheel_machine(client); Wheel_info_trace.Wheel_offline(client); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs" index a265a27..6e92d6e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/VK5Job.cs" @@ -35,7 +35,12 @@ client.Connect(); return; } - #region MyRegion + #region 淇℃伅浜や簰 + info_interaction.wheeldata(client); + info_interaction.scan(client); + info_interaction.labeller(client); + #endregion + #region 杞﹁疆淇℃伅杩芥函 Wheel_info_trace.Wheel_online(client); Wheel_info_trace.Wheel_machine(client); Wheel_info_trace.Wheel_offline(client); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/\345\244\247\345\261\217/src/views/centerRight4.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/\345\244\247\345\261\217/src/views/centerRight4.vue" index dcc4797..b3e3510 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/\345\244\247\345\261\217/src/views/centerRight4.vue" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/\345\244\247\345\261\217/src/views/centerRight4.vue" @@ -68,7 +68,7 @@ oddRowBGC: '#0f1325', //濂囨暟琛� evenRowBGC: '#171c33', //鍋舵暟琛� index: true, - columnWidth: [50,130,100,60,200], + columnWidth: [50,130,100,60,270], align: ['center'], } }).catch((x)=>{ -- Gitblit v1.9.3