From fcd49db2ee33ee2e1d33e5a41e53d9897a8a3b0f Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期四, 05 六月 2025 19:19:10 +0800
Subject: [PATCH] 限制plc伸到位报警,和限制开始作业无限点击问题
---
project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs | 224 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 188 insertions(+), 36 deletions(-)
diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
index 0c52ddb..c5ba941 100644
--- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
+++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs
@@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SqlSugar;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
@@ -55,25 +56,84 @@
int ret = (int)para.RetractionSpeed;//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
int liftPosition= (int)para.LeftPosition;//宸︿几鍑轰綅缃�
int rigtpostition= (int)para.RightPosition;//鍙充几鍑轰綅缃�
+ try
+ {
+ 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 = "宸插埌鍘熷鐐�" };
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+ 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 == "浼稿嚭")
{
- devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
- devices.Value.left.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
- devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//宸︿几鍑轰綅缃�
- devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
- devices.Value.right.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
- devices.Value.right.Communicator.Write<int>("D1002", rigtpostition);//鍙充几鍑轰綅缃�
+ try
+ {
+ devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
+ devices.Value.left.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
+ devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//宸︿几鍑轰綅缃�
+ }
+ catch (Exception)
+ {
+
+ }
+ try
+ {
+ devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
+ devices.Value.right.Communicator.Write<bool>("M102", true);//浼稿嚭鎸夐挳
+ devices.Value.right.Communicator.Write<int>("D1002", rigtpostition);//鍙充几鍑轰綅缃�
+ }
+ catch (Exception)
+ {
+
+ }
+
Console.WriteLine($"鑷姩浼哥缉鏉嗕几鍑� {ext},鍙充几鍑轰綅缃畕liftPosition}锛屽彸浼稿嚭浣嶇疆{rigtpostition}");
}
else if (ExtendedState == "缂╁洖")
{
- devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
- devices.Value.left.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
- devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
- devices.Value.right.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
+ try
+ {
+ devices.Value.left.Communicator.Write<int>("D1001", ext);//宸LC鑷姩浼稿嚭缂╁洖閫熷害
+ devices.Value.left.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
+ }
+ catch (Exception)
+ {
+
+ }
+ try
+ {
+ devices.Value.right.Communicator.Write<int>("D1001", ret);//鍙砅LC鑷姩浼稿嚭缂╁洖閫熷害
+ devices.Value.right.Communicator.Write<bool>("M103", true);//缂╁洖鎸夐挳
+ }
+ catch (Exception)
+ {
+
+ }
+
Console.WriteLine($"鑷姩浼哥缉鏉嗙缉鍥� {ret}");
}
+
else
{
return new WebResponseContent { Status = false, Message = "鏈煡鐨勬搷浣滃懡浠�" };
@@ -123,18 +183,49 @@
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鎵嬪姩浼稿嚭缂╁洖閫熷害
+ try
+ {
+ 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 = "宸插埌鍘熷鐐�" };
+ }
+ }
+ catch (Exception)
+ {
+
+
+ }
+ 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);//浼稿嚭鎸夐挳
- Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄤ几鍑虹缉鍥瀧ext}");
+ 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);
- Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄤ几鍑虹缉鍥瀧ext}");
+ Console.WriteLine($"{position}浼哥缉鏉嗘墜鍔ㄧ缉鍥瀧ext}");
}
else if (position == "鍙�" && ExtendedState == "浼稿嚭")
{
@@ -155,7 +246,7 @@
ManualExtend = ext,
ManualRetraction = ret
}
- };//杩欓噷瑕佸姞杩斿洖閫熷害
+ };
}
catch (Exception ex)
{
@@ -243,8 +334,26 @@
return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" };
};
var devices = GetDevicesByDeptId(deid);
- devices.Value.left.Communicator.Write<bool>("M104", true);
- devices.Value.right.Communicator.Write<bool>("M104", true);
+ try
+ {
+ devices.Value.left.Communicator.Write<bool>("M104", true);
+ }
+ catch (Exception)
+ {
+
+
+ }
+ try
+ {
+ devices.Value.right.Communicator.Write<bool>("M104", true);
+ }
+ catch (Exception)
+ {
+
+
+ }
+
+
return new WebResponseContent { Status =true,Message="鏆傚仠鎴愬姛",Data = devices};
}
catch (Exception ex)
@@ -254,6 +363,68 @@
}
}
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠绋嬪簭鏈�鏂扮殑浼哥缉鏉嗛�熷害
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent BackfillSpeed()
+ {
+ try
+ {
+ if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
+ {
+ return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" };
+
+ }
+ var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault();
+ if (para == null)
+ {
+ return new WebResponseContent { Message = "浣犺繕娌℃湁閰嶇疆閫熷害" };
+ }
+ return new WebResponseContent { Status = true, Data = para };
+ }
+ catch (Exception ex)
+ {
+
+ return new WebResponseContent { Status = false, Message = ex.Message };
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇褰撳墠浼哥缉鏉嗙殑浣嶇疆(鑷姩)
+ /// </summary>
+ /// <param name="ExtendedState"></param>
+ /// <returns></returns>
+ public WebResponseContent CurrentLocation()
+ {
+ try
+ {
+ if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
+ {
+ return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" };
+
+ }
+ var devices = GetDevicesByDeptId(deid);
+
+
+ var deviceslift = devices.Value.left.Communicator.Read<float>("D80");
+ var devicesright = devices.Value.right.Communicator.Read<float>("D80");
+ Console.WriteLine($"褰撳墠宸﹀彸浼哥缉鏉嗚繑鍥為�熷害鍒嗗埆涓轰负{deviceslift}");
+
+
+ return new WebResponseContent
+ {
+ Status = true,
+ Data = new { lift = deviceslift, Right = devicesright }
+ };
+ }
+ catch (Exception ex)
+ {
+
+ return new WebResponseContent { Status = false, Message = ex.Message };
+ }
+ }
/// <summary>
@@ -279,30 +450,11 @@
- public WebResponseContent BackfillSpeed()
- {
- try
- {
- if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid))
- {
- return new WebResponseContent { Status = false, Message = "閰嶇疆椤� DepartmentID 鏃犳硶杞崲涓烘暣鏁�" };
- }
- var para = BaseDal.QueryData().Where(x => x.Deptid == deid).OrderByDescending(x => x.CreateDate).FirstOrDefault();
- if (para==null)
- {
- return new WebResponseContent { Message = "浣犺繕娌℃湁閰嶇疆閫熷害" };
- }
- return new WebResponseContent { Status = true, Data = para };
- }
- catch (Exception ex)
- {
- return new WebResponseContent { Status = false, Message = ex.Message };
- }
- }
-
+
+
}
}
--
Gitblit v1.9.3