This commit is contained in:
xyy
2026-03-26 19:43:52 +08:00
parent 7bbf829224
commit b161e884e7
14 changed files with 452 additions and 268 deletions

View File

@@ -1,9 +1,11 @@
using MembranePoreTester.Communication;
using System.Collections.ObjectModel;
using System.ComponentModel; // 用于 PropertyChanged
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using static OfficeOpenXml.ExcelErrorValue;
namespace MembranePoreTester.ViewModels
{
@@ -117,15 +119,19 @@ namespace MembranePoreTester.ViewModels
private async Task WritePressureModeAsync(string mode)
{
ushort val = mode == "高压" ? (ushort)1 : (ushort)0;
if (IsDisposed) return;
ushort val = mode.ToString().Contains("高压") ? (ushort)0 : (ushort)1;
try
{
await _plcService.WriteRegisterAsync(_plcConfig.PressureModeRegister, val);
await _plcService.WriteSingleRegisterAsync(_plcConfig.PressureModeRegister, val);
}
catch (Exception ex)
{
MessageBox.Show($"写压力模式失败: {ex.Message}");
}
}
@@ -144,7 +150,7 @@ namespace MembranePoreTester.ViewModels
public MainViewModel()
{
for (int i = 1; i <= 3; i++)
for (int i = 1; i <= 1; i++)
{
var station = new StationItem
{