33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System;
|
|
using XP.Hardware.MotionControl.Abstractions;
|
|
using XP.Hardware.MotionControl.Config;
|
|
using XP.Hardware.Plc.Abstractions;
|
|
|
|
namespace XP.Hardware.MotionControl.Implementations
|
|
{
|
|
/// <summary>
|
|
/// 基于 PLC 的实体摇杆实现 | PLC-based Physical Joystick Implementation
|
|
/// 信号名称硬编码在 MotionSignalNames 中 | Signal names hardcoded in MotionSignalNames
|
|
/// </summary>
|
|
public class PlcJoystick : IJoystick
|
|
{
|
|
private readonly ISignalDataService _signalService;
|
|
private bool _isJoystickActive;
|
|
|
|
public PlcJoystick(ISignalDataService signalService)
|
|
{
|
|
_signalService = signalService ?? throw new ArgumentNullException(nameof(signalService));
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public bool IsJoystickActive => _isJoystickActive;
|
|
|
|
/// <inheritdoc/>
|
|
public void UpdateStatus()
|
|
{
|
|
// 读取实体摇杆输入激活信号 | Read physical joystick input active signal
|
|
_isJoystickActive = _signalService.GetValueByName<byte>(MotionSignalNames.Joystick_Active) == 10;
|
|
}
|
|
}
|
|
}
|