From 9250e3e48760f91fbefef03331fc7b14b4b1be18 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期六, 07 六月 2025 13:09:59 +0800
Subject: [PATCH] 修改数字大屏接口

---
 project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs |   98 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 74 insertions(+), 24 deletions(-)

diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
index c737cc9..9f88df3 100644
--- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
+++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
@@ -56,26 +56,43 @@
                 int ret = (int)para.RetractionSpeed;//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
                 int liftPosition= (int)para.LeftPosition;//宸︿几鍑轰綅缃�
                 int rigtpostition= (int)para.RightPosition;//鍙充几鍑轰綅缃�
-                var leftorigin = devices.Value.left.Communicator.Read<bool>("M115");//宸lc鍒板師鐐逛綅缃俊鍙�
-                var rightorigin = devices.Value.right.Communicator.Read<bool>("M115");//鍙硃lc鍒拌揪鍘熺偣浣嶇疆淇″彿
-                var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//宸lc鍒拌揪鐩爣浣嶇疆
-                var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//鍙硃lc鍒拌揪鐩爣浣嶇疆
-
-                if (leftorigin == true || rightorigin == true)
+                try
                 {
-                    return new WebResponseContent { Status = false, Message = "宸插埌鍘熷鐐�" };
+                    var leftorigin = devices.Value.left.Communicator.Read<bool>("M115");//宸lc鍒板師鐐逛綅缃俊鍙�
+                    var rightorigin = devices.Value.right.Communicator.Read<bool>("M115");//鍙硃lc鍒拌揪鍘熺偣浣嶇疆淇″彿
+                    if (leftorigin == true || rightorigin == true)
+                    {
+                        return new WebResponseContent { Status = false, Message = "宸插埌鍘熷鐐�" };
+                    }
                 }
-                if (lefttarget == true || righttarget == true)
+                catch (Exception)
                 {
-                    return new WebResponseContent { Status = false, Message = "宸插埌鏈�澶у��" };
-                }
 
+
+                }
+                try
+                {
+                    var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//宸lc鍒拌揪鐩爣浣嶇疆
+                    var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//鍙硃lc鍒拌揪鐩爣浣嶇疆
+                    if (lefttarget == true || righttarget == true)
+                    {
+                        return new WebResponseContent { Status = false, Message = "宸插埌鏈�澶у��" };
+                    }
+
+                }
+                catch (Exception)
+                {
+
+
+                }
                 if (ExtendedState == "浼稿嚭")
                 {
                     try
                     {
                         devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
                         devices.Value.left.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
+                        Thread.Sleep(100); // 绛夊緟100ms锛堟ā鎷熸寜閽寜涓嬶級
+                        devices.Value.left.Communicator.Write<bool>("M102", false); // 閲婃斁鎸夐挳
                         devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//宸︿几鍑轰綅缃�
                     }
                     catch (Exception)
@@ -86,6 +103,8 @@
                     {
                         devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
                         devices.Value.right.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
+                        Thread.Sleep(100); // 绛夊緟100ms锛堟ā鎷熸寜閽寜涓嬶級
+                        devices.Value.right.Communicator.Write<bool>("M102", false); // 閲婃斁鎸夐挳
                         devices.Value.right.Communicator.Write<int>("D1002", rigtpostition);//鍙充几鍑轰綅缃�
                     }
                     catch (Exception)
@@ -93,7 +112,7 @@
 
                     }
                     
-                    Console.WriteLine($"鑷姩浼哥缉鏉嗕几鍑� {ext},鍙充几鍑轰綅缃畕liftPosition}锛屽彸浼稿嚭浣嶇疆{rigtpostition}");
+                    Console.WriteLine($"鑷姩浼哥缉鏉嗕几鍑� {ext},宸︿几鍑轰綅缃畕liftPosition}锛屽彸浼稿嚭浣嶇疆{rigtpostition}");
                 }
                 else if (ExtendedState == "缂╁洖")
                 {
@@ -101,6 +120,8 @@
                     {
                         devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
                         devices.Value.left.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
+                        Thread.Sleep(100); // 绛夊緟100ms锛堟ā鎷熸寜閽寜涓嬶級
+                        devices.Value.left.Communicator.Write<bool>("M103", false); // 閲婃斁鎸夐挳
                     }
                     catch (Exception)
                     {
@@ -110,6 +131,8 @@
                     {
                         devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
                         devices.Value.right.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
+                        Thread.Sleep(100); // 绛夊緟100ms锛堟ā鎷熸寜閽寜涓嬶級
+                        devices.Value.right.Communicator.Write<bool>("M103", false); // 閲婃斁鎸夐挳
                     }
                     catch (Exception)
                     {
@@ -127,7 +150,7 @@
                 return new WebResponseContent { Status = true, Message = "鎴愬姛",
                     Data = new
                     {
-                        ExtendSpeed = ext,//
+                        ExtendSpeed = ext,
                         RetractionSpeed = ret,
                        
                     }
@@ -168,45 +191,72 @@
                 var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault();
                 int ext = (int)para.ManualExtend;//宸LC鎵嬪姩浼稿嚭缂╁洖閫熷害
                 int ret = (int)para.ManualRetraction;//鍙砅LC鎵嬪姩浼稿嚭缂╁洖閫熷害
-                
-                var leftorigin = devices.Value.left.Communicator.Read<bool>("M115");//宸lc鍒板師鐐逛綅缃俊鍙�
-                var rightorigin = devices.Value.right.Communicator.Read<bool>("M115");//鍙硃lc鍒拌揪鍘熺偣浣嶇疆淇″彿
-                var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//宸lc鍒拌揪鐩爣浣嶇疆
-                var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//鍙硃lc鍒拌揪鐩爣浣嶇疆
-
-                if (leftorigin==true|| rightorigin==true)
+                int liftPosition = (int)para.LeftPosition;//宸︿几鍑轰綅缃�
+                int rigtpostition = (int)para.RightPosition;//鍙充几鍑轰綅缃�
+                try
                 {
-                    return new WebResponseContent { Status = false, Message = "宸插埌鍘熷鐐�" };
+                    var leftorigin = devices.Value.left.Communicator.Read<bool>("M115");//宸lc鍒板師鐐逛綅缃俊鍙�
+                    var rightorigin = devices.Value.right.Communicator.Read<bool>("M115");//鍙硃lc鍒拌揪鍘熺偣浣嶇疆淇″彿
+                    if (leftorigin == true || rightorigin == true)
+                    {
+                        return new WebResponseContent { Status = false, Message = "宸插埌鍘熷鐐�" };
+                    }
                 }
-                if(lefttarget==true|| righttarget == true)
+                catch (Exception)
                 {
-                    return new WebResponseContent { Status = false, Message = "宸插埌鏈�澶у��" };
-                }
 
+                    
+                }
+                try
+                {
+                    var lefttarget = devices.Value.left.Communicator.Read<bool>("M116");//宸lc鍒拌揪鐩爣浣嶇疆
+                    var righttarget = devices.Value.right.Communicator.Read<bool>("M116");//鍙硃lc鍒拌揪鐩爣浣嶇疆
+                    if (lefttarget == true || righttarget == true)
+                    {
+                        return new WebResponseContent { Status = false, Message = "宸插埌鏈�澶у��" };
+                    }
+
+                }
+                catch (Exception)
+                {
+
+                    
+                }
+              
 
                 if (position == "宸�" && ExtendedState == "浼稿嚭")
                 {
                     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 == "缂╁洖")
                 {
                     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}");
                 }
                 else if (position == "鍙�" && ExtendedState == "浼稿嚭")
                 {
                     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 == "缂╁洖")
                 {
                     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, 

--
Gitblit v1.9.3