| | |
| | | int liftPos = (int)para.LeftPosition; |
| | | int rightPos = (int)para.RightPosition; |
| | | |
| | | // ç¬ç«å¤æå·¦/峿¯å¦å¯æ§è¡ |
| | | bool canLeft = true, canRight = true; |
| | | |
| | | try |
| | | { |
| | | var leftOrigin = devices.Value.left.Communicator.Read<bool>("M115");//å°è¾¾åç¹ |
| | | if (leftOrigin) |
| | | if (devices.Value.left.Communicator.Read<bool>("M117")) |
| | | { |
| | | messages.Add($"{deptId}轨éå·¦PLCå·²å°åç¹"); |
| | | canLeft = false; |
| | | |
| | | return new WebResponseContent { Status = false, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { } |
| | | try |
| | | { |
| | | var rightOrigin = devices.Value.right.Communicator.Read<bool>("M115"); |
| | | if (rightOrigin) |
| | | { |
| | | messages.Add($"{deptId}轨éå³PLCå·²å°åç¹"); |
| | | canRight = false; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//å·¦plcå°è¾¾ç®æ ä½ç½® |
| | | if (lefttarget) |
| | | { |
| | | messages.Add($"{deptId}轨éå·¦plcå°è¾¾ç®æ ä½ç½®"); |
| | | canLeft = false; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | try |
| | | { |
| | | var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//å³plcå°è¾¾ç®æ ä½ç½® |
| | | if (righttarget) |
| | | if (devices.Value.right.Communicator.Read<bool>("M117")) |
| | | { |
| | | messages.Add($"{deptId}轨éå³plcå°è¾¾ç®æ ä½ç½®"); |
| | | canRight = false; |
| | | return new WebResponseContent { Status = false, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | if (extendedState == "伸åº") |
| | | { |
| | | if (canLeft) |
| | | { |
| | | try |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1001", ext); |
| | | devices.Value.left.Communicator.Write<bool>("M102", true); |
| | | devices.Value.left.Communicator.Write<int>("D1002", liftPos); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | if (canRight) |
| | | { |
| | | try |
| | | { |
| | | |
| | | devices.Value.right.Communicator.Write<int>("D1001", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M102", true); |
| | | devices.Value.right.Communicator.Write<int>("D1002", rightPos); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (extendedState == "缩å") |
| | | |
| | | try |
| | | { |
| | | if (canLeft) |
| | | { |
| | | try |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1001", ext); |
| | | devices.Value.left.Communicator.Write<bool>("M103", true); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | if (canRight) |
| | | { |
| | | try |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1001", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M103", true); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | |
| | | } |
| | | } |
| | | if (devices.Value.left.Communicator.Read<float>("D80")>= liftPos-5)//å°è¾¾æå¤§ä½ç½®) |
| | | { |
| | | messages.Add($"轨éç«{deptId}左伸缩æå·²å°æå¤§ä½ç½®"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1022", liftPos);//伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1002", ext);//å·¦PLCèªå¨å¨ä¼¸åºç¼©åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M102", true);//ä¼¸åºæé® |
| | | |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | try |
| | | { |
| | | if (devices.Value.left.Communicator.Read<float>("D80") >=rightPos-5) |
| | | { |
| | | messages.Add($"轨éç«{deptId}å³ä¼¸ç¼©æå·²å°æå¤§ä½ç½®"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1022", rightPos); |
| | | devices.Value.right.Communicator.Write<int>("D1002", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M102", true); |
| | | |
| | | } } |
| | | catch { } |
| | | |
| | | } |
| | | else if (extendedState == "缩å") |
| | | { |
| | | |
| | | try |
| | | { |
| | | if (devices.Value.left.Communicator.Read<bool>("M115")) //å°è¾¾åç¹ä½ |
| | | { |
| | | messages.Add($"轨éç«{deptId}左伸缩æå·²å°åç¹"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1022", liftPos);//伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1002", ext);//å·¦PLCèªå¨ä¼¸=缩ååºç¼©åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M103", true);//å·¦plc缩åæé® |
| | | |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | |
| | | |
| | | try |
| | | { |
| | | if (devices.Value.right.Communicator.Read<bool>("M115")) |
| | | { |
| | | messages.Add($"轨éç«{deptId}å³ä¼¸ç¼©æå·²å°åç¹"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1022", rightPos); |
| | | devices.Value.right.Communicator.Write<int>("D1002", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M103", true); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | catch { } |
| | | |
| | | } |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "æªç¥æä½å½ä»¤" }; |
| | |
| | | /// <param name="DeptId">è¡éå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ManualOperation(string position, string ExtendedState,int DeptId) |
| | | { |
| | | { |
| | | try |
| | | { |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "é
置项 DepartmentID æ æ³è½¬æ¢ä¸ºæ´æ°" }; |
| | | } |
| | | var devices = GetDevicesByDeptId(deid); |
| | | |
| | | var devices = GetDevicesByDeptId(DeptId); |
| | | if (devices == null) |
| | | return new WebResponseContent { Status = false, Message = "è®¾å¤æªæ¾å°" }; |
| | | //俩个plcå·¦å³åä¸ä¸ª |
| | | //OtherDevice liftotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG001"); |
| | | //OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == "SSG002"); |
| | | |
| | | var para = BaseDal.QueryData(x=>x.Deptid== DeptId).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | if (para == null) |
| | | return new WebResponseContent { Status = false, Message = "åæ°æªé
ç½®" }; |
| | | |
| | | //æ¾å°Dt_Parametersä¸çææ°ä¸æ¡æ°æ®æ ¹æ®å½åçdeid |
| | | var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | int ext = (int)para.ManualExtend;//å·¦PLCæå¨ä¼¸åºç¼©åé度 |
| | | int ret = (int)para.ManualRetraction;//å³PLCæå¨ä¼¸åºç¼©åé度 |
| | | int liftPosition = (int)para.LeftPosition;//左伸åºä½ç½® |
| | | int rigtpostition = (int)para.RightPosition;//å³ä¼¸åºä½ç½® |
| | | bool canLeft = true, |
| | | canRight = true; |
| | | //bool canLeft = true, |
| | | // canRight = true; |
| | | string message = ""; |
| | | |
| | | try |
| | | { |
| | | var leftOrigin = devices.Value.left.Communicator.Read<bool>("M115"); |
| | | |
| | | |
| | | if (leftOrigin) |
| | | if (devices.Value.left.Communicator.Read<bool>("M117")) //é»è®¤æ¯flase |
| | | { |
| | | message += "å·¦PLCå·²å°åç¹ï¼"; |
| | | canLeft = false; |
| | | |
| | | return new WebResponseContent { Status = true, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { } |
| | | { |
| | | } |
| | | try |
| | | { |
| | | var rightOrigin = devices.Value.right.Communicator.Read<bool>("M115"); |
| | | if (rightOrigin) |
| | | if (devices.Value.right.Communicator.Read<bool>("M117")) |
| | | { |
| | | message += "å³PLCå·²å°åç¹ï¼"; |
| | | canRight = false; |
| | | return new WebResponseContent { Status = false, Message = "ç°å¨æ£å¨è¿è¡ä¸ï¼çå¾
æä½å®æ" }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//å·¦plcå°è¾¾ç®æ ä½ç½® |
| | | if (lefttarget) |
| | | { |
| | | message += "å·¦plcå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | canLeft = false; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | try |
| | | { |
| | | var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//å³plcå°è¾¾ç®æ ä½ç½® |
| | | if (righttarget) |
| | | { |
| | | message += "å³plcå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | canRight = false; |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | |
| | | |
| | | if (canLeft) |
| | | if (position == "å·¦" && ExtendedState == "伸åº") |
| | | { |
| | | if (position == "å·¦" && ExtendedState == "伸åº") |
| | | if (devices.Value.left.Communicator.Read<float>("D80") >= liftPosition - 5) //å°è¾¾ç®æ ä½ç½® |
| | | { |
| | | message += "左伸缩æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1004", liftPosition);//左伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1000", ext);//å·¦PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M100", true);//ä¼¸åºæé® |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.left.Communicator.Write<bool>("M100", false); // éæ¾æé® |
| | | devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//左伸åºä½ç½® |
| | | |
| | | |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ext}"); |
| | | } |
| | | else if (position == "å·¦" && ExtendedState == "缩å") |
| | | |
| | | } |
| | | else if (position == "å·¦" && ExtendedState == "缩å") |
| | | { |
| | | if (devices.Value.left.Communicator.Read<bool>("M115"))//缩åçæ¶å夿) |
| | | { |
| | | message += "å·¦PLCå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1004", liftPosition);//伸åºä½ç½® |
| | | devices.Value.left.Communicator.Write<int>("D1000", ext);//å·¦PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M101", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.left.Communicator.Write<bool>("M101", false); // éæ¾æé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ext}"); |
| | | } |
| | | |
| | | } |
| | | if (canRight) |
| | | |
| | | if (position == "å³" && ExtendedState == "伸åº") |
| | | { |
| | | if (position == "å³" && ExtendedState == "伸åº") |
| | | if (devices.Value.right.Communicator.Read<float>("D80") >= rigtpostition - 5) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå°è¾¾ç®æ ä½ç½®ï¼"; |
| | | } |
| | | else |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1004", rigtpostition);//å³ä¼¸åºä½ç½® |
| | | devices.Value.right.Communicator.Write<int>("D1000", ret);//å³PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.right.Communicator.Write<bool>("M100", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.right.Communicator.Write<bool>("M100", false); // éæ¾æé® |
| | | devices.Value.right.Communicator.Write<int>("D1002", liftPosition);//左伸åºä½ç½® |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ret}"); |
| | | } |
| | | else if (position == "å³" && ExtendedState == "缩å") |
| | | |
| | | |
| | | } |
| | | else if (position == "å³" && ExtendedState == "缩å") |
| | | { |
| | | if (devices.Value.right.Communicator.Read<bool>("M115")) |
| | | { |
| | | message += "å³ä¼¸ç¼©æå·²å°åç¹ï¼"; |
| | | } |
| | | else |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1004", rigtpostition);//伸åºä½ç½® |
| | | devices.Value.right.Communicator.Write<int>("D1000", ret);//å³PLCæå¨ä¼¸åºç¼©åé度 |
| | | devices.Value.right.Communicator.Write<bool>("M101", true); |
| | | Thread.Sleep(100); // çå¾
100msï¼æ¨¡ææé®æä¸ï¼ |
| | | devices.Value.right.Communicator.Write<bool>("M101", false); // éæ¾æé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ret}"); |
| | | } |
| | | |
| | | } |
| | | |
| | | else |
| | | |
| | | |
| | | return new WebResponseContent |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "ç¶æåæ°é误" }; |
| | | } |
| | | |
| | | return new WebResponseContent { Status = true, |
| | | Message = string.IsNullOrEmpty(message) ? "æ§è¡æå" : $"æ§è¡å¤±è´¥ï¼{message}", |
| | | Status = true, |
| | | Message = string.IsNullOrEmpty(message) ? "æ§è¡æå" : $"{message}", |
| | | Data = new |
| | | { |
| | | ManualExtend = ext, |
| | | ManualRetraction = ret, |
| | | message |
| | | } |
| | | |
| | | }; |
| | | |
| | | } |
| | | |
| | | |
| | | catch (Exception ex) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |