From 9b85a8b67aa6354ee9ea1a13c5799bf1c934922f Mon Sep 17 00:00:00 2001 From: IPC-610 <IPC-610@DESKTOP-6LEOOS3> Date: 星期四, 31 十月 2024 18:12:14 +0800 Subject: [PATCH] 修改问题 --- Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 703 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 702 insertions(+), 1 deletions(-) diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs index 612c67d..dd5008e 100644 --- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs +++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs @@ -1,7 +1,9 @@ 锘� using Admin.NET.Core.Service; using Elastic.Clients.Elasticsearch; +using Microsoft.CodeAnalysis.Text; using StackExchange.Profiling.Internal; +using System.Drawing.Drawing2D; using WCS.Application.Entity; using WCS.Application.Service.WcsDevice.Dto; @@ -13,14 +15,713 @@ [ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)] public class WcsDeviceService : IDynamicApiController, ITransient { + private readonly SqlSugarRepository<WcsPlc> _wcsPlcRep; private readonly SqlSugarRepository<WcsDevice> _wcsDeviceRep; private readonly SysCacheService _sysCacheService; - public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep, SysCacheService sysCacheService) + public WcsDeviceService(SqlSugarRepository<WcsPlc> wcsPlcRep,SqlSugarRepository<WcsDevice> wcsDeviceRep, SysCacheService sysCacheService) { + _wcsPlcRep = wcsPlcRep; _wcsDeviceRep = wcsDeviceRep; _sysCacheService = sysCacheService; } + #region 宸ヤ綔鍙版搷浣� + + + /// <summary> + /// 鎵嬪姩鎿嶄綔PLC閿佸畾鍐欏叆宸ヤ綅淇℃伅 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpPost] + [ApiDescriptionSettings(Name = "WriteLocationInfo")] + [DisplayName("鎵嬪姩鎿嶄綔PLC閿佸畾鍐欏叆宸ヤ綅淇℃伅")] + public async Task WriteLocationInfo(WcsDeviceUpInfo input) + { + WcsPlc modPlc; + string DbNum = "";// DB鍧� + + if (string.IsNullOrWhiteSpace(input.LocatNo))//濡傛灉宸ヤ綅涓虹┖ + { + throw Oops.Bah("宸ヤ綅涓嶈兘涓虹┖"); + } + var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync(); + switch (input.Layer) + { + case "1": + modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + case "2": + modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = "DB91"; + break; + case "3": + modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + default: + throw Oops.Bah("妤煎眰淇℃伅閿欒"); + } + + var device = await _wcsDeviceRep.Context.Queryable<WcsDevice>().FirstAsync(s => s.PlcId == modPlc.Id && s.StationNum == input.LocatNo && s.IsDelete == false && s.DeviceType == DeviceTypeEnum.Show); + if (device == null) + { + throw Oops.Bah("褰撳墠妤煎眰鏈煡璇㈠埌璇ュ伐浣嶄俊鎭�"); + } + PLCUtil modUtil = new PLCUtil(modPlc); + + switch (input.TypeName) + { + case "suoding": // 閿佸畾 + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48.0", input.LocatNo); + break; + + default: + break; + } + + modUtil.Close(); + } + + + /// <summary> + /// 鑾峰彇宸ヤ綅涓婁俊鎭� + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpPost] + [ApiDescriptionSettings(Name = "GetLocationInfo")] + [DisplayName("鑾峰彇宸ヤ綅涓婁俊鎭�")] + public async Task<WcsDeviceUpInfo> GetLocationInfo(WcsDeviceUpInfo input) + { + WcsPlc modPlc; + string DbNum = "";// DB鍧� + + if (string.IsNullOrWhiteSpace(input.LocatNo))//濡傛灉宸ヤ綅涓虹┖ + { + throw Oops.Bah("宸ヤ綅涓嶈兘涓虹┖"); + } + var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync(); + switch (input.Layer) + { + case "1": + modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + case "2": + modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = "DB1100"; + break; + case "3": + modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + default: + throw Oops.Bah("妤煎眰淇℃伅閿欒"); + } + + var device = await _wcsDeviceRep.Context.Queryable<WcsDevice>().FirstAsync(s => s.PlcId == modPlc.Id && s.StationNum == input.LocatNo && s.IsDelete == false && s.DeviceType == DeviceTypeEnum.Show); + if (device == null) + { + throw Oops.Bah("褰撳墠妤煎眰鏈煡璇㈠埌璇ュ伐浣嶄俊鎭�"); + } + PLCUtil modUtil = new PLCUtil(modPlc); + WcsDeviceUpInfo data = new WcsDeviceUpInfo(); + data.FuncName = ""; + data.Layer = ""; + data.LocatNo = input.LocatNo; + data.TypeName = ""; + var (result2, value2) = modUtil.GetPlcDBValue(PLCDataTypeEnum.String, DbNum, "4"); + data.PalletNo = value2; + var (result3, value3) = modUtil.GetPlcDBValue(PLCDataTypeEnum.String, DbNum, "14"); + data.TaskNo = value3; + var (result4, value4) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "34"); + data.StartLoction = value4.ToString(); + var (result5, value5) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "36"); + data.EndLoction = value5.ToString(); + + var (result6, value6) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "38"); + data.StartPai = value6.ToString(); + var (result7, value7) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "40"); + data.StartLie = value7.ToString(); + var (result8, value8) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "42"); + data.StartCeng = value8.ToString(); + + + var (result9, value9) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "44"); + data.EndPai = value9.ToString(); + var (result10, value10) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "46"); + data.EndLie = value10.ToString(); + var (result11, value11) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48"); + data.EndCeng = value11.ToString(); + + modUtil.Close(); + return data; + } + /// <summary> + /// 鎵嬪姩鎿嶄綔PLC淇℃伅 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpPost] + [ApiDescriptionSettings(Name = "WriteInfo")] + [DisplayName("鎵嬪姩鎿嶄綔Plc")] + public async Task WriteInfo(WcsDeviceUpInfo input) + { + WcsPlc modPlc; + string DbNum = "";// DB鍧� + + if (string.IsNullOrWhiteSpace(input.LocatNo))//濡傛灉宸ヤ綅涓虹┖ + { + throw Oops.Bah("宸ヤ綅涓嶈兘涓虹┖"); + } + var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync(); + switch (input.Layer) + { + case "1": + modPlc = plcList.FirstOrDefault(m=>m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + case "2": + modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = "DB91"; + break; + case "3": + modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + default: + throw Oops.Bah("妤煎眰淇℃伅閿欒"); + } + + var device = await _wcsDeviceRep.Context.Queryable<WcsDevice>().FirstAsync(s => s.PlcId == modPlc.Id && s.StationNum == input.LocatNo && s.IsDelete == false && s.DeviceType == DeviceTypeEnum.Show); + if (device == null) + { + throw Oops.Bah("褰撳墠妤煎眰鏈煡璇㈠埌璇ュ伐浣嶄俊鎭�"); + } + PLCUtil modUtil = new PLCUtil(modPlc); + + + // true 锛� 鎵嬪姩妯″紡 false:鑷姩妯″紡 + var (result, value) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.4"); + if (result.IsSucceed) + { + if (input.TypeName != "shoudong" && value.ToString().ToLower() == "false" && input.TypeName != "huifu" && input.TypeName != "UpTask" ) + { + throw Oops.Bah("褰撳墠涓鸿嚜鍔ㄦā寮忥紝璇峰厛鍒囨崲涓烘墜鍔ㄦā寮�"); + } + } + else + { + throw Oops.Bah("璇诲彇PLC鎵嬭嚜鍔ㄥ�煎け璐�"); + } + + switch (input.TypeName) + { + case "zidong": // 鑷姩 + //modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48.0", input.LocatNo); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.4", "false"); + break; + case "shoudong": // 鎵嬪姩 + //modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48.0", input.LocatNo); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.4", "true"); + break; + case "huifu": // 鎶ヨ鎭㈠ + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "47.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "47.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + + break; + case "1diandong": // 1鐐瑰姩 + if(input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.7", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.7", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "1liandong": // 1鑱斿姩 + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.3", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.3", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "2diandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "2liandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.4", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.4", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "3diandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.5", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.5", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "3liandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.1", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.1", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "4diandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.6", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.6", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "4liandong": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.2", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.2", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "yizaisheng": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.5", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.5", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "yizaijiang": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.6", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.6", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "fanzhuansheng": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.7", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "51.7", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "fanzhuanjiang": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "52.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "52.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "UpTask": + var (result1, value2) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.0"); + if (result.IsSucceed) + { + if (value2 == true) + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.0", "false"); + } + else + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.0", "true"); + } + } + else + { + throw Oops.Bah("璇诲彇PLC鍊煎け璐�"); + } + + + break; + default: + break; + } + + modUtil.Close(); + } + + + /// <summary> + /// 鎵嬪姩鍐欏叆PLC浠诲姟淇℃伅 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpPost] + [ApiDescriptionSettings(Name = "WriteTaskInfo")] + [DisplayName("鍐欏叆Plc浠诲姟淇℃伅")] + public async Task WriteTaskInfo(WcsDeviceUpInfo input) + { + WcsPlc modPlc; + string DbNum = "";// DB鍧� + string TaskDbNum = "";// DB鍧� + + if (string.IsNullOrWhiteSpace(input.LocatNo))//濡傛灉宸ヤ綅涓虹┖ + { + throw Oops.Bah("宸ヤ綅涓嶈兘涓虹┖"); + } + var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync(); + switch (input.Layer) + { + case "1": + modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + case "2": + modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = "DB91"; + TaskDbNum = "DB1100"; + break; + case "3": + modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌{input.Layer}妤煎眰PLC淇℃伅"); + DbNum = ""; + break; + default: + throw Oops.Bah("妤煎眰淇℃伅閿欒"); + } + + var device = await _wcsDeviceRep.Context.Queryable<WcsDevice>().FirstAsync(s => s.PlcId == modPlc.Id && s.StationNum == input.LocatNo && s.IsDelete == false && s.DeviceType == DeviceTypeEnum.Show); + if (device == null) + { + throw Oops.Bah("褰撳墠妤煎眰鏈煡璇㈠埌璇ュ伐浣嶄俊鎭�"); + } + + PLCUtil modUtil = new PLCUtil(modPlc); + //var (result, value) = modUtil.GetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.0"); + //if (result.IsSucceed) + //{ + // if (value.ToString().ToLower() != "false") + // { + // throw Oops.Bah("璇峰厛鍒囨崲涓烘洿鏀逛换鍔℃ā寮�"); + // } + //} + //else + //{ + // throw Oops.Bah("璇诲彇PLC鎵嬭嚜鍔ㄥ�煎け璐�"); + //} + //modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, DbNum, "48.0", input.LocatNo); + switch (input.TypeName) + { + case "writeTask": + modUtil.SetPlcDBValue(PLCDataTypeEnum.String, TaskDbNum, "4", input.PalletNo); + modUtil.SetPlcDBValue(PLCDataTypeEnum.String, TaskDbNum, "14", input.TaskNo); + //modUtil.SetPlcDBValue(PLCDataTypeEnum.Int, TaskDbNum, "34", input.StartLoction); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "36.0", input.EndLoction); + + + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "38", input.StartPai); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "40", input.StartLie); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "42", input.StartCeng); + + + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "44", input.EndPai); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "46", input.EndLie); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Short, TaskDbNum, "48", input.EndCeng); + + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.3", "true"); + Thread.Sleep(1000); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.3", "false"); + break; + case "writeTaskDelete": + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.2", "true"); + Thread.Sleep(1000); + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "50.2", "false"); + break; + + default: + break; + } + + modUtil.Close(); + } + + + + /// <summary> + /// 鎵嬪姩鍐欏叆PLC鍚仠淇℃伅 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + [HttpPost] + [ApiDescriptionSettings(Name = "WriteStartStop")] + [DisplayName("鍐欏叆PLC鍚仠淇℃伅")] + public async Task WriteStartStop(WcsDeviceStartStop input) + { + WcsPlc modPlc; + string DbNum = "";// DB鍧� + + + var plcList = await _wcsPlcRep.Context.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.ConveyorLine && s.IsDelete == false).ToListAsync(); + if (input.Layer == "1") + { + modPlc = plcList.FirstOrDefault(m => m.Text == "1灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌1妤煎眰PLC淇℃伅"); + DbNum = ""; + } + else if (input.Layer == "2") + { + modPlc = plcList.FirstOrDefault(m => m.Text == "2灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌2妤煎眰PLC淇℃伅"); + DbNum = "DB91"; + PLCUtil modUtil = new PLCUtil(modPlc); + switch (input.Type) + { + case "TwoPalletStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoPalletStop": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.1", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoMaStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.0", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.0", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoMaStop": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.1", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.1", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoMaTwoStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.2", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.2", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoMaTwoStop": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.3", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "58.3", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoBoxStart": + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.2", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.2", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + case "TwoBoxStop": + + if (input.FuncName == "true") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.3", "true"); + } + else if (input.FuncName == "false") + { + modUtil.SetPlcDBValue(PLCDataTypeEnum.Bit, DbNum, "46.3", "false"); + } + else + { + throw Oops.Bah("浜嬩欢缁撴灉閿欒"); + } + break; + default: + break; + } + modUtil.Close(); + } + else if (input.Layer == "3") + { + modPlc = plcList.FirstOrDefault(m => m.Text == "3灞傛墭鐩樿緭閫佺嚎"); + if (modPlc == null) + throw Oops.Bah($"鏈煡璇㈠埌3妤煎眰PLC淇℃伅"); + DbNum = ""; + } + else + { + throw Oops.Bah("鎿嶄綔绫诲瀷淇℃伅閿欒"); + } + + } + + #endregion + /// <summary> /// 鍒嗛〉鏌ヨ璁惧淇℃伅 /// </summary> -- Gitblit v1.8.0