diff --git a/HighWayIot.Plc/HighWayIot.Plc.csproj b/HighWayIot.Plc/HighWayIot.Plc.csproj index 7bf2639..9bb10b6 100644 --- a/HighWayIot.Plc/HighWayIot.Plc.csproj +++ b/HighWayIot.Plc/HighWayIot.Plc.csproj @@ -52,6 +52,7 @@ + diff --git a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs index ffc65de..766e854 100644 --- a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs +++ b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs @@ -24,7 +24,7 @@ namespace HighWayIot.Plc.PlcHelper //SPEC编号写入 try { - if (!PlcConnect.PlcWrite1("D206", uint.Parse(paraEntity.SpecCode), DataTypeEnum.UInt32).IsSuccess) + if (!PlcConnect.PlcWrite2("D206", uint.Parse(paraEntity.SpecCode), DataTypeEnum.UInt32).IsSuccess) return false; } catch @@ -33,7 +33,7 @@ namespace HighWayIot.Plc.PlcHelper } //SPEC名称写入 - if (!PlcConnect.PlcWrite1("D290", paraEntity.SpecName, DataTypeEnum.String).IsSuccess) + if (!PlcConnect.PlcWrite2("D290", paraEntity.SpecName, DataTypeEnum.String).IsSuccess) return false; //工位参数写入 @@ -57,17 +57,18 @@ namespace HighWayIot.Plc.PlcHelper bitDatas[1] = bitDatas[1].SetBoolByIndex(1, paraEntity.S9 ?? false); ushort bitData = bitDatas.FromBytes(); - if (!PlcConnect.PlcWrite1("D390", bitData, DataTypeEnum.UInt16).IsSuccess) return false; + if (!PlcConnect.PlcWrite2("D390", bitData, DataTypeEnum.UInt16).IsSuccess) + return false; - if (!PlcConnect.PlcWrite1("D391", paraEntity.RimInch ?? 0, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2("D391", paraEntity.RimInch ?? 0, DataTypeEnum.UInt16).IsSuccess) return false; - if (!PlcConnect.PlcWrite1("D392", paraEntity.LightWidth ?? 0, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2("D392", paraEntity.LightWidth ?? 0, DataTypeEnum.UInt16).IsSuccess) return false; - if (!PlcConnect.PlcWrite1("D393", paraEntity.SlowDistance ?? 0, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2("D393", paraEntity.SlowDistance ?? 0, DataTypeEnum.UInt16).IsSuccess) return false; - if (!PlcConnect.PlcWrite1("D394", paraEntity.StopDistance ?? 0, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2("D394", paraEntity.StopDistance ?? 0, DataTypeEnum.UInt16).IsSuccess) return false; - if (!PlcConnect.PlcWrite1("D398", paraEntity.TireWeight ?? 0, DataTypeEnum.Float).IsSuccess) + if (!PlcConnect.PlcWrite2("D398", paraEntity.TireWeight ?? 0, DataTypeEnum.Float).IsSuccess) return false; return true; @@ -149,7 +150,7 @@ namespace HighWayIot.Plc.PlcHelper if (value == null) { // 根据业务需求选择:返回false或使用默认值(例如0) - if (!PlcConnect.PlcWrite1($"D{add}", 0, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2($"D{add}", 0, DataTypeEnum.UInt16).IsSuccess) return false; } @@ -166,7 +167,7 @@ namespace HighWayIot.Plc.PlcHelper } // 写入PLC并检查结果 - if (!PlcConnect.PlcWrite1($"D{add}", valueToWrite, DataTypeEnum.UInt16).IsSuccess) + if (!PlcConnect.PlcWrite2($"D{add}", valueToWrite, DataTypeEnum.UInt16).IsSuccess) return false; add++; @@ -180,7 +181,7 @@ namespace HighWayIot.Plc.PlcHelper public List DownLoadFormPlc(ref ZxRecipeParaEntity paraEntity) { //一次性读取 - OperateResult result = PlcConnect.MelsecInstance1.Read("D290", 120); + OperateResult result = PlcConnect.MelsecInstance2.Read("D290", 120); byte[] data; if (result.IsSuccess) { @@ -192,16 +193,16 @@ namespace HighWayIot.Plc.PlcHelper } //读取SPEC编号 - paraEntity.SpecCode = PlcConnect.ReadUInt321("D206").ToString(); + paraEntity.SpecCode = PlcConnect.ReadUInt322("D206").ToString(); //读取SPEC名称 - paraEntity.SpecName = PlcConnect.MelsecInstance1.ByteTransform.TransString(data, 0, 10, Encoding.ASCII); + paraEntity.SpecName = PlcConnect.MelsecInstance2.ByteTransform.TransString(data, 0, 10, Encoding.ASCII); //读取工位参数 List positionEntitys = SelectReadPositionPara(data); //公共参数读取 - ushort bitData = PlcConnect.MelsecInstance1.ByteTransform.TransUInt16(data, (390 - 290) * 2); + ushort bitData = PlcConnect.MelsecInstance2.ByteTransform.TransUInt16(data, (390 - 290) * 2); byte[] bitDatas = bitData.ToBytes(); paraEntity.S0 = bitDatas[0].GetBoolByIndex(0); paraEntity.S1 = bitDatas[0].GetBoolByIndex(1); @@ -214,11 +215,11 @@ namespace HighWayIot.Plc.PlcHelper paraEntity.S8 = bitDatas[1].GetBoolByIndex(0); paraEntity.S9 = bitDatas[1].GetBoolByIndex(1); - paraEntity.RimInch = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (391 - 290) * 2);//("D391"); - paraEntity.LightWidth = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (392 - 290) * 2);//("D392"); - paraEntity.SlowDistance = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (393 - 290) * 2);//("D393"); - paraEntity.StopDistance = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (394 - 290) * 2);//("D394"); - paraEntity.TireWeight = PlcConnect.MelsecInstance1.ByteTransform.TransSingle(data, (398 - 290) * 2);//("D398"); + paraEntity.RimInch = PlcConnect.MelsecInstance2.ByteTransform.TransInt16(data, (391 - 290) * 2);//("D391"); + paraEntity.LightWidth = PlcConnect.MelsecInstance2.ByteTransform.TransInt16(data, (392 - 290) * 2);//("D392"); + paraEntity.SlowDistance = PlcConnect.MelsecInstance2.ByteTransform.TransInt16(data, (393 - 290) * 2);//("D393"); + paraEntity.StopDistance = PlcConnect.MelsecInstance2.ByteTransform.TransInt16(data, (394 - 290) * 2);//("D394"); + paraEntity.TireWeight = PlcConnect.MelsecInstance2.ByteTransform.TransSingle(data, (398 - 290) * 2);//("D398"); return positionEntitys; } diff --git a/HighWayIot.Plc/PlcHelper/RecipeSignal.cs b/HighWayIot.Plc/PlcHelper/RecipeSignal.cs new file mode 100644 index 0000000..0a9bdfa --- /dev/null +++ b/HighWayIot.Plc/PlcHelper/RecipeSignal.cs @@ -0,0 +1,47 @@ +using HighWayIot.Log4net; +using HslCommunication; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Plc.PlcHelper +{ + public class RecipeSignal + { + /// + /// 读取排程信号 + /// + /// + public Dictionary ReadSchedulingSignal() + { + Dictionary result = new Dictionary(); + + OperateResult operateResult = PlcConnect.MelsecInstance1.Read("B991", 8); + + if (!operateResult.IsSuccess) + { + LogHelper.Instance.Error("排程监视信息读取失败"); + return null; + } + + byte[] bytes = operateResult.Content; + + int boolIndex = 0; + for (int i = 0x901 - 0x901; i < 0x93E - 0x901 + 1; i++) + { + result.Add(boolIndex, bytes[i / 8].GetBoolByIndex(i % 8)); + boolIndex++; + } + + for (int i = 0x941 - 0x941; i < 0x97E - 0x941 + 1; i++) + { + result.Add(boolIndex, bytes[i / 8].GetBoolByIndex(i % 8)); + boolIndex++; + } + + return result; + } + } +} diff --git a/HighWayIot.Plc/PlcHelper/TransferSingal.cs b/HighWayIot.Plc/PlcHelper/TransferSingal.cs index 581df87..3aaa6f8 100644 --- a/HighWayIot.Plc/PlcHelper/TransferSingal.cs +++ b/HighWayIot.Plc/PlcHelper/TransferSingal.cs @@ -86,7 +86,7 @@ namespace HighWayIot.Plc.PlcHelper /// 第一个Byte数组是第二个Byte数组是开始横裁信号,第三个是结束横裁信号 public bool[][] ReadDrumReadyAndCountReadySignal() { - OperateResult operateResult = PlcConnect.MelsecInstance1.Read("B991", 2); + OperateResult operateResult = PlcConnect.MelsecInstance1.Read("B980", 3); if (!operateResult.IsSuccess) { @@ -110,8 +110,8 @@ namespace HighWayIot.Plc.PlcHelper //开始和结束横裁的信号 for (int i = 0; i < 8; i++) { - result[1][i] = data[0].GetBoolByIndex(i); - result[2][i] = data[2].GetBoolByIndex(i); + result[1][i + 1] = data[2].GetBoolByIndex(i); + result[2][i + 1] = data[4].GetBoolByIndex(i); } return result; diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs index a255052..e82c863 100644 --- a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs +++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs @@ -21,19 +21,17 @@ namespace HighWayIot.Plc.PlcHelper /// public bool WriteStationSingal(int rgvStationNo, int deviceNo) { - LogHelper.Instance.Info($"{rgvStationNo}工位, {deviceNo}号车"); - return true; - //int point = 0x600; + int point = 0x600; - ////选择是哪个小车 - //point += (deviceNo - 1) * 32; + //选择是哪个小车 + point += (deviceNo - 1) * 32; - ////选择是小车的哪个点位 - //point += rgvStationNo; + //选择是小车的哪个点位 + point += rgvStationNo; - //bool result = PlcConnect.PlcWrite2($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess; + bool result = PlcConnect.PlcWrite2($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess; - //return result; + return result; } /// diff --git a/HighWayIot.Repository/HighWayIot.Repository.csproj b/HighWayIot.Repository/HighWayIot.Repository.csproj index f05f400..7ad1940 100644 --- a/HighWayIot.Repository/HighWayIot.Repository.csproj +++ b/HighWayIot.Repository/HighWayIot.Repository.csproj @@ -62,6 +62,7 @@ + @@ -71,6 +72,7 @@ + diff --git a/HighWayIot.Repository/domain/ZxCarParaEntity.cs b/HighWayIot.Repository/domain/ZxCarParaEntity.cs index f9a494e..95ea6b2 100644 --- a/HighWayIot.Repository/domain/ZxCarParaEntity.cs +++ b/HighWayIot.Repository/domain/ZxCarParaEntity.cs @@ -11,7 +11,7 @@ namespace HighWayIot.Repository.domain /// 小车参数 /// [SugarTable("zx_car_para")] - internal class ZxCarParaEntity + public class ZxCarParaEntity { /// /// 备 注: diff --git a/HighWayIot.Repository/domain/ZxOpenMixMaterialEntity.cs b/HighWayIot.Repository/domain/ZxOpenMixMaterialEntity.cs new file mode 100644 index 0000000..05bc095 --- /dev/null +++ b/HighWayIot.Repository/domain/ZxOpenMixMaterialEntity.cs @@ -0,0 +1,30 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.domain +{ + /// + /// 开炼机物料配置表 + /// + [SugarTable("zx_open_mix_material")] + public class ZxOpenMixMaterialEntity + { + /// + /// 备 注:工位编号 + /// 默认值: + /// + [SugarColumn(ColumnName = "station_no", IsPrimaryKey = true, IsIdentity = true)] + public int StationNo { get; set; } + + /// + /// 备 注:物料名称 + /// 默认值: + /// + [SugarColumn(ColumnName = "material_name")] + public string MaterialName { get; set; } = string.Empty; + } +} diff --git a/HighWayIot.Repository/domain/ZxSchedulingEntity.cs b/HighWayIot.Repository/domain/ZxSchedulingEntity.cs index 385b540..3d6450d 100644 --- a/HighWayIot.Repository/domain/ZxSchedulingEntity.cs +++ b/HighWayIot.Repository/domain/ZxSchedulingEntity.cs @@ -8,7 +8,7 @@ namespace Models /// 生产排程实体类 /// [SugarTable("zx_scheduling")] - public class ZxScheduling + public class ZxSchedulingEntity { /// /// 备 注: diff --git a/HighWayIot.Repository/service/ZxCarParaService.cs b/HighWayIot.Repository/service/ZxCarParaService.cs index d5f90b8..59a32cd 100644 --- a/HighWayIot.Repository/service/ZxCarParaService.cs +++ b/HighWayIot.Repository/service/ZxCarParaService.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace HighWayIot.Repository.service { - internal class ZxCarParaService + public class ZxCarParaService { private static readonly Lazy lazy = new Lazy(() => new ZxCarParaService()); diff --git a/HighWayIot.Repository/service/ZxOpenMixMaterialService.cs b/HighWayIot.Repository/service/ZxOpenMixMaterialService.cs new file mode 100644 index 0000000..1f6c96b --- /dev/null +++ b/HighWayIot.Repository/service/ZxOpenMixMaterialService.cs @@ -0,0 +1,61 @@ +using HighWayIot.Log4net; +using HighWayIot.Repository.domain; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.service +{ + public class ZxOpenMixMaterialService + { + private static readonly Lazy lazy = new Lazy(() => new ZxOpenMixMaterialService()); + + public static ZxOpenMixMaterialService Instance + { + get + { + return lazy.Value; + } + } + + private LogHelper log = LogHelper.Instance; + Repository _repository => new Repository("sqlserver"); + + /// + /// 查询配置信息 + /// + /// + public List GetInfos() + { + try + { + List entity = _repository.GetList(); + return entity; + } + catch (Exception ex) + { + log.Error("开炼机配置信息获取异常", ex); + return null; + } + } + + /// + /// 更新配置信息 + /// + /// + public bool UpDateInfos(List entity) + { + try + { + return _repository.UpdateRange(entity); + } + catch (Exception ex) + { + log.Error("开炼机配置信息更新异常", ex); + return false; + } + } + } +} diff --git a/HighWayIot.Repository/service/ZxRecipeService.cs b/HighWayIot.Repository/service/ZxRecipeService.cs index b873917..219b6e4 100644 --- a/HighWayIot.Repository/service/ZxRecipeService.cs +++ b/HighWayIot.Repository/service/ZxRecipeService.cs @@ -63,6 +63,25 @@ namespace HighWayIot.Repository.service } } + /// + /// 根据配方名称查询条配方参数 + /// + /// + /// + public ZxRecipeEntity GetSingleInfoByRecipeName(string recipeName) + { + try + { + ZxRecipeEntity entity = _repository.GetSingle(x => x.RecipeName == recipeName && x.IsDeleted == false); + return entity; + } + catch(Exception ex) + { + log.Error("根据一个配方名称查询到多条配方信息", ex); + return null; + } + } + /// /// 获取所有配方名称 /// diff --git a/HighWayIot.Repository/service/ZxSchedulingService.cs b/HighWayIot.Repository/service/ZxSchedulingService.cs index b745d42..11ecbf9 100644 --- a/HighWayIot.Repository/service/ZxSchedulingService.cs +++ b/HighWayIot.Repository/service/ZxSchedulingService.cs @@ -23,17 +23,17 @@ namespace HighWayIot.Repository.service } private LogHelper log = LogHelper.Instance; - Repository _repository => new Repository("sqlserver"); + Repository _repository => new Repository("sqlserver"); /// /// 查询所有排程信息 /// /// - public List GetSchedulingInfo(Expression> expression = null) + public List GetSchedulingInfo(Expression> expression = null) { try { - List entity; + List entity; if (expression != null) { entity = _repository.GetList(expression); @@ -56,7 +56,7 @@ namespace HighWayIot.Repository.service ///// ///// ///// - //public bool InsertSchedulingInfo(ZxScheduling entity) + //public bool InsertSchedulingInfo(ZxSchedulingEntity entity) //{ // try // { @@ -74,11 +74,11 @@ namespace HighWayIot.Repository.service /// /// /// - public bool UpdateSchedulingInfo(ZxScheduling entity) + public bool UpdateSchedulingInfo(List entity) { try { - return _repository.Update(entity); + return _repository.UpdateRange(entity); } catch (Exception ex) { diff --git a/HighWayIot.Rfid/BaseRFIDDataAnalyse.cs b/HighWayIot.Rfid/BaseRFIDDataAnalyse.cs index ae2eb7d..c2a5422 100644 --- a/HighWayIot.Rfid/BaseRFIDDataAnalyse.cs +++ b/HighWayIot.Rfid/BaseRFIDDataAnalyse.cs @@ -39,6 +39,8 @@ namespace HighWayIot.Rfid result.Status = data[index]; index++; + result.Data = new byte[result.DataLength]; + //取Data Array.Copy(data, 5, result.Data, 0, result.DataLength); index += result.DataLength; @@ -48,12 +50,12 @@ namespace HighWayIot.Rfid int xor = 0; for (int i = 0; i < 3 + result.DataLength; i++) { - xor ^= data[i]; + xor ^= data[i + 2]; } - if(xor != data[data.Length - 1]) + if(xor != data[data.Length - 2]) { _logHelper.Error("数据校验和未通过"); - return new BaseReciveDataEntity(); + return null; } return result; @@ -71,15 +73,16 @@ namespace HighWayIot.Rfid int index = 2; //指令头 - result[0] = 0xBB; - result[1] = 0xDD; - + result[0] = 0xAA; + result[1] = 0x55; + //数据长度 result[index] = (byte)entity.Data.Length; index++; //指令编号 result[index] = entity.Code; + index++; //数据 Array.Copy(entity.Data, 0, result, 4, entity.Data.Length); @@ -87,9 +90,9 @@ namespace HighWayIot.Rfid //校验和 int xor = 0; - for (int i = 2; i < 2 + entity.Data.Length; i++) + for (int i = 0; i < 2 + entity.Data.Length; i++) { - xor ^= result[i]; + xor ^= result[i + 2]; } result[index] = (byte)xor; index++; diff --git a/HighWayIot.Rfid/RfidDataAnalyse.cs b/HighWayIot.Rfid/RfidDataAnalyse.cs index 69d0257..17b61a0 100644 --- a/HighWayIot.Rfid/RfidDataAnalyse.cs +++ b/HighWayIot.Rfid/RfidDataAnalyse.cs @@ -17,14 +17,16 @@ namespace HighWayIot.Rfid public byte[] Send02H(ushort millisecond) { byte[] bytes = BitConverter.GetBytes(millisecond); - + bytes = bytes.Reverse().ToArray(); BaseSendDataEntity entity = new BaseSendDataEntity() { Code = 0x02, Data = bytes }; - return BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); + byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); + + return result; } /// @@ -35,17 +37,28 @@ namespace HighWayIot.Rfid public Receive02HEntity Receive02H(byte[] bytes) { BaseReciveDataEntity recive = BaseRFIDDataAnalyse.BaseReceiveAnalyse(bytes); + if (recive == null) + { + return null; + } byte[] DataBytes = recive.Data; Receive02HEntity entity = new Receive02HEntity(); - //取读到多少个标签 int index = 0; - entity.TagCount = DataBytes[index]; - index++; + if (DataBytes.Length != 0) + { + //取读到多少个标签 + entity.TagCount = DataBytes[index]; + entity.Data = new List(); + index++; + } + else + { + entity.TagCount = 0; + } //取每一个读到的标签 - entity.Data = new List(); for (int i = 0; i < entity.TagCount; i++) { Single02HReceive EPCData = new Single02HReceive(); @@ -63,11 +76,20 @@ namespace HighWayIot.Rfid index++; //取EPC区域 + EPCData.PC = new byte[2]; Array.Copy(DataBytes, index, EPCData.PC, 0, 2); index += 2; //取读到标签的EPC - Array.Copy(DataBytes, index, EPCData.EPC, 0, 12); + EPCData.EPC = new byte[12]; + try + { + Array.Copy(DataBytes, index, EPCData.EPC, 0, 12); + } + catch + { + return null; + } index += 12; entity.Data.Add(EPCData); diff --git a/HighWayIot.TouchSocket/TouchSocketTcpClient.cs b/HighWayIot.TouchSocket/TouchSocketTcpClient.cs index 4fd5865..57f842b 100644 --- a/HighWayIot.TouchSocket/TouchSocketTcpClient.cs +++ b/HighWayIot.TouchSocket/TouchSocketTcpClient.cs @@ -29,6 +29,8 @@ namespace HighWayIot.TouchSocket /// public Dictionary Clients = new Dictionary(); + public int ClientsCount = 0; + public Action GetMessageAction; public async Task CreateTcpClient(string ip, string port) @@ -53,9 +55,10 @@ namespace HighWayIot.TouchSocket };//有客户端断开连接 tcpClient.Received = async (client, e) => { - - GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP); - + await Task.Run(() => + { + GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP); + }); }; //接收信号 await tcpClient.SetupAsync(new TouchSocketConfig() @@ -83,7 +86,7 @@ namespace HighWayIot.TouchSocket }); } while (!result.IsSuccess); - _logHelper.Info($"{ip}:{port}连接成功"); + _logHelper.Info($"{ip}:{port}连接成功 {++ClientsCount}/17"); Clients.Add(ip, tcpClient); return true; diff --git a/HighWayIot.Winform/Business/RecipeSendBusiness.cs b/HighWayIot.Winform/Business/RecipeSendBusiness.cs new file mode 100644 index 0000000..abb1a7e --- /dev/null +++ b/HighWayIot.Winform/Business/RecipeSendBusiness.cs @@ -0,0 +1,95 @@ +using HighWayIot.Log4net; +using HighWayIot.Plc; +using HighWayIot.Plc.PlcHelper; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Schema; +using Timer = System.Threading.Timer; + +namespace HighWayIot.Winform.Business +{ + public class RecipeSendBusiness + { + Timer GetSchedulingTimer; + + RecipeSignal recipeSignal = new RecipeSignal(); + + ZxSchedulingService zxSchedulingService = ZxSchedulingService.Instance; + + ZxRecipeParaService zxRecipeParaService = ZxRecipeParaService.Instance; + + ZxRecipePositionParaService zxRecipePositionParaService = ZxRecipePositionParaService.Instance; + + RecipeParaHelper recipeParaHelper = new RecipeParaHelper(); + + public RecipeSendBusiness() + { + GetSchedulingTimer = new Timer(new System.Threading.TimerCallback(ReadSignal), null, 0, 1000); + } + + /// + /// 重复读取 + /// + /// + public void ReadSignal(object o) + { + Dictionary a = recipeSignal.ReadSchedulingSignal(); + + if(a == null) + { + return; + } + + if (a == null) + { + LogHelper.Instance.Error("排程信号读取失败"); + } + + foreach (var item in a) + { + if (item.Value) + { + var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); + + if ((item.Key + 1) < 63) + { + string recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo1; + ZxRecipeParaEntity recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + List zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + PlcConnect.PlcWrite2($"B{(item.Key + 0x901).ToString("X")}", false, DataTypeEnum.Bool); + } + } + else + { + string recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeNo2; + ZxRecipeParaEntity recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + List zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + PlcConnect.PlcWrite2($"B{(item.Key + 0x941).ToString("X")}", false, DataTypeEnum.Bool); + } + } + return; + } + } + } + } +} diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs index b0b5dc9..ecd9ae9 100644 --- a/HighWayIot.Winform/Business/WorkStationBusiness.cs +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -110,11 +110,12 @@ namespace HighWayIot.Winform.Business { foreach (var setting in _readerSetting) { - await _touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108"); + await Task.Run(() => + { + _touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108"); + }); } - _logHelper.Info("所有读写器均连接成功"); - IsAllConnected = true; } @@ -165,6 +166,10 @@ namespace HighWayIot.Winform.Business public void ReciveRFIDSingal(byte[] bytes, string ip) { Receive02HEntity entity = _rfidDataAnalyse.Receive02H(bytes); + if (entity == null || entity.Data == null) + { + return ; + } //if(entity.TagCount != 1) //{ // _logHelper.Error("返回多标签!"); @@ -195,7 +200,8 @@ namespace HighWayIot.Winform.Business try { ///写入对应的PLC信号 - _workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo)); + //_workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo)); + LogHelper.Instance.Info($"{workstationNo}工位, {deviceNo}号车"); } catch (Exception ex) { diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index 9788647..b5b50a5 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -53,6 +53,7 @@ + diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs index b3b161b..a3d539a 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs @@ -92,7 +92,7 @@ namespace HighWayIot.Winform.MainForm this.MainMenu.Location = new System.Drawing.Point(0, 0); this.MainMenu.Name = "MainMenu"; this.MainMenu.Padding = new System.Windows.Forms.Padding(5, 1, 0, 1); - this.MainMenu.Size = new System.Drawing.Size(1475, 24); + this.MainMenu.Size = new System.Drawing.Size(1904, 24); this.MainMenu.TabIndex = 1; this.MainMenu.Text = "menuStrip1"; // @@ -164,7 +164,7 @@ namespace HighWayIot.Winform.MainForm // this.DaliyReportStripItem.Image = global::HighWayIot.Winform.Properties.Resources.报表数据; this.DaliyReportStripItem.Name = "DaliyReportStripItem"; - this.DaliyReportStripItem.Size = new System.Drawing.Size(180, 22); + this.DaliyReportStripItem.Size = new System.Drawing.Size(124, 22); this.DaliyReportStripItem.Text = "日报表"; this.DaliyReportStripItem.Click += new System.EventHandler(this.StripMenuItemClick); // @@ -172,7 +172,7 @@ namespace HighWayIot.Winform.MainForm // this.OperateLogStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.操作日志; this.OperateLogStripMenuItem.Name = "OperateLogStripMenuItem"; - this.OperateLogStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.OperateLogStripMenuItem.Size = new System.Drawing.Size(124, 22); this.OperateLogStripMenuItem.Text = "操作日志"; this.OperateLogStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); // @@ -180,7 +180,7 @@ namespace HighWayIot.Winform.MainForm // this.AlarmLogStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.报警日志; this.AlarmLogStripMenuItem.Name = "AlarmLogStripMenuItem"; - this.AlarmLogStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.AlarmLogStripMenuItem.Size = new System.Drawing.Size(124, 22); this.AlarmLogStripMenuItem.Text = "报警日志"; this.AlarmLogStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); // @@ -287,7 +287,7 @@ namespace HighWayIot.Winform.MainForm this.UserControlTabs.Margin = new System.Windows.Forms.Padding(0); this.UserControlTabs.Name = "UserControlTabs"; this.UserControlTabs.SelectedIndex = 0; - this.UserControlTabs.Size = new System.Drawing.Size(1476, 817); + this.UserControlTabs.Size = new System.Drawing.Size(1905, 995); this.UserControlTabs.TabIndex = 3; // // ClosePageButton @@ -297,7 +297,7 @@ namespace HighWayIot.Winform.MainForm this.ClosePageButton.Cursor = System.Windows.Forms.Cursors.Hand; this.ClosePageButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.ClosePageButton.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.ClosePageButton.Location = new System.Drawing.Point(1455, 1); + this.ClosePageButton.Location = new System.Drawing.Point(1884, 1); this.ClosePageButton.Name = "ClosePageButton"; this.ClosePageButton.Size = new System.Drawing.Size(20, 20); this.ClosePageButton.TabIndex = 4; @@ -322,9 +322,9 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel4, this.StripLabel2, this.TimeStripLabel}); - this.statusStrip1.Location = new System.Drawing.Point(0, 841); + this.statusStrip1.Location = new System.Drawing.Point(0, 1019); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(1475, 22); + this.statusStrip1.Size = new System.Drawing.Size(1904, 22); this.statusStrip1.TabIndex = 5; this.statusStrip1.Text = "statusStrip1"; // @@ -361,7 +361,7 @@ namespace HighWayIot.Winform.MainForm // LogInformationToolStrip // this.LogInformationToolStrip.Name = "LogInformationToolStrip"; - this.LogInformationToolStrip.Size = new System.Drawing.Size(851, 17); + this.LogInformationToolStrip.Size = new System.Drawing.Size(1280, 17); this.LogInformationToolStrip.Spring = true; this.LogInformationToolStrip.Text = "message"; // @@ -422,7 +422,7 @@ namespace HighWayIot.Winform.MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1475, 863); + this.ClientSize = new System.Drawing.Size(1904, 1041); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.ClosePageButton); this.Controls.Add(this.UserControlTabs); diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index 8c208cc..34ca398 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -42,6 +42,11 @@ namespace HighWayIot.Winform.MainForm /// WorkStationBusiness workStationBusiness = new WorkStationBusiness(); + /// + /// 配方排程刷新类 + /// + RecipeSendBusiness recipeSendBusiness = new RecipeSendBusiness(); + /// /// 底边栏消息提示刷新 /// diff --git a/HighWayIot.Winform/MainForm/LoginForm.Designer.cs b/HighWayIot.Winform/MainForm/LoginForm.Designer.cs index 20876d4..2140fd4 100644 --- a/HighWayIot.Winform/MainForm/LoginForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/LoginForm.Designer.cs @@ -115,7 +115,7 @@ namespace HighWayIot.Winform.MainForm | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pictureBox1.Image = global::HighWayIot.Winform.Properties.Resources.MesnacLogoHighPixel; - this.pictureBox1.Location = new System.Drawing.Point(50, 27); + this.pictureBox1.Location = new System.Drawing.Point(51, 39); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(174, 189); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; diff --git a/HighWayIot.Winform/Program.cs b/HighWayIot.Winform/Program.cs index 30a819c..7021331 100644 --- a/HighWayIot.Winform/Program.cs +++ b/HighWayIot.Winform/Program.cs @@ -31,22 +31,27 @@ namespace HighWayIot.Winform //Console.OutputEncoding = System.Text.Encoding.UTF8; //Console.InputEncoding = System.Text.Encoding.UTF8; - - - AllocConsole();//调用系统API,调用控制台窗口 - // 设置控制台编码为系统默认编码(解决乱码问题) - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - //创建窗体 - LoginForm loginform = new LoginForm(); - logger.Info("程序初始化成功"); - //验证成功显示主窗体 - if (loginform.ShowDialog() == DialogResult.OK) + try { - logger.Info("登陆成功"); - Application.Run(new BaseForm()); + AllocConsole();//调用系统API,调用控制台窗口 + // 设置控制台编码为系统默认编码(解决乱码问题) + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + //创建窗体 + LoginForm loginform = new LoginForm(); + logger.Info("程序初始化成功"); + //验证成功显示主窗体 + if (loginform.ShowDialog() == DialogResult.OK) + { + logger.Info("登陆成功"); + Application.Run(new BaseForm()); + } + FreeConsole();//释放控制台 } - FreeConsole();//释放控制台 + catch(Exception ex) + { + logger.Error("程序初始化异常", ex); + } } } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.Designer.cs index b317bd3..bfb9f5d 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.Designer.cs @@ -31,68 +31,190 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages /// private void InitializeComponent() { - this.RoleDataGridView = new System.Windows.Forms.DataGridView(); - this.AddRole = new System.Windows.Forms.Button(); - this.ButtonPanel = new System.Windows.Forms.Panel(); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).BeginInit(); - this.ButtonPanel.SuspendLayout(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.RefreshOpenMixMaterial = new System.Windows.Forms.Button(); + this.SaveOpenMixMaterial = new System.Windows.Forms.Button(); + this.OpenMixMaterial5 = new System.Windows.Forms.ComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.OpenMixMaterial4 = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.OpenMixMaterial3 = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.OpenMixMaterial2 = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.OpenMixMaterial1 = new System.Windows.Forms.ComboBox(); + this.groupBox1.SuspendLayout(); this.SuspendLayout(); // - // RoleDataGridView + // OpenMixMaterial1 // - this.RoleDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.RoleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.RoleDataGridView.Location = new System.Drawing.Point(0, 65); - this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.RoleDataGridView.Name = "RoleDataGridView"; - this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(883, 497); - this.RoleDataGridView.TabIndex = 0; - this.RoleDataGridView.Tag = ""; + this.OpenMixMaterial1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OpenMixMaterial1.FormattingEnabled = true; + this.OpenMixMaterial1.Location = new System.Drawing.Point(84, 32); + this.OpenMixMaterial1.Name = "OpenMixMaterial1"; + this.OpenMixMaterial1.Size = new System.Drawing.Size(234, 24); + this.OpenMixMaterial1.TabIndex = 1; // - // AddRole + // groupBox1 // - this.AddRole.Location = new System.Drawing.Point(11, 11); - this.AddRole.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.AddRole.Name = "AddRole"; - this.AddRole.Size = new System.Drawing.Size(103, 39); - this.AddRole.TabIndex = 1; - this.AddRole.Text = "查询操作信息"; - this.AddRole.UseVisualStyleBackColor = true; + this.groupBox1.Controls.Add(this.RefreshOpenMixMaterial); + this.groupBox1.Controls.Add(this.SaveOpenMixMaterial); + this.groupBox1.Controls.Add(this.OpenMixMaterial5); + this.groupBox1.Controls.Add(this.label5); + this.groupBox1.Controls.Add(this.OpenMixMaterial4); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.OpenMixMaterial3); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.OpenMixMaterial2); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(OpenMixMaterial1); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(3, 3); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(365, 251); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "开炼机胶料配置"; // - // ButtonPanel + // RefreshOpenMixMaterial // - this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.AddRole); - this.ButtonPanel.Location = new System.Drawing.Point(0, 0); - this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(883, 61); - this.ButtonPanel.TabIndex = 4; + this.RefreshOpenMixMaterial.Font = new System.Drawing.Font("宋体", 12F); + this.RefreshOpenMixMaterial.Location = new System.Drawing.Point(224, 191); + this.RefreshOpenMixMaterial.Name = "RefreshOpenMixMaterial"; + this.RefreshOpenMixMaterial.Size = new System.Drawing.Size(94, 43); + this.RefreshOpenMixMaterial.TabIndex = 11; + this.RefreshOpenMixMaterial.Text = "刷新"; + this.RefreshOpenMixMaterial.UseVisualStyleBackColor = true; + this.RefreshOpenMixMaterial.Click += new System.EventHandler(this.RefreshOpenMixMaterial_Click); // - // OperateConfigPage + // SaveOpenMixMaterial + // + this.SaveOpenMixMaterial.Font = new System.Drawing.Font("宋体", 12F); + this.SaveOpenMixMaterial.Location = new System.Drawing.Point(20, 191); + this.SaveOpenMixMaterial.Name = "SaveOpenMixMaterial"; + this.SaveOpenMixMaterial.Size = new System.Drawing.Size(94, 43); + this.SaveOpenMixMaterial.TabIndex = 10; + this.SaveOpenMixMaterial.Text = "保存"; + this.SaveOpenMixMaterial.UseVisualStyleBackColor = true; + this.SaveOpenMixMaterial.Click += new System.EventHandler(this.SaveOpenMixMaterial_Click); + // + // OpenMixMaterial5 + // + this.OpenMixMaterial5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OpenMixMaterial5.FormattingEnabled = true; + this.OpenMixMaterial5.Location = new System.Drawing.Point(84, 152); + this.OpenMixMaterial5.Name = "OpenMixMaterial5"; + this.OpenMixMaterial5.Size = new System.Drawing.Size(234, 24); + this.OpenMixMaterial5.TabIndex = 9; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label5.Location = new System.Drawing.Point(16, 153); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(62, 22); + this.label5.TabIndex = 8; + this.label5.Text = "#5工位"; + // + // OpenMixMaterial4 + // + this.OpenMixMaterial4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OpenMixMaterial4.FormattingEnabled = true; + this.OpenMixMaterial4.Location = new System.Drawing.Point(84, 122); + this.OpenMixMaterial4.Name = "OpenMixMaterial4"; + this.OpenMixMaterial4.Size = new System.Drawing.Size(234, 24); + this.OpenMixMaterial4.TabIndex = 7; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.Location = new System.Drawing.Point(16, 123); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(62, 22); + this.label4.TabIndex = 6; + this.label4.Text = "#4工位"; + // + // OpenMixMaterial3 + // + this.OpenMixMaterial3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OpenMixMaterial3.FormattingEnabled = true; + this.OpenMixMaterial3.Location = new System.Drawing.Point(84, 92); + this.OpenMixMaterial3.Name = "OpenMixMaterial3"; + this.OpenMixMaterial3.Size = new System.Drawing.Size(234, 24); + this.OpenMixMaterial3.TabIndex = 5; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label3.Location = new System.Drawing.Point(16, 93); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(62, 22); + this.label3.TabIndex = 4; + this.label3.Text = "#3工位"; + // + // OpenMixMaterial2 + // + this.OpenMixMaterial2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.OpenMixMaterial2.FormattingEnabled = true; + this.OpenMixMaterial2.Location = new System.Drawing.Point(84, 62); + this.OpenMixMaterial2.Name = "OpenMixMaterial2"; + this.OpenMixMaterial2.Size = new System.Drawing.Size(234, 24); + this.OpenMixMaterial2.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label2.Location = new System.Drawing.Point(16, 63); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(62, 22); + this.label2.TabIndex = 2; + this.label2.Text = "#2工位"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(16, 33); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(62, 22); + this.label1.TabIndex = 0; + this.label1.Text = "#1工位"; + // + // EquipParamSettingPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; - this.Controls.Add(this.ButtonPanel); - this.Controls.Add(this.RoleDataGridView); + this.Controls.Add(this.groupBox1); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "OperateConfigPage"; - this.Size = new System.Drawing.Size(883, 562); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); - this.ButtonPanel.ResumeLayout(false); + this.Name = "EquipParamSettingPage"; + this.Size = new System.Drawing.Size(1905, 995); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); this.ResumeLayout(false); } #endregion - private DataGridView RoleDataGridView; - private Button AddRole; - private Panel ButtonPanel; + private GroupBox groupBox1; + private Label label1; + private Button RefreshOpenMixMaterial; + private Button SaveOpenMixMaterial; + private ComboBox OpenMixMaterial5; + private Label label5; + private ComboBox OpenMixMaterial4; + private Label label4; + private ComboBox OpenMixMaterial3; + private Label label3; + private ComboBox OpenMixMaterial2; + private Label label2; + private ComboBox OpenMixMaterial1; + } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs index b174bbb..66f724f 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs @@ -1,4 +1,7 @@ -using System; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,14 +15,100 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages { public partial class EquipParamSettingPage : UserControl { + ZxMaterialService zxMaterialService = ZxMaterialService.Instance; + + ZxOpenMixMaterialService zxOpenMixMaterialService = ZxOpenMixMaterialService.Instance; + + List zxMaterialEntities = new List(); + public EquipParamSettingPage() { InitializeComponent(); + Init(); } - private void UpdateRole_Click(object sender, EventArgs e) + /// + /// 初始化 + /// + private void Init() { + zxMaterialEntities = zxMaterialService.GetMaterialInfos().Select(x => x.MaterialName).ToList(); + zxMaterialEntities.Insert(0, ""); + OpenMixMaterial1.DataSource = zxMaterialEntities; + List zxMaterialEntities1 = new List(zxMaterialEntities); + OpenMixMaterial2.DataSource = zxMaterialEntities1; + List zxMaterialEntities2 = new List(zxMaterialEntities); + OpenMixMaterial3.DataSource = zxMaterialEntities2; + List zxMaterialEntities3 = new List(zxMaterialEntities); + OpenMixMaterial4.DataSource = zxMaterialEntities3; + List zxMaterialEntities4 = new List(zxMaterialEntities); + OpenMixMaterial5.DataSource = zxMaterialEntities4; + + List list = zxOpenMixMaterialService.GetInfos(); + if (list != null && list.Count > 0) + { + OpenMixMaterial1.SelectedItem = list[0].MaterialName; + OpenMixMaterial2.SelectedItem = list[1].MaterialName; + OpenMixMaterial3.SelectedItem = list[2].MaterialName; + OpenMixMaterial4.SelectedItem = list[3].MaterialName; + OpenMixMaterial5.SelectedItem = list[4].MaterialName; + } + } + /// + /// 保存开炼机物料配置 + /// + /// + /// + private void SaveOpenMixMaterial_Click(object sender, EventArgs e) + { + List list = new List() + { + new ZxOpenMixMaterialEntity() + { + StationNo = 1, + MaterialName = OpenMixMaterial1.SelectedItem.ToString() + }, + new ZxOpenMixMaterialEntity() + { + StationNo = 2, + MaterialName = OpenMixMaterial2.SelectedItem.ToString() + }, + new ZxOpenMixMaterialEntity() + { + StationNo = 3, + MaterialName = OpenMixMaterial3.SelectedItem.ToString() + }, + new ZxOpenMixMaterialEntity() + { + StationNo = 4, + MaterialName = OpenMixMaterial4.SelectedItem.ToString() + }, + new ZxOpenMixMaterialEntity() + { + StationNo = 5, + MaterialName = OpenMixMaterial5.SelectedItem.ToString() + } + }; + + if (zxOpenMixMaterialService.UpDateInfos(list)) + { + MessageBox.Show("开炼机物料配置信息保存成功"); + } + else + { + MessageBox.Show("开炼机物料配置信息保存失败"); + } + } + + /// + /// 刷新开炼机物料配置 + /// + /// + /// + private void RefreshOpenMixMaterial_Click(object sender, EventArgs e) + { + Init(); } } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.resx index 1af7de1..9663715 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.resx +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + False + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs index 70b7ce2..2d2d24d 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs @@ -31,38 +31,49 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages /// private void InitializeComponent() { - this.RoleDataGridView = new System.Windows.Forms.DataGridView(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + this.SchedulingDataGridView = new System.Windows.Forms.DataGridView(); this.SelectConfigButton = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); this.UpdateConfigButton = new System.Windows.Forms.Button(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeName1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName1 = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.SpecName1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeName2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName2 = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.SpecName2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.SchedulingDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); // - // RoleDataGridView + // SchedulingDataGridView // - this.RoleDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.SchedulingDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.RoleDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.RoleDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.SchedulingDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.SchedulingDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Id, this.DeviceNo, this.RecipeName1, this.SpecName1, this.RecipeName2, this.SpecName2}); - this.RoleDataGridView.Location = new System.Drawing.Point(0, 65); - this.RoleDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.RoleDataGridView.Name = "RoleDataGridView"; - this.RoleDataGridView.RowTemplate.Height = 25; - this.RoleDataGridView.Size = new System.Drawing.Size(1105, 676); - this.RoleDataGridView.TabIndex = 0; - this.RoleDataGridView.Tag = ""; + this.SchedulingDataGridView.Location = new System.Drawing.Point(0, 65); + this.SchedulingDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.SchedulingDataGridView.Name = "SchedulingDataGridView"; + this.SchedulingDataGridView.RowHeadersVisible = false; + this.SchedulingDataGridView.RowTemplate.Height = 25; + this.SchedulingDataGridView.Size = new System.Drawing.Size(1105, 676); + this.SchedulingDataGridView.TabIndex = 0; + this.SchedulingDataGridView.Tag = ""; + this.SchedulingDataGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.SchedulingDataGridView_CellEnter); + this.SchedulingDataGridView.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.SchedulingDataGridView_EditingControlShowing); // // SelectConfigButton // @@ -98,38 +109,71 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.UpdateConfigButton.UseVisualStyleBackColor = true; this.UpdateConfigButton.Click += new System.EventHandler(this.UpdateConfigButton_Click); // + // Id + // + this.Id.DataPropertyName = "Id"; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Id.DefaultCellStyle = dataGridViewCellStyle7; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.Id.Width = 50; + // // DeviceNo // + this.DeviceNo.DataPropertyName = "DeviceNo"; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.DeviceNo.DefaultCellStyle = dataGridViewCellStyle8; this.DeviceNo.HeaderText = "机台编号"; this.DeviceNo.Name = "DeviceNo"; + this.DeviceNo.ReadOnly = true; + this.DeviceNo.Resizable = System.Windows.Forms.DataGridViewTriState.False; // // RecipeName1 // + this.RecipeName1.DataPropertyName = "RecipeName1"; + dataGridViewCellStyle9.BackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle9.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.Black; + this.RecipeName1.DefaultCellStyle = dataGridViewCellStyle9; this.RecipeName1.HeaderText = "成品代号 - 上模"; this.RecipeName1.Name = "RecipeName1"; - this.RecipeName1.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.RecipeName1.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeName1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.RecipeName1.Width = 150; // // SpecName1 // this.SpecName1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.SpecName1.DataPropertyName = "SpecName1"; + dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.SpecName1.DefaultCellStyle = dataGridViewCellStyle10; this.SpecName1.HeaderText = "标称尺度 - 上模"; this.SpecName1.Name = "SpecName1"; + this.SpecName1.Resizable = System.Windows.Forms.DataGridViewTriState.False; // // RecipeName2 // + this.RecipeName2.DataPropertyName = "RecipeName2"; + dataGridViewCellStyle11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.RecipeName2.DefaultCellStyle = dataGridViewCellStyle11; this.RecipeName2.HeaderText = "成品代号 - 下模"; this.RecipeName2.Name = "RecipeName2"; - this.RecipeName2.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.RecipeName2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.RecipeName2.Resizable = System.Windows.Forms.DataGridViewTriState.False; this.RecipeName2.Width = 150; // // SpecName2 // this.SpecName2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.SpecName2.DataPropertyName = "SpecName2"; + dataGridViewCellStyle12.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.SpecName2.DefaultCellStyle = dataGridViewCellStyle12; this.SpecName2.HeaderText = "标称尺度 - 下模"; this.SpecName2.Name = "SpecName2"; - this.SpecName2.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.SpecName2.Resizable = System.Windows.Forms.DataGridViewTriState.False; this.SpecName2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ProductionScheduling @@ -138,11 +182,11 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; this.Controls.Add(this.ButtonPanel); - this.Controls.Add(this.RoleDataGridView); + this.Controls.Add(this.SchedulingDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "ProductionScheduling"; this.Size = new System.Drawing.Size(1105, 741); - ((System.ComponentModel.ISupportInitialize)(this.RoleDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.SchedulingDataGridView)).EndInit(); this.ButtonPanel.ResumeLayout(false); this.ResumeLayout(false); @@ -150,14 +194,15 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages #endregion - private DataGridView RoleDataGridView; + private DataGridView SchedulingDataGridView; private Button SelectConfigButton; private Panel ButtonPanel; private Button UpdateConfigButton; + private DataGridViewTextBoxColumn Id; private DataGridViewTextBoxColumn DeviceNo; - private DataGridViewTextBoxColumn RecipeName1; + private DataGridViewComboBoxColumn RecipeName1; private DataGridViewTextBoxColumn SpecName1; - private DataGridViewTextBoxColumn RecipeName2; + private DataGridViewComboBoxColumn RecipeName2; private DataGridViewTextBoxColumn SpecName2; } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs index e954044..49120af 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs @@ -1,9 +1,13 @@ -using System; +using HighWayIot.Log4net; +using HighWayIot.Repository.service; +using Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,7 +16,15 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages { public partial class ProductionScheduling : UserControl { + ZxSchedulingService zxSchedulingService = ZxSchedulingService.Instance; + ZxRecipeService zxRecipeService = ZxRecipeService.Instance; + + List zxRecipeEntities = new List(); + + List zxSchedulingEntity = new List(); + + BindingSource bindingSource = new BindingSource(); public ProductionScheduling() { @@ -22,17 +34,132 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages private void init() { + zxSchedulingEntity = zxSchedulingService.GetSchedulingInfo(); + SchedulingDataGridView.AutoGenerateColumns = false; + bindingSource.DataSource = zxSchedulingEntity; + SchedulingDataGridView.DataSource = null; + SchedulingDataGridView.DataSource = bindingSource; + ComboBoxBind(); + } + private void ComboBoxBind() + { + zxRecipeEntities = zxRecipeService.GetRecipeInfos(); + RecipeName1.DataSource = null; + RecipeName2.DataSource = null; + + List r1 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); + r1.Insert(0, ""); + RecipeName1.DataSource = r1; + List r2 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); + r2.Insert(0, ""); + RecipeName2.DataSource = r2; } private void UpdateConfigButton_Click(object sender, EventArgs e) { - + if (zxSchedulingService.UpdateSchedulingInfo(zxSchedulingEntity)) + { + MessageBox.Show("更新成功"); + } + else + { + MessageBox.Show("更新失败"); + } } private void SelectConfigButton_Click(object sender, EventArgs e) { + zxSchedulingEntity = zxSchedulingService.GetSchedulingInfo(); + bindingSource.DataSource = null; + bindingSource.DataSource = zxSchedulingEntity; + } + private void SchedulingDataGridView_CellEnter(object sender, DataGridViewCellEventArgs e) + { + //实现单击一次显示下拉列表框 + if (SchedulingDataGridView.Columns[e.ColumnIndex] is DataGridViewComboBoxColumn && e.RowIndex != -1) + { + SendKeys.Send("{F4}"); + } + } + + /** + **第一步: + **/ + ComboBox cbo = new ComboBox(); + private void SchedulingDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) + { + if (SchedulingDataGridView.CurrentCell.OwningColumn.Name.Contains("RecipeName") && SchedulingDataGridView.CurrentCell.RowIndex != -1) + { + //保存当前的事件源。为了触发事件后。在取消 + cbo = e.Control as ComboBox; + cbo.SelectedIndexChanged += new EventHandler(cbo_SelectedIndexChanged); + } + } + + /** + **第二步: + **/ + void cbo_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBox combox = sender as ComboBox; + //添加离开combox的事件(重要;) + combox.Leave += new EventHandler(combox_Leave); + try + { + //在这里就可以做值是否改变判断 + if (combox.SelectedItem != null) + { + int row = SchedulingDataGridView.CurrentCell.RowIndex; + int column = SchedulingDataGridView.CurrentCell.ColumnIndex; + + if(column == 2) + { + ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeName(combox.Text); + if (recipe == null) + { + zxSchedulingEntity[row].SpecName1 = string.Empty; + zxSchedulingEntity[row].RecipeNo1 = string.Empty; + } + else + { + zxSchedulingEntity[row].SpecName1 = recipe.RecipeSpecName; + zxSchedulingEntity[row].RecipeNo1 = recipe.RecipeCode; + } + } + + if(column == 4) + { + ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeName(combox.Text); + if (recipe == null) + { + zxSchedulingEntity[row].SpecName2 = string.Empty; + zxSchedulingEntity[row].RecipeNo2 = string.Empty; + } + else + { + zxSchedulingEntity[row].SpecName2 = recipe.RecipeSpecName; + zxSchedulingEntity[row].RecipeNo2 = recipe.RecipeCode; + } + } + SchedulingDataGridView.Refresh(); + } + } + catch (Exception ex) + { + LogHelper.Instance.Error("硫化排程发生错误", ex); + } + } + + /** + **第三步:离开combox时,把事件删除 + **/ + public void combox_Leave(object sender, EventArgs e) + { + ComboBox combox = sender as ComboBox; + //做完处理,须撤销动态事件 + combox.SelectedIndexChanged -= new EventHandler(cbo_SelectedIndexChanged); } } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx index 0cb14bb..340ae03 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + True diff --git a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs index 9050ed0..8f3db80 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs @@ -42,6 +42,7 @@ this.label4 = new System.Windows.Forms.Label(); this.LengthTextBox = new System.Windows.Forms.TextBox(); this.button3 = new System.Windows.Forms.Button(); + this.RFIDtext = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // button1 @@ -60,7 +61,7 @@ this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(93, 51); this.button2.TabIndex = 1; - this.button2.Text = "测试1连接"; + this.button2.Text = "RFID测试"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // @@ -169,11 +170,19 @@ this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // + // RFIDtext + // + this.RFIDtext.Location = new System.Drawing.Point(216, 102); + this.RFIDtext.Name = "RFIDtext"; + this.RFIDtext.Size = new System.Drawing.Size(93, 21); + this.RFIDtext.TabIndex = 15; + // // TestPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; + this.Controls.Add(this.RFIDtext); this.Controls.Add(this.button3); this.Controls.Add(this.label4); this.Controls.Add(this.LengthTextBox); @@ -211,5 +220,6 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox LengthTextBox; private System.Windows.Forms.Button button3; + private System.Windows.Forms.TextBox RFIDtext; } } diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index 3d5aca1..694341b 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -1,7 +1,10 @@ using HighWayIot.Log4net; using HighWayIot.Plc; using HighWayIot.Plc.PlcHelper; +using HighWayIot.Rfid; +using HighWayIot.TouchSocket; using HighWayIot.Winform.Business; +using HighWayIot.Winform.Properties; using HslCommunication; using System; using System.Collections; @@ -21,6 +24,16 @@ namespace HighWayIot.Winform.UserControlPages { private static LogHelper logger = LogHelper.Instance; + /// + /// TCP客户端 + /// + private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance; + + /// + /// RFID数据分析 + /// + private RfidDataAnalyse _rfidDataAnalyse = new RfidDataAnalyse(); + public TestPage() { InitializeComponent(); @@ -72,12 +85,10 @@ namespace HighWayIot.Winform.UserControlPages private async void button2_Click(object sender, EventArgs e) { - bool res = false; - await Task.Run(() => - { - res = PlcConnect.IsConnect1; - }); - PlcShowValue.Text = res.ToString(); + var a = await _touchSocketTcpClient.Send($"10.20.48.{RFIDtext.Text}", _rfidDataAnalyse.Send02H(1000)); + LogHelper.Instance.Info($"10.20.48.{RFIDtext.Text} 发送" + (a ? "成功" : "失败")); + + } ///