将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using HslCommunication;
|
||||
using XP.Hardware.Plc.Exceptions;
|
||||
|
||||
namespace XP.Hardware.PLC.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// PLC 辅助类,提供数据类型转换和地址解析辅助方法 | PLC helper class, provides data type conversion and address parsing helper methods
|
||||
/// </summary>
|
||||
public static class PlcHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查操作结果,抛出统一异常 | Check operation result and throw unified exception
|
||||
/// </summary>
|
||||
/// <param name="result">操作结果 | Operation result</param>
|
||||
public static void CheckSuccess(OperateResult result)
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
throw new PlcException($"PLC操作失败: {result.Message} (Code: {result.ErrorCode})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user