/// <summary> /// 读到一个值后的处理(判断,保存数据,刷新画面曲线) /// </summary> public void DataTreating2() { //string FullFileName = Global.DateFilePath + Global.DateFileName1; var Point = new Models.Point() { x = Global.Point2.x, y = (short)(Global.Point2.y - 1000) }; ActualPoint2.x = (float)Math.Round(Point.x * Global.SystemPara.con_factor_x, 1); ActualPoint2.y = (float)Math.Round(Point.y * Global.SystemPara.con_factor_y, 2); //测试状态 if (Working2) { if (Global.Point2.x >= Global.SystemPara.con_chek_x && Global.Point2.y >= Global.SystemPara.con_chek_y)//进入压洞状态 { SubWorking2 = true; CanStop2 = CanRedo2 = false; if (Global.Point2.y > Global.MaxPressure2) //设置最大压力 { Global.MaxPressure2 = (short)Global.Point2.y; //其实没太大意义 } var temppoint = new DataPoint(ActualPoint2.x, ActualPoint2.y); LineSeries2.Points.Add(temppoint); Global.lstPoint2.Add(Point); } // else if (Global.Point1.x < Global.SystemPara.con_chek_x || Global.Point1.y < Global.SystemPara.con_chek_y)//不在压洞状态 else { SubWorking2 = false; CanStop2 = CanRedo2 = true; } if (LastSubWorking2 && !SubWorking2)//一个洞压完 { //调用异步写数据库和写数据文件代码 Workrec2.LastTime = DateTime.Now; Holerec2.MaxPressure = (float)Math.Round((Global.MaxPressure2 - 1000) * Global.SystemPara.con_factor_y, 2); Holerec2.TestTime = DateTime.Now; Holerec2.SerialNo = Workrec2.SerialNo; Workrec2.HoleCount = Holerec2.HoleNumber; Holerec2.Data = CommonMethods.ListToString(Global.lstPoint2); Holerec2.MacId = 2; CommonMethods.AddHolerec(Holerec2); //向数据库写记录 CommonMethods.AddWorkrec(Workrec2); //向数据库写记录 大多数是UPDATE if (Global.SystemPara.AutoOut) //根据需要确定是否要写到excel文件中 { var fileName = Global.SystemPara.OutputPath + Workrec2.SerialNo + ".xls"; if (CommonMethods.GetFilePath(fileName)) { NopiExcelHelper <Models.Point> .AddExcel(Global.lstPoint2, fileName, "hole" + Global.HoleRecod2.HoleNumber.ToString(), (float)Global.HoleRecod2.MaxPressure); } } Global.MaxPressure2 = 0; Holerec2.HoleNumber++; } if (!SubWorking2) { LineSeries2.Points.Clear(); Global.lstPoint2.Clear(); } LastSubWorking2 = SubWorking2; } //非测试状态 else { Global.lstPoint2.Clear(); CanStop2 = CanRedo2 = false; CanStart2 = true; } }
/// <summary> /// 读到一个值后的处理(判断,保存数据,刷新画面曲线) /// </summary> public void DataTreating1() { //string FullFileName = Global.DateFilePath + Global.DateFileName1; var Point = new Models.Point() { x = Global.Point1.x, y = (short)(Global.Point1.y - 1000) }; ActualPoint1.x = (float)Math.Round(Point.x * Global.SystemPara.con_factor_x, 1); ActualPoint1.y = (float)Math.Round(Point.y * Global.SystemPara.con_factor_y, 2); //测试状态 if (Working1) { if (Global.Point1.x >= Global.SystemPara.con_chek_x && Global.Point1.y >= Global.SystemPara.con_chek_y)//进入压洞状态 { SubWorking1 = true; CanStop1 = CanRedo1 = false; if (Global.Point1.y > Global.MaxPressure1) //设置最大压力 { Global.MaxPressure1 = (short)Global.Point1.y; //其实没太大意义 } var temppoint = new DataPoint(ActualPoint1.x, ActualPoint1.y); LineSeries1.Points.Add(temppoint); Global.lstPoint1.Add(Point); } // else if (Global.Point1.x < Global.SystemPara.con_chek_x || Global.Point1.y < Global.SystemPara.con_chek_y)//不在压洞状态 else { SubWorking1 = false; CanStop1 = CanRedo1 = true; } if (LastSubWorking1 && !SubWorking1)//一个洞压完 { //调用异步写数据库和写数据文件代码 Workrec1.LastTime = DateTime.Now; Holerec1.MaxPressure = (float)Math.Round((Global.MaxPressure1 - 1000) * Global.SystemPara.con_factor_y, 2); Holerec1.TestTime = DateTime.Now; Holerec1.SerialNo = Workrec1.SerialNo; Workrec1.HoleCount = Holerec1.HoleNumber; Holerec1.Data = CommonMethods.ListToString(Global.lstPoint1); Holerec1.MacId = 1; CommonMethods.AddHolerec(Holerec1); //向数据库写记录 CommonMethods.AddWorkrec(Workrec1); //向数据库写记录 大多数是UPDATE if (Global.SystemPara.AutoOut) //根据需要确定是否要写到excel文件中 { var fileName = Global.SystemPara.OutputPath + Workrec1.SerialNo + ".xls"; if (CommonMethods.GetFilePath(fileName)) { NopiExcelHelper <Models.Point> .AddExcel(Global.lstPoint1, fileName, "hole" + Global.HoleRecod1.HoleNumber.ToString(), (float)Global.HoleRecod1.MaxPressure); } } //这个地方要增加设置窗口重新测试按钮为不可用? Global.MaxPressure1 = 0; Holerec1.HoleNumber++; #region 要删除 ReadValue.Distance = 0; ReadValue.Pressure = 320; ReadValue.IsMax = false; Thread.Sleep(10000); #endregion } if (!SubWorking1) { LineSeries1.Points.Clear(); Global.lstPoint1.Clear(); } LastSubWorking1 = SubWorking1; } //非测试状态 else { Global.lstPoint1.Clear(); CanStop1 = CanRedo1 = false; CanStart1 = true; } }