This commit is contained in:
wxt
2026-02-02 19:39:09 +08:00
parent 36a43a497a
commit 7a6c759ac3
3 changed files with 113 additions and 273 deletions

View File

@@ -85,6 +85,7 @@ namespace 建材不燃性试验炉
// 初始化工具类
c = new DataChange();
ma=new Function(_modbusMaster);
// 启动状态定时器
_statusTimer.Start();

View File

@@ -357,12 +357,6 @@
Padding="5,2"/>
</Grid>
</Grid>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock Text="关键计时节点提醒:" FontSize="12" Foreground="#666666" Margin="0,0,10,0"/>
<CheckBox x:Name="chkTime10min" Content="10分钟" FontSize="12" Margin="0,0,10,0"/>
<CheckBox x:Name="chkTime30min" Content="30分钟" FontSize="12" Margin="0,0,10,0"/>
<CheckBox x:Name="chkTime60min" Content="60分钟" FontSize="12"/>
</StackPanel>
</StackPanel>
<!-- 新增:温度平衡设置区域 -->
@@ -433,7 +427,7 @@
Padding="5,3"
Margin="0,0,0,5"/>
</StackPanel>
<TextBlock Text="平衡条件: 10分钟最大温差10°C 且 温度漂移2°C"
<TextBlock Text="平衡条件: 温度波动正常至少10分钟最大温差10°C 且 温度漂移2°C"
FontSize="12"
Foreground="#666666"
Margin="0,3,0,0"/>
@@ -789,17 +783,13 @@
FontWeight="Bold"
Foreground="#2C3E50"/>
</StackPanel>
<TextBlock x:Name="txtTempFluctuationStatus"
Text="温度波动: ±0°C (允许±5°C)"
FontSize="12"
Foreground="#666666"
Margin="0,5,0,0"/>
<StackPanel Orientation="Horizontal" >
<Border Background="#27AE60"
CornerRadius="4"
Padding="8,4">
Padding="8,4" Margin="0,5,0,5">
<TextBlock x:Name="txtFurnaceTempStatus"
Text="炉内温度波动正常"
Text="炉内温度波动"
Foreground="White"
FontSize="12"
FontWeight="SemiBold"/>
@@ -807,19 +797,19 @@
<Border Background="#27AE60"
CornerRadius="4"
Padding="8,4">
Padding="8,4" Margin="10,5,0,5">
<TextBlock x:Name="txtSampleInternalTempStatus"
Text="式样中心温度波动正常"
Text="式样中心温度波动"
Foreground="White"
FontSize="12"
FontWeight="SemiBold"/>
FontWeight="SemiBold" />
</Border>
<Border Background="#27AE60"
CornerRadius="4"
Padding="8,4">
Padding="8,4" Margin="10,5,0,5">
<TextBlock x:Name="txtSampleSurfaceTempStatus"
Text="式样表面温度波动正常"
Text="式样表面温度波动"
Foreground="White"
FontSize="12"
FontWeight="SemiBold"/>
@@ -857,7 +847,7 @@
</StackPanel>
<TextBlock x:Name="txtBalanceCondition"
Text="平衡条件: 炉内温度波动:±5℃10分钟 且 最大温差10°C 且 温度漂移2°C"
Text="平衡条件: 炉内温度波动正常至少10分钟 且 最大温差10°C 且 温度漂移2°C"
FontSize="12"
Foreground="#666666"
Margin="0,5,0,0"/>
@@ -885,106 +875,102 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 左侧图标 -->
<TextBlock Text="🔥"
FontSize="24"
VerticalAlignment="Center"
Margin="0,0,15,0"/>
<!-- 中间:状态信息 -->
<StackPanel Grid.Column="1">
<TextBlock Text="最终平衡判断"
FontSize="13"
Foreground="#666666"
FontWeight="SemiBold"/>
FontSize="13"
Foreground="#666666"
FontWeight="SemiBold"/>
<!-- 第一行:状态和计时 -->
<StackPanel Orientation="Horizontal" Margin="0,2,0,0">
<TextBlock x:Name="txtFinalBalanceState"
Text="未开始"
FontSize="16"
FontWeight="Bold"
Foreground="#2C3E50"
Margin="0,0,15,0"/>
Text="未开始"
FontSize="16"
FontWeight="Bold"
Foreground="#2C3E50"
Margin="0,0,15,0"/>
<TextBlock Text="计时:"
FontSize="14"
Foreground="#666666"
Margin="0,0,5,0"/>
FontSize="14"
Foreground="#666666"
Margin="0,0,5,0"/>
<TextBlock x:Name="txtFinalBalanceTimer"
Text="00:00"
FontSize="14"
FontWeight="SemiBold"
Foreground="#E74C3C"/>
Text="00:00"
FontSize="14"
FontWeight="SemiBold"
Foreground="#E74C3C"/>
</StackPanel>
<!-- 第二行:温度数据 -->
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock Text="初始:"
FontSize="12"
Foreground="#666666"/>
FontSize="12"
Foreground="#666666"/>
<TextBlock x:Name="txtFinalBalanceInitialTemp"
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"
Margin="0,0,10,0"/>
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"
Margin="0,0,10,0"/>
<TextBlock Text="最高:"
FontSize="12"
Foreground="#666666"/>
FontSize="12"
Foreground="#666666"/>
<TextBlock x:Name="txtFinalBalanceMaxTemp"
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#E74C3C"
Margin="0,0,10,0"/>
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#E74C3C"
Margin="0,0,10,0"/>
<TextBlock Text="当前:"
FontSize="12"
Foreground="#666666"/>
FontSize="12"
Foreground="#666666"/>
<TextBlock x:Name="txtFinalBalanceCurrentTemp"
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"/>
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"/>
</StackPanel>
<!-- 第三行:数据统计 -->
<StackPanel Orientation="Horizontal" Margin="0,3,0,0">
<TextBlock Text="数据点:"
FontSize="12"
Foreground="#666666"/>
FontSize="12"
Foreground="#666666"/>
<TextBlock x:Name="txtFinalBalanceDataCount"
Text="0"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"
Margin="0,0,10,0"/>
Text="0"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"
Margin="0,0,10,0"/>
<TextBlock Text="漂移:"
FontSize="12"
Foreground="#666666"/>
FontSize="12"
Foreground="#666666"/>
<TextBlock x:Name="txtFinalBalanceDrift"
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"/>
Text="0.0°C"
FontSize="12"
FontWeight="SemiBold"
Foreground="#2C3E50"/>
</StackPanel>
</StackPanel>
<!-- 右侧:状态指示 -->
<Border Grid.Column="2"
x:Name="finalBalanceStatusBorder"
Background="#BDC3C7"
CornerRadius="4"
Padding="8,4"
Margin="10,0,0,0"
VerticalAlignment="Center">
x:Name="finalBalanceStatusBorder"
Background="#BDC3C7"
CornerRadius="4"
Padding="8,4"
Margin="10,0,0,0"
VerticalAlignment="Center">
<TextBlock x:Name="txtFinalBalanceStatusText"
Text="等待开始"
Foreground="White"
FontSize="12"
FontWeight="SemiBold"/>
Text="等待开始"
Foreground="White"
FontSize="12"
FontWeight="SemiBold"/>
</Border>
</Grid>
</Border>
@@ -1004,31 +990,8 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 时间图标 -->
<!-- 试验时间信息 -->
<StackPanel Grid.Column="1">
<TextBlock Text="试验时间"
FontSize="13"
Foreground="#666666"/>
<TextBlock x:Name="txtTestTime"
Text="00:00:00"
FontSize="18"
FontWeight="Bold"
Foreground="#2C3E50"/>
<TextBlock x:Name="txtTimeReminder"
Text="下一个节点: 10分钟"
FontSize="12"
Foreground="#F39C12"
Margin="0,2,0,0"/>
</StackPanel>
<!-- 燃烧状态信息 -->
<StackPanel Grid.Column="3">
@@ -1064,45 +1027,6 @@
</StackPanel>
</Grid>
<!-- 第二行:试验进度 -->
<StackPanel Grid.Row="1" Margin="0,15,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="试验进度"
FontSize="13"
Foreground="#666666"
FontWeight="SemiBold"
VerticalAlignment="Center"/>
<TextBlock x:Name="txtProgress"
Text="0%"
FontSize="13"
Foreground="#3498DB"
FontWeight="Bold"
Margin="10,0,0,0"
VerticalAlignment="Center"/>
</StackPanel>
<!-- 进度条 -->
<Border Height="8"
Background="#E0E0E0"
CornerRadius="4"
Margin="0,5,0,0">
<Border x:Name="progressBar"
Width="0"
Height="8"
Background="#3498DB"
CornerRadius="4"
HorizontalAlignment="Left"/>
</Border>
</StackPanel>
</Grid>
</Border>
</StackPanel>

View File

@@ -122,7 +122,7 @@ namespace 建材不燃性试验炉
private void InitializeBalanceDisplays()
{
txtBalanceTimeElapsed.Text = "0秒";
txtBalanceCondition.Text = "平衡条件: 炉内温度波动:±5℃10分钟 且 最大温差10°C 且 温度漂移≤±2°C";
txtBalanceCondition.Text = "平衡条件: 炉内温度波动:±5℃10分钟 且 最大温差10°C 且 温度漂移2°C";
txtBalanceStatus.Text = "温度平衡状态: 未开始判断";
balanceStatusBorder.Background = new SolidColorBrush(Colors.Gray);
txtBalanceResult.Text = "未判断";
@@ -199,13 +199,7 @@ namespace 建材不燃性试验炉
if (_isTestRunning)
{
_testElapsedTime = _testElapsedTime.Add(TimeSpan.FromSeconds(1));
txtTestTime.Text = _testElapsedTime.ToString(@"hh\:mm\:ss");
// 更新进度
UpdateTestProgress();
// 检查计时节点
CheckTimeReminders();
}
}
@@ -313,9 +307,6 @@ namespace 建材不燃性试验炉
// 启动试验计时器
_testTimer.Start();
// 重置进度条
progressBar.Width = 0;
txtProgress.Text = "0%";
UpdateStatusBar("试验开始");
ResetFinalBalanceUI();
@@ -388,86 +379,7 @@ namespace 建材不燃性试验炉
{
ma?.BtnClickFunctionForNew(Function.ButtonType., 70);
}
private void UpdateTestProgress()
{
// 假设试验总时长为60分钟
TimeSpan totalDuration = TimeSpan.FromMinutes(60);
double progress = (_testElapsedTime.TotalSeconds / totalDuration.TotalSeconds) * 100;
if (progress > 100) progress = 100;
Dispatcher.Invoke(() =>
{
// 更新进度条
double maxWidth = 400; // 进度条容器宽度
progressBar.Width = maxWidth * (progress / 100);
txtProgress.Text = $"{progress:F1}%";
});
}
private void CheckTimeReminders()
{
if (!_isTestRunning) return;
TimeSpan reminderTime = TimeSpan.Zero;
string reminderText = "";
if (_testElapsedTime.TotalMinutes >= 10 && chkTime10min.IsChecked == true)
{
reminderTime = TimeSpan.FromMinutes(10);
reminderText = "10分钟节点";
}
else if (_testElapsedTime.TotalMinutes >= 30 && chkTime30min.IsChecked == true)
{
reminderTime = TimeSpan.FromMinutes(30);
reminderText = "30分钟节点";
}
else if (_testElapsedTime.TotalMinutes >= 60 && chkTime60min.IsChecked == true)
{
reminderTime = TimeSpan.FromMinutes(60);
reminderText = "60分钟节点";
}
if (reminderTime != TimeSpan.Zero)
{
txtTimeReminder.Text = $"已完成: {reminderText}";
// 显示消息
if (_testElapsedTime.TotalMinutes >= reminderTime.TotalMinutes &&
_testElapsedTime.TotalMinutes < reminderTime.TotalMinutes + 1)
{
UpdateStatusBar($"达到{reminderText}");
}
}
// 更新下一个节点
UpdateNextReminder();
}
private void UpdateNextReminder()
{
if (!_isTestRunning) return;
if (_testElapsedTime.TotalMinutes < 10 && chkTime10min.IsChecked == true)
{
txtTimeReminder.Text = $"下一个节点: 10分钟 (剩余:{10 - _testElapsedTime.TotalMinutes:F1}分钟)";
}
else if (_testElapsedTime.TotalMinutes < 30 && chkTime30min.IsChecked == true)
{
txtTimeReminder.Text = $"下一个节点: 30分钟 (剩余:{30 - _testElapsedTime.TotalMinutes:F1}分钟)";
}
else if (_testElapsedTime.TotalMinutes < 60 && chkTime60min.IsChecked == true)
{
txtTimeReminder.Text = $"下一个节点: 60分钟 (剩余:{60 - _testElapsedTime.TotalMinutes:F1}分钟)";
}
else
{
txtTimeReminder.Text = "所有计时节点已完成";
}
}
#endregion
@@ -753,8 +665,16 @@ namespace 建材不燃性试验炉
return;
}
// 读取三个温度值
float furnaceTemp = 0, sampleInternalTemp = 0, sampleSurfaceTemp = 0;
float TempSet = 0, furnaceTemp = 0, sampleInternalTemp = 0, sampleSurfaceTemp = 0;
//炉内温度设定
ReadAndUpdateRegister(350, 2, value =>
{
TempSet = value;
Dispatcher.Invoke(() => txtTestTemp.Text = $"{value:F0}°C");
});
// 炉内温度相关 (D1226, D1230)
ReadAndUpdateRegister(1230, 2, value =>
@@ -873,7 +793,13 @@ namespace 建材不燃性试验炉
}
// 获取目标温度
if (!double.TryParse(txtTestTemp.Text, out double targetTemp))
//if (!double.TryParse(txtTestTemp.Text, out double targetTemp))
//{
// targetTemp = 0;
//}
// 获取目标温度
if (!double.TryParse(txtTestTemp.Text.Replace("°C", ""), out double targetTemp))
{
targetTemp = 0;
}
@@ -883,7 +809,7 @@ namespace 建材不燃性试验炉
txtFurnaceTempStatus);
// 检查样品内部温度波动
CheckSingleTemperature("样品内部", sampleInternalTemp, targetTemp, allowedFluctuation,
CheckSingleTemperature("样品中心", sampleInternalTemp, targetTemp, allowedFluctuation,
txtSampleInternalTempStatus);
// 检查样品表面温度波动
@@ -908,26 +834,26 @@ namespace 建材不燃性试验炉
string statusText;
string backgroundColor;
if (Math.Abs(targetTemp) < 0.001) // 目标温度为0表示未设置
{
statusText = $"{tempName}温度: {currentTemp:F1}°C";
backgroundColor = "#95A5A6"; // 灰色 - 未设置目标
}
else if (actualFluctuation <= allowedFluctuation)
{
statusText = $"{tempName}温度波动正常 (±{actualFluctuation:F1}°C)";
//if (Math.Abs(targetTemp) < 0.001) // 目标温度为0表示未设置
//{
// statusText = $"{tempName}温度: {currentTemp:F1}°C";
// backgroundColor = "#95A5A6"; // 灰色 - 未设置目标
//}
//else if (actualFluctuation <= allowedFluctuation)
//{
statusText = $"{tempName}温度波动 (±{actualFluctuation:F1}°C)";
backgroundColor = "#27AE60"; // 绿色 - 正常
}
else if (actualFluctuation <= allowedFluctuation * 2) // 在2倍范围内
{
statusText = $"{tempName}温度波动警告 (±{actualFluctuation:F1}°C)";
backgroundColor = "#F39C12"; // 橙色 - 警告
}
else
{
statusText = $"{tempName}温度波动异常 (±{actualFluctuation:F1}°C)";
backgroundColor = "#E74C3C"; // 红色 - 异常
}
//}
//else if (actualFluctuation <= allowedFluctuation * 2) // 在2倍范围内
//{
// statusText = $"{tempName}温度波动警告 (±{actualFluctuation:F1}°C)";
// backgroundColor = "#F39C12"; // 橙色 - 警告
//}
//else
//{
// statusText = $"{tempName}温度波动异常 (±{actualFluctuation:F1}°C)";
// backgroundColor = "#E74C3C"; // 红色 - 异常
//}
// 更新UI
Dispatcher.Invoke(() =>
@@ -1211,9 +1137,6 @@ namespace 建材不燃性试验炉
txtCombustionNote.Text = "";
// 重置复选框
chkTime10min.IsChecked = false;
chkTime30min.IsChecked = false;
chkTime60min.IsChecked = false;
chkHasFlame.IsChecked = false;
chkHasSmoke.IsChecked = false;
@@ -1233,11 +1156,6 @@ namespace 建材不燃性试验炉
// 重置试验时间
_testElapsedTime = TimeSpan.Zero;
txtTestTime.Text = "00:00:00";
// 重置进度条
progressBar.Width = 0;
txtProgress.Text = "0%";
}
private void btnSaveData_Click(object sender, RoutedEventArgs e)
@@ -1306,7 +1224,7 @@ namespace 建材不燃性试验炉
// 试验过程
data.AppendLine("四、试验过程");
data.AppendLine($" 试验时间: {txtTestTime.Text}");
//data.AppendLine($" 试验时间: {txtTestTime.Text}");
data.AppendLine($" 火焰: {(chkHasFlame.IsChecked == true ? "" : "")}");
data.AppendLine($" 冒烟: {(chkHasSmoke.IsChecked == true ? "" : "")}");
data.AppendLine($" 备注: {txtCombustionNote.Text}");
@@ -1348,7 +1266,7 @@ namespace 建材不燃性试验炉
csv.AppendLine($"重量损失百分比,{txtWeightLossDisplay.Text.Replace(":", "")},%,");
csv.AppendLine($"试验温度,{txtTestTemp.Text},°C,");
csv.AppendLine($"温度波动允许值,{txtTempFluctuation.Text},°C,");
csv.AppendLine($"试验时间,{txtTestTime.Text},,");
//csv.AppendLine($"试验时间,{txtTestTime.Text},,");
csv.AppendLine($"是否有火焰,{(chkHasFlame.IsChecked == true ? "" : "")},,");
csv.AppendLine($"是否有冒烟,{(chkHasSmoke.IsChecked == true ? "" : "")},,");
csv.AppendLine($"燃烧状态备注,{txtCombustionNote.Text},,");
@@ -1568,7 +1486,7 @@ namespace 建材不燃性试验炉
private void ResetBalanceUI()
{
txtBalanceTimeElapsed.Text = "0秒";
txtBalanceCondition.Text = "平衡条件: 炉温(750±5)℃ 10分钟, 最大温差10℃, 漂移2℃";
txtBalanceCondition.Text = "平衡条件: 炉温(750±5)℃ 10分钟, 最大温差10℃, 漂移2℃";
txtBalanceStatus.Text = "温度平衡状态: 判断中...";
balanceStatusBorder.Background = new SolidColorBrush(Colors.Gray);
txtBalanceResult.Text = "判断中";
@@ -1824,7 +1742,7 @@ namespace 建材不燃性试验炉
if (!_balanceStatistics.Condition2)
failureReasons += " 最大温差>10℃";
if (!_balanceStatistics.Condition3)
failureReasons += " 10分钟漂移>2℃";
failureReasons += " 10分钟漂移<2℃";
txtBalanceStatus.Text = $"温度平衡状态: 未达到标准\n{failureReasons}";
}
@@ -2126,9 +2044,6 @@ namespace 建材不燃性试验炉
// 更新状态显示
Dispatcher.Invoke(() =>
{
txtTestTime.Text = testDuration.ToString(@"hh\:mm\:ss");
progressBar.Width = 400; // 进度条满
txtProgress.Text = "100%";
// 显示平衡结果
string result = isForced ? "60分钟强制结束" : "达到温度平衡";
@@ -2271,7 +2186,7 @@ namespace 建材不燃性试验炉
LossPercent = weightLossPercent,
FlameDuration = flameDuration,
TestDate = DateTime.Now.ToString("yyyy-MM-dd"),
TestDuration = txtTestTime.Text,
TestDuration = txtFinalBalanceTimer.Text,
BalanceStatus = "达到平衡",
Remarks = $"火焰:{(chkHasFlame.IsChecked == true ? "" : "")} 冒烟:{(chkHasSmoke.IsChecked == true ? "" : "")}"
};