This commit is contained in:
xyy
2026-04-07 21:10:37 +08:00
parent 48056e5b58
commit a1532d7954
4 changed files with 42 additions and 3 deletions

View File

@@ -27,6 +27,8 @@ namespace MembranePoreTester.Communication
// ========== 控制线圈 ==========
public ushort PressureModeRegister { get; set; } // 高压/低压模式寄存器
public ushort PressCoil { get; set; } // 加压线圈M100
public ushort PressCoil2 { get; set; } // 加压线圈M100
public ushort PressCoil3 { get; set; } // 加压线圈M100
public ushort StartCoil { get; set; } // 启动线圈M20
public ushort EnableCoil { get; set; } // 使能线圈M21只读状态
public ushort StopCoil { get; set; } // 停止线圈M7
@@ -80,6 +82,16 @@ namespace MembranePoreTester.Communication
public ushort BigFlow3 { get; set; } // 工位1
public ushort SmallFlowAlarm { get; set; } // 小流量计报警 M210
public ushort BigFlowAlarm { get; set; } // 大流量报警 M213
public ushort HighPressAlarm { get; set; } // 高压超限 M180
public ushort LowPressAlarm { get; set; } // 低压超限 M195
}
/// <summary>

View File

@@ -269,14 +269,29 @@ namespace MembranePoreTester.ViewModels
{
try
{
ushort coilAddress = _plcConfig.PressCoil; // 根据工位选择不同的线圈地址
switch (StationId)
{
case 1:
coilAddress = _plcConfig.PressCoil;
break;
case 2:
coilAddress = _plcConfig.PressCoil2;
break;
case 3:
coilAddress = _plcConfig.PressCoil3;
break;
}
// 先读取PLC当前的加压状态
bool currentStatus = await _plcService.ReadCoilAsync(_plcConfig.PressCoil);
bool currentStatus = await _plcService.ReadCoilAsync(coilAddress);
// 切换状态
_isPressing = !currentStatus;
// 写入新状态到PLC
await WriteCoilAsync(_plcConfig.PressCoil, _isPressing);
await WriteCoilAsync(coilAddress, _isPressing);
// 更新按钮文字
PressButtonText = _isPressing ? "停止加压" : "加压";

View File

@@ -15,6 +15,9 @@
// 线圈控制M 元件)
"PressCoil": 140, // 加压线圈M100ON 开始加压OFF 停止
"PressCoil2": 141, // 加压线圈M100ON 开始加压OFF 停止
"PressCoil3": 142, // 加压线圈M100ON 开始加压OFF 停止
"StartCoil": 20, // 启动线圈M20ON 启动测试程序
"EnableCoil": 21, // 使能线圈M21状态反馈只读
"StopCoil": 7, // 停止线圈M7ON 停止测试
@@ -69,7 +72,16 @@
"SmallFlow3": 47, // M64
"BigFlow1": 49, //
"BigFlow2": 42, //
"BigFlow3": 46 //
"BigFlow3": 46, //
"SmallFlowAlarm": 210,
"BigFlowAlarm": 213,
"HighPressAlarm": 180, //高压超限
"LowPressAlarm": 195 //低压超限
}
}

Binary file not shown.