类 AoE

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

public class AoE extends Object implements IMailboxProtocol
AoE (ADS over EtherCAT) 完整实现 对齐 C# AoEInstance: Read/Write/ReadWrite/SendCommand + 订阅管理 + SetConfig/GetConfig
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static class 
    ADS 状态结果
    static class 
    AoE 配置结果
    static class 
    AoE 协议异常 (AoE protocol exception).
    static enum 
    AoE 结果错误码 (ETG.1020 Table 16, 对齐 C# AoEResultCode).
    static class 
    设备信息结果
    static interface 
    订阅回调接口
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final int
    CoE (CANopen over EtherCAT) 路由 IndexGroup
    static final int
    SoE (Servo over EtherCAT) 路由 IndexGroup
  • 构造器概要

    构造器
    构造器
    说明
    AoE(short masterIndex, short slaveIndex)
     
  • 方法概要

    修饰符和类型
    方法
    说明
    protected Executor
    默认 Executor, 子类或用户可覆盖以使用自定义线程池 (Default Executor, subclass or user can override for custom thread pool)
    int[]
    获取所有活跃的 AoE 订阅列表 对应 C# GetActiveSubscriptions
    static String
    GetAdsStateDescription(int adsState)
    ADS 状态码描述 对应 C# GetAdsStateDescription
    获取 AoE 配置 (NetId 和 Port) 对齐 C# AoEInstance.GetConfig
    long
    最近一次 AoE/ADS 错误码.
    最后一次邮箱事务的统一状态.
    协议名称 ("CoE" / "FoE" / "SoE" / "AoE" / "EoE" / "VoE" / "FSoE").
    byte
    协议类型 (ECT_MBXT_*): AoE=0x01, EoE=0x02, CoE=0x03, FoE=0x04, SoE=0x05, FSoE=0x08, VoE=0x0F.
    邮箱统计快照.
    boolean
    InitializeSlaveNetId(byte[] netId)
     
    boolean
    InitializeSlaveNetId(byte[] netId, int timeoutUs)
    初始化从站 AoE Net ID (ETG.1020 §9.4) 在 IP→PreOp 状态切换期间调用,将 Net ID 写入从站 ADS 路由表。
    boolean
    从站是否支持 AoE 邮箱协议.
    byte[]
    Read(int indexGroup, int indexOffset, int length)
     
    byte[]
    Read(int indexGroup, int indexOffset, int length, int timeoutUs)
    便捷读操作
    readAsync(int indexGroup, int indexOffset, int length)
    异步 ADS 读取 (默认超时) (Async ADS read with default timeout)
    readAsync(int indexGroup, int indexOffset, int length, int timeoutUs)
    异步 ADS 读取 (Asynchronously ADS read).
    byte[]
    ReadCoEViaAoE(int index, int subindex, int readLength)
     
    byte[]
    ReadCoEViaAoE(int index, int subindex, int readLength, int timeoutUs)
    通过 AoE 路由读取 CoE 对象 (IndexGroup=0xF302) IndexOffset 编码: (index 无效输入:'<'无效输入:'<' 16) | subindex
     
    ReadDeviceInfo(int timeoutUs)
    读取设备信息 (Command 0x01)
    byte[]
    ReadSoEViaAoE(int idn, int readLength)
     
    byte[]
    ReadSoEViaAoE(int idn, int readLength, int timeoutUs)
    通过 AoE 路由读取 SoE IDN (IndexGroup=0xF420) IndexOffset 编码: IDN 编号
     
    ReadState(int timeoutUs)
    读取 ADS 状态 (Command 0x04)
    byte[]
    ReadWrite(int indexGroup, int indexOffset, int readLength, byte[] writeData, int timeoutUs)
    ADS ReadWrite 操作
    readWriteAsync(int indexGroup, int indexOffset, int readLength, byte[] writeData, int timeoutUs)
    异步 ADS ReadWrite (Asynchronously ADS read-write).
    void
    重置邮箱统计.
    byte[]
    SendCommand(short targetPort, short commandId, byte[] commandData, int timeoutUs)
    发送 ADS 命令
    boolean
    SetConfig(byte[] targetNetId, short targetPort, byte[] sourceNetId, short sourcePort)
    设置 AoE 配置 (NetId 和 Port) 对齐 C# AoEInstance.SetConfig
    int
    Subscribe(int indexGroup, int indexOffset, int dataLength, AoE.NotificationCallback callback, int cycleTimeMs)
    添加通知订阅
    boolean
    Unsubscribe(int handle)
    取消订阅
    void
    取消所有订阅
    boolean
    Write(int indexGroup, int indexOffset, byte[] data)
     
    boolean
    Write(int indexGroup, int indexOffset, byte[] data, int timeoutUs)
    便捷写操作
    writeAsync(int indexGroup, int indexOffset, byte[] data)
    异步 ADS 写入 (默认超时) (Async ADS write with default timeout)
    writeAsync(int indexGroup, int indexOffset, byte[] data, int timeoutUs)
    异步 ADS 写入 (Asynchronously ADS write).
    boolean
    WriteCoEViaAoE(int index, int subindex, byte[] data)
     
    boolean
    WriteCoEViaAoE(int index, int subindex, byte[] data, int timeoutUs)
    通过 AoE 路由写入 CoE 对象 (IndexGroup=0xF302) IndexOffset 编码: (index 无效输入:'<'无效输入:'<' 16) | subindex
    boolean
    WriteControl(short adsState, short deviceState)
     
    boolean
    WriteControl(short adsState, short deviceState, byte[] data, int timeoutUs)
    写入控制命令 (Command 0x05)
    boolean
    WriteSoEViaAoE(int idn, byte[] data)
     
    boolean
    WriteSoEViaAoE(int idn, byte[] data, int timeoutUs)
    通过 AoE 路由写入 SoE IDN (IndexGroup=0xF420) IndexOffset 编码: IDN 编号

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • COE_INDEX_GROUP

      public static final int COE_INDEX_GROUP
      CoE (CANopen over EtherCAT) 路由 IndexGroup
      另请参阅:
    • SOE_INDEX_GROUP

      public static final int SOE_INDEX_GROUP
      SoE (Servo over EtherCAT) 路由 IndexGroup
      另请参阅:
  • 构造器详细资料

    • AoE

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

    • 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
      返回:
      协议类型 0x01 (AoE).
    • getProtocolName

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

      public boolean isSupported()
      从站是否支持 AoE 邮箱协议.
      Whether the slave supports AoE.
      指定者:
      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()
      最近一次 AoE/ADS 错误码.
      Last AoE/ADS 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
    • ReadWrite

      public byte[] ReadWrite(int indexGroup, int indexOffset, int readLength, byte[] writeData, int timeoutUs)
      ADS ReadWrite 操作
      参数:
      indexGroup - 索引组
      indexOffset - 索引偏移
      readLength - 读取长度 (0=纯写入)
      writeData - 写入数据 (null=只读)
      timeoutUs - 超时 (微秒)
      返回:
      读取数据, 失败返回 null
    • Read

      public byte[] Read(int indexGroup, int indexOffset, int length, int timeoutUs)
      便捷读操作
    • Read

      public byte[] Read(int indexGroup, int indexOffset, int length)
    • Write

      public boolean Write(int indexGroup, int indexOffset, byte[] data, int timeoutUs)
      便捷写操作
    • Write

      public boolean Write(int indexGroup, int indexOffset, byte[] data)
    • defaultExecutor

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

      public CompletableFuture<byte[]> readAsync(int indexGroup, int indexOffset, int length, int timeoutUs)
      异步 ADS 读取 (Asynchronously ADS read).
      参数:
      indexGroup - 索引组 (index group)
      indexOffset - 索引偏移 (index offset)
      length - 读取长度 (length in bytes)
      timeoutUs - 超时微秒 (timeout in microseconds)
      返回:
      包含响应字节的 CompletableFuture (CompletableFuture with response bytes)
      抛出:
      AoE.AoEProtocolException - 读取失败 (AoE read failure)
    • readAsync

      public CompletableFuture<byte[]> readAsync(int indexGroup, int indexOffset, int length)
      异步 ADS 读取 (默认超时) (Async ADS read with default timeout)
    • writeAsync

      public CompletableFuture<Boolean> writeAsync(int indexGroup, int indexOffset, byte[] data, int timeoutUs)
      异步 ADS 写入 (Asynchronously ADS write).
      参数:
      indexGroup - 索引组 (index group)
      indexOffset - 索引偏移 (index offset)
      data - 数据字节 (payload bytes)
      timeoutUs - 超时微秒 (timeout in microseconds)
      返回:
      成功为 true 的 CompletableFuture (CompletableFuture resolving to true on success)
      抛出:
      AoE.AoEProtocolException - 写入失败 (AoE write failure)
    • writeAsync

      public CompletableFuture<Boolean> writeAsync(int indexGroup, int indexOffset, byte[] data)
      异步 ADS 写入 (默认超时) (Async ADS write with default timeout)
    • readWriteAsync

      public CompletableFuture<byte[]> readWriteAsync(int indexGroup, int indexOffset, int readLength, byte[] writeData, int timeoutUs)
      异步 ADS ReadWrite (Asynchronously ADS read-write).
      参数:
      indexGroup - 索引组 (index group)
      indexOffset - 索引偏移 (index offset)
      readLength - 读取长度 (read length, 0 = write-only)
      writeData - 写入数据 (write payload, null = read-only)
      timeoutUs - 超时微秒 (timeout in microseconds)
      返回:
      包含读取响应字节的 CompletableFuture (CompletableFuture with read response bytes)
      抛出:
      AoE.AoEProtocolException - 操作失败 (AoE read-write failure)
    • ReadCoEViaAoE

      public byte[] ReadCoEViaAoE(int index, int subindex, int readLength, int timeoutUs)
      通过 AoE 路由读取 CoE 对象 (IndexGroup=0xF302) IndexOffset 编码: (index 无效输入:'<'无效输入:'<' 16) | subindex
      参数:
      index - CoE 对象索引
      subindex - CoE 子索引
      readLength - 期望读取长度
      timeoutUs - 超时 (微秒)
      返回:
      读取数据, 失败返回 null
    • ReadCoEViaAoE

      public byte[] ReadCoEViaAoE(int index, int subindex, int readLength)
    • WriteCoEViaAoE

      public boolean WriteCoEViaAoE(int index, int subindex, byte[] data, int timeoutUs)
      通过 AoE 路由写入 CoE 对象 (IndexGroup=0xF302) IndexOffset 编码: (index 无效输入:'<'无效输入:'<' 16) | subindex
      参数:
      index - CoE 对象索引
      subindex - CoE 子索引
      data - 写入数据
      timeoutUs - 超时 (微秒)
      返回:
      是否成功
    • WriteCoEViaAoE

      public boolean WriteCoEViaAoE(int index, int subindex, byte[] data)
    • ReadSoEViaAoE

      public byte[] ReadSoEViaAoE(int idn, int readLength, int timeoutUs)
      通过 AoE 路由读取 SoE IDN (IndexGroup=0xF420) IndexOffset 编码: IDN 编号
      参数:
      idn - SoE IDN 编号
      readLength - 期望读取长度
      timeoutUs - 超时 (微秒)
      返回:
      读取数据, 失败返回 null
    • ReadSoEViaAoE

      public byte[] ReadSoEViaAoE(int idn, int readLength)
    • WriteSoEViaAoE

      public boolean WriteSoEViaAoE(int idn, byte[] data, int timeoutUs)
      通过 AoE 路由写入 SoE IDN (IndexGroup=0xF420) IndexOffset 编码: IDN 编号
      参数:
      idn - SoE IDN 编号
      data - 写入数据
      timeoutUs - 超时 (微秒)
      返回:
      是否成功
    • WriteSoEViaAoE

      public boolean WriteSoEViaAoE(int idn, byte[] data)
    • InitializeSlaveNetId

      public boolean InitializeSlaveNetId(byte[] netId, int timeoutUs)
      初始化从站 AoE Net ID (ETG.1020 §9.4) 在 IP→PreOp 状态切换期间调用,将 Net ID 写入从站 ADS 路由表。 写入 IndexGroup=1, IndexOffset=3。
      参数:
      netId - 6 字节的 AMS Net ID
      timeoutUs - 超时 (微秒)
      返回:
      是否成功
    • InitializeSlaveNetId

      public boolean InitializeSlaveNetId(byte[] netId)
    • SendCommand

      public byte[] SendCommand(short targetPort, short commandId, byte[] commandData, int timeoutUs)
      发送 ADS 命令
    • ReadDeviceInfo

      public AoE.DeviceInfo ReadDeviceInfo(int timeoutUs)
      读取设备信息 (Command 0x01)
    • ReadDeviceInfo

      public AoE.DeviceInfo ReadDeviceInfo()
    • ReadState

      public AoE.AdsState ReadState(int timeoutUs)
      读取 ADS 状态 (Command 0x04)
    • ReadState

      public AoE.AdsState ReadState()
    • WriteControl

      public boolean WriteControl(short adsState, short deviceState, byte[] data, int timeoutUs)
      写入控制命令 (Command 0x05)
    • WriteControl

      public boolean WriteControl(short adsState, short deviceState)
    • SetConfig

      public boolean SetConfig(byte[] targetNetId, short targetPort, byte[] sourceNetId, short sourcePort)
      设置 AoE 配置 (NetId 和 Port) 对齐 C# AoEInstance.SetConfig
      参数:
      targetNetId - 目标 AMS NetId (6 字节)
      targetPort - 目标 AMS Port
      sourceNetId - 源 AMS NetId (6 字节)
      sourcePort - 源 AMS Port
      返回:
      成功返回 true
    • GetConfig

      public AoE.AoEConfig GetConfig()
      获取 AoE 配置 (NetId 和 Port) 对齐 C# AoEInstance.GetConfig
      返回:
      配置信息, 失败时 Success=false
    • Subscribe

      public int Subscribe(int indexGroup, int indexOffset, int dataLength, AoE.NotificationCallback callback, int cycleTimeMs)
      添加通知订阅
      参数:
      indexGroup - 索引组
      indexOffset - 索引偏移
      dataLength - 数据长度
      callback - 回调
      返回:
      通知句柄, 失败返回 -1
    • Unsubscribe

      public boolean Unsubscribe(int handle)
      取消订阅
    • UnsubscribeAll

      public void UnsubscribeAll()
      取消所有订阅
    • GetActiveSubscriptions

      public int[] GetActiveSubscriptions()
      获取所有活跃的 AoE 订阅列表 对应 C# GetActiveSubscriptions
      返回:
      活跃订阅数组
    • GetAdsStateDescription

      public static String GetAdsStateDescription(int adsState)
      ADS 状态码描述 对应 C# GetAdsStateDescription
      参数:
      adsState - ADS 状态码
      返回:
      状态描述字符串