From 01c5166aad248cf4de78d7aeb53c31f961835f02 Mon Sep 17 00:00:00 2001 From: yanjinhui <3306209981@qq.com> Date: 星期日, 27 四月 2025 08:46:23 +0800 Subject: [PATCH] 1 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 1 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs" index 3aa137c..9acca79 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/ParametersService.cs" @@ -1,13 +1,18 @@ 锘縰sing System; using System.Collections.Generic; +using System.DirectoryServices; using System.Linq; using System.Text; using System.Threading.Tasks; using AutoMapper; +using SqlSugar; +using WIDESEAWCS_Core; using WIDESEAWCS_Core.BaseRepository; using WIDESEAWCS_Core.BaseServices; using WIDESEAWCS_ITelescopicService; using WIDESEAWCS_Model.Models; +using WIDESEAWCS_QuartzJob; + namespace WIDESEAWCS_TelescopicService { @@ -17,10 +22,101 @@ public ParametersService(IRepository<Dt_Parameters> BaseDal) : base(BaseDal) { - } + /// <summary> + /// 鑷姩鎺у埗浼哥缉鏉嗙殑浼稿嚭鍜岀缉鍥為�熷害 + /// </summary> + /// <param name="ExtendedState">浼�/鍑虹姸鎬�</param> + /// <returns></returns> + public WebResponseContent automation(string ExtendedState) + { + try + { + OtherDevice liftotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "宸︽眹宸漃LC"); + OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "鍙虫眹宸漃LC"); + //鎵惧埌Dt_Parameters涓殑鏈�鏂颁竴鏉℃暟鎹� + var para=BaseDal.QueryData().OrderBy(x=>x.CreateDate).FirstOrDefault(); + int ext= (int)para.ExtendSpeed;//鑷姩浼稿嚭閫熷害 + int ret= (int)para.RetractionSpeed;//鑷姩缂╁洖閫熷害 + if (ExtendedState == "浼稿嚭") + { + var values = liftotherDevice.Communicator.Write<int>("D500", ext);//閫熷害 + var button = liftotherDevice.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + var rightvalues = rightotherDevice.Communicator.Write<int>("D500", ext);//閫熷害 + var rightbutton = rightotherDevice.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"浼哥缉鏉嗕几鍑簕ext}"); + + } + if (ExtendedState=="缂╁洖") + { + var values = liftotherDevice.Communicator.Write<int>("D501", ext);//閫熷害 + var button = liftotherDevice.Communicator.Write<bool>("M101", true);//缂╁洖鎸夐挳 + var rightvalues = rightotherDevice.Communicator.Write<int>("D501", ext);//閫熷害 + var rightbutton = rightotherDevice.Communicator.Write<bool>("M101", true);//缂╁洖鎸夐挳 + Console.WriteLine($"浼哥缉鏉嗙缉鍥瀧ret}"); + } + return new WebResponseContent { Status = true, Message = "鎴愬姛" }; + } + catch (Exception ex) + { + + return new WebResponseContent { Status = false, Message = ex.Message }; + } + } + + + /// <summary> + /// 鎵嬪姩鎺у埗锛屼几缂╂潌鐨勭缉鍥炲拰浼稿嚭閫熷害 + /// </summary> + /// <param name="position">浼哥缉鏉嗙殑浣嶇疆锛堝乏鍙筹級</param> + /// <param name="ExtendedState">浼�/缂╃姸鎬�</param> + /// <returns></returns> + /// + public WebResponseContent ManualOperation(string position, string ExtendedState) + { + try + { + //淇╀釜plc宸﹀彸鍚勪竴涓� + OtherDevice liftotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "宸︽眹宸漃LC"); + OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "鍙虫眹宸漃LC"); + //鎵惧埌Dt_Parameters涓殑鏈�鏂颁竴鏉℃暟鎹� + var para = BaseDal.QueryData().OrderBy(x => x.CreateDate).FirstOrDefault(); + int ext = (int)para.ManualExtend;//鑷姩浼稿嚭閫熷害 + int ret = (int)para.ManualRetraction;//鑷姩缂╁洖閫熷害 + if (position == "宸�" && ExtendedState == "浼稿嚭") + { + var values = liftotherDevice.Communicator.Write<int>("D500", ext);//閫熷害 + var button = liftotherDevice.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"{position}浼哥缉鏉嗕几鍑簕ext}"); + } + if (position == "宸�" && ExtendedState == "缂╁洖") + { + var values = liftotherDevice.Communicator.Write<int>("D501", ret); + var button = liftotherDevice.Communicator.Write<bool>("M101", true);//缂╁洖鎸夐挳 + Console.WriteLine($"{position}浼哥缉鏉嗙缉鍥瀧ret}"); + } + if (position == "鍙�" && ExtendedState == "浼稿嚭") + { + var values = rightotherDevice.Communicator.Write<int>("D500", ext);//閫熷害 + var button = rightotherDevice.Communicator.Write<bool>("M100", true);//浼稿嚭鎸夐挳 + Console.WriteLine($"{position}浼哥缉鏉嗕几鍑簕ext}"); + } + if (position == "鍙�" && ExtendedState == "缂╁洖") + { + var values = rightotherDevice.Communicator.Write<int>("D501", ret); + var button = rightotherDevice.Communicator.Write<bool>("M101", true);//缂╁洖鎸夐挳 + Console.WriteLine($"{position}浼哥缉鏉嗙缉鍥瀧ret}"); + } + return new WebResponseContent { Status = true, Message = "鎴愬姛" }; + } + catch (Exception ex) + { + return new WebResponseContent { Status = false, Message = ex.Message }; + + } + } } } -- Gitblit v1.9.3