类 FoE

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

public class FoE extends Object implements IMailboxProtocol
FoE (File over EtherCAT) 完整实现 对齐 C# FoEInstance: 文件下载/上传、CRC 校验、进度回调、包数量估算
  • 构造器详细资料

    • FoE

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

    • getLastError

      public EtherCATTypes.FoEErrorCode getLastError()
      获取最后一次操作的FoE错误码
    • 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
      返回:
      协议类型 0x04 (FoE).
    • getProtocolName

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

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

      public static EtherCATTypes.FoEErrorCode mapDllFoEError(int dllErrorCode)
      将DLL错误码映射到FoE错误码
    • DefaultTimeoutMs

      public int DefaultTimeoutMs()
    • DefaultTimeoutMs

      public void DefaultTimeoutMs(int value)
    • DefaultPassword

      public int DefaultPassword()
    • DefaultPassword

      public void DefaultPassword(int value)
    • EnableProgressHook

      public void EnableProgressHook(FoE.ProgressCallback callback, int estimatedTotalPackets)
      设置进度回调
    • DisableProgressHook

      public void DisableProgressHook()
      禁用进度回调
    • setBusyHook

      public void setBusyHook(FoE.FoEBusyListener listener)
      设置 FoE BUSY 回调 / install FoE BUSY hook.
      对齐 C# FoEInstance.EnableProgressHook 中 FOESetBusyHook 部分.
      参数:
      listener - BUSY 监听器; 传 null 则禁用 / pass null to clear the hook.
    • cancel

      public boolean cancel()
      请求取消当前 FoE 传输 / request cancellation of the current FoE transfer. 透传 DLL FOERequestCancel, native 主循环下一次迭代退出.
      Sets the DLL cancel flag; the ongoing transfer bails out at the next iteration of the internal loop.
      返回:
      true=DLL 接受取消请求 / true if the DLL accepted the cancel request.
    • clearCancel

      public boolean clearCancel()
      清除 FoE 取消标志 / clear the FoE cancel flag. 通常由 Read/Write 入口自动清零, 仅异常复位时调用.
      Normally cleared automatically by Read/Write entry points; use only for manual reset paths.
    • Download

      public byte[] Download(String filename, Integer password, Integer timeoutMs)
      从从站设备下载(读取)文件
      参数:
      filename - 文件名
      password - 密码, null 使用默认值
      timeoutMs - 超时, null 使用默认值
      返回:
      文件内容, 失败返回 null
    • Download

      public byte[] Download(String filename, Integer password, Integer timeoutMs, boolean enableCrc)
      从从站设备下载(读取)文件 (支持 CRC 校验) 对齐 C# FoEInstance.Download(enableCrc)
      参数:
      filename - 文件名
      password - 密码, null 使用默认值
      timeoutMs - 超时, null 使用默认值
      enableCrc - 是否启用 CRC 校验
      返回:
      文件内容, 失败返回 null
    • Download

      public byte[] Download(String filename)
    • DownloadWithCrc

      public byte[] DownloadWithCrc(String filename)
      带 CRC 校验的文件下载便捷方法
    • DownloadWithCrc

      public byte[] DownloadWithCrc(String filename, Integer password, Integer timeoutMs)
      带 CRC 校验的文件下载
    • Upload

      public boolean Upload(String filename, byte[] fileData, Integer password, Integer timeoutMs)
      上传(写入)文件到从站设备
    • Upload

      public boolean Upload(String filename, byte[] fileData, Integer password, Integer timeoutMs, boolean enableCrc)
      上传(写入)文件到从站设备 (支持 CRC 校验) 对齐 C# FoEInstance.Upload(enableCrc)
      参数:
      filename - 文件名
      fileData - 文件内容
      password - 密码, null 使用默认值
      timeoutMs - 超时, null 使用默认值
      enableCrc - 是否启用 CRC 校验
      返回:
      成功返回 true
    • Upload

      public boolean Upload(String filename, byte[] fileData)
    • UploadWithCrc

      public boolean UploadWithCrc(String filename, byte[] fileData)
      带 CRC 校验的文件上传便捷方法
    • UploadWithCrc

      public boolean UploadWithCrc(String filename, byte[] fileData, Integer password, Integer timeoutMs)
      带 CRC 校验的文件上传
    • EstimatePacketCount

      public int EstimatePacketCount(int fileSize, int mailboxSize)
      估算文件传输所需的数据包数量
    • EstimatePacketCount

      public int EstimatePacketCount(int fileSize)
    • defaultExecutor

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

      public CompletableFuture<byte[]> downloadAsync(String filename, Integer password, Integer timeoutMs)
      异步从从站下载文件 (Asynchronously download file from slave).
      参数:
      filename - 文件名 (remote filename)
      password - 密码, null 使用默认 (password, null = default)
      timeoutMs - 超时毫秒, null 使用默认 (timeout ms, null = default)
      返回:
      包含文件字节的 CompletableFuture (CompletableFuture with file bytes)
      抛出:
      FoE.FoEProtocolException - 下载失败 (FoE protocol failure)
    • downloadAsync

      public CompletableFuture<byte[]> downloadAsync(String filename)
      异步下载文件 (默认密码/超时) (Async download with default password/timeout)
    • uploadAsync

      public CompletableFuture<Boolean> uploadAsync(String filename, byte[] fileData, Integer password, Integer timeoutMs)
      异步上传文件到从站 (Asynchronously upload file to slave).
      参数:
      filename - 文件名 (remote filename)
      fileData - 文件内容 (file bytes)
      password - 密码, null 使用默认 (password, null = default)
      timeoutMs - 超时毫秒, null 使用默认 (timeout ms, null = default)
      返回:
      成功为 true 的 CompletableFuture (CompletableFuture resolving to true on success)
      抛出:
      FoE.FoEProtocolException - 上传失败 (FoE protocol failure)
    • uploadAsync

      public CompletableFuture<Boolean> uploadAsync(String filename, byte[] fileData)
      异步上传文件 (默认密码/超时) (Async upload with default password/timeout)
    • getErrorDescription

      public static String getErrorDescription(EtherCATTypes.FoEErrorCode errorCode)
      获取 FoE 错误代码的中文描述文本 (对齐 C# GetErrorDescription)
      参数:
      errorCode - 错误代码
      返回:
      错误描述字符串