添加VK4、VK5的通信处理逻辑(VK4、VK5)开发完成
¶Ô±ÈÐÂÎļþ |
| | |
| | | using 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åå
¥è¾éä¿¡æ¯ï¼i_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åå
¥è¾éä¿¡æ¯ï¼i_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}æªæ¾å°SNï¼{o_wp_id}çå·¥åä¿¡æ¯\nåå
¥è¾éä¿¡æ¯ï¼i_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}æªæ¾å°SNï¼{o_wp_id}çå·¥åä¿¡æ¯\nåå
¥è¾éä¿¡æ¯ï¼i_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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | oddRowBGC: '#0f1325', //奿°è¡ |
| | | evenRowBGC: '#171c33', //å¶æ°è¡ |
| | | index: true, |
| | | columnWidth: [50,130,100,60,200], |
| | | columnWidth: [50,130,100,60,270], |
| | | align: ['center'], |
| | | } |
| | | }).catch((x)=>{ |