更新
This commit is contained in:
@@ -7,19 +7,18 @@
|
||||
public byte SlaveId { get; set; }
|
||||
|
||||
// 硬度
|
||||
//public ushort HardnessValue { get; set; }
|
||||
public ushort HardnessMax { get; set; }
|
||||
public ushort HardnessStartCoil { 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 HardnessShishilizhi { get; set; }
|
||||
// 脆碎度
|
||||
public ushort FriabilityStartCoil { get; set; }
|
||||
public ushort WeightBefore { get; set; } // 天平重量寄存器(可选)
|
||||
|
||||
156
PLC.cs
156
PLC.cs
@@ -1,156 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace 片剂四用仪
|
||||
{
|
||||
internal class PLC
|
||||
{
|
||||
// "CSI-Z420片剂四用仪"
|
||||
//"软元件名" "注释"
|
||||
//"X000" "溶出电机原点"
|
||||
//"X001" "崩解电机原点"
|
||||
//"X002" "脆碎度电机原点"
|
||||
//"X003" "硬度电机原点"
|
||||
//"X007" "急停"
|
||||
//"Y000" "硬度电机脉冲"
|
||||
//"Y001" "脆碎度电机脉冲"
|
||||
//"Y002" "崩解电机脉冲"
|
||||
//"Y003" "溶出电机脉冲"
|
||||
//"Y004" "硬度电机方向"
|
||||
//"Y005" "脆碎度电机方向"
|
||||
//"Y006" "崩解电机方向"
|
||||
//"Y007" "溶出电机方向"
|
||||
//"M0" "硬前进"
|
||||
//"M1" "硬后退"
|
||||
//"M2" "脆正转"
|
||||
//"M3" "脆反转"
|
||||
//"M4" "崩正转"
|
||||
//"M5" "崩反转"
|
||||
//"M6" "溶正转"
|
||||
//"M7" "溶反转"
|
||||
//"M40" "溶出开始"
|
||||
//"M41" "溶出使能"
|
||||
//"M42" "溶出完成"
|
||||
//"M43" "溶出停止"
|
||||
//"M44" "暂停(提示取样)"
|
||||
//"M50" "崩解开始"
|
||||
//"M51" "崩解使能"
|
||||
//"M52" "崩解完成"
|
||||
//"M53" "崩解停止"
|
||||
//"M60" "时间设置"
|
||||
//"M70" "硬度开始"
|
||||
//"M71" "硬度使能"
|
||||
//"M72" "硬度完成"
|
||||
//"M73" "硬度停止"
|
||||
//"M74" "感应力标志"
|
||||
//"M80" "脆碎开始"
|
||||
//"M81" "脆碎使能"
|
||||
//"M82" "脆碎完成"
|
||||
//"M83" "脆碎停止"
|
||||
//"M90" "硬复位启动"
|
||||
//"M91" "硬复位使能"
|
||||
//"M92" "硬复位完成"
|
||||
//"M95" "脆复位启动"
|
||||
//"M96" "脆复位使能"
|
||||
//"M97" "脆复位完成"
|
||||
//"M100" "崩复位启动"
|
||||
//"M101" "崩复位使能"
|
||||
//"M102" "崩复位完成"
|
||||
//"M105" "溶复位启动"
|
||||
//"M106" "溶复位使能"
|
||||
//"M107" "溶复位完成"
|
||||
//"M200" "硬度电机极限"
|
||||
//"M201" "硬度电机等于"
|
||||
//"M202" "硬度电机小于"
|
||||
//"M210" "大于"
|
||||
//"M211" "等于"
|
||||
//"M212" "小于"
|
||||
//"M215" "称重保护大于"
|
||||
//"M216" "称重保护等于"
|
||||
//"M217" "称重保护小于"
|
||||
//"M220" "大于"
|
||||
//"M221" "等于"
|
||||
//"M222" "小于"
|
||||
//"M225" "大于"
|
||||
//"M226" "等于"
|
||||
//"M227" "小于"
|
||||
//"M230" "大于"
|
||||
//"M231" "等于"
|
||||
//"M232" "小于"
|
||||
//"M1300" "称重校零"
|
||||
//"M8000" "常通"
|
||||
//"M8002" "上电"
|
||||
//"M8013" "1s脉冲"
|
||||
//"D10" "硬度当前位置"
|
||||
//"D40" "溶出步"
|
||||
//"D42" "溶出计时递增s"
|
||||
//"D44" "溶出计时递增min"
|
||||
//"D50" "崩解步"
|
||||
//"D52" "崩解计时递增s"
|
||||
//"D54" "崩解计时递增min"
|
||||
//"D60" "秒"
|
||||
//"D61" "分"
|
||||
//"D62" "时"
|
||||
//"D63" "日"
|
||||
//"D64" "月"
|
||||
//"D65" "年"
|
||||
//"D66" "周"
|
||||
//"D70" "硬度步"
|
||||
//"D72" "最大力采集"
|
||||
//"D74" "判定比较"
|
||||
//"D80" "碎脆度步"
|
||||
//"D82" "脆测次数递增"
|
||||
//"D90" "硬复位步"
|
||||
//"D94" "脆复位步"
|
||||
//"D100" "崩复位步"
|
||||
//"D104" "溶复位步"
|
||||
//"D290" "硬mm脉冲"
|
||||
//"D292" "脆r脉冲"
|
||||
//"D294" "崩r脉冲"
|
||||
//"D296" "溶r脉冲"
|
||||
//"D298" "硬度电机极限输入"
|
||||
//"D300" "硬度速度输入mm/min"
|
||||
//"D306" "硬速度int"
|
||||
//"D310" "硬度位移输入mm/min"
|
||||
//"D314" "硬度位移int+"
|
||||
//"D316" "硬度位移int-"
|
||||
//"D320" "脆速度输入r/min"
|
||||
//"D326" "脆速度int"
|
||||
//"D330" "崩速度输入r/min"
|
||||
//"D336" "崩速度int"
|
||||
//"D340" "溶速度输入r/min"
|
||||
//"D346" "溶速度int"
|
||||
//"D400" "硬度破损判定输入N"
|
||||
//"D410" "脆碎试验时间设置"
|
||||
//"D412" "脆碎前质量输入"
|
||||
//"D414" "脆碎后质量输入"
|
||||
//"D416" "失重率%"
|
||||
//"D420" "崩解时间min设置"
|
||||
//"D430" "溶出时间min设置"
|
||||
//"D432" "溶出间隔取样时间设置"
|
||||
//"D434" "溶出间隔时间过渡"
|
||||
//"D500" "时钟设置"
|
||||
//"D1300" "力读取"
|
||||
//"D1304" "力浮点"
|
||||
//"D1308" "校准后力"
|
||||
//"D1314" "力显示"
|
||||
//"D1320" "力系数"
|
||||
//"D1322" "力保护"
|
||||
//"D1410" "数据读取"
|
||||
//"D1412" "数据浮点"
|
||||
//"D1416" "算"
|
||||
//"D1418" "算"
|
||||
//"D1420" "算"
|
||||
//"D1422" "温度"
|
||||
//"D1428" "温度系数"
|
||||
//"D1430" "温度显示"
|
||||
//"D8340" "硬度脉冲"
|
||||
//"D8350" "脆碎度脉冲"
|
||||
//"D8360" "崩解脉冲"
|
||||
//"D8370" "溶出脉冲"
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,6 @@ namespace TabletTester2025.ViewModels
|
||||
// 在构造函数中
|
||||
OpenSettingsCommand = new AsyncRelayCommand(() => { new SettingsWindow().ShowDialog(); return Task.CompletedTask; });
|
||||
OpenHistoryCommand = new AsyncRelayCommand(() => { new HistoryWindow().ShowDialog(); return Task.CompletedTask; });
|
||||
OpenCalibrationCommand = new AsyncRelayCommand(() => { MessageBox.Show("校准功能待实现"); return Task.CompletedTask; });
|
||||
|
||||
// 跳转到 PlcDataPage 页面
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace TabletTester2025.ViewModels
|
||||
{
|
||||
public partial class StationViewModel : ObservableObject
|
||||
{
|
||||
private DispatcherTimer _hardnessGlobalTimer;
|
||||
private readonly IPlcService _plc;
|
||||
private readonly PlcConfiguration _plcConfig;
|
||||
private readonly DatabaseService _db;
|
||||
@@ -75,7 +76,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 int _hardnessMaxN = 72; //最大力采集
|
||||
//[ObservableProperty] private double _hardnessMaxN = 72; //最大力采集
|
||||
[ObservableProperty] private double _hardnessShishilizhi = 0.0; //最大力采集
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +107,8 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private int _hardnessIntervalSec = 2;
|
||||
[ObservableProperty] private int _hardnessCurrentCount;
|
||||
[ObservableProperty] private double _hardnessMax;
|
||||
[ObservableProperty] private double _hardnessMin;
|
||||
|
||||
|
||||
|
||||
|
||||
[ObservableProperty] private bool _disintegrationPass; // 新增
|
||||
@@ -221,23 +224,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(模拟按下再松开按钮)
|
||||
@@ -245,12 +241,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;
|
||||
|
||||
});
|
||||
@@ -1101,11 +1093,10 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
private async Task RunHardnessAsync()
|
||||
{
|
||||
// 点击启动才执行一次
|
||||
if (Phase != TestPhase.Idle) return;
|
||||
CurrentTest = TestType.Hardness;
|
||||
Phase = TestPhase.Running;
|
||||
HardnessPass = false;
|
||||
_hardnessResults.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1118,44 +1109,17 @@ namespace TabletTester2025.ViewModels
|
||||
double currentWeiyi = HardnessWeiyi;
|
||||
|
||||
|
||||
// 如果你需要把这3个值发给PLC,就在这里发一次(测试开始用当前参数)
|
||||
// 写入PLC
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessSudu, (float)currentSpeed);
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessWeiyi, (float)currentWeiyi);
|
||||
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessStartCoil, true);//启动
|
||||
|
||||
// 开始循环测试
|
||||
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);
|
||||
completed = await _plc.ReadCoilAsync(_plcConfig.HardnessCompleteCoil);
|
||||
}
|
||||
|
||||
double val = await _plc.ReadFloatAsync(_plcConfig.HardnessPoSun);
|
||||
_hardnessResults.Add(val);
|
||||
//HardnessPoSun = val;
|
||||
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
// 计算结果
|
||||
HardnessAvg = _hardnessResults.Average();
|
||||
HardnessMax = _hardnessResults.Max();
|
||||
HardnessMin = _hardnessResults.Min();
|
||||
HardnessCurrentCount = count;
|
||||
HardnessRSD = (StandardDeviation(_hardnessResults) / HardnessAvg) * 100;
|
||||
HardnessPass = HardnessAvg >= min && HardnessAvg <= max;
|
||||
|
||||
Phase = TestPhase.Completed;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await App.Current.Dispatcher.InvokeAsync(() => MessageBox.Show($"硬度测试出错:{ex.Message}"));
|
||||
Phase = TestPhase.Error;
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1544,8 +1508,7 @@ namespace TabletTester2025.ViewModels
|
||||
// 硬度
|
||||
HardnessAvg = HardnessAvg,
|
||||
HardnessRSD = HardnessRSD,
|
||||
HardnessMax = HardnessMax,
|
||||
HardnessMin = HardnessMin,
|
||||
|
||||
HardnessTestCount = HardnessTestCount,
|
||||
HardnessInternalMin = HardnessInternalMin,
|
||||
HardnessInternalMax = HardnessInternalMax,
|
||||
|
||||
@@ -60,19 +60,19 @@
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource GroupTitle}" Text="⚙ 硬度测试参数"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="硬度速度输入mm/min"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="速度输入(mm/min)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_HardnessSpeed"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="硬度位移输入mm/min"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="位移输入(mm)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_HardnessDisplacement"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="硬度电机极限输入"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="电机极限输入"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_HardnessMotorLimit"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="硬度破损判定输入N"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="破损判定输入(N)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_HardnessDamageThreshold"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -87,7 +87,7 @@
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource GroupTitle}" Text="⚙ 脆碎度测试参数"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="脆碎试验时间设置"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="试验时间设置"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_BrittlenessTestTime"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
@@ -99,7 +99,7 @@
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_PostBrittlenessMass"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="失重率%"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="失重率(%)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_WeightLossRate"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -110,11 +110,11 @@
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource GroupTitle}" Text="⚙ 崩解测试参数"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="崩速度r/min"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="崩解速度(r/min)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_DisintegrationSpeed"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="崩解时间min设置"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="崩解时间设置(min)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_DisintegrationTime"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -125,7 +125,7 @@
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource GroupTitle}" Text="⚙ 溶出测试参数"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="溶出时间min设置"/>
|
||||
<TextBlock Style="{StaticResource SettingLabel}" Text="溶出时间设置(min)"/>
|
||||
<TextBox Style="{StaticResource SettingTextBox}" Name="txt_DissolutionTime"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"HardnessWeiyi": 310, // 硬度位移输入mm/min
|
||||
"HardnessPoSun": 400, // 硬度破损判定输入N
|
||||
"HardnessMax": 72, //最大力采集
|
||||
"HardnessShishilizhi": 1314, //力显示
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
"FriabilityStartCoil3": 80, //脆碎工位1启动测试M70
|
||||
"FriabilityStartCoilStop": 83, // 脆碎停止
|
||||
"FriabilityStartCoilReset": 95, // 脆碎复位启动
|
||||
"HardnessCompleteCoil": 11,
|
||||
|
||||
|
||||
"WeightBefore": 412,
|
||||
"WeightAfter": 414,
|
||||
@@ -58,8 +59,8 @@
|
||||
"Dissolution2Time": 440
|
||||
},
|
||||
"PharmaStandard": {
|
||||
"HardnessMin_N": 40,
|
||||
"HardnessMax_N": 60,
|
||||
|
||||
|
||||
"HardnessTestCount": 6,
|
||||
"FriabilityTargetRpm": 25.0,
|
||||
"FriabilityTargetRounds": 100,
|
||||
|
||||
Reference in New Issue
Block a user