| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Repositories; |
| | | using WIDESEA_WCS.WCSClient; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | |
| | | namespace WIDESEA_WCS |
| | | { |
| | |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | /// <summary> |
| | | /// æ¥è¯¢è½¦è½®æ°æ® |
| | | /// </summary> |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | |
| | | #region æ¥è¯¢è½¦è½®æ°æ® |
| | | public void QueryWheeldata(PLCClient client) |
| | | { |
| | | try |
| | |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client); |
| | | if ((Int16)on == 1) |
| | | if ((byte)on == 1) |
| | | { |
| | | var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client); |
| | | var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type); |
| | | if (geometry == null) |
| | | { |
| | | //DBExtension.Write(details.Where(x => x.plcdetail_name == "W_i_status").First(), client, (Int16)2); |
| | | client.WriteByOrder("W_i_status", (Int16)2, name);//1-æ¾å°æ°æ®ï¼2-æªæ¾å°å·¥ä»¶ç±»åæ°æ® |
| | | client.WriteByOrder("W_i_skip_op", "1", name);//å±è½å·¥èº(å±è½è§è§æ£æµ/å±è½æ¶æ²¹); |
| | | //0-使ç¨ï¼1-è·³è¿ |
| | | client.WriteByOrder("R_oi_on", (Int16)0, name); |
| | | //1-æ¾å°æ°æ®ï¼2-æªæ¾å°å·¥ä»¶ç±»åæ°æ® |
| | | client.WriteByOrder("W_i_status", (byte)2, name); |
| | | //å±è½å·¥èº(å±è½è§è§æ£æµ/å±è½æ¶æ²¹); |
| | | //client.WriteByOrder("W_i_skip_op", "1", name); |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | } |
| | | else |
| | | { |
| | | client.WriteByOrder("W_i_status", (Int16)1, name); |
| | | //1-æ¾å°æ°æ®ï¼2-æªæ¾å°å·¥ä»¶ç±»åæ°æ® |
| | | client.WriteByOrder("W_i_status", (byte)1, name); |
| | | client.WriteByOrder("W_i_parameter_a", (float)geometry.a, name); |
| | | client.WriteByOrder("W_i_parameter_b", (float)geometry.b, name); |
| | | client.WriteByOrder("W_i_parameter_c", (float)geometry.c, name); |
| | |
| | | client.WriteByOrder("W_i_parameter_g", (float)geometry.g, name); |
| | | client.WriteByOrder("W_i_parameter_h", (float)geometry.h, name); |
| | | //å±è½å·¥èº(å±è½è§è§æ£æµ/å±è½æ¶æ²¹) |
| | | client.WriteByOrder("W_i_skip_op", "0", name);//å符串åå
¥-2 |
| | | client.WriteByOrder("R_oi_on", (Int16)0, name); |
| | | if (name != "è¾é䏿æ¥è¯¢è½¦è½®") |
| | | { |
| | | client.WriteByOrder("W_i_skip_op_SJ1", (byte)1, name);//å±è½è§è§æ£æµè®¾å¤1 |
| | | client.WriteByOrder("W_i_skip_op_SJ2", (byte)1, name);//å±è½è§è§æ£æµè®¾å¤2 |
| | | client.WriteByOrder("W_i_skip_op_LT", (byte)1, name);//å±è½é¾æ¡æº |
| | | } |
| | | client.WriteByOrder("R_oi_on", (byte)0, name); |
| | | } |
| | | } |
| | | } |
| | |
| | | throw; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æ¥è¯¢è®¢å,æ¯å¦éè¦å å·¥ |
| | | /// </summary> |
| | | #endregion |
| | | |
| | | #region æ¥è¯¢è®¢å,æ¯å¦éè¦å å·¥ |
| | | public void QueryOrder(PLCClient client) |
| | | { |
| | | try |
| | |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | var on = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_oi_on").First(), client); |
| | | if ((Int16)on == 1) |
| | | if ((byte)on == 1) |
| | | { |
| | | var wp_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_id").First(), client); |
| | | //éæ·»å æ¥è¯¢è½¦è½®SNå·è®¢åé»è¾ |
| | | //éæ·»å æ¥è¯¢è½¦è½®SNå·è®¢åé»è¾ éæ·»å å
¥åºæ¨¡å¼å¤æï¼æå¨å
¥åºæ¨¡å¼é人工添å å
¥åºåºåºï¼å¦åæ¥è¦ |
| | | |
| | | |
| | | var wp_type = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_o_wp_type").First(), client); |
| | | var geometry = dataRepository.FindFirst(x => x.TypeId == (Int32)wp_type); |
| | | if (geometry == null) |
| | | { |
| | | client.WriteByOrder("W_i_status", (Int16)2, name);//1-好,å
许å å·¥ï¼2-ä¸å¨å表ä¸ï¼3-ä¸å 工车轮类å |
| | | //1-好,å
许å å·¥ï¼2-ä¸å¨å表ä¸ï¼3-ä¸å 工车轮类åï¼4-æå¨å
¥åºæ¨¡å¼äººå·¥æªéæ©åºåº |
| | | client.WriteByOrder("W_i_status", (Int16)2, name); |
| | | client.WriteByOrder("R_oi_on", (Int16)0, name); |
| | | } |
| | | else |
| | | { |
| | | //1-好,å
许å å·¥ï¼2-ä¸å¨å表ä¸ï¼3-ä¸å 工车轮类åï¼4-æå¨å
¥åºæ¨¡å¼äººå·¥æªéæ©åºåº |
| | | client.WriteByOrder("W_i_status", (Int16)1, name); |
| | | //client.WriteByOrder("W_i_job_id", "", name); |
| | | //client.WriteByOrder("W_i_drawing_id", "", name); |
| | |
| | | throw; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 䏿ä½äº¤äº |
| | | /// </summary> |
| | | #endregion |
| | | |
| | | #region 䏿ä½äº¤äº |
| | | public void Layofflevel(PLCClient client) |
| | | { |
| | | try |
| | | { |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº", "䏿åº" }; |
| | | var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "龿¡æº"); |
| | | if (Pipeline_client == null) throw new Exception("龿¡æºè°åº¦æå¡æªå¼å¯ï¼"); |
| | | if (!Pipeline_client.IsConnected) throw new Exception("ä¸é¾æ¡æºè¿æ¥è¶
æ¶ï¼"); |
| | | var Pipelineplc = repository.FindFirst(x => x.plcinfo_name == Pipeline_client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº" }; |
| | | foreach (string name in names) |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | |
| | | var Request = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Request_Load").First(), client); |
| | | if (!Request) continue; |
| | | var PartStatus = (Int32)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok |
| | | |
| | | List<string> StationCodes = new List<string>() { "X01001001", "X01001002", "X01001003" }; |
| | | if (name == "2åå
䏿åº") |
| | | StationCodes = new List<string>() { "X02001001", "X02001002", "X02001003" }; |
| | | if (name == "3åå
䏿åº") |
| | | StationCodes = new List<string>() { "X03001001", "X03001002" }; |
| | | var Wheel_Type = (Int32)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_Type").First(), client);//车轮类å |
| | | var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString();//车轮SNå· |
| | | |
| | | |
| | | client.WriteByOrder("W_AreaNr", (Int16)1, name);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)1, name);//æçä¸ç第å 个车轮 |
| | | client.WriteByOrder("W_Storage_Type", true, name);//æçç±»å1-横æ¾;2-ç«æ¾ |
| | | for (int i = 0; i < StationCodes.Count - 1; i++) |
| | | { |
| | | var PartStatus = (Int32)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok |
| | | string NG = StationCodes[StationCodes.Count - 1];//NGè´§ä½ |
| | | var station = stationinfoRepository.FindFirst(x => x.stationCode == StationCodes[i] && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity < 5); |
| | | if (station == null) continue; |
| | | var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == StationCodes[i]).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | if (PalletSignal == 1) |
| | | { |
| | | if (PartStatus == 1 && NG != station.stationCode) |
| | | { |
| | | client.WriteByOrder("W_AreaNr", (Int16)i + 1, name);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)station.quantity + 1, name);//æçä¸ç第å 个车轮 |
| | | } |
| | | else if (PartStatus == 2 && NG == station.stationCode) |
| | | { |
| | | client.WriteByOrder("W_AreaNr", (Int16)i + 1, name);//åºåè´§ä½å· |
| | | client.WriteByOrder("W_IndexNr", (Int16)station.quantity + 1, name);//æçä¸ç第å 个车轮 |
| | | } |
| | | client.WriteByOrder("W_Storage_Type", (Int16)1, name);//æçç±»å1-横æ¾;2-ç«æ¾(ææ¶åªææ¨ªæ¾æç) |
| | | client.WriteByOrder("W_Enabl_Load", true, name);//æ¯å¦å
许 |
| | | |
| | | } |
| | | } |
| | | var finished = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_load_finished").First(), client);//æ¾æå®æ |
| | | if (finished) |
| | | { |
| | | |
| | | var AreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_AreaNr").First(), client); |
| | | var station = stationinfoRepository.FindFirst(x => x.stationCode == StationCodes[AreaNr - 1]); |
| | | station.quantity = station.quantity++; |
| | | stationinfoRepository.Update(station); |
| | | client.WriteByOrder("W_Storage_update", true, name);//è´§ä½ç¶ææ´æ° |
| | | } |
| | | } |
| | |
| | | throw; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// é²åæªæ½ |
| | | /// </summary> |
| | | static bool Gantry_Out_of_Area1;//æ¡æ¶æ¯å¦å¨åºåå
|
| | | static bool Gantry_Out_of_Area2;//æ¡æ¶æ¯å¦å¨åºåå
|
| | | static bool Gantry_Out_of_Area3;//æ¡æ¶æ¯å¦å¨åºåå
|
| | | static bool Gantry_Out_of_Area4;//æ¡æ¶æ¯å¦å¨åºåå
|
| | | public void Stupidproofmeasure(PLCClient client) |
| | | { |
| | | try |
| | | { |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> names = new List<string>() { "1åå
é²å", "2åå
é²å", "3åå
é²å", "䏿åºé²å" }; |
| | | foreach (string name in names) |
| | | { |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList(); |
| | | var Release_In = (bool)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Release_In").First(), client);//å
许è¿å
¥ |
| | | if (!Release_In) { } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |