| | |
| | | |
| | | int ext = (int)para.ExtendSpeed;//左PLC自动伸出缩回速度 |
| | | int ret = (int)para.RetractionSpeed;//右PLC自动伸出缩回速度 |
| | | int liftPosition= (int)para.LeftPosition;//左伸出位置 |
| | | int rigtpostition= (int)para.RightPosition;//右伸出位置 |
| | | |
| | | 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);//伸出按钮 |
| | | Console.WriteLine($"自动伸缩杆伸出 {ext}"); |
| | | devices.Value.right.Communicator.Write<int>("D1002", rigtpostition);//右伸出位置 |
| | | Console.WriteLine($"自动伸缩杆伸出 {ext},右伸出位置{liftPosition},右伸出位置{rigtpostition}"); |
| | | } |
| | | else if (ExtendedState == "缩回") |
| | | { |
| | |
| | | Data = new |
| | | { |
| | | ExtendSpeed = ext,// |
| | | RetractionSpeed = ret |
| | | RetractionSpeed = ret, |
| | | |
| | | } |
| | | }; |
| | | } |
| | |
| | | RetractionSpeed = entity.RetractionSpeed, |
| | | ManualExtend = entity.ManualExtend, |
| | | ManualRetraction = entity.ManualRetraction, |
| | | LeftPosition = entity.LeftPosition, |
| | | RightPosition = entity.RightPosition, |
| | | Deptid = isAdmin ? deid : dept.GetValueOrDefault()//如果当前用户是管理员,就用配置文件中的 DepartmentID,否则用传入的 entity 参数中的 Deptid |
| | | }; |
| | | // 添加数据 |
| | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | ///当自动伸出需要暂停时,暂停按钮 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent PauseButton() |
| | | { |
| | | try |
| | | { |
| | | //根据int.TryParse(AppSettings.Get("DepartmentID")读取到当前是轨道几,所有人都只能操作当前 |
| | | if (!int.TryParse(AppSettings.Get("DepartmentID"), out int deid)) |
| | | { |
| | | 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); |
| | | return new WebResponseContent { Status =true,Message="暂停成功",Data = devices}; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | return new WebResponseContent { Status = false, Message = ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |