| | |
| | | return; |
| | | } |
| | | client.WriteByOrder("W_Palpitate", client.ReadByOrder<bool>("R_Palpitate", "å¿è·³")); |
| | | Loadinglevel(client); |
| | | AutoEmptyTray(client); |
| | | StationState(client); |
| | | } |
| | | /// <summary> |
| | | /// ä¸æåº |
| | | /// </summary> |
| | | /// <param name="client"></param> |
| | | private void Loadinglevel(PLCClient client, string number = "䏿åº") |
| | | { |
| | | try |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "æ¡æ¶"); |
| | | if (Gantry_client == null) throw new Exception("æ¡æ¶è°åº¦æå¡æªå¼å¯ï¼"); |
| | | if (!Gantry_client.IsConnected) throw new Exception("䏿¡æ¶è¿æ¥è¶
æ¶ï¼"); |
| | | var Gantryplc = repository.FindFirst(x => x.plcinfo_name == Gantry_client.PLCName); |
| | | |
| | | |
| | | #region 䏿宿 |
| | | |
| | | var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | if (AreaNr != 0) |
| | | { |
| | | var station = stationinfoRepository.Find(x => x.area == area_code(number) && x.stationCode.Substring(x.stationCode.Length - 1, 1) == AreaNr.ToString()).FirstOrDefault(); |
| | | if (station != null) |
| | | { |
| | | var bindSNS = station.bindSN.Split(","); |
| | | var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | |
| | | #region ä¿¡æ¯æ¥è¯¢ç¡®è®¤ |
| | | var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | if (QueryDate) |
| | | { |
| | | var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//ä¿¡æ¯ç¡®è®¤ |
| | | if (!Date_Vaild)//ä¿¡æ¯æè¯¯ï¼è®°å½æ¥å¿ |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | station.remark = $"æªæ¥è¯¢å°SNå·ï¼{bindSNS[bindSNS.Length - 1]}ç订å"; |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{station.stationCode}æªæ¥è¯¢å°SNå·ï¼{bindSNS[bindSNS.Length - 1]}ç订å", "PCS"); |
| | | return; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è´§ä½ç¶ææ´æ°å¤ä½ |
| | | var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | if (!finished && updatefinished) |
| | | { |
| | | Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | WriteLog.Write_Log(number + "䏿宿", number + "è´§ä½ç¶ææ´æ°ä¿¡å·å¤ä½", "æåï¼", |
| | | $"è¯»åæ¡æ¶ä¿¡æ¯ï¼\nä¸æå®æä¿¡å·ï¼{finished}\n\nåå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ä¿¡å·ï¼{false}"); |
| | | } |
| | | #endregion |
| | | |
| | | if (finished && !updatefinished) |
| | | { |
| | | |
| | | #region 夿åºåå·æ¯å¦ä¸è´ |
| | | var area = Gantry_client.ReadByOrder<Int16>("place_prog", number);//æ¾æå®æçåºåå· |
| | | |
| | | WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (AreaNr != area) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // //WriteDBLog.Error(name + "æ¥è¦", $"PCSåºåå·ï¼{AreaNr}ï¼æ¡æ¶åºåå·ï¼{area}é误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼", "PCS"); |
| | | // WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "夿åºåå·æ¯å¦ä¸è´", $"PCSåºåå·ï¼{AreaNr}ï¼\næ¡æ¶åºåå·ï¼{area}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | // return; |
| | | //} |
| | | #endregion |
| | | |
| | | #region å¤æè½¦è½®æ°éæ¯å¦ä¸è´ |
| | | var quantity = Gantry_client.ReadByOrder<Int16>("pos_prog", number);//æ¡æ¶è®°å½ç车轮æ°é |
| | | |
| | | WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | //if (quantity != station.quantity) |
| | | //{ |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // WriteLog.Write_Log(number + "åæå®æåºé", bindSNS[bindSNS.Length - 1], "å¤æè½¦è½®æ°éæ¯å¦ä¸è´", $"åºåå·ï¼{AreaNr}ï¼\næ¡æ¶è½¦è½®æ°ï¼{quantity}\nPCS车轮æ°ï¼{station.quantity}\né误信æ¯ï¼PCSåºåå·ä¸æ¡æ¶åºåå·ä¸ä¸è´ï¼"); |
| | | // return; |
| | | //} |
| | | #endregion |
| | | |
| | | Updatemes(bindSNS[bindSNS.Length - 1]); |
| | | station.quantity = station.quantity - 1; |
| | | station.bindSN = OperStr(bindSNS); |
| | | if (station.quantity <= 0) |
| | | { |
| | | station.stationType = string.Empty; |
| | | station.Number = string.Empty; |
| | | station.heatNumber = string.Empty; |
| | | station.tray_status = "EmptyTray"; |
| | | } |
| | | var count = stationinfoRepository.Update(station, true); |
| | | if (count < 1) |
| | | { |
| | | WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{station.stationCode}", "PCS"); |
| | | return; |
| | | } |
| | | |
| | | Gantry_client.WriteByOrder("W_Storage_update", true, number);//è´§ä½ç¶ææ´æ° |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | |
| | | #region æ¸
ç©ºä¿¡æ¯ |
| | | Gantry_client.WriteByOrder("W_AreaNr", (Int16)0, number);//åºåè´§ä½å· |
| | | Gantry_client.WriteByOrder("W_IndexNr", (Int16)0, number);//æçä¸ç第å 个车轮 |
| | | Gantry_client.WriteByOrder("W_Storage_Type", (Int16)0, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)0, number);//车轮类å |
| | | #endregion |
| | | |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("åæå®æ", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ï¼{true}\nW_RequestUnloadï¼{false}", "PCS"); |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ç³è¯·ä¸æ |
| | | |
| | | if (!Gantry_client.ReadByOrder<bool>("W_RequestUnload", number)) |
| | | { |
| | | var Station = stationinfoRepository.Find(x => x.area == area_code(number) && x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.lastUpdateTime).FirstOrDefault(); |
| | | if (Station != null) |
| | | { |
| | | var SNS = Station.bindSN.Split(","); |
| | | List<string> list = new List<string>(); |
| | | foreach (var SN in SNS) |
| | | { |
| | | if (!string.IsNullOrEmpty(SN)) |
| | | list.Add(SN); |
| | | } |
| | | //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | if (list.Count != Station.quantity) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | stationinfoRepository.Update(Station, true); |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | #endregion |
| | | return; |
| | | } |
| | | |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | |
| | | if (PalletSignal == 1 && MaterialSignal == 1) |
| | | { |
| | | Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//车轮类å |
| | | var area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); |
| | | Gantry_client.WriteByOrder("W_AreaNr", (Int16)area, number);//åºåè´§ä½å· |
| | | Gantry_client.WriteByOrder("W_IndexNr", (Int16)SNS.Length, number);//æçä¸ç第å 个车轮 |
| | | Gantry_client.WriteByOrder("W_Storage_Type", (Int16)1, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SNå· |
| | | Gantry_client.WriteByOrder("W_RequestUnload", true, number); |
| | | #region æ¥å¿è®°å½ |
| | | WriteDBLog.Success("䏿åºç³è¯·", $"读åæçå
çµä¿¡å·ï¼{PalletSignal}\n读å第ä¸ä¸ªè½¦è½®å
çµä¿¡å·ï¼{MaterialSignal}\n\n" + |
| | | $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{area}\næçä¸ç第å 个车轮ï¼{SNS.Length}\næçç±»åï¼{1}\n车轮类åï¼{(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | } |
| | | |
| | | #region æ´æ°ä¸ä¸ªæ£æµä¸æä»»å¡ |
| | | Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); |
| | | if (!agvtaskService.Find(x => x.agv_toaddress == Station.stationCode).Any()) |
| | | { |
| | | var task = agvtaskService.Find(x => x.agv_taskstate == "Queue" && (x.agv_tasktype == "TaskType_OutsourceOutbound" || x.agv_tasktype == "TaskType_Outbound") && x.agv_toaddress == "").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | task.agv_taskstate = "Create"; |
| | | task.agv_toaddress = Station.stationCode; |
| | | agvtaskService.Update(task, true); |
| | | WriteDBLog.Success("æ´æ°ä¸ä¸ªæ£æµä¸æä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}", "PCS"); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region MyRegion |
| | | |
| | | /////æ¥æ¾ä¸æåºçè´§ä½ |
| | | //var Stations = stationinfoRepository.Find(x => x.area == area_code(number)).OrderBy(x => x.lastUpdateTime);//æ ¹æ®æ¶é´å
åæåº |
| | | // //éæµè¯ä¸ä¸ |
| | | //var Station = Stations?.Where(x => x.enable && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).OrderBy(x => x.quantity).FirstOrDefault(); |
| | | |
| | | //if (Station != null) |
| | | //{ |
| | | // var SNS = Station.bindSN.Split(","); |
| | | // List<string> list = new List<string>(); |
| | | // foreach (var SN in SNS) |
| | | // { |
| | | // if (!string.IsNullOrEmpty(SN)) |
| | | // list.Add(SN); |
| | | // } |
| | | // //ç¼åæ¶ä¸è½¦è½®æ°éä¸SNå·æ°éä¸ä¸è´ |
| | | // if (list.Count != Station.quantity) |
| | | // { |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = "车轮æ°éä¸SNå·æ°éä¸ä¸è´"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Error("䏿åº", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}车轮æ°éä¸SNå·æ°éä¸ä¸è´", "PCS"); |
| | | // #endregion |
| | | // return; |
| | | // } |
| | | // var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == Station.stationCode).ToList(); |
| | | // var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | // var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | |
| | | // var AreaNr = Gantry_client.ReadByOrder<Int16>("W_AreaNr", number);//读åè´§ä½å·ä¿¡æ¯ |
| | | // if (PalletSignal == 1 && MaterialSignal == 1) |
| | | // { |
| | | // if (AreaNr == 0) |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)Convert.ToInt16(QueryMateriel(Station.stationType) == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId), number);//车轮类å |
| | | // var area = Convert.ToInt16(Station.stationCode.Substring(Station.stationCode.Length - 1, 1)); |
| | | // Gantry_client.WriteByOrder("W_AreaNr", (Int16)area, number);//åºåè´§ä½å· |
| | | // Gantry_client.WriteByOrder("W_IndexNr", (Int16)SNS.Length, number);//æçä¸ç第å 个车轮 |
| | | // Gantry_client.WriteByOrder("W_Storage_Type", (Int16)1, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | // Gantry_client.WriteByOrder("W_Wheel_id", SNS[SNS.Length - 1], number);//车轮SNå· |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", true, number); |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Success("䏿åºç³è¯·", $"读åæçå
çµä¿¡å·ï¼{PalletSignal}\n读å第ä¸ä¸ªè½¦è½®å
çµä¿¡å·ï¼{MaterialSignal}\n\n" + |
| | | // $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nåºåè´§ä½å·ï¼{area}\næçä¸ç第å 个车轮ï¼{SNS.Length}\næçç±»åï¼{1}\n车轮类åï¼{(QueryMateriel(Station.stationType).TypeId == null ? QueryMateriel1(Station.stationType).TypeId : QueryMateriel(Station.stationType).TypeId)}" + |
| | | // $"\n车轮SNå·ï¼{SNS[SNS.Length - 1]}\nW_RequestUnloadï¼true", "PCS"); |
| | | // #endregion |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number); |
| | | // } |
| | | |
| | | // var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList(); |
| | | // var Gantry_Out_of_Area = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//æ¡æ¶æ¯å¦å¨åºåå
|
| | | |
| | | // var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//ä¿¡æ¯æ¥è¯¢ |
| | | // if (QueryDate) |
| | | // { |
| | | // var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//ä¿¡æ¯ç¡®è®¤ |
| | | // if (!Date_Vaild)//ä¿¡æ¯æè¯¯ï¼è®°å½æ¥å¿ |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = $"æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // WriteDBLog.Error("䏿åºä¿¡æ¯æ¥è¯¢", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nW_RequestUnloadï¼false\n\n{Station.stationCode}æªæ¥è¯¢å°SNå·ï¼{SNS[SNS.Length - 1]}ç订å", "PCS"); |
| | | // return; |
| | | // } |
| | | // } |
| | | // var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹å宿 |
| | | // var updatefinished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "W_Storage_update").First(), Gantry_client);//è´§ä½ç¶ææ´æ° |
| | | // if (!finished && updatefinished) |
| | | // Gantry_client.WriteByOrder("W_Storage_update", false, number);//è´§ä½ç¶ææ´æ° |
| | | // if (finished && !updatefinished) |
| | | // { |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | // Updatemes(SNS[SNS.Length - 1]); |
| | | // Station.quantity = Station.quantity - 1; |
| | | // Station.bindSN = OperStr(SNS); |
| | | // if (Station.quantity <= 0) |
| | | // { |
| | | // Station.stationType = string.Empty; |
| | | // Station.Number = string.Empty; |
| | | // Station.heatNumber = string.Empty; |
| | | // Station.tray_status = "EmptyTray"; |
| | | // } |
| | | // var count = stationinfoRepository.Update(Station, true); |
| | | // if (count < 1) |
| | | // { |
| | | // WriteDBLog.Error("åæå®æ", $"䏿ä½ä¿¡æ¯æ´æ°å¤±è´¥ï¼ä¸æä½ç¼å·ï¼{Station.stationCode}", "PCS"); |
| | | // return; |
| | | // } |
| | | |
| | | // #region æ¸
ç©ºä¿¡æ¯ |
| | | // Gantry_client.WriteByOrder("W_AreaNr", (Int16)0, number);//åºåè´§ä½å· |
| | | // Gantry_client.WriteByOrder("W_IndexNr", (Int16)0, number);//æçä¸ç第å 个车轮 |
| | | // Gantry_client.WriteByOrder("W_Storage_Type", (Int16)0, number); //æçç±»å1-横æ¾;2-ç«æ¾ |
| | | // Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)0, number);//车轮类å |
| | | // #endregion |
| | | |
| | | // Gantry_client.WriteByOrder("W_Storage_update", true, number);//è´§ä½ç¶ææ´æ° |
| | | // #region æ¥å¿è®°å½ |
| | | // WriteDBLog.Success("åæå®æ", $"åå
¥æ¡æ¶ä¿¡æ¯ï¼\nè´§ä½ç¶ææ´æ°ï¼{true}\nW_RequestUnloadï¼{false}", "PCS"); |
| | | // #endregion |
| | | |
| | | // #region æ¥è¦ |
| | | // PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | // MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | // if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1)) |
| | | // { |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = "车轮æ°é大äº0ï¼å
çµæ£æµæ æçææ è½¦è½®"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // WriteDBLog.Error(number + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | // } |
| | | // else if (Station.quantity < 1 && MaterialSignal == 1) |
| | | // { |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = "车轮æ°éå°äº0ï¼å
çµæ£æµæè½¦è½®"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, number);//æ¥è¦ |
| | | // WriteDBLog.Error(number + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | // } |
| | | // #endregion |
| | | |
| | | |
| | | // } |
| | | //} |
| | | //else |
| | | // Gantry_client.WriteByOrder("W_RequestUnload", false, number);//ä¿¡å·ä¸ºfalseæ¡æ¶åæ¢è¿å
¥ |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("䏿åº", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// èªå¨å空æ |
| | | /// </summary> |
| | | /// <param name="client"></param> |
| | | private void AutoEmptyTray(PLCClient client) |
| | | { |
| | | try |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context); |
| | | Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context); |
| | | Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName); |
| | | List<string> stationCodes = new List<string>() { "S01001001", "S01001002", "W01001001", "W01001002", "W01001003" }; |
| | | string remark = ""; |
| | | foreach (var stationCode in stationCodes) |
| | | { |
| | | try |
| | | { |
| | | remark = "æ¥è¯¢ç«å°"; |
| | | var station = stationinfoRepository.Find(x => x.stationCode == stationCode && x.enable).FirstOrDefault(); |
| | | if (station == null) continue; |
| | | remark = "æ¥è¯¢èµ·ç¹æ¯å¦åå¨ä»»å¡"; |
| | | if (stationCode.Contains("W") && agvtaskService.Find(x => x.agv_fromaddress == stationCode || x.agv_toaddress == stationCode).Any()) continue; |
| | | else |
| | | { |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == stationCode).Any()) continue; |
| | | } |
| | | remark = "读åå
çµä¿¡å·"; |
| | | var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == stationCode).ToList(); |
| | | var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读åæçä¿¡å·:1:æ,2æ |
| | | var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | if (PalletSignal == 1 && MaterialSignal == 2 && (station.stationCode.Contains("S0100100") ? station.tray_status == "EmptyTray" : true)) |
| | | { |
| | | var area = station.tray_type == "SmallTray" ? "11" : "10"; |
| | | remark = "æ¥è¯¢æ¯å¦åå¨è¡¥ç©ºæéåä»»å¡"; |
| | | var task = agvtaskService.Find(x => (x.agv_toaddress.Contains("W") || x.agv_toaddress.Contains("X")) && x.agv_taskstate == "Queue" && x.agv_tasktype == "TaskType_EmptyPallet" && x.agv_Traytype == station.tray_type).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | task.agv_fromaddress = station.stationCode; |
| | | task.StarQuantity = 0; |
| | | task.agv_taskstate = "Create"; |
| | | if (station.stationCode.Contains("S0100100")) |
| | | task.agv_grade = 3; |
| | | agvtaskService.Update(task, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Success("æ´æ°ç©ºæéåä»»å¡", $"ä»»å¡ç¼å·ï¼{task.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | continue; |
| | | } |
| | | remark = "æ¥è¯¢ç©ºæå çä½"; |
| | | #region 空æå ç |
| | | var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("DD") && x.quantity < 5 && x.enable).ToList(); |
| | | var EmptyStation = EmptyStations.Where(x => x.tray_type == station.tray_type && x.location_state == LocationStateEnum.Stroge.ToString()).FirstOrDefault(); |
| | | if (EmptyStation == null) |
| | | EmptyStation = EmptyStations.Where(x => x.location_state == LocationStateEnum.Empty.ToString() && x.quantity == 0).FirstOrDefault(); |
| | | #endregion |
| | | remark = "æ¥æ¾åºå
空æä½"; |
| | | if (EmptyStation == null)//æ¥æ¾åºå
空æç |
| | | EmptyStation = GetStation.EmptyPalletStation(area); |
| | | |
| | | |
| | | if (EmptyStation != null) |
| | | { |
| | | #region åä¸ä¸ªç©ºæä½åªè½åæ¶çæä¸ä¸ªç©ºæä»»å¡ |
| | | remark = "æ¥è¯¢ç©ºæä½æ¯å¦åå¨ä»»å¡"; |
| | | if (agvtaskService.Find(x => x.agv_fromaddress == EmptyStation.stationCode || x.agv_toaddress == EmptyStation.stationCode).Any()) |
| | | return; |
| | | #endregion |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = station.stationCode.Contains("S0100100") ? 3 : 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = EmptyStation.quantity, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = EmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = "EmptyTray",//station.tray_status, |
| | | agv_Traytype = station.tray_type, |
| | | }; |
| | | agvtaskService.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(EmptyStation, true); |
| | | WriteDBLog.Success("å建èªå¨å空æä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}ï¼æçä¿¡å·:{PalletSignal},è´§ç©ä¿¡å·:{MaterialSignal}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("å建èªå¨å空æä»»å¡", $"{stationCode}ï¼{remark}é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteDBLog.Error("å建èªå¨å空æä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ£æµå
çµç¶æä¸ç³»ç»è´§ä½ç¶ææ¯å¦ä¸è´ |
| | | /// </summary> |
| | | /// <param name="client"></param> |
| | | private void StationState(PLCClient client) |
| | | { |
| | | try |
| | | { |
| | | List<string> names = new List<string>() { "1åå
䏿åº", "2åå
䏿åº", "3åå
䏿åº" };/*, "䏿åº"*/ |
| | | foreach (var name in names) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); |
| | | var Stations = stationinfoRepository.Find(x => x.area == area_code(name) && x.enable && !x.location_state.Contains("Busy") && x.location_state != LocationStateEnum.Abnormal.ToString()); |
| | | foreach (var Station in Stations) |
| | | { |
| | | var PalletSignal = client.ReadByOrder<Int16>("R_PalletSignal", Station.stationCode);//读åæçä¿¡å·:1:æ,2æ |
| | | var MaterialSignal = client.ReadByOrder<Int16>("R_MaterialSignal", Station.stationCode);//读åè´§ç©ä¿¡å·:1:æ,2æ |
| | | if (Station.quantity > 0 && (PalletSignal != 1 || MaterialSignal != 1))//ç³»ç»è´§ä½æè½¦è½®ï¼å
çµæ£æµæ 车轮 |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = $"车轮æ°é大äº0ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | if (Station.location_state == LocationStateEnum.Stroge.ToString() && PalletSignal != 1) |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = $"è´§ä½ç¶æä¸ºæè´§ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | if (Station.location_state == LocationStateEnum.Empty.ToString() && (PalletSignal == 1 || MaterialSignal == 1))//ç³»ç»è´§ä½ä¸ºç©ºï¼å
çµæ£æµææ |
| | | { |
| | | Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | Station.remark = $"è´§ä½ç¶æä¸ºç©ºè´§ä½ï¼æçå
çµä¿¡å·ä¸ºï¼{PalletSignal}ï¼è´§ç©å
çµä¿¡å·ä¸ºï¼{MaterialSignal}"; |
| | | stationinfoRepository.Update(Station, true); |
| | | client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | WriteDBLog.Error(name + "æ¥è¦", $"è´§ä½ç¼å·ï¼{Station.stationCode}ï¼é误信æ¯ï¼{Station.remark}", "PCS"); |
| | | continue; |
| | | } |
| | | //if (Station.quantity < 1 && MaterialSignal == 1)//ç³»ç»è´§ä½æ 车轮ï¼å
çµæ£æµæè½¦è½® |
| | | //{ |
| | | // Station.location_state = LocationStateEnum.Abnormal.ToString(); |
| | | // Station.remark = "è´§ä½æ 车轮ï¼å
çµæ£æµæè½¦è½®"; |
| | | // stationinfoRepository.Update(Station, true); |
| | | // client.WriteByOrder("W_AlarmSignal", (Int16)2, name);//æ¥è¦ |
| | | // continue; |
| | | //} |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | //throw; |
| | | } |
| | | } |
| | | public static string area_code(string area_name) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_areainfoRepository areainfoRepository = new dt_areainfoRepository(Context); |
| | | var areainfo = areainfoRepository.Find(x => x.area_name == area_name).FirstOrDefault(); |
| | | return areainfo.area_code.ToString(); |
| | | } |
| | | |
| | | private string OperStr(string[] strArrty) |
| | | { |
| | | string[] newstr = strArrty.RemoveLast(1); |
| | | string Newsn = string.Join(",", newstr); |
| | | |
| | | return Newsn; |
| | | } |
| | | public static dt_geometry_data QueryMateriel(string type) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | var materielinfo = dataRepository.Find(x => x.Description == type).OrderBy(x => x.TypeId).FirstOrDefault(); |
| | | return materielinfo; |
| | | } |
| | | public static dt_geometry_data_detectionline QueryMateriel1(string type) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_geometry_data_detectionlineRepository detectionlineRepository = new dt_geometry_data_detectionlineRepository(Context); |
| | | var materielinfo1 = detectionlineRepository.Find(x => x.Description == type).OrderBy(x => x.TypeId).FirstOrDefault(); |
| | | return materielinfo1; |
| | | } |
| | | public static string QueryMateriel(int typeId) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context); |
| | | var materielinfo = dataRepository.FindFirst(x => x.TypeId == typeId); |
| | | return materielinfo.Description; |
| | | } |
| | | /// <summary> |
| | | /// æ´æ¹å·¥åç¶æ |
| | | /// </summary> |
| | | /// <param name="SN"></param> |
| | | public static void Updatemes(string SN) |
| | | { |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(Context); |
| | | Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(Context); |
| | | IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); |
| | | //var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == SN).First(); |
| | | var Mes_Work = workinfoRepository.Find(x => x.SN == SN && x.processCode == "28").FirstOrDefault(); |
| | | var mes_Detail = mes_DetailRepository.Find(x => x.SN == SN && x.jobID == Mes_Work.jobID).FirstOrDefault(); |
| | | if (mes_Detail != null) |
| | | { |
| | | mes_Detail.Status = "ä¸çº¿"; |
| | | mes_Detail.FinishTime = DateTime.Now; |
| | | //freeDB.DataBase.Update<dt_mes_detail>().SetSource(mes_Detail).UpdateColumns(x => new { x.Status, x.FinishTime }).ExecuteAffrows(); |
| | | mes_DetailRepository.Update(mes_Detail, true); |
| | | //var mes_Head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_Detail.jobID).First(); |
| | | var mes_Head = mes_HeadRepository.Find(x => x.jobID == mes_Detail.jobID).FirstOrDefault(); |
| | | if (mes_Head != null) |
| | | { |
| | | mes_Head.finishNum = mes_Head.finishNum + 1; |
| | | //freeDB.DataBase.Update<dt_mes_head>().SetSource(mes_Head).UpdateColumns(x => new { x.finishNum }).ExecuteAffrows(); |
| | | mes_HeadRepository.Update(mes_Head, true); |
| | | } |
| | | } |
| | | Pipeline pipeline = new Pipeline(); |
| | | pipeline.Loadinglevel(client); |
| | | pipeline.AutoEmptyTray(client); |
| | | pipeline.StationState(client); |
| | | } |
| | | } |
| | | } |