This commit is contained in:
wxt
2026-02-04 20:54:22 +08:00
parent a64e57093c
commit d1340ea331
3 changed files with 70 additions and 19 deletions

View File

@@ -131,10 +131,10 @@ namespace 材料热传导系数
/// </summary>
public float PressureDifference { get; set; }
/// <summary>
/// 标准误差
/// </summary>
public float StandardError { get; set; }
///// <summary>
///// 标准误差
///// </summary>
//public float StandardError { get; set; }
public DateTime CreateTime { get; set; }

View File

@@ -46,6 +46,7 @@ namespace 全自动水压检测仪
private System.Windows.Forms.Timer _readTimer;
private System.Windows.Forms.Timer _readTimerTwo; // 第二个定时器引用
private System.Windows.Forms.Timer _readTimetCompareResult; // 第二个定时器引用
private bool _isManualInput = false; // 手动输入标记
private bool _isSwitchingWindow = false; // 窗口切换标记,避免并发
@@ -99,7 +100,7 @@ namespace 全自动水压检测仪
// 只创建定时器,不在构造器中启动,避免在 Load 前访问未初始化的资源
_readTimer = InitTimer(); // 保存引用
_readTimerTwo = InitTimerTwo(); // 保存第二个定时器引用
_readTimetCompareResult = InitTimerCompare();
// 初始化报警监控定时器
_alarmMonitorTimer = InitAlarmMonitorTimer();
@@ -373,6 +374,43 @@ namespace 全自动水压检测仪
return timer;
}
bool? isValid = null;
private System.Windows.Forms.Timer InitTimerCompare()
{
var timer = new System.Windows.Forms.Timer()
{
Interval = 1000
};
timer.Tick += async (s, e) =>
{
if (!_isManualInput && _modbusMaster != null)
{
try
{
//2
float settingValue = 0, currentValue = 0;
float.TryParse(uiTextBox11.Text, out settingValue);
float.TryParse(uiLabel22.Text, out currentValue);
if (currentValue > settingValue)
{
isValid = false;
_modbusMaster.WriteSingleCoil(1, 10082, true);
timer?.Stop();
}
else
{
isValid = true;
}
}
catch { }
}
};
// 不在此处 Start
return timer;
}
private async Task ReadLeakTestParametersAsync()
{
// 检查窗体状态
@@ -1052,14 +1090,14 @@ namespace 全自动水压检测仪
Type = uiLight1.State == UILightState.On ? 1 : 0,
//新增
kzh = string.Empty,
jh = string.Empty,
kzh = kzh,
jh = uiTextBox10.Text,
endtime = DateTime.Now,
quantity = 0,
lldh = string.Empty,
standarderror = 0,
quantity = quantity,
lldh = uiTextBox2.Text,
standarderror = standarderror,
starttime = starttime,
testresult = string.Empty
testresult = (isValid ?? false) ? "合格" : "不合格"
});
_repository.InsertReportItems(new ConductivityTestData
@@ -1081,6 +1119,7 @@ namespace 全自动水压检测仪
});
isAddTag = true;
_readTimetCompareResult?.Stop();
}
private bool TryReconnect()
{
@@ -1375,6 +1414,7 @@ namespace 全自动水压检测仪
// 清除图表数据,开始新的测试
_chartManager?.ClearData();
Debug.WriteLine("[NormalTemperatureMode] 启动测试,清除图表数据");
_readTimetCompareResult.Start();
}
//停止测试
@@ -1512,7 +1552,9 @@ namespace 全自动水压检测仪
private string _currentTemperatureMode = ""; // 保存当前温度模式
private string _currentBarcode = ""; // 保存当前条码
string kzh = string.Empty;
int quantity = 0;
decimal standarderror = 0;
private void uiButton8_Click(object sender, EventArgs e)
{
try
@@ -1549,7 +1591,8 @@ namespace 全自动水压检测仪
string zh = uiTextBox10.Text;
// 2. 从数据库查询数据
ScanData scanData = GetScanDataByBarcode(lldh, zh);
kzh = scanData.kzh;
quantity = scanData.quantity ?? 0;
if (scanData == null)
{
SafeInvoke(() =>

View File

@@ -63,15 +63,15 @@ namespace 全自动水压检测仪
SafeInvoke(() =>
{
float diffpressure = 0, exit_temperature = 0, dwelltime = 0, temperature = 0;
float pressureDifference = 0, standardError = 0;
float pressureDifference = 0; decimal standardError = 0;
int quantity = 0;
float.TryParse(uiTextBox4?.Text ?? "", out diffpressure);
float.TryParse(uiTextBox9?.Text ?? "", out exit_temperature);
float.TryParse(uiTextBox5?.Text ?? "", out dwelltime);
float.TryParse(uiTextBox1?.Text ?? "", out temperature);
float.TryParse(uiTextBoxPressureDiff?.Text ?? "", out pressureDifference);
float.TryParse(uiTextBoxStandardError?.Text ?? "", out standardError);
decimal.TryParse(uiTextBoxStandardError?.Text ?? "", out standardError);
int.TryParse(uiTextBoxQuantity?.Text ?? "", out quantity);
string temperatureMode = "";
@@ -88,7 +88,7 @@ namespace 全自动水压检测仪
string contactNumber = uiTextBox2?.Text?.Trim() ?? "";
string itemNumber = uiTextBox11?.Text?.Trim() ?? "";
string engravingNumber = uiTextBoxEngravingNumber?.Text?.Trim() ?? "";
if (string.IsNullOrEmpty(contactNumber))
{
MessageBox.Show("请输入联络单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -119,8 +119,16 @@ namespace 全自动水压检测仪
IsHighMode = temperature > 0,
temperature = temperature,
PressureDifference = pressureDifference,
StandardError = standardError,
TemperatureMode = temperatureMode
TemperatureMode = temperatureMode,
jh = uiTextBox11.Text,
CreateTime = DateTime.Now,
kzh = uiTextBoxEngravingNumber.Text,
lldh = uiTextBox2.Text,
pressuresetting = pressureDifference,
quantity = quantity,
standarderror = standardError
});
// 重新加载数据