枚举的使用
com.darra.ethercat.data.EcState
使用EcState的程序包
程序包
说明
-
com.darra.ethercat.data中EcState的使用
修饰符和类型方法说明EcState.Status.baseState()获取基础状态 (低 4 位, 不含 Error 标志)static EcStateEcState.fromValue(int val) 从数值转换为基础状态枚举 (**不保留 Error 位**, 仅返回低 4 位对应的基础状态).EcatSlaveDiag.EcAlStatusMirror.getAlState()AL State 基础枚举 (低字节低 4 位, 不含 Error 标志)static EcState返回带有指定名称的该类型的枚举常量。static EcState[]EcState.values()返回包含该枚举类型的常量的数组, 顺序与声明这些常量的顺序相同 -
com.darra.ethercat.master中EcState的使用
修饰符和类型方法说明State.getState()获取当前主站 EtherCAT 状态EtherCATMaster.State()获取主站 EtherCAT 状态 (C# State 对应)参数类型为EcState的com.darra.ethercat.master中的方法修饰符和类型方法说明static intState.getStateLevel(EcState state) 获取状态级别 (用于比较状态优先级)static booleanState.isStateCompatible(EcState current, EcState required) 判断当前状态是否满足要求voidMasterEvents.SlaveStateChangedListener.onSlaveStateChanged(short masterIndex, short slaveIndex, EcState oldState, EcState newState) voidMasterEvents.StateChangedListener.onStateChanged(EcState oldState, EcState newState) boolean切换 EtherCAT 主站状态.boolean设置主站状态 (阻塞, 等待转换完成)void设置主站状态 (C# SetState 对应)EtherCATMaster.setStateAsync(EcState state) 异步版 setState, 不阻塞调用线程.EtherCATMaster.setStateAsync(EcState state, Consumer<String> progress) 异步版 setState (带进度回调), 不阻塞调用线程, 经主站串行闸排队隔离。booleanState.setStateSequence(EcState targetState, int timeoutMs) 顺序设置主站状态 (INIT → PREOP → SAFEOP → OP)booleanState.waitForSlaveState(int slaveIndex, EcState target, int timeoutMs, int pollIntervalMs) 轮询等待单个从站到达指定状态 (PDO 启动后状态确认场景)booleanState.waitForState(EcState target) 等待主站到达指定状态 (默认 10s 超时, 50ms 轮询间隔)booleanState.waitForState(EcState target, int timeoutMs, int pollIntervalMs) 轮询等待主站到达指定状态 (对齐 C# WaitForState / C++ master_state::WaitForState) 不发起状态切换, 仅等待已请求的转换完成 / PDO 流稳定确认 -
com.darra.ethercat.slave中EcState的使用
参数类型为EcState的com.darra.ethercat.slave中的方法修饰符和类型方法说明voidSlaveEvents.StateChangedListener.onStateChanged(EcState oldState, EcState newState) boolean设置从站 EtherCAT 状态 (默认 3000ms 超时)boolean设置从站 EtherCAT 状态voidSlaveEvents.triggerStateChanged(EcState oldState, EcState newState) 触发状态变化 (包外访问: MasterEvents 路由事件到从站) -
com.darra.ethercat.statics中EcState的使用
参数类型为EcState的com.darra.ethercat.statics中的方法 -
com.darra.ethercat.sugar中EcState的使用
声明为EcState的com.darra.ethercat.sugar中的字段修饰符和类型字段说明final EcStateSlaveStateQueue.StateChangeEvent.newStatefinal EcStateSlaveStateQueue.StateChangeEvent.oldState返回变量类型为EcState的类型的com.darra.ethercat.sugar中的方法修饰符和类型方法说明MasterStreams.slavesByState(EtherCATMaster master) 按 EcState 分组, 用于一次性诊断 "网络上有多少从站卡在哪个状态".MasterStreams.stateCounts(EtherCATMaster master) 按 EcState 计数.参数类型为EcState的com.darra.ethercat.sugar中的方法修饰符和类型方法说明static booleanSlaveListExt.allInState(EtherCATMaster master, EcState state) 全网从站是否都进入了指定状态.static booleanSlaveListExt.anyInState(EtherCATMaster master, EcState state) 是否存在任意从站处于指定状态.static longSlaveListExt.countByState(EtherCATMaster master, EcState state) 处于指定状态的从站数.static CompletableFuture<Boolean> MasterAsync.setStateAsync(EtherCATMaster master, EcState state) 异步设置主站状态.static CompletableFuture<Boolean> MasterAsync.setStateAsync(EtherCATMaster master, EcState state, Duration timeout) 带超时的异步设置主站状态.MasterStreams.slavesInState(EtherCATMaster master, EcState state) 过滤指定 EtherCAT 状态的从站.MasterStreams.slavesNotInState(EtherCATMaster master, EcState state) 过滤**不在**指定状态的从站.MasterBuilder.targetState(EcState state) 目标 EtherCAT 状态.参数类型为EcState的com.darra.ethercat.sugar中的构造器