类 SoE

java.lang.Object
com.darra.ethercat.slave.SoE
所有已实现的接口:
IMailboxProtocol

public class SoE extends Object implements IMailboxProtocol
SoE (Servo over EtherCAT) 完整实现 对齐 C# SoEInstance: IDN 读写、类型化读取、命令执行、参数信息、通知
  • 构造器详细资料

    • SoE

      public SoE(short masterIndex, short slaveIndex, byte driveNumber)
    • SoE

      public SoE(short masterIndex, short slaveIndex)
  • 方法详细资料

    • getLastSoEError

      public EtherCATTypes.SoEError getLastSoEError()
      获取最后一次操作的SoE错误码
    • getProtocolType

      public byte getProtocolType()
      从接口复制的说明: IMailboxProtocol
      协议类型 (ECT_MBXT_*): AoE=0x01, EoE=0x02, CoE=0x03, FoE=0x04, SoE=0x05, FSoE=0x08, VoE=0x0F.
      Protocol type constant (ECT_MBXT_*).
      指定者:
      getProtocolType 在接口中 IMailboxProtocol
      返回:
      协议类型 0x05 (SoE).
    • getProtocolName

      public String getProtocolName()
      从接口复制的说明: IMailboxProtocol
      协议名称 ("CoE" / "FoE" / "SoE" / "AoE" / "EoE" / "VoE" / "FSoE").
      Protocol name literal.
      指定者:
      getProtocolName 在接口中 IMailboxProtocol
      返回:
      协议名称 "SoE".
    • isSupported

      public boolean isSupported()
      从站是否支持 SoE 邮箱协议.
      Whether the slave supports SoE.
      指定者:
      isSupported 在接口中 IMailboxProtocol
    • getLastStatus

      public MailboxStatus getLastStatus()
      从接口复制的说明: IMailboxProtocol
      最后一次邮箱事务的统一状态. 初始为 MailboxStatus.PENDING.
      Status of the most recent mailbox transaction; initial value is MailboxStatus.PENDING.
      指定者:
      getLastStatus 在接口中 IMailboxProtocol
      返回:
      最近一次邮箱事务状态.
    • getLastErrorCode

      public long getLastErrorCode()
      最近一次 SoE Error Code.
      Last SoE protocol error code.
      指定者:
      getLastErrorCode 在接口中 IMailboxProtocol
    • getStatistics

      public MailboxStatistics getStatistics()
      邮箱统计快照.
      Mailbox statistics snapshot.

      [审计补齐 roundSDKSAN2] 经真实导出的 native EcxMbxGetStats 拉取.

      指定者:
      getStatistics 在接口中 IMailboxProtocol
    • resetStatistics

      public void resetStatistics()
      重置邮箱统计.
      Reset mailbox statistics.

      [审计补齐 roundSDKSAN2] 真调 native EcxMbxResetStats 重置统计.

      指定者:
      resetStatistics 在接口中 IMailboxProtocol
    • Read

      public byte[] Read(short idn, byte elementFlags, int timeoutMs)
      读取 IDN 参数 (原始字节)
      参数:
      idn - IDN 编号
      elementFlags - 元素标志 (默认 0x40=读取值)
      timeoutMs - 超时 (毫秒)
    • Read

      public byte[] Read(short idn)
    • Write

      public boolean Write(short idn, byte[] data, byte elementFlags, int timeoutMs)
      写入 IDN 参数
    • Write

      public boolean Write(short idn, byte[] data)
    • defaultExecutor

      protected Executor defaultExecutor()
      默认 Executor, 子类或用户可覆盖以使用自定义线程池 (Default Executor, subclass or user can override for custom thread pool)
    • readAsync

      public CompletableFuture<byte[]> readAsync(short idn, byte elementFlags, int timeoutMs)
      异步读取 IDN (Asynchronously read IDN).
      参数:
      idn - IDN 编号 (IDN number)
      elementFlags - 元素标志 (element flags, default 0x40 = value)
      timeoutMs - 超时毫秒 (timeout ms)
      返回:
      包含响应字节的 CompletableFuture (CompletableFuture with response bytes)
      抛出:
      SoE.SoEProtocolException - 读取失败 (SoE read failure)
    • readAsync

      public CompletableFuture<byte[]> readAsync(short idn)
      异步读取 IDN (默认 elementFlags=0x40, 默认超时) (Async read IDN with default flags/timeout)
    • writeAsync

      public CompletableFuture<Boolean> writeAsync(short idn, byte[] data, byte elementFlags, int timeoutMs)
      异步写入 IDN (Asynchronously write IDN).
      参数:
      idn - IDN 编号 (IDN number)
      data - 数据字节 (payload bytes)
      elementFlags - 元素标志 (element flags)
      timeoutMs - 超时毫秒 (timeout ms)
      返回:
      成功为 true 的 CompletableFuture (CompletableFuture resolving to true on success)
      抛出:
      SoE.SoEProtocolException - 写入失败 (SoE write failure)
    • writeAsync

      public CompletableFuture<Boolean> writeAsync(short idn, byte[] data)
      异步写入 IDN (默认 elementFlags=0x40, 默认超时) (Async write IDN with default flags/timeout)
    • ReadInt16

      public Short ReadInt16(short idn, byte elementFlags, int timeoutMs)
    • ReadInt16

      public Short ReadInt16(short idn)
    • ReadInt32

      public Integer ReadInt32(short idn, byte elementFlags, int timeoutMs)
    • ReadInt32

      public Integer ReadInt32(short idn)
    • ReadUInt16

      public Integer ReadUInt16(short idn)
    • ReadUInt32

      public Long ReadUInt32(short idn)
    • ReadFloat

      public Float ReadFloat(short idn)
    • ReadDouble

      public Double ReadDouble(short idn)
    • ReadString

      public String ReadString(short idn)
    • ReadName

      public String ReadName(short idn, int timeoutMs)
      读取参数名称 (ElementFlag 0x02) (2026-05-08: 对齐 C# SoE.cs:554 严格 UTF-8 → ASCII → Latin-1 兜底)
    • ReadName

      public String ReadName(short idn)
    • ReadUnit

      public String ReadUnit(short idn, int timeoutMs)
      读取参数单位 (ElementFlag 0x08) (2026-05-08: 对齐 C# SoE.cs:564 严格 UTF-8 → ASCII → Latin-1 兜底)
    • ReadUnit

      public String ReadUnit(short idn)
    • ReadMinValue

      public byte[] ReadMinValue(short idn)
      读取最小值 (ElementFlag 0x10)
    • ReadMaxValue

      public byte[] ReadMaxValue(short idn)
      读取最大值 (ElementFlag 0x20)
    • ReadDefaultValue

      public byte[] ReadDefaultValue(short idn)
      读取默认值 (ElementFlag 0x80)
    • WriteInt16

      public boolean WriteInt16(short idn, short value)
    • WriteInt32

      public boolean WriteInt32(short idn, int value)
    • WriteUInt16

      public boolean WriteUInt16(short idn, int value)
    • WriteUInt32

      public boolean WriteUInt32(short idn, long value)
    • ExecuteCommand

      public boolean ExecuteCommand(short idn, int timeoutMs, int pollIntervalMs)
      执行 SoE 程序命令 (SERCOS Procedure Command)
      参数:
      idn - 命令 IDN 编号
      timeoutMs - 超时 (毫秒)
      pollIntervalMs - 轮询间隔 (毫秒)
      返回:
      是否成功
    • ExecuteCommand

      public boolean ExecuteCommand(short idn)
    • GetAvailableIDNs

      public List<Short> GetAvailableIDNs(int timeoutMs)
      获取该驱动器支持的所有 IDN 列表
    • GetAvailableIDNs

      public List<Short> GetAvailableIDNs()
    • GetParameterInfo

      public SoE.SoEParameter GetParameterInfo(short idn, int timeoutMs)
      获取指定 IDN 的详细参数信息
    • GetParameterInfo

      public SoE.SoEParameter GetParameterInfo(short idn)
    • ReadDataState

      public Integer ReadDataState(short idn, int timeoutMs)
      读取 IDN 的 Data State (Element 0x01)
    • ReadDataState

      public Integer ReadDataState(short idn)
    • GetIDNMapping

      public SoE.ServoMappingInfo GetIDNMapping(int timeoutMs)
      读取 AT/MDT 映射配置
    • GetIDNMapping

      public SoE.ServoMappingInfo GetIDNMapping()
    • GetAllDriveMappings

      public Map<Byte,SoE.ServoMappingInfo> GetAllDriveMappings(int timeoutMs)
      获取所有驱动器的映射
    • GetAllDriveMappings

      public Map<Byte,SoE.ServoMappingInfo> GetAllDriveMappings()
    • addNotificationListener

      public void addNotificationListener(SoE.NotificationListener listener)
      注册通知监听器
    • addEmergencyListener

      public void addEmergencyListener(SoE.SoEEmergencyListener listener)
      [2026-04-24 C# Sync] 注册 SoE Emergency 监听器 (OpCode=6).
      Register an SoE Emergency listener (dispatched from DLL OpCode=6).
    • removeEmergencyListener

      public void removeEmergencyListener(SoE.SoEEmergencyListener listener)
      移除 SoE Emergency 监听器 / remove an Emergency listener.
    • dispatchHardwareNotification

      public void dispatchHardwareNotification(short idn, byte elementFlags, byte[] newValue)
      硬件 Notification 分发入口 / hardware Notification dispatch entry. 由 MasterEvents 在 DLL 回调线程上调用, 将事件投递到已注册监听器.
      Called by MasterEvents from the native callback thread; forwards to registered notification listeners.
    • dispatchHardwareEmergency

      public void dispatchHardwareEmergency(short errorCode)
      硬件 Emergency 分发入口 / hardware Emergency dispatch entry. 由 MasterEvents 在 DLL OpCode=6 回调时调用.
      Called by MasterEvents on DLL OpCode=6 callback.
    • EnableNotification

      public boolean EnableNotification(short idn, int timeoutMs)
      启用指定 IDN 的参数变化通知
    • EnableNotification

      public boolean EnableNotification(short idn)
    • DisableNotification

      public void DisableNotification(short idn)
      禁用指定 IDN 的通知
    • DisableAllNotifications

      public void DisableAllNotifications()
      禁用所有通知
    • GetMonitoredIDNs

      public List<Short> GetMonitoredIDNs()
      获取正在监控的 IDN 列表
    • PollNotifications

      public int PollNotifications(int timeoutMs)
      轮询检测已监控 IDN 的变化
      返回:
      检测到变化的数量
    • PollNotifications

      public int PollNotifications()
    • ReadAllParameters

      public List<SoE.SoEParameter> ReadAllParameters()
      批量读取常见 SoE 参数 遍历标准 Sercos IDN 子集,跳过读取失败的条目
      返回:
      成功读取到的参数列表
    • ReadAllParameters

      public List<SoE.SoEParameter> ReadAllParameters(int timeoutMs)
      批量读取常见 SoE 参数
      参数:
      timeoutMs - 每个 IDN 的读取超时 (毫秒)
      返回:
      成功读取到的参数列表
    • ReadParameter

      public SoE.SoEParameter ReadParameter(short idn)
      读取单个 SoE 参数的元信息与当前值
      参数:
      idn - 参数 IDN
      返回:
      SoEParameter 实例
    • ReadParameter

      public SoE.SoEParameter ReadParameter(short idn, int timeoutMs)
      读取单个 SoE 参数的元信息与当前值
      参数:
      idn - 参数 IDN
      timeoutMs - 超时 (毫秒)
      返回:
      SoEParameter 实例
    • WriteParameter

      public boolean WriteParameter(short idn, byte[] value)
      写入 SoE 参数
      参数:
      idn - 参数 IDN
      value - 要写入的字节数据
      返回:
      写入成功返回 true
    • WriteParameter

      public boolean WriteParameter(short idn, byte[] value, int timeoutMs)
      写入 SoE 参数
      参数:
      idn - 参数 IDN
      value - 要写入的字节数据
      timeoutMs - 超时 (毫秒)
      返回:
      写入成功返回 true
    • FormatByteArray

      public static String FormatByteArray(byte[] data)
      字节数组格式化为十六进制字符串 对应 C# FormatByteArray
      参数:
      data - 字节数组
      返回:
      格式化后的十六进制字符串
    • encodeIdn

      public static short encodeIdn(boolean isStandard, byte parameterSet, short dataBlock)
      将 (Standard?, Set, Block) 三元组编码为 16 位 IDN (对齐 DLL SoEIdnEncode).
      Encode (Standard?, Set, Block) into a 16-bit SERCOS IDN.
      参数:
      isStandard - true = S-x-xxxx 标准 IDN, false = P-x-xxxx 厂商 IDN
      parameterSet - 参数集 0..7 (3 bit)
      dataBlock - 数据块编号 0..4095 (12 bit)
      返回:
      16 位 IDN, 与 DLL SoEIdnEncode 输出完全一致
    • decodeIdn

      public static SoE.IdnTriple decodeIdn(short idn)
      将 16 位 IDN 解码为 (Standard?, Set, Block) 三元组 (对齐 DLL SoEIdnDecode).
      Decode a 16-bit SERCOS IDN.
    • tryParseSercosIdn

      public static Short tryParseSercosIdn(String text)
      解析 SERCOS IDN 字符串 ("S-0-0040" / "P-1-0123") 为 16 位 IDN.
      Parse a SERCOS IDN string. Returns null on malformed input.
    • FormatByteArray

      public static String FormatByteArray(byte[] data, int dataType)
      根据数据类型智能格式化字节数组
      参数:
      data - 字节数组
      dataType - 0=Binary, 1=UInt, 2=Int, 3=Hex, 4=String, 6=Float
      返回:
      格式化字符串