Compare commits
4 Commits
175d0983d4
...
41435205a4
| Author | SHA1 | Date | |
|---|---|---|---|
| 41435205a4 | |||
| a2f95ee043 | |||
| 625eb4cda5 | |||
| cc5356aaad |
@@ -7,14 +7,19 @@
|
||||
public byte SlaveId { get; set; }
|
||||
|
||||
// 硬度
|
||||
public ushort HardnessValue { get; set; }
|
||||
//public ushort HardnessValue { get; set; }
|
||||
public ushort HardnessStartCoil { get; set; }
|
||||
public ushort HardnessStartCoil2 { get; set; }
|
||||
public ushort HardnessStartCoil3 { get; set; }
|
||||
|
||||
public ushort HardnessCompleteCoil { get; set; }
|
||||
public ushort HardnessStartReset { get; set; }
|
||||
public ushort HardnessStartStop { get; set; }
|
||||
|
||||
|
||||
public ushort HardnessSudu { get; set; }
|
||||
public ushort HardnessWeiyi { get; set; }
|
||||
public ushort HardnessPoSun { get; set; }
|
||||
public ushort HardnessForward { get; set; }
|
||||
public ushort HardnessBack { get; set; }
|
||||
|
||||
// 脆碎度
|
||||
public ushort FriabilityStartCoil { get; set; }
|
||||
public ushort WeightBefore { get; set; } // 天平重量寄存器(可选)
|
||||
|
||||
@@ -58,6 +58,21 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private bool _hardnessPass;
|
||||
[ObservableProperty] private double _hardnessAvg;
|
||||
[ObservableProperty] private double _hardnessRSD;
|
||||
|
||||
|
||||
//硬度新增
|
||||
//[ObservableProperty] private int _hardnessForward = 0;//硬前进
|
||||
//[ObservableProperty] private int _hardnessBack = 1;//硬后退
|
||||
//[ObservableProperty] private int _hardnessOver = 72; //硬度完成
|
||||
//[ObservableProperty] private int _hardnessStartOver = 92;// 硬复位完成
|
||||
//[ObservableProperty] private int _hardnessLimit = 298;// 硬度电机极限输入
|
||||
[ObservableProperty] private double _hardnessSudu = 300;// 硬度速度输入mm/min
|
||||
[ObservableProperty] private double _hardnessWeiyi = 100; // 硬度位移输入mm
|
||||
//[ObservableProperty] private double _hardnessPoSun = 400; // 硬度破损判定输入N
|
||||
//[ObservableProperty] private int _hardnessMaxN = 72; //最大力采集
|
||||
|
||||
|
||||
|
||||
private List<double> _hardnessResults = new();
|
||||
|
||||
// 脆碎度
|
||||
@@ -93,7 +108,8 @@ namespace TabletTester2025.ViewModels
|
||||
public IAsyncRelayCommand HardnessUpCommand { get; }
|
||||
public IAsyncRelayCommand HardnessDownCommand { get; }
|
||||
public IAsyncRelayCommand HardnessResetCommand { get; }
|
||||
public IAsyncRelayCommand PrintHardnessCommand { get; }
|
||||
public IAsyncRelayCommand HardnessForward { get; }//前进
|
||||
public IAsyncRelayCommand HardnessBack { get; }//后退
|
||||
|
||||
// 脆碎度新增
|
||||
[ObservableProperty] private double _friabilityTargetRpm = 25;
|
||||
@@ -229,7 +245,22 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
});
|
||||
|
||||
PrintHardnessCommand = new AsyncRelayCommand(async () => await PrintReport("硬度"));
|
||||
// 硬前进按钮命令
|
||||
HardnessForward = new AsyncRelayCommand(async () =>
|
||||
{
|
||||
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessForward, true);
|
||||
await Task.Delay(100); // 脉冲宽度,和复位按钮保持一致
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessForward, false);
|
||||
});
|
||||
|
||||
// 硬后退按钮命令
|
||||
HardnessForward = new AsyncRelayCommand(async () =>
|
||||
{
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessBack, true);
|
||||
await Task.Delay(100); // 脉冲宽度,和复位按钮保持一致
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessBack, false);
|
||||
});
|
||||
|
||||
// 硬度命令停止
|
||||
StopHardnessCommand = new AsyncRelayCommand(async() => {
|
||||
@@ -294,9 +325,7 @@ namespace TabletTester2025.ViewModels
|
||||
{
|
||||
switch (CurrentTest)
|
||||
{
|
||||
case TestType.Hardness:
|
||||
HardnessValue = await _plc.ReadFloatAsync(_plcConfig.HardnessValue);
|
||||
break;
|
||||
|
||||
case TestType.Disintegration:
|
||||
DisintegrationTemp = await _plc.ReadFloatAsync(_plcConfig.DisintegrationTemp);
|
||||
IsBasketMovingUp = await _plc.ReadCoilAsync(_plcConfig.DisintegrationMovingUpCoil);
|
||||
@@ -787,7 +816,7 @@ namespace TabletTester2025.ViewModels
|
||||
if (Phase != TestPhase.Idle) return;
|
||||
CurrentTest = TestType.Hardness;
|
||||
Phase = TestPhase.Running;
|
||||
HardnessPass = false; // 添加这一行
|
||||
HardnessPass = false;
|
||||
_hardnessResults.Clear();
|
||||
|
||||
try
|
||||
@@ -796,33 +825,44 @@ namespace TabletTester2025.ViewModels
|
||||
double min = App.CurrentPharmaParams.HardnessMin_N;
|
||||
double max = App.CurrentPharmaParams.HardnessMax_N;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
{ // 1. 给PLC发指令:启动单次硬度测试
|
||||
double currentSpeed = _hardnessSudu;
|
||||
double currentWeiyi = _hardnessWeiyi;
|
||||
|
||||
|
||||
// 如果你需要把这3个值发给PLC,就在这里发一次(测试开始用当前参数)
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessSudu, (float)currentSpeed);
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessWeiyi, (float)currentWeiyi);
|
||||
|
||||
|
||||
// 开始循环测试
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessStartCoil, true);
|
||||
|
||||
bool completed = false;
|
||||
while (!completed && Phase == TestPhase.Running)
|
||||
{
|
||||
await Task.Delay(200);// 每200ms轮询一次状态
|
||||
|
||||
await Task.Delay(200);
|
||||
completed = await _plc.ReadCoilAsync(_plcConfig.HardnessCompleteCoil);
|
||||
}
|
||||
double val = await _plc.ReadFloatAsync(_plcConfig.HardnessValue);
|
||||
_hardnessResults.Add(val); // 把结果存到列表里
|
||||
|
||||
HardnessValue = val; // 更新界面上的实时测试力值
|
||||
double val = await _plc.ReadFloatAsync(_plcConfig.HardnessPoSun);
|
||||
_hardnessResults.Add(val);
|
||||
//HardnessPoSun = val;
|
||||
|
||||
await Task.Delay(1000); // 间隔1秒,再进行下一次测试
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
// 计算结果
|
||||
HardnessAvg = _hardnessResults.Average();
|
||||
HardnessMax= _hardnessResults.Max();
|
||||
HardnessMax = _hardnessResults.Max();
|
||||
HardnessMin = _hardnessResults.Min();
|
||||
|
||||
HardnessCurrentCount = count;
|
||||
HardnessRSD = (StandardDeviation(_hardnessResults) / HardnessAvg) * 100;
|
||||
HardnessPass = HardnessAvg >= min && HardnessAvg <= max;
|
||||
Phase = TestPhase.Completed;//恢复启动按钮
|
||||
|
||||
Phase = TestPhase.Completed;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -832,11 +872,6 @@ namespace TabletTester2025.ViewModels
|
||||
finally
|
||||
{
|
||||
Phase = TestPhase.Idle;
|
||||
|
||||
// 在保存前设置崩解合格标志:剩余管数为0 且 崩解时间未超时
|
||||
//DisintegrationPass = (RemainingTubes == 0 && DisintegrationSeconds <= App.CurrentPharmaParams.DisintegrationMaxSeconds);
|
||||
|
||||
|
||||
await SaveBatchResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,18 +268,17 @@
|
||||
|
||||
<GroupBox Header="测试参数设置" Grid.Row="0" Margin="0,5">
|
||||
<UniformGrid Columns="2" Rows="2" Margin="10">
|
||||
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,0" >
|
||||
<TextBlock Text="硬度速度输入(mm/min)" Width="180" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding HardnessSudu, UpdateSourceTrigger=PropertyChanged}" Width="120" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,0">
|
||||
<TextBlock Text="硬度位移输入(mm/min)" Width="180" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="硬度位移输入(mm)" Width="180" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding HardnessWeiyi, UpdateSourceTrigger=PropertyChanged}" Width="120" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,0">
|
||||
<TextBlock Text="硬度破损判定输入(N)" Width="180" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding HardnessPoSun, UpdateSourceTrigger=PropertyChanged}" Width="120" />
|
||||
</StackPanel>
|
||||
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -293,43 +292,13 @@
|
||||
<UniformGrid Columns="3">
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="最大值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="最大力值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessMax, StringFormat=F1}" Foreground="#1565C0" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="最小值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessMin, StringFormat=F1}" Foreground="#1565C0" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="平均值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessAvg, StringFormat=F1}" Foreground="#2E7D32" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="参数状态显示" Grid.Row="1">
|
||||
<UniformGrid Columns="2">
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="试验次数" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessCurrentCount, StringFormat=F0}" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Style="{StaticResource MetricCard}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="测试力值(N)" Style="{StaticResource MetricLabel}"/>
|
||||
<TextBlock Text="{Binding HardnessValue, StringFormat=F1}" Foreground="#D98200" Style="{StaticResource MetricValue}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
<WrapPanel Grid.Row="2" Style="{StaticResource CommandBar}">
|
||||
<Button Command="{Binding HardnessResetCommand}" Content="复位" Style="{StaticResource ResetButton}"/>
|
||||
<Button Command="{Binding HardnessForward}" Content="前进" Style="{StaticResource ActionButton}" Background="#607D8B"/>
|
||||
|
||||
@@ -7,24 +7,21 @@
|
||||
"IpAddress": "192.168.1.10",
|
||||
"Port": 502,
|
||||
"SlaveId": 1,
|
||||
"HardnessValue": 100,
|
||||
//"HardnessValue": 72,
|
||||
"HardnessStartCoil": 70, //硬度工位1启动测试M70
|
||||
"HardnessStartCoil2": 70, //硬度工位1启动测试M70
|
||||
"HardnessStartCoil3": 70, //硬度工位1启动测试M70
|
||||
|
||||
"HardnessStartStop": 73, // 硬度停止
|
||||
"HardnessStartReset": 90, // 硬复位启动
|
||||
|
||||
"HardnessForward": 0, //硬前进
|
||||
"HardnessBack": 1, //硬后退
|
||||
|
||||
"HardnessOver": 72, //硬度完成
|
||||
|
||||
"HardnessStartOver": 92, // 硬复位启动
|
||||
"HardnessLimit": 298, // 硬度电机极限输入
|
||||
"HardnessSudu": 300, // 硬度速度输入mm/min
|
||||
"HardnessWeiyi": 310, // 硬度位移输入mm/min
|
||||
"HardnessPoSun": 310, // 硬度破损判定输入N
|
||||
"HardnessMax": 310, //最大力采集
|
||||
"HardnessPoSun": 400, // 硬度破损判定输入N
|
||||
"HardnessMax": 72, //最大力采集
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +40,6 @@
|
||||
"DisintegrationMovingUpCoil": 30,
|
||||
"DisintegrationStartCoil": 50,
|
||||
"DisintegrationStopCoil": 53,
|
||||
"DisintegrationResetCoil": 100,
|
||||
"DisintegrationSpeed": 330,
|
||||
"DisintegrationTime": 420,
|
||||
"DisintegrationCompleteCoils": [ 200, 201, 202, 203, 204, 205 ],
|
||||
@@ -54,16 +50,12 @@
|
||||
"DissolutionStartCoil": 40,
|
||||
"Dissolution1StartCoil": 40,
|
||||
"Dissolution1StopCoil": 43,
|
||||
"Dissolution1ResetCoil": 105,
|
||||
"Dissolution1SampleAckCoil": 44,
|
||||
"Dissolution2StartCoil": 30,
|
||||
"Dissolution2StopCoil": 33,
|
||||
"Dissolution2ResetCoil": 110,
|
||||
"Dissolution2SampleAckCoil": 34,
|
||||
"Dissolution1Time": 430,
|
||||
"Dissolution2Time": 440,
|
||||
"Dissolution1SampleInterval": 432,
|
||||
"Dissolution2SampleInterval": 442
|
||||
"Dissolution2Time": 440
|
||||
},
|
||||
"PharmaStandard": {
|
||||
"HardnessMin_N": 40,
|
||||
|
||||
Reference in New Issue
Block a user