| | |
| | | using 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 |
| | | { |
| | |
| | | |
| | | 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 == "å·¦æ±å·PLC"); |
| | | OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "峿±å·PLC"); |
| | | //æ¾å°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 == "å·¦æ±å·PLC"); |
| | | OtherDevice rightotherDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceName == "峿±å·PLC"); |
| | | //æ¾å°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 }; |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |