From ac93c4092a21dbf0fa9cf8b9b1302f2d5d183f61 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 09 六月 2025 20:48:20 +0800
Subject: [PATCH] 修改提示字段

---
 project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs |  241 ++++++++++++++++++++++++-----------------------
 1 files changed, 122 insertions(+), 119 deletions(-)

diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
index 68f1eda..4382f87 100644
--- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
+++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
@@ -15,6 +15,7 @@
 using WIDESEAWCS_ITelescopicService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
+using static WIDESEAWCS_Common.Face.TH_Faces;
 
 
 namespace WIDESEAWCS_TelescopicService
@@ -37,6 +38,7 @@
         /// <returns></returns>
         public WebResponseContent automation(string ExtendedState)
         {
+            
             try
             {
 
@@ -56,54 +58,27 @@
                 int ret = (int)para.RetractionSpeed;//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
                 int liftPosition = (int)para.LeftPosition;//宸︿几鍑轰綅缃�
                 int rigtpostition = (int)para.RightPosition;//鍙充几鍑轰綅缃�
-                bool canLeftWork = true;
-                bool canRightWork = true;
                 string message = "";
-                    try
-                    {
-                        var leftorigin = devices.Value.left.Communicator.Read<bool>("M115");  //鍒拌揪鍘熺偣浣嶇疆
-                        if (leftorigin)
-                        {
-                            canLeftWork = false;
-                            message += "宸LC宸插埌鍘熺偣锛�";
-                        }
-                    }
-                    catch (Exception)
-                    {  
-                    }
-                    try
-                    {
-                        var rightorigin = devices.Value.right.Communicator.Read<bool>("M115");
-                        if (rightorigin)
-                        {
-                            canRightWork = false;
-                            message += "鍙砅LC宸插埌鍘熺偣锛�";
-                        }
-                    }
-                    catch (Exception)
-                    { 
-                    }
 
                 try
                 {
-                    var lefttarget = devices.Value.left.Communicator.Read<bool>("M116"); //鍒拌揪鏈�澶т綅缃�
-                   
-                    if (lefttarget)
+                    if (devices.Value.left.Communicator.Read<bool>("M117"))
                     {
-                        canLeftWork = false;
-                        message += "宸LC宸插埌鏈�澶у�硷紱";
+                        
+                        return new WebResponseContent { Status = true, Message = "鐜板湪姝e湪杩涜涓紝绛夊緟鎿嶄綔瀹屾垚" };
                     }
-                  
+                    
                 }
-                catch { }
+                catch (Exception)
+                {
+                }
                 try
                 {
-                    var righttarget = devices.Value.right.Communicator.Read<bool>("M116");
-                    if (righttarget)
+                    if (devices.Value.right.Communicator.Read<bool>("M117"))
                     {
-                        canRightWork = false;
-                        message += "鍙砅LC宸插埌鏈�澶у�硷紱";
+                        return new WebResponseContent { Status = true, Message = "鐜板湪姝e湪杩涜涓紝绛夊緟鎿嶄綔瀹屾垚" };
                     }
+                    
                 }
                 catch (Exception)
                 {
@@ -111,51 +86,79 @@
 
                 if (ExtendedState == "浼稿嚭")
                 {
-                    if (canLeftWork)
-                    {
+                   
                         try
                         {
-                            devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩鍔ㄤ几鍑虹缉鍥為�熷害
+                        if (devices.Value.left.Communicator.Read<float>("D80")>= liftPosition-5)//鍒拌揪鏈�澶т綅缃�)
+                        {
+                            message += "宸︿几缂╂潌鍒拌揪鐩爣浣嶇疆锛�";
+                        }
+                        else
+                        {
+                            devices.Value.left.Communicator.Write<int>("D1022", liftPosition);//浼稿嚭浣嶇疆
+                            devices.Value.left.Communicator.Write<int>("D1002", ext);//宸LC鑷姩鍔ㄤ几鍑虹缉鍥為�熷害
                             devices.Value.left.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
-                            devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//浼稿嚭浣嶇疆
+                            
+                        } 
                         }
                         catch { }
-                    }
-
-                    if (canRightWork)
-                    {
+                
                         try
                         {
-                            devices.Value.right.Communicator.Write<int>("D1001", ret);
-                            devices.Value.right.Communicator.Write<bool>("M102", true);
-                            devices.Value.right.Communicator.Write<int>("D1002", rigtpostition);
+                        if (devices.Value.right.Communicator.Read<float>("D80") >= rigtpostition-5)
+                        {
+                            message += "鍙充几缂╂潌鍒拌揪鐩爣浣嶇疆锛�";
                         }
+                        else
+                        {
+                            devices.Value.right.Communicator.Write<int>("D1022", rigtpostition);
+                            devices.Value.right.Communicator.Write<int>("D1002", ret);
+                            devices.Value.right.Communicator.Write<bool>("M102", true);
+                            
+                        }                        }
                         catch { }
-                    }
+                    
                 }
                 else if (ExtendedState == "缂╁洖")
                 {
-                    if (canLeftWork)
-                    {
+                    
                         try
                         {
-                            devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼�=缂╁洖鍑虹缉鍥為�熷害
+                        if (devices.Value.left.Communicator.Read<bool>("M115")) //鍒拌揪鍘熺偣浣�
+                        {
+                            message += "宸︿几缂╂潌宸插埌鍘熺偣锛�";
+                        }
+                        else
+                        {
+                            devices.Value.left.Communicator.Write<int>("D1022", liftPosition);
+                            devices.Value.left.Communicator.Write<int>("D1002", ext);//宸LC鑷姩浼�=缂╁洖鍑虹缉鍥為�熷害
                             devices.Value.left.Communicator.Write<bool>("M103", true);//宸lc缂╁洖鎸夐挳
                             
-                        }
-                        catch { }
+                            
+                        }                           
                     }
+                        catch { }
 
-                    if (canRightWork)
-                    {
+                   
                         try
                         {
-                            devices.Value.right.Communicator.Write<int>("D1001", ret);
+                        if (devices.Value.right.Communicator.Read<bool>("M115"))
+                        {
+                            message += "鍙充几缂╂潌宸插埌鍘熺偣锛�";
+                        }
+                        else
+                        {
+                            devices.Value.right.Communicator.Write<int>("D1022", rigtpostition);
+                            devices.Value.right.Communicator.Write<int>("D1002", ret);
                             devices.Value.right.Communicator.Write<bool>("M103", true);
+                            
+
+                        }
+                          
                           
                         }
                         catch { }
-                    }
+                    
                 }
                 else
                 {
@@ -165,8 +168,8 @@
                 return new WebResponseContent
                 {
                     Status = true,
-                    Message = string.IsNullOrEmpty(message) ? "鎵ц鎴愬姛" : $"閮ㄥ垎PLC鏈墽琛岋細{message}",
-                    Data = new { ExtendSpeed = ext, RetractionSpeed = ret }
+                    Message = string.IsNullOrEmpty(message) ? "鎵ц鎴愬姛" : $"{message}",
+                    Data = new { ExtendSpeed = ext, RetractionSpeed = ret,liftweiz= liftPosition,rightweiz= rigtpostition }
                 };
 
             }
@@ -207,114 +210,112 @@
                 int ret = (int)para.ManualRetraction;//鍙砅LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                 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 (devices.Value.left.Communicator.Read<bool>("M117")) //榛樿鏄痜lase 
+                    {
 
-                    if (leftOrigin)
-                    {
-                        message += "宸LC宸插埌鍘熺偣锛�";
-                        canLeft=false;
+                        return new WebResponseContent { Status = true, Message = "鐜板湪姝e湪杩涜涓紝绛夊緟鎿嶄綔瀹屾垚" };
                     }
-                  
-                }
-                catch (Exception )
-                {     }
-                try
-                {
-                    var rightOrigin = devices.Value.right.Communicator.Read<bool>("M115");
-                    if (rightOrigin)
-                    {
-                        message += "鍙砅LC宸插埌鍘熺偣锛�";
-                        canRight = false;
-                    }
+
                 }
                 catch (Exception)
                 {
                 }
-
                 try
                 {
-                    try
+                    if (devices.Value.right.Communicator.Read<bool>("M117"))
                     {
-                        var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//宸lc鍒拌揪鐩爣浣嶇疆
-                        if (lefttarget)
-                        {
-                            message += "宸lc鍒拌揪鐩爣浣嶇疆锛�";
-                            canLeft = false;
-                        }
+                        return new WebResponseContent { Status = true, Message = "鐜板湪姝e湪杩涜涓紝绛夊緟鎿嶄綔瀹屾垚" };
                     }
-                    catch (Exception)
-                    {
-                    }
-                    try
-                    {
-                        var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//鍙硃lc鍒拌揪鐩爣浣嶇疆
-                        if (righttarget)
-                        {
-                            message += "鍙硃lc鍒拌揪鐩爣浣嶇疆锛�";
-                            canRight = false;
-                        }
 
-                    }
-                    catch (Exception)
-                    {
-                    }
                 }
-                catch (Exception )
-                { }
-                if (canLeft) //娌℃湁鍒板師鐐规垨鏈�澶у�肩殑鏃跺�欐墠鎵ц涓嬮潰鐨勮鍙�
+                catch (Exception)
                 {
-                    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);//宸LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                         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 += "宸︿几缂╂潌宸插埌鍘熺偣锛�";
+                    }
+                    else
+                    {
+                        devices.Value.left.Communicator.Write<int>("D1004", liftPosition);//浼稿嚭浣嶇疆
                         devices.Value.left.Communicator.Write<int>("D1000", ext);//宸LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                         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);//鍙砅LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                         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);//鍙砅LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                         devices.Value.right.Communicator.Write<bool>("M101", true);
                         Thread.Sleep(100); // 绛夊緟100ms锛堟ā鎷熸寜閽寜涓嬶級
                         devices.Value.right.Communicator.Write<bool>("M101", false); // 閲婃斁鎸夐挳
                         Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄧ缉鍥瀧ret}");
                     }
-                }             
-                return new WebResponseContent { Status = true, 
-                    Message = string.IsNullOrEmpty(message) ? "鎵ц鎴愬姛" : $"鎵ц澶辫触锛歿message}", 
+
+                }
+               
+
+
+                return new WebResponseContent
+                {
+                    Status = true,
+                    Message = string.IsNullOrEmpty(message) ? "鎵ц鎴愬姛" : $"{message}",
                     Data = new
                     {
                         ManualExtend = ext,
@@ -323,6 +324,8 @@
                     }
                 };
             }
+
+
             catch (Exception ex)
             {
                 return new WebResponseContent { Status = false, Message = ex.Message };

--
Gitblit v1.9.3