页面样式
This commit is contained in:
@@ -18,6 +18,7 @@ namespace TabletTester2025.ViewModels
|
||||
{
|
||||
public partial class StationViewModel : ObservableObject
|
||||
{
|
||||
private DispatcherTimer _hardnessGlobalTimer;
|
||||
private readonly IPlcService _plc;
|
||||
private readonly PlcConfiguration _plcConfig;
|
||||
private readonly DatabaseService _db;
|
||||
@@ -69,8 +70,8 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private double _hardnessSudu = 300;// 硬度速度输入mm/min
|
||||
[ObservableProperty] private double _hardnessWeiyi = 100; // 硬度位移输入mm
|
||||
//[ObservableProperty] private double _hardnessPoSun = 400; // 硬度破损判定输入N
|
||||
[ObservableProperty] private double _hardnessMaxN = 72; //最大力采集
|
||||
//[ObservableProperty] private double HardnessShishilizhi = 72; //最大力采集
|
||||
//[ObservableProperty] private double _hardnessMaxN = 72; //最大力采集
|
||||
[ObservableProperty] private double _hardnessShishilizhi = 0.0; //最大力采集
|
||||
|
||||
|
||||
|
||||
@@ -100,7 +101,7 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private int _hardnessIntervalSec = 2;
|
||||
[ObservableProperty] private int _hardnessCurrentCount;
|
||||
[ObservableProperty] private double _hardnessMax;
|
||||
[ObservableProperty] private double _hardnessMin;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -180,7 +181,7 @@ namespace TabletTester2025.ViewModels
|
||||
_db = db;
|
||||
_excel = excel;
|
||||
_alarm = alarm;
|
||||
|
||||
_ = InitializeHardnessAllDataAsync();
|
||||
StartHardnessCommand = new AsyncRelayCommand(RunHardnessAsync);
|
||||
StartFriabilityCommand = new AsyncRelayCommand(RunFriabilityAsync);
|
||||
StartDisintegrationCommand = new AsyncRelayCommand(RunDisintegrationAsync);
|
||||
@@ -213,23 +214,16 @@ namespace TabletTester2025.ViewModels
|
||||
DissolutionPlotModel.Series.Add(_dissolution1Series);
|
||||
DissolutionPlotModel.Series.Add(_dissolution2Series);
|
||||
|
||||
// 硬度命令
|
||||
//HardnessUpCommand = new AsyncRelayCommand(async () =>
|
||||
//{
|
||||
|
||||
|
||||
// await _plc.WriteCoilAsync(0x20, true);
|
||||
// await Task.Delay(100);
|
||||
// await _plc.WriteCoilAsync(0x20, false);
|
||||
//});
|
||||
|
||||
HardnessDownCommand = new AsyncRelayCommand(async () =>
|
||||
HardnessDownCommand = new AsyncRelayCommand(async () =>
|
||||
{
|
||||
await _plc.WriteCoilAsync(0x21, true);
|
||||
await Task.Delay(100);
|
||||
await _plc.WriteCoilAsync(0x21, false);
|
||||
});
|
||||
|
||||
//复位
|
||||
//硬复位
|
||||
HardnessResetCommand = new AsyncRelayCommand(async () =>
|
||||
{
|
||||
// 1. 标准PLC按钮脉冲逻辑:置1 → 延时 → 置0(模拟按下再松开按钮)
|
||||
@@ -237,12 +231,8 @@ namespace TabletTester2025.ViewModels
|
||||
await Task.Delay(100); // 脉冲宽度,可根据PLC程序调整20~100ms
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessStartReset, false);
|
||||
_hardnessResults.Clear();
|
||||
HardnessValue = 0;
|
||||
HardnessAvg = 0;
|
||||
HardnessRSD = 0;
|
||||
HardnessCurrentCount = 0;
|
||||
HardnessMax = 0;
|
||||
HardnessMin = 0;
|
||||
HardnessShishilizhi = 0;
|
||||
Phase = TestPhase.Idle;
|
||||
|
||||
});
|
||||
@@ -312,6 +302,31 @@ namespace TabletTester2025.ViewModels
|
||||
_ = LoadDissolutionTimesAsync();
|
||||
}
|
||||
|
||||
private async Task InitializeHardnessAllDataAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 从PLC读取4个值
|
||||
float speed = await _plc.ReadFloatAsync(_plcConfig.HardnessSudu);
|
||||
float weiyi = await _plc.ReadFloatAsync(_plcConfig.HardnessWeiyi);
|
||||
float realTimeForce = await _plc.ReadFloatAsync(_plcConfig.HardnessShishilizhi);
|
||||
float maxForce = await _plc.ReadFloatAsync(_plcConfig.HardnessMax);
|
||||
|
||||
// 赋值到界面绑定属性,自动显示
|
||||
HardnessSudu = speed;
|
||||
HardnessWeiyi = weiyi;
|
||||
HardnessMax = maxForce;
|
||||
HardnessValue = realTimeForce;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 读取失败用默认值,不影响程序运行
|
||||
HardnessSudu = 300;
|
||||
HardnessWeiyi = 100;
|
||||
HardnessMax = 0.0;
|
||||
HardnessValue = 0.0;
|
||||
}
|
||||
}
|
||||
private async Task PrintReport(string testName)
|
||||
{
|
||||
await App.Current.Dispatcher.InvokeAsync(() =>
|
||||
|
||||
@@ -295,7 +295,6 @@
|
||||
<TextBlock Text="最大力值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessMax, StringFormat=F1}" Foreground="#1565C0" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
|
||||
@@ -59,8 +59,8 @@
|
||||
"Dissolution2Time": 440
|
||||
},
|
||||
"PharmaStandard": {
|
||||
"HardnessMin_N": 40,
|
||||
"HardnessMax_N": 60,
|
||||
|
||||
|
||||
"HardnessTestCount": 6,
|
||||
"FriabilityMaxLossPercent": 1.0,
|
||||
"DisintegrationMaxSeconds": 900,
|
||||
|
||||
Reference in New Issue
Block a user