This commit is contained in:
@@ -106,12 +106,12 @@ namespace MembranePoreTester.ViewModels
|
||||
if (TestMode.Contains("湿膜"))
|
||||
{
|
||||
float rawFlow = await _plcService.ReadWetFlowAsync();
|
||||
flow = Math.Round(ConvertFlowByMode(rawFlow), 2);
|
||||
flow = Math.Round(ConvertFlowByMode(rawFlow), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
float rawFlow = await _plcService.ReadDryFlowAsync();
|
||||
flow = Math.Round(ConvertFlowByMode(rawFlow), 2);
|
||||
flow = Math.Round(ConvertFlowByMode(rawFlow), 3);
|
||||
}
|
||||
|
||||
if (pressure <= 0 || flow <= 0)
|
||||
@@ -424,7 +424,7 @@ namespace MembranePoreTester.ViewModels
|
||||
if (TestMode == "湿膜")
|
||||
{
|
||||
float rawWet = await _plcService.ReadWetFlowAsync();
|
||||
newPoint.WetFlow = ConvertFlowByMode(ConvertFlowByMode(rawWet));
|
||||
newPoint.WetFlow = ConvertFlowByMode(rawWet);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -577,9 +577,95 @@ namespace MembranePoreTester.ViewModels
|
||||
.ToList();
|
||||
}
|
||||
|
||||
//private void GenerateReport()
|
||||
//{
|
||||
// ReportGenerator.GeneratePoreDistributionReport(Record);
|
||||
//}
|
||||
|
||||
private void GenerateReport()
|
||||
{
|
||||
ReportGenerator.GeneratePoreDistributionReport(Record);
|
||||
// 可选:先清洗数据再生成报告(但不改变原集合)
|
||||
var cleanedPoints = CleanDataPoints(Record.DataPoints);
|
||||
if (cleanedPoints.Count < 2)
|
||||
{
|
||||
MessageBox.Show("有效数据点不足,无法生成报告。");
|
||||
return;
|
||||
}
|
||||
// 临时替换 Record 中的数据点用于报告(不影响界面)
|
||||
var originalPoints = Record.DataPoints.ToList();
|
||||
Record.DataPoints.Clear();
|
||||
foreach (var p in cleanedPoints)
|
||||
Record.DataPoints.Add(p);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ReportGenerator.GeneratePoreDistributionReport(Record, PlotModel);
|
||||
|
||||
// 恢复原始数据
|
||||
Record.DataPoints.Clear();
|
||||
foreach (var p in originalPoints)
|
||||
Record.DataPoints.Add(p);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//// 清空现有数据
|
||||
//Record.DataPoints.Clear();
|
||||
|
||||
//Random rand = new Random();
|
||||
|
||||
//// 生成湿膜数据(模拟压力从0到100,流量先增后减)
|
||||
//for (double pressure = 0; pressure <= 100; pressure += 5)
|
||||
//{
|
||||
// // 模拟流量曲线:先上升后下降,峰值在40-60之间
|
||||
// double wetFlow = 0;
|
||||
// if (pressure < 30)
|
||||
// wetFlow = pressure * 1.5; // 上升段
|
||||
// else if (pressure < 60)
|
||||
// wetFlow = 45 - (pressure - 30) * 0.5; // 下降段
|
||||
// else
|
||||
// wetFlow = 30 - (pressure - 60) * 0.8; // 继续下降
|
||||
|
||||
// // 添加随机波动 (±15%)
|
||||
// wetFlow = wetFlow * (0.85 + rand.NextDouble() * 0.3);
|
||||
// wetFlow = Math.Round(Math.Max(0, wetFlow), 2);
|
||||
|
||||
// // 干膜数据(稍低于湿膜)
|
||||
// double dryFlow = wetFlow * (0.6 + rand.NextDouble() * 0.3);
|
||||
// dryFlow = Math.Round(dryFlow, 2);
|
||||
|
||||
// Record.DataPoints.Add(new Models.DataPoint
|
||||
// {
|
||||
// Pressure = Math.Round(pressure, 2),
|
||||
// WetFlow = wetFlow,
|
||||
// DryFlow = dryFlow
|
||||
// });
|
||||
//}
|
||||
|
||||
//// 设置一些测试基本参数
|
||||
//Record.SampleType = "平板膜";
|
||||
//Record.SampleSpec = "φ47mm";
|
||||
//Record.RoomTemperature = 22.5;
|
||||
//Record.SoakingTime = 2.0;
|
||||
//Record.Liquid = TestLiquid.Predefined.FirstOrDefault();
|
||||
//Record.LiquidManufacturer = "测试厂家";
|
||||
//Record.PressureUnit = "kPa";
|
||||
//Record.BubblePointPressure = 45.6;
|
||||
//Record.AveragePoreSize = 0.856;
|
||||
//Record.TestDate = DateTime.Now;
|
||||
//Record.Tester = "测试员";
|
||||
|
||||
//// 刷新曲线显示
|
||||
//UpdatePlot();
|
||||
|
||||
//ReportGenerator.GeneratePoreDistributionReport(Record, PlotModel);
|
||||
|
||||
}
|
||||
|
||||
private void OpenFlowCalibration()
|
||||
@@ -725,17 +811,45 @@ namespace MembranePoreTester.ViewModels
|
||||
|
||||
private void ExportToExcel()
|
||||
{
|
||||
// 使用当前数据点(已通过手动删除或自动清洗,保证有效性)
|
||||
var dataPoints = Record.DataPoints.ToList();
|
||||
if (dataPoints.Count == 0)
|
||||
{
|
||||
MessageBox.Show("没有数据可导出。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
var saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Excel文件|*.xlsx",
|
||||
FileName = $"泡点法_工位{StationId}_{DateTime.Now:yyyyMMddHHmmss}.xlsx"
|
||||
FileName = $"孔分布_工位{StationId}_{DateTime.Now:yyyyMMddHHmmss}.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == true)
|
||||
{
|
||||
// 转换为Entity后导出
|
||||
var entity = new BubblePointEntity { /* 从Record复制 */ };
|
||||
ExportHelper.ExportBubblePoint(entity, saveFileDialog.FileName);
|
||||
MessageBox.Show("导出成功");
|
||||
var entity = new PoreDistributionEntity
|
||||
{
|
||||
StationId = this.StationId,
|
||||
TestDate = Record.TestDate,
|
||||
Tester = Record.Tester ?? "系统操作员",
|
||||
SampleType = Record.SampleType,
|
||||
SampleSpec = Record.SampleSpec ?? "缺省值",
|
||||
RoomTemperature = Record.RoomTemperature,
|
||||
SoakingTime = Record.SoakingTime,
|
||||
LiquidName = Record.Liquid?.Name,
|
||||
LiquidSurfaceTension = Record.Liquid?.SurfaceTension ?? 0,
|
||||
LiquidManufacturer = Record.LiquidManufacturer ?? "缺省值",
|
||||
PressureUnit = Record.PressureUnit,
|
||||
BubblePointPressure = Record.BubblePointPressure,
|
||||
AveragePoreSize = AveragePoreSize, // 已计算的平均孔径
|
||||
DataPoints = dataPoints.Select(dp => new DataPointEntity
|
||||
{
|
||||
Pressure = dp.Pressure,
|
||||
WetFlow = dp.WetFlow,
|
||||
DryFlow = dp.DryFlow
|
||||
}).ToList()
|
||||
};
|
||||
ExportHelper.ExportPoreDistribution(entity, saveFileDialog.FileName);
|
||||
MessageBox.Show("导出成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user