类的使用
com.darra.ethercat.master.EtherCATMaster
使用EtherCATMaster的程序包
程序包
说明
-
com.darra.ethercat.master中EtherCATMaster的使用
修饰符和类型方法说明static EtherCATMasterEtherCATMaster.create()创建并初始化主站 (自动分配编号)static EtherCATMasterEtherCATMaster.create(short masterIndex) 创建并初始化指定编号的主站static EtherCATMasterEtherCATMaster.createFromJson(String jsonConfig) 一步初始化: JSON 配置 -> 创建主站static EtherCATMasterEtherCATMaster.createFromJsonFile(String jsonFilePath) 一步初始化: 从 JSON 文件EtherCATMaster.enableAutoStartup()启用自动启动配置 (Build 时执行) 已有启动参数的从站 (ENI/DENI 已配置) 会被跳过, 仅对未配置的从站生效。设置 ENI/DENI 配置文件路径 (延迟配置, Build 时生效) 对应 C# SetENI()EtherCATMaster.setEsiFile(String path) 设置单个 ESI 文件路径 (延迟配置, Build 时生效) 可多次调用添加多个 ESI 文件 对应 C# SetEsiFile()EtherCATMaster.setEsiFiles(String path) 设置 ESI 文件目录路径 (延迟配置, Build 时生效) 加载目录下所有 ESI 文件。EtherCATMaster.SetNetwork(String primary) 设置网络适配器 (无冗余, C# SetNetwork 对应)EtherCATMaster.SetNetwork(String primary, String secondary) 设置网络适配器 (C# SetNetwork 对应)参数类型为EtherCATMaster的com.darra.ethercat.master中的构造器限定符构造器说明BuildResult(boolean success, int slaveCount, short masterIndex, String message, EtherCATMaster master) EventsEmcyRecorder(EtherCATMaster master) 创建 EMCY 记录器 -
com.darra.ethercat.slave中EtherCATMaster的使用
参数类型为EtherCATMaster的com.darra.ethercat.slave中的构造器 -
com.darra.ethercat.sugar中EtherCATMaster的使用
参数类型为EtherCATMaster的com.darra.ethercat.sugar中的方法修饰符和类型方法说明static booleanSlaveListExt.allInState(EtherCATMaster master, EcState state) 全网从站是否都进入了指定状态.static booleanSlaveListExt.anyInState(EtherCATMaster master, EcState state) 是否存在任意从站处于指定状态.static CompletableFuture<Integer> MasterAsync.applyStartupParametersAsync(EtherCATMaster master, byte transition, byte timing) 异步对所有从站应用启动参数.static DiagnosticQueueDiagnosticQueue.attach(EtherCATMaster master, int capacity) 创建并注册到 master.static SlaveStateQueueSlaveStateQueue.attach(EtherCATMaster master, int capacity) 创建并注册到 master, 满了丢弃最早.static DiagnosticQueueDiagnosticQueue.attachStrict(EtherCATMaster master, int capacity) 创建并注册到 master.static CompletableFuture<Boolean> MasterAsync.bootToOpAsync(EtherCATMaster master, String primary, String secondary) 一键启动: 网卡 -> OP -> PDO.static CompletableFuture<Integer> MasterAsync.configureDCAllAsync(EtherCATMaster master, int sync0Ns, int sync1Ns) 异步配置 DC 全网.static longSlaveListExt.countByState(EtherCATMaster master, EcState state) 处于指定状态的从站数.static longSlaveListExt.dcCapableCount(EtherCATMaster master) 支持 DC 的从站数.MasterStreams.dcCapableSlaves(EtherCATMaster master) 过滤所有支持 DC 的从站.MasterStreams.findByConfigAddr(EtherCATMaster master, short configAddr) 按配置地址查找 (config_addr 在 EtherCAT 网络上唯一).MasterStreams.findByIdentity(EtherCATMaster master, int vendorId, int productCode) 按 (vendorId, productCode) 查找首个从站.MasterStreams.findByName(EtherCATMaster master, String name) 按名称 (精确等于) 查找首个匹配从站.static booleanSlaveListExt.hasLostSlave(EtherCATMaster master) 是否存在丢失从站.static List<SlaveIdentity> SlaveListExt.identities(EtherCATMaster master) 一次性抓取全网身份快照.static longSlaveListExt.lostCount(EtherCATMaster master) 丢失从站数.MasterStreams.lostSlaves(EtherCATMaster master) 过滤已经丢失/掉线的从站.static MasterScopeMasterScope.of(EtherCATMaster master) 包装一个已经 build 完成的 master.static CompletableFuture<Boolean> MasterAsync.setNetworkAsync(EtherCATMaster master, String primary, String secondary) 异步设置网卡.static CompletableFuture<Boolean> MasterAsync.setStateAsync(EtherCATMaster master, EcState state) 异步设置主站状态.static CompletableFuture<Boolean> MasterAsync.setStateAsync(EtherCATMaster master, EcState state, Duration timeout) 带超时的异步设置主站状态.MasterStreams.slaveOpt(EtherCATMaster master, int slaveIndex) 安全获取指定 1-based 编号的从站, 返回Optional.MasterStreams.slaves(EtherCATMaster master) 从 Master 获取从站 Stream.MasterStreams.slavesAsMap(EtherCATMaster master) 把所有从站按 1-based 序号组织成Map, 适合需要 O(1) 随机访问的场景.static NavigableMap<Integer, Slave> MasterStreams.slavesAsNavigableMap(EtherCATMaster master) 按 1-based 序号排序的 NavigableMap, 支持 firstKey/lastKey/floor/ceiling.MasterStreams.slavesByGroup(EtherCATMaster master) 按 Group 字节分组.MasterStreams.slavesByName(EtherCATMaster master, String namePart) 过滤包含指定子串的从站名 (大小写敏感).MasterStreams.slavesByState(EtherCATMaster master) 按 EcState 分组, 用于一次性诊断 "网络上有多少从站卡在哪个状态".MasterStreams.slavesByVendor(EtherCATMaster master, int vendorId) 过滤指定 VendorId 的从站.MasterStreams.slavesByVendorId(EtherCATMaster master) 按 vendorId 分组.MasterStreams.slavesInState(EtherCATMaster master, EcState state) 过滤指定 EtherCAT 状态的从站.MasterStreams.slavesNotInState(EtherCATMaster master, EcState state) 过滤**不在**指定状态的从站.SlaveListExt.sortedByConfigAddr(EtherCATMaster master) 按 ConfigAddr 升序排列, 适合按物理拓扑顺序枚举.SlaveListExt.sortedBySlaveNum(EtherCATMaster master) 按从站 1-based 序号排序的 List 副本 (主线已经按序号顺序, 这里 explicit 一次).SlaveListExt.sortedByVendorThenIndex(EtherCATMaster master) 按 VendorId 排序后再按序号排序 (混合多厂商场景, 同厂商排一起).MasterStreams.stateCounts(EtherCATMaster master) 按 EcState 计数.static Slave[]SlaveListExt.toArray(EtherCATMaster master) 拍快照成Slave[](跨线程安全 — 主线 List 是 Collections.unmodifiableList). -
com.darra.ethercat.utils中EtherCATMaster的使用
参数类型为EtherCATMaster的com.darra.ethercat.utils中的方法修饰符和类型方法说明static intEsiManager.applyAllSlaves(EtherCATMaster master) 自动给主站下所有从站匹配 ESI 并绑定 (对齐 DLL EcEsi_ApplyAllSlaves)static booleanXml.ApplyXMLConfiguration(Xml.MasterXMLConfiguration config, EtherCATMaster master) 将 XML 配置应用到主站 (对应 C# ApplyXMLConfiguration)static intEsiManager.bindToSlave(EtherCATMaster master, int slaveIndex, String filePath) 给单个从站绑定 ESI 文件 (对齐 DLL EcEsi_BindToSlave)static booleanEni.saveENI(EtherCATMaster master, String filePath) 保存 ENI 文件 (基于运行时主站, managed XML 生成, 对齐 C# SaveENI(DarraEtherCAT, string)).StartupConfigurationVerifier.verifyAll(EtherCATMaster master) 验证所有从站的启动配置StartupConfigurationVerifier.verifyConfiguration(EtherCATMaster master, List<StartupConfigurationVerifier.ExpectedSlaveConfig> expectedConfigs, boolean strictMode) 验证主站配置是否与预期配置匹配