| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | |
| | | |
| | | if (ExtendedState == "伸出") |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1001", ext);//左PLC自动伸出缩回速度 |
| | | devices.Value.left.Communicator.Write<bool>("M102", true);//伸出按钮 |
| | | devices.Value.left.Communicator.Write<int>("D1002", liftPosition);//左伸出位置 |
| | | devices.Value.right.Communicator.Write<int>("D1001", ret);//右PLC自动伸出缩回速度 |
| | | 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);//左PLC自动伸出缩回速度 |
| | | 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);//右PLC自动伸出缩回速度 |
| | | 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);//左PLC自动伸出缩回速度 |
| | | devices.Value.left.Communicator.Write<bool>("M103", true);//缩回按钮 |
| | | devices.Value.right.Communicator.Write<int>("D1001", ret);//右PLC自动伸出缩回速度 |
| | | devices.Value.right.Communicator.Write<bool>("M103", true);//缩回按钮 |
| | | try |
| | | { |
| | | devices.Value.left.Communicator.Write<int>("D1001", ext);//左PLC自动伸出缩回速度 |
| | | devices.Value.left.Communicator.Write<bool>("M103", true);//缩回按钮 |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | } |
| | | try |
| | | { |
| | | devices.Value.right.Communicator.Write<int>("D1001", ret);//右PLC自动伸出缩回速度 |
| | | devices.Value.right.Communicator.Write<bool>("M103", true);//缩回按钮 |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | } |
| | | |
| | | Console.WriteLine($"自动伸缩杆缩回 {ret}"); |
| | | } |
| | | |
| | | else |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "未知的操作命令" }; |
| | |
| | | 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) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | try |
| | | { |
| | | devices.Value.right.Communicator.Write<bool>("M104", true); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | |
| | | return new WebResponseContent { Status =true,Message="暂停成功",Data = devices}; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <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> |
| | |
| | | |
| | | |
| | | |
| | | 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 }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |