diff --git a/ProductionSystem/Forms/HomeFormInfo.cs b/ProductionSystem/Forms/HomeFormInfo.cs index 8ff5414..6146791 100644 --- a/ProductionSystem/Forms/HomeFormInfo.cs +++ b/ProductionSystem/Forms/HomeFormInfo.cs @@ -78,18 +78,14 @@ namespace ProductionSystem.Forms InitMiddleTestItems(); cmbProductType.SelectedItem = new ListItem { Value = Program.ProductType, Text = Program.ProductType }; - //var temp = _paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB); //string str1 = temp.PZF1.TargetVal; //string str2 = temp.PZF1.Lin; //string str3 = temp.PZF1.Com; } - - private void Init() - { - + { Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ2").ToList(); Program.BZ3 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ3").ToList(); @@ -157,30 +153,16 @@ namespace ProductionSystem.Forms //PLC心跳监测 Task.Run(HeartMonitor, cancellationTokenSource.Token); - //读取点位信息 DoSomething doSomething = new DoSomething(); doSomething.ReadPlc(); - topMyResultControls = topFlowLayoutPanel.Controls.OfType().ToList(); - //展示顶部数据 Task.Run(ShowTopData, cancellationTokenSource.Token); - //展示中间部分数据 Task.Run(ShowMiddleData, cancellationTokenSource.Token); - - Task.Run(ShowMiddleData2, cancellationTokenSource.Token); - - - hslCurveHistory.RemoveAllCurve(); - - - - - } /// @@ -221,63 +203,7 @@ namespace ProductionSystem.Forms if (paraColumnConfig == null) { LogHelper.Error(null, $"根据机型[{Program.ProductType}],在参数项字段配置表未查询到通讯协议的相关配置!"); - } - //else - //{ - // for (int i = 0; i < paraColumnConfig.Count; i++) - // { - // var protocolConfig = _protocolConfigService.QueryActiveProtocolConfigByCode(paraColumnConfig[i].ProtocolType); - // if (protocolConfig == null) - // { - // Loading.CloseWaitForm(); - // CustomMessageBoxHelper.AlertShow(this, $"根据通讯协议编码[{protocolConfig.ProtocolCode}]未查询到协议配置!"); - // return; - // } - // Program.ProtocolConigCode = protocolConfig.Remark; - // Program.ProtocolType = protocolConfig.ProtocolType; - // Program.MsgFormat = protocolConfig.MsgFormat; - // Program.PortName = protocolConfig.Port; - // Program.BaudRate = protocolConfig.Bps; - // Program.Parity = EnumHelper.ConvertEnumToInt(protocolConfig.ChkBit); - // Program.DataBits = protocolConfig.DataBit; - // Program.StopBits = protocolConfig.StopBit; - // Program.StationNo = protocolConfig.StationNo ?? 1; - - // //#region 串口 - // //try - // //{ - - // // if (Program._serialPort != null) - // // { - // // Program._serialPort.Close(); - // // } - // // Program._serialPort = null; - // // Program._serialPort = new SerialPort - // // { - // // PortName = Program.PortName, - // // BaudRate = Program.BaudRate, - // // Parity = (Parity)Program.Parity, - // // DataBits = Program.DataBits, - // // StopBits = (StopBits)Program.StopBits, - // // ReadTimeout = 100, - // // WriteTimeout = 100 - // // }; - // // Program._serialPort.Open(); - // // if (Program.ProtocolDeviceHelper == null) - // // { - // // Program.ProtocolDeviceHelper = new ProtocolDeviceHelper(); - // // } - // // Program.ProtocolDeviceHelper.WriteData("68 02 00 41 6C 17 16"); - // // Thread.Sleep(20); - // // Program.ProtocolDeviceHelper.WriteData("68 07 00 04 00 20 A1 07 00 00 3B 16"); - // //} - // //catch (Exception ex) - // //{ - // // LogHelper.Error(ex, $"串口打开失败:{ex.Message}"); - // //} - // //#endregion - // } - //} + } #region 往PLC写入产品型号和标识码及参数配置 if (!OmronHelper.PLCIsConnected) @@ -438,7 +364,6 @@ namespace ProductionSystem.Forms } middleFlowLayoutPanel.Controls.Clear();//清空控件 - //var groupControlMinHeight = 65; var groupControlMinHeight = 55; for (int i = 0; i < paraCategorys.Count; i++) { @@ -505,7 +430,6 @@ namespace ProductionSystem.Forms MaximumSize = new Size(284, 34), Font = new Font("Tahoma", 9F), Name = $"MiddleMyTestResultControl{i}", - //Size = new Size(265, 34), Size = new Size(200, 29), TestResultPLCPointCode = testResult?.Key, TestValPLCPointCode = testVal?.Key, @@ -603,108 +527,7 @@ namespace ProductionSystem.Forms } } - })); - //if (M249.Val != "0.000" && M249.Val != "10.000") - //{ - // /*获取步序名称================2023-11-7注释===================================*/ - // //decimal.TryParse(M249.Val, out var result); - // //var intResult = Convert.ToInt32(result); - // //var stepName = EnumHelper.GetEnumDescription((StepEnum)intResult); - // /*获取步序名称===================================================*/ - - // float.TryParse(val, out float floatVal); - // // 把数据新增到每一个数组里,并指定最大3000个数,再多就覆盖之前的 - // switch (testValPoint?.Key) - // { - // case "M1"://进口压力 - // SoftBasic.AddArrayData(ref Program.Times, new DateTime[] { DateTime.Now }, 3000); - // SoftBasic.AddArrayData(ref Program.InPressData, new float[] { floatVal }, 3000); - // break; - // case "M2"://出口压力 - // SoftBasic.AddArrayData(ref Program.OutPressData, new float[] { floatVal }, 3000); - // break; - // case "M3"://罐压力 - // SoftBasic.AddArrayData(ref Program.GastankPressData, new float[] { floatVal }, 3000); - // break; - // case "M4"://电压值 - // SoftBasic.AddArrayData(ref Program.VoltageData, new float[] { floatVal }, 3000); - // break; - // case "M5"://电流值 - // SoftBasic.AddArrayData(ref Program.CurrentData, new float[] { floatVal }, 3000); - // break; - // case "M9"://X轴震动值 - // SoftBasic.AddArrayData(ref Program.XVibrateData, new float[] { floatVal }, 3000); - // break; - // case "M10"://Y轴振动值 - // SoftBasic.AddArrayData(ref Program.YVibrateData, new float[] { floatVal }, 3000); - // break; - // case "M11"://Z轴振动值 - // SoftBasic.AddArrayData(ref Program.ZVibrateData, new float[] { floatVal }, 3000); - // break; - // case "M12"://噪音 - // SoftBasic.AddArrayData(ref Program.NoiseData, new float[] { floatVal }, 3000); - // break; - // default: - // break; - // } - - // #region 2023-11-7注释 曲线区域用不到 - // //if (intResult != tempStepNum) - // //{ - // // tempStepNum = intResult; - // // stepChangeCount++; - // // switch (stepChangeCount) - // // { - // // case 1: - // // stepName1 = stepName; - // // sectionStartIndex1 = 0; - // // break; - // // case 2: - // // stepName2 = stepName; - // // sectionEndIndex1 = Program.InPressData.Length; - // // sectionStartIndex2 = Program.InPressData.Length + 1; - // // break; - // // case 3: - // // stepName3 = stepName; - // // sectionEndIndex2 = Program.InPressData.Length; - // // sectionStartIndex3 = Program.InPressData.Length + 1; - // // break; - // // case 4: - // // stepName4 = stepName; - // // sectionEndIndex3 = Program.InPressData.Length; - // // sectionStartIndex4 = Program.InPressData.Length + 1; - // // break; - // // case 5: - // // stepName5 = stepName; - // // sectionEndIndex4 = Program.InPressData.Length; - // // sectionStartIndex5 = Program.InPressData.Length + 1; - // // break; - // // case 6: - // // stepName6 = stepName; - // // sectionEndIndex5 = Program.InPressData.Length; - // // sectionStartIndex6 = Program.InPressData.Length + 1; - // // break; - // // case 7: - // // stepName7 = stepName; - // // sectionEndIndex6 = Program.InPressData.Length; - // // sectionStartIndex7 = Program.InPressData.Length + 1; - // // break; - // // case 8: - // // stepName8 = stepName; - // // sectionEndIndex7 = Program.InPressData.Length; - // // sectionStartIndex8 = Program.InPressData.Length + 1; - // // break; - // // case 9: - // // stepName9 = stepName; - // // sectionEndIndex8 = Program.InPressData.Length; - // // sectionStartIndex9 = Program.InPressData.Length + 1; - // // break; - // // default: - // // break; - // // } - // //} - // #endregion - //} + })); } } } @@ -789,14 +612,9 @@ namespace ProductionSystem.Forms if (d1304Value.ToDouble().ToInt() == 1) { Step3(); - - } - //高压 改成第四部 - - var d1312 = GetPlcValue("D1312"); // d1312 = "1"; if (d1312.ToDouble().ToInt() == 1) @@ -844,28 +662,18 @@ namespace ProductionSystem.Forms // var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); // } - - - //if (d1308.ToDouble().ToInt()==0) //{ // var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1358"); // var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); //} - - - - - //if (d1310.ToDouble().ToInt() == 0) //{ // var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1360"); // var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); //} - - - + var d1314 = GetPlcValue("D1314"); // d1314 = "1"; if (d1314.ToDouble().ToInt() ==1) @@ -874,30 +682,17 @@ namespace ProductionSystem.Forms } - //if (d1314.ToDouble().ToInt() == 0) //{ // var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1917"); // var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); //} - - - - - //if (d1312.ToDouble().ToInt() ==0) //{ // var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1362"); // var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); //}' - - - - - - - middleIsCanRound = true; } } @@ -911,7 +706,6 @@ namespace ProductionSystem.Forms return plcTiaoMa; } - private void Step1() { @@ -921,11 +715,7 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - - - step.ProductBarcode = GetCode(); - - + step.ProductBarcode = GetCode(); var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB, Program.ProductType); @@ -1057,35 +847,29 @@ namespace ProductionSystem.Forms val = pzf1.TargetVal.ToDouble().ToInt(); ExvTool exv = new ExvTool(pzf1.Com, val); var exv1 = exv.ToAction(); - step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = exv.Val; step.WriteValue = val.ToString(); step.CreateTime = DateTime.Now; - step.EquipmentName = "DZPZF1_DB"; stepService.AddProductStep(step); //水泵1 - var sb1 = model.SB1; val = sb1.TargetVal.ToDouble().ToInt(); UxTool uxTool = new UxTool(sb1.Com, val); var ya = uxTool.ToAction(); - step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = uxTool.Val; step.WriteValue = uxTool.Write; step.CreateTime = DateTime.Now; step.EquipmentName = "SB1ZS_DB"; stepService.AddProductStep(step); - //D1350 - var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1362"); var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{1}"); } @@ -1101,16 +885,10 @@ namespace ProductionSystem.Forms var sb1 = model.SB1; UxTool uxTool = new UxTool(sb1.Com,0); uxTool.ToAction(); - - - - var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1350"); var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{0}"); } - - private void Step2() { @@ -1423,53 +1201,37 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - step.ProductBarcode = GetCode(); - - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); //四通1 var stf1= model.STF1; int val = stf1.TargetVal.ToDouble().ToInt(); SitongTool sitongTool = new SitongTool(stf1.Com,val); - var si1 = sitongTool.ToAction(); - + var si1 = sitongTool.ToAction(); step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; step.WriteValue = val.ToString(); step.CreateTime = DateTime.Now; - step.EquipmentName = "FKSTF1ZT_DB"; - + step.EquipmentName = "FKSTF1ZT_DB"; stepService.AddProductStep(step); //四通2 var stf2 = model.STF2; sitongTool = new SitongTool(stf2.Com, stf2.TargetVal.ToDouble().ToInt()); - var si2 = sitongTool.ToAction(); - + var si2 = sitongTool.ToAction(); step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; step.WriteValue = val.ToString(); - step.CreateTime = DateTime.Now; - + step.CreateTime = DateTime.Now; step.EquipmentName = "FKSTF2ZT_DB"; - stepService.AddProductStep(step); - - - - - - - + stepService.AddProductStep(step); var point =Program.CommandPointKeyValues.FirstOrDefault(m=>m.Key=="D1358"); var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{1}"); } - - private void Step6() { T_Product_Step step = new T_Product_Step @@ -1479,9 +1241,6 @@ namespace ProductionSystem.Forms }; step.ProductBarcode = GetCode(); - - - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); //四通1 @@ -1525,11 +1284,7 @@ namespace ProductionSystem.Forms StepName = "BZ8_DB", ProductType = Program.ProductType }; - - - step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); //四通1 @@ -1537,40 +1292,32 @@ namespace ProductionSystem.Forms int val = stf1.TargetVal.ToDouble().ToInt(); SitongTool sitongTool = new SitongTool(stf1.Com, val); var si1 = sitongTool.ToAction(); - step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; step.WriteValue = val.ToString(); step.CreateTime = DateTime.Now; step.EquipmentName = "FKSTF1ZT_DB"; - stepService.AddProductStep(step); - //四通2 var stf2 = model.STF2; sitongTool = new SitongTool(stf2.Com, stf2.TargetVal.ToDouble().ToInt()); var si2 = sitongTool.ToAction(); - step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; step.WriteValue = val.ToString(); step.CreateTime = DateTime.Now; - step.EquipmentName = "FKSTF2ZT_DB"; stepService.AddProductStep(step); - var point = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "D1917"); var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{1}"); } - private int count = 0; private void ShowMiddleData2() { while (!cancellationTokenSource.IsCancellationRequested) { - var readM248 = OmronHelper.GetPlcVal(M248.DataType, M248.Address); string plcTiaoMa=readM248.val.ToString().Replace("\r", "").Replace("\n", ""); string tiaoma = txtProductCode.Text.Replace("\r", "").Replace("\n", ""); @@ -1581,16 +1328,10 @@ namespace ProductionSystem.Forms { CleanMiddleData("BZ"+i); CleanMiddleDataDB($"BZ{i}_DB"); - } - - + } } else { - - - - GetPlc(Program.BZ1, "BZ1"); GetPlc(Program.BZ2, "BZ2"); GetPlc(Program.BZ3, "BZ3"); @@ -1600,7 +1341,6 @@ namespace ProductionSystem.Forms GetPlc(Program.BZ7, "BZ7"); GetPlc(Program.BZ8, "BZ8"); - Collect("BZ1"); Collect("BZ2"); Collect("BZ3"); @@ -1619,11 +1359,8 @@ namespace ProductionSystem.Forms SetMiddleData("BZ7_DB"); SetMiddleData("BZ8_DB"); } - Thread.Sleep(Program.ReadPlcRate); } - - } private TResult2Service _result2Service = new TResult2Service(); @@ -1656,7 +1393,7 @@ namespace ProductionSystem.Forms { t.Electricity = GetPlcValue("D1202"); t.Voltage = GetPlcValue("D1200"); - if (t.Electricity != "0.000" || t.Voltage != "0.0000") + if (t.Electricity != "0.000" || t.Voltage != "0.000") { _result2Service.AddTResult2(t); } @@ -1667,7 +1404,7 @@ namespace ProductionSystem.Forms { t.Electricity = GetPlcValue("D1206"); t.Voltage = GetPlcValue("D1204"); - if (t.Electricity != "0.000" || t.Voltage != "0.0000") + if (t.Electricity != "0.000" || t.Voltage != "0.000") { _result2Service.AddTResult2(t); } @@ -1677,7 +1414,7 @@ namespace ProductionSystem.Forms { t.Electricity = GetPlcValue("D1210"); t.Voltage = GetPlcValue("D1208"); - if (t.Electricity != "0.000" || t.Voltage != "0.0000") + if (t.Electricity != "0.000" || t.Voltage != "0.000") { _result2Service.AddTResult2(t); } @@ -1687,7 +1424,7 @@ namespace ProductionSystem.Forms { t.Xll = GetPlcValue("D1224"); t.Xllzt = GetPlcValue("D1226"); - if (t.Xll != "0.000" || t.Xllzt != "0.0000") + if (t.Xll != "0.000" || t.Xllzt != "0.000") { _result2Service.AddTResult2(t); } @@ -1700,7 +1437,7 @@ namespace ProductionSystem.Forms t.Xll = GetPlcValue("D1214"); t.Xllzt = GetPlcValue("D1114"); - if (t.Xll != "0.000" || t.Xllzt != "0.0000") + if (t.Xll != "0.000" || t.Xllzt != "0.000") { _result2Service.AddTResult2(t); } @@ -1712,7 +1449,7 @@ namespace ProductionSystem.Forms { t.Xll = GetPlcValue("D1216"); t.Xllzt = GetPlcValue("D1116"); - if (t.Xll != "0.000" || t.Xllzt != "0.0000") + if (t.Xll != "0.000" || t.Xllzt != "0.000") { _result2Service.AddTResult2(t); } @@ -1722,7 +1459,7 @@ namespace ProductionSystem.Forms { t.Xll = GetPlcValue("D1212"); t.Xllzt = GetPlcValue("D1112"); - if (t.Xll != "0.000" || t.Xllzt != "0.0000") + if (t.Xll != "0.000" || t.Xllzt != "0.000") { _result2Service.AddTResult2(t); } @@ -1747,165 +1484,7 @@ namespace ProductionSystem.Forms } - ///// - ///// 添加曲线区域 - ///// - ///// 临时变化次数 - //private void AddCurveSection(int stepChangeCount) - //{ - // //这里swith是为了避免最后做的一个工序的区域结束索引获取不到 - // switch (stepChangeCount) - // { - // case 1: - // sectionEndIndex1 = Program.InPressData.Length - 1; - // break; - // case 2: - // sectionEndIndex2 = Program.InPressData.Length - 1; - // break; - // case 3: - // sectionEndIndex3 = Program.InPressData.Length - 1; - // break; - // case 4: - // sectionEndIndex4 = Program.InPressData.Length - 1; - // break; - // case 5: - // sectionEndIndex5 = Program.InPressData.Length - 1; - // break; - // case 6: - // sectionEndIndex6 = Program.InPressData.Length - 1; - // break; - // case 7: - // sectionEndIndex7 = Program.InPressData.Length - 1; - // break; - // case 8: - // sectionEndIndex8 = Program.InPressData.Length - 1; - // break; - // case 9: - // sectionEndIndex9 = Program.InPressData.Length - 1; - // break; - // default: - // break; - // } - - // if (sectionEndIndex1 > 0 && sectionEndIndex1 > sectionStartIndex1) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex1, - // EndIndex = sectionEndIndex1, - // MarkText = stepName1, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex2 > 0 && sectionEndIndex2 > sectionStartIndex2) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex2, - // EndIndex = sectionEndIndex2, - // MarkText = stepName2, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex3 > 0 && sectionEndIndex3 > sectionStartIndex3) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex3, - // EndIndex = sectionEndIndex3, - // MarkText = stepName3, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex4 > 0 && sectionEndIndex4 > sectionStartIndex4) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex4, - // EndIndex = sectionEndIndex4, - // MarkText = stepName4, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex5 > 0 && sectionEndIndex5 > sectionStartIndex5) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex5, - // EndIndex = sectionEndIndex5, - // MarkText = stepName5, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex6 > 0 && sectionEndIndex6 > sectionStartIndex6) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex6, - // EndIndex = sectionEndIndex6, - // MarkText = stepName6, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex7 > 0 && sectionEndIndex7 > sectionStartIndex7) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex7, - // EndIndex = sectionEndIndex7, - // MarkText = stepName7, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex8 > 0 && sectionEndIndex8 > sectionStartIndex8) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex8, - // EndIndex = sectionEndIndex8, - // MarkText = stepName8, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - // if (sectionEndIndex9 > 0 && sectionEndIndex9 > sectionStartIndex9) - // { - // hslCurveHistory.AddMarkForeSection(new HslMarkForeSection() - // { - // StartIndex = sectionStartIndex9, - // EndIndex = sectionEndIndex9, - // MarkText = stepName9, - // StartHeight = 0.2f, - // Height = 0.8f, - // IsRenderTimeText = false - // }); - // } - //} - #region 中间控件PLC值采集 - - - - - - - - private void GetPlc(List values,string txt) { @@ -1939,7 +1518,6 @@ namespace ProductionSystem.Forms }; return tagDict; } - private string GetStep() { var dic = GetTagDict(); @@ -1961,19 +1539,10 @@ namespace ProductionSystem.Forms } } - - - } return str; } - - - - - - #endregion /// @@ -2040,9 +1609,7 @@ namespace ProductionSystem.Forms int head = 0; if (testResultPoint != null) - { - - + { if (paraCategory == "BZ1") { //电压采集值 @@ -2111,7 +1678,6 @@ namespace ProductionSystem.Forms } } - var testResult = OmronHelper.GetPlcVal(testResultPoint.DataType, testResultPoint.Address); testResultPoint.Val = testResult.val; result = testResult.val; @@ -2153,13 +1719,14 @@ namespace ProductionSystem.Forms } } - - + /// + /// 清空中间数据 + /// + /// private void CleanMiddleData(string paraCategory) { try { - var groupControls = middleFlowLayoutPanel.Controls.OfType().FirstOrDefault(m => m.Tag.ToString().Contains(paraCategory)); var tagDict = GetTagDict(); //如果有GroupControl控件,设置突出颜色 @@ -2168,8 +1735,7 @@ namespace ProductionSystem.Forms var layOutControl = groupControls.Controls.OfType().FirstOrDefault(m => m.Name.Contains(paraCategory)); //var entity = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == ls[i - 1]); - - + if (layOutControl != null) { var middleMyTestResultControls = layOutControl.Controls.OfType().ToList(); @@ -2180,26 +1746,17 @@ namespace ProductionSystem.Forms if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed) { var result = string.Empty; - var val = string.Empty; - - } - this.Invoke(new Action(() => - { - - - - SetColor(middleMyTestResultControls[j], -1,"0.000"); - - - })); + var val = string.Empty; } + this.Invoke(new Action(() => + { + SetColor(middleMyTestResultControls[j], -1,"0.000"); + })); } + } } - - - } - + } } catch (Exception ex) { @@ -2207,8 +1764,12 @@ namespace ProductionSystem.Forms } } - - + /// + /// 设置状态和颜色 + /// + /// + /// + /// private void SetColor(MyTestResultControl control, int status,string testValText) { switch (status) @@ -2230,7 +1791,6 @@ namespace ProductionSystem.Forms control.TestResultText = "NG"; break; } - //control.TestResultBackColor = Color.Red; } @@ -2265,18 +1825,7 @@ namespace ProductionSystem.Forms //获取点位 var paraCode = middleMyTestResultControls[j].ParaCode; - var step = productStepService.QueryLatestStep(paraCategory, paraCode, Program.ProductType,GetCode()); - if (string.IsNullOrEmpty(testResultPoint) || string.IsNullOrEmpty(testValPoint)) - { - //进行sql 进行查询sql - - //val=dataProductService.QueryDataProduct(paraCategory, paraCode); - - - } - - - + var step = productStepService.QueryLatestStep(paraCategory, paraCode, Program.ProductType,GetCode()); this.Invoke(new Action(() => { if (step == null) @@ -2327,7 +1876,10 @@ namespace ProductionSystem.Forms } } - + /// + /// 清除中间DB块 + /// + /// private void CleanMiddleDataDB(string paraCategory) { try @@ -2368,81 +1920,81 @@ namespace ProductionSystem.Forms /// /// 清空中间控件的数据 /// - private void ClearMiddleData() - { - var groupControls = middleFlowLayoutPanel.Controls.OfType().Where(m => m.Name.Contains("GroupControl")).ToList(); - //如果有GroupControl控件 - if (groupControls != null && groupControls.Count > 0) - { - for (int i = 0; i < groupControls.Count; i++) - { - var layOutControl = groupControls[i].Controls.OfType().FirstOrDefault(); - if (layOutControl != null) - { - var middleMyTestResultControls = layOutControl.Controls.OfType().ToList(); - if (middleMyTestResultControls.Any()) - { - for (int j = 0; j < middleMyTestResultControls.Count; j++) - { - if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed) - { - this.Invoke(new Action(() => - { - middleMyTestResultControls[j].TestResultText = ""; - middleMyTestResultControls[j].TestResultForeColor = Color.Black; - middleMyTestResultControls[j].TestResultBackColor = Color.Gainsboro; - middleMyTestResultControls[j].TestValText = ""; - })); - } - } - } - } - } + //private void ClearMiddleData() + //{ + // var groupControls = middleFlowLayoutPanel.Controls.OfType().Where(m => m.Name.Contains("GroupControl")).ToList(); + // //如果有GroupControl控件 + // if (groupControls != null && groupControls.Count > 0) + // { + // for (int i = 0; i < groupControls.Count; i++) + // { + // var layOutControl = groupControls[i].Controls.OfType().FirstOrDefault(); + // if (layOutControl != null) + // { + // var middleMyTestResultControls = layOutControl.Controls.OfType().ToList(); + // if (middleMyTestResultControls.Any()) + // { + // for (int j = 0; j < middleMyTestResultControls.Count; j++) + // { + // if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed) + // { + // this.Invoke(new Action(() => + // { + // middleMyTestResultControls[j].TestResultText = ""; + // middleMyTestResultControls[j].TestResultForeColor = Color.Black; + // middleMyTestResultControls[j].TestResultBackColor = Color.Gainsboro; + // middleMyTestResultControls[j].TestValText = ""; + // })); + // } + // } + // } + // } + // } - } - Program.MiddlePointKeyValues.ForEach(m => m.Val = ""); - } + // } + // Program.MiddlePointKeyValues.ForEach(m => m.Val = ""); + //} /// /// 初始化曲线区域数据 /// - private void InitCurveSectionData() - { - //曲线区域的开始索引 - sectionStartIndex1 = 0; - sectionStartIndex2 = 0; - sectionStartIndex3 = 0; - sectionStartIndex4 = 0; - sectionStartIndex5 = 0; - sectionStartIndex6 = 0; - sectionStartIndex7 = 0; - sectionStartIndex8 = 0; - sectionStartIndex9 = 0; - //曲线区域的结束索引 - sectionEndIndex1 = -1; - sectionEndIndex2 = -1; - sectionEndIndex3 = -1; - sectionEndIndex4 = -1; - sectionEndIndex5 = -1; - sectionEndIndex6 = -1; - sectionEndIndex7 = -1; - sectionEndIndex8 = -1; - sectionEndIndex9 = -1; - - stepName1 = ""; - stepName2 = ""; - stepName3 = ""; - stepName4 = ""; - stepName5 = ""; - stepName6 = ""; - stepName7 = ""; - stepName8 = ""; - stepName9 = ""; - - stepChangeCount = 0;//步序变化次数 - tempStepNum = 0;//临时存储步序号 - } + //private void InitCurveSectionData() + //{ + // //曲线区域的开始索引 + // sectionStartIndex1 = 0; + // sectionStartIndex2 = 0; + // sectionStartIndex3 = 0; + // sectionStartIndex4 = 0; + // sectionStartIndex5 = 0; + // sectionStartIndex6 = 0; + // sectionStartIndex7 = 0; + // sectionStartIndex8 = 0; + // sectionStartIndex9 = 0; + // //曲线区域的结束索引 + // sectionEndIndex1 = -1; + // sectionEndIndex2 = -1; + // sectionEndIndex3 = -1; + // sectionEndIndex4 = -1; + // sectionEndIndex5 = -1; + // sectionEndIndex6 = -1; + // sectionEndIndex7 = -1; + // sectionEndIndex8 = -1; + // sectionEndIndex9 = -1; + + // stepName1 = ""; + // stepName2 = ""; + // stepName3 = ""; + // stepName4 = ""; + // stepName5 = ""; + // stepName6 = ""; + // stepName7 = ""; + // stepName8 = ""; + // stepName9 = ""; + + // stepChangeCount = 0;//步序变化次数 + // tempStepNum = 0;//临时存储步序号 + //} /// /// 心跳监测 @@ -2635,97 +2187,6 @@ namespace ProductionSystem.Forms } } - //#region 显示单一曲线 - - //private void ShowDefault() - //{ - // CurveCkOutPress.Checked = true; - //} - - //private void CheckedChanged(object sender, EventArgs e) - //{ - // var checkEdit = sender as CheckEdit; - // var layoutControl = bottomPanelControl.Controls.OfType().FirstOrDefault(); - // var checks = layoutControl.Controls.OfType().ToList(); - // if (checkEdit.Checked) - // { - // foreach (var item in checks) - // { - // if (item != sender) - // { - // item.Checked = false; - // hslCurveHistory.SetCurveVisible(item.Text, false); - // } - // } - // hslCurveHistory.SetCurveVisible(checkEdit.Text, true); - - // switch (checkEdit.Text) - // { - // //case "出口压力": - // // hslCurveHistory.ValueMaxLeft = Program.OutPressData.Length > 0 ? Program.OutPressData.Max() : 1200; - // // if (Program.OutPressData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("出口压力", Program.OutPressData, Color.Tomato, CurveStyle.Curve, "{0:F2} Mpa"); - // // } - // // break; - // //case "进口压力": - // // hslCurveHistory.ValueMaxLeft = Program.InPressData.Length > 0 ? Program.InPressData.Max() : 1200; - // // if (Program.InPressData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("进口压力", Program.InPressData, Color.DodgerBlue, CurveStyle.Curve, "{0:F2} Mpa"); - // // } - // // break; - // //case "罐压力": - // // hslCurveHistory.ValueMaxLeft = Program.GastankPressData.Length > 0 ? Program.GastankPressData.Max() : 1200; - // // if (Program.GastankPressData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("罐压力", Program.GastankPressData, Color.Yellow, CurveStyle.Curve, "{0:F2} Mpa"); - // // } - // // break; - // //case "X轴震动": - // // hslCurveHistory.ValueMaxLeft = Program.XVibrateData.Length > 0 ? Program.XVibrateData.Max() : 100; - // // if (Program.XVibrateData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("X轴震动", Program.XVibrateData, Color.White, CurveStyle.Curve, "{0:F2} Hz"); - // // } - // // break; - // //case "Y轴震动": - // // hslCurveHistory.ValueMaxLeft = Program.YVibrateData.Length > 0 ? Program.YVibrateData.Max() : 100; - // // if (Program.YVibrateData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("Y轴震动", Program.YVibrateData, Color.Green, CurveStyle.Curve, "{0:F2} Hz"); - // // } - // // break; - // //case "Z轴震动": - // // hslCurveHistory.ValueMaxLeft = Program.ZVibrateData.Length > 0 ? Program.ZVibrateData.Max() : 100; - // // if (Program.ZVibrateData.Length > 0) - // // { - // // hslCurveHistory.SetLeftCurve("Z轴震动", Program.ZVibrateData, Color.Orange, CurveStyle.Curve, "{0:F2} Hz"); - // // } - // // break; - // case "电压": - // hslCurveHistory.ValueMaxLeft = Program.VoltageData.Length > 0 ? Program.VoltageData.Max() : 500; - // if (Program.VoltageData.Length > 0) - // { - // hslCurveHistory.SetLeftCurve("电压", Program.VoltageData, Color.DarkOliveGreen, CurveStyle.Curve, "{0:F2} V"); - // } - // break; - // case "电流": - // hslCurveHistory.ValueMaxLeft = Program.CurrentData.Length > 0 ? Program.CurrentData.Max() : 200; - // if (Program.CurrentData.Length > 0) - // { - // hslCurveHistory.SetLeftCurve("电流", Program.CurrentData, Color.Gold, CurveStyle.Curve, "{0:F2} A"); - // } - // break; - // default: - // break; - // } - - // hslCurveHistory.RenderCurveUI(); - // } - //} - //#endregion - /// /// 异步更新控件内容 /// diff --git a/ProductionSystem_Service/ProductStepService.cs b/ProductionSystem_Service/ProductStepService.cs index fe80b82..0df8c17 100644 --- a/ProductionSystem_Service/ProductStepService.cs +++ b/ProductionSystem_Service/ProductStepService.cs @@ -41,6 +41,7 @@ namespace ProductionSystem_Service && m.EquipmentName == equipmentName && m.ProductType == productType) .Where(x=>x.ProductBarcode==productCode) + .OrderByDescending(x=>x.CreateTime) .First(); } } diff --git a/ProductionSystem_Service/TResult2Service.cs b/ProductionSystem_Service/TResult2Service.cs index 43b9c66..90b2a8b 100644 --- a/ProductionSystem_Service/TResult2Service.cs +++ b/ProductionSystem_Service/TResult2Service.cs @@ -50,8 +50,8 @@ namespace ProductionSystem_Service /// public TestResut2Res Query(TestResut2Vm vm) { - int totalRecord = 0; - var iq= db.Queryable(). + int totalRecord = 0; + var iq= db.Queryable(). WhereIF(!string.IsNullOrEmpty(vm.ProductType), x => x.ProductType == vm.ProductType) .WhereIF(!string.IsNullOrEmpty(vm.ProductCode),x=>x.ProductBarcode == vm.ProductCode) .WhereIF(!string.IsNullOrEmpty(vm.BeginTime),x=>x.CreateTime>=Convert.ToDateTime(vm.BeginTime)) @@ -59,10 +59,7 @@ namespace ProductionSystem_Service .OrderByDescending(x => x.CreateTime) .ToPageList(vm.PageIndex,vm.PageSize, ref totalRecord); - int totalPage = (totalRecord + vm.PageSize - 1) / vm.PageSize; - - TestResut2Res testResut2Res = new TestResut2Res(); testResut2Res.Total= totalPage; testResut2Res.Data = iq;