| | |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_ITelescopicService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// èªå¨æ§å¶ä¼¸ç¼©æç伸åºå缩åé度 |
| | | /// èªå¨æ§å¶ä¼¸ç¼©æç伸åºå缩åé度ï¼ä¸æ¬¡æ§æ§å¶ææçï¼ |
| | | /// </summary> |
| | | /// <param name="ExtendedState">伸/åºç¶æ</param> |
| | | /// <param name="account">ç¨æ·è´¦å·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent automation(string ExtendedState, string account) |
| | | public WebResponseContent automation(string extendedState) |
| | | { |
| | | try |
| | | { |
| | | var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault(); |
| | | if (loginer == null) |
| | | return new WebResponseContent { Status = false, Message = "ç»å½ç¨æ·ä¸åå¨" }; |
| | | |
| | | // 设å¤ç¼å·è§åæ¯æé¨é¨ç¼å·ä¾æ¬¡ä¸º SSG001~SSG010 |
| | | string liftDeviceCode = $"SSG{(loginer.Dept_Id * 2 - 1):D3}"; |
| | | string rightDeviceCode = $"SSG{(loginer.Dept_Id * 2):D3}"; |
| | | |
| | | OtherDevice liftDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == liftDeviceCode); |
| | | OtherDevice rightDevice = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightDeviceCode); |
| | | |
| | | if (liftDevice == null || rightDevice == null) |
| | | for (int deptId = 1; deptId <= 5; deptId++) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = $"è®¾å¤ {liftDeviceCode} æ {rightDeviceCode} æªæ¾å°" }; |
| | | var devices = GetDevicesByDeptId(deptId); |
| | | if (devices == null) |
| | | { |
| | | Console.WriteLine($"DeptId={deptId} æªæ¾å°è®¾å¤ï¼è·³è¿"); |
| | | continue; |
| | | } |
| | | |
| | | var para = BaseDal.QueryData() |
| | | .Where(x => x.Deptid == deptId) |
| | | .OrderByDescending(x => x.CreateDate) |
| | | .FirstOrDefault(); |
| | | |
| | | if (para == null) |
| | | { |
| | | Console.WriteLine($"DeptId={deptId} æªæ¾å°åæ°é
ç½®ï¼è·³è¿"); |
| | | continue; |
| | | } |
| | | |
| | | int ext = (int)para.ExtendSpeed; |
| | | int ret = (int)para.RetractionSpeed; |
| | | |
| | | if (extendedState == "伸åº") |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D500", ext);//伸åºé度 |
| | | devices.Value.left.Communicator.Write<bool>("M100", true);//ä¼¸åºæé® |
| | | |
| | | devices.Value.right.Communicator.Write<int>("D500", ext); |
| | | devices.Value.right.Communicator.Write<bool>("M100", true); |
| | | |
| | | Console.WriteLine($"DeptId={deptId} ä¼¸åºæä½ï¼é度={ext}"); |
| | | } |
| | | else if (extendedState == "缩å") |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D501", ret);//伸åºé度 |
| | | devices.Value.left.Communicator.Write<bool>("M101", true);//ä¼¸åºæé® |
| | | |
| | | devices.Value.right.Communicator.Write<int>("D501", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M101", true); |
| | | |
| | | Console.WriteLine($"DeptId={deptId} 缩åæä½ï¼é度={ret}"); |
| | | } |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "æªç¥çæä½å½ä»¤" }; |
| | | } |
| | | } |
| | | |
| | | if (liftDevice.Communicator == null || rightDevice.Communicator == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "设å¤é讯æªåå§å" }; |
| | | } |
| | | |
| | | //æ¾å°Dt_Parametersä¸çææ°ä¸æ¡æ°æ® |
| | | var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | if (para == null) |
| | | return new WebResponseContent { Status = false, Message = "æªæ¾å°åæ°é
ç½®" }; |
| | | |
| | | int ext = (int)para.ExtendSpeed; |
| | | int ret = (int)para.RetractionSpeed; |
| | | |
| | | if (ExtendedState == "伸åº") |
| | | { |
| | | liftDevice.Communicator.Write<int>("D500", ext); |
| | | liftDevice.Communicator.Write<bool>("M100", true); |
| | | rightDevice.Communicator.Write<int>("D500", ext); |
| | | rightDevice.Communicator.Write<bool>("M100", true); |
| | | Console.WriteLine($"伸缩æä¼¸åº {ext}"); |
| | | } |
| | | else if (ExtendedState == "缩å") |
| | | { |
| | | liftDevice.Communicator.Write<int>("D501", ret); |
| | | liftDevice.Communicator.Write<bool>("M101", true); |
| | | rightDevice.Communicator.Write<int>("D501", ret); |
| | | rightDevice.Communicator.Write<bool>("M101", true); |
| | | Console.WriteLine($"伸缩æç¼©å {ret}"); |
| | | } |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "æªç¥çæä½å½ä»¤" }; |
| | | } |
| | | |
| | | return new WebResponseContent { Status = true, Message = "æå" }; |
| | | return new WebResponseContent { Status = true, Message = "å
¨é¨è®¾å¤æä½å®æ" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | return new WebResponseContent { Status = false, Message = $"æä½å¼å¸¸ï¼{ex.Message}" }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | // 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 }; |
| | | // 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 }; |
| | | |
| | | // } |
| | | //} |
| | | // } |
| | | //} |
| | | |
| | | |
| | | public WebResponseContent ManualOperation(string position, string ExtendedState,string account) |
| | | |
| | | /// <summary> |
| | | /// æå¨æ§å¶ï¼ä¼¸ç¼©æç缩åå伸åºé度 |
| | | /// </summary> |
| | | /// <param name="position">伸缩æçä½ç½®ï¼å·¦å³ï¼</param> |
| | | /// <param name="ExtendedState">伸/ç¼©ç¶æ</param> |
| | | /// <param name="DeptId">è¡éå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ManualOperation(string position, string ExtendedState,int DeptId) |
| | | { |
| | | try |
| | | { |
| | | var loginer = _user.QueryData(x => x.UserName == account).FirstOrDefault(); |
| | | if (loginer == null) |
| | | return new WebResponseContent { Status = false, Message = "ç¨æ·ä¸åå¨" }; |
| | | |
| | | var devices = GetDevicesByDeptId((int)loginer.Dept_Id); |
| | | var devices = GetDevicesByDeptId(DeptId); |
| | | if (devices == null) |
| | | return new WebResponseContent { Status = false, Message = "è®¾å¤æªæ¾å°" }; |
| | | |
| | | var para = BaseDal.QueryData().OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | var para = BaseDal.QueryData(x=>x.Deptid== DeptId).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | if (para == null) |
| | | return new WebResponseContent { Status = false, Message = "åæ°æªé
ç½®" }; |
| | | |
| | |
| | | |
| | | if (position == "å·¦" && ExtendedState == "伸åº") |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D500", ext); |
| | | devices.Value.left.Communicator.Write<bool>("M100", true); |
| | | devices.Value.left.Communicator.Write<int>("D500", ext);//伸åºé度 |
| | | devices.Value.left.Communicator.Write<bool>("M100", true);//ä¼¸åºæé® |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ext}"); |
| | | } |
| | | else if (position == "å·¦" && ExtendedState == "缩å") |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D501", ret); |
| | | devices.Value.left.Communicator.Write<int>("D501", ret);//缩åé度 |
| | | devices.Value.left.Communicator.Write<bool>("M101", true); |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ret}"); |
| | | } |
| | | else if (position == "å³" && ExtendedState == "伸åº") |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D500", ext); |
| | | devices.Value.right.Communicator.Write<bool>("M100", true); |
| | | Console.WriteLine($"{position}伸缩ææå¨ä¼¸åº{ext}"); |
| | | } |
| | | else if (position == "å³" && ExtendedState == "缩å") |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D501", ret); |
| | | devices.Value.right.Communicator.Write<bool>("M101", true); |
| | | Console.WriteLine($"{position}伸缩ææå¨ç¼©å{ret}"); |
| | | } |
| | | |
| | | else |
| | |
| | | // 左设å¤å·ï¼1 -> 001ï¼2 -> 003ï¼3 -> 005... |
| | | int baseCode = 1 + (deptId - 1) * 2; |
| | | string leftCode = $"SSG{baseCode.ToString("D3")}"; |
| | | //å³è®¾å¤ï¼1->002 ,2->004 |
| | | string rightCode = $"SSG{(baseCode + 1).ToString("D3")}"; |
| | | |
| | | var left = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == leftCode); |
| | | var right = (OtherDevice)Storage.Devices.Find(x => x.DeviceCode == rightCode); |
| | | |