Properties and state machine
NIC enumeration and scanning (NIC selection / quick scan / full scan / cancel) are covered in Initialization § NIC and scan. This page covers only properties, the state machine and runtime control.
Properties
| Category | Property | Type | Access | Description |
|---|---|---|---|---|
| Basic information | MasterNumber | ushort | Read-only | Master instance number |
SlaveCount | int | Read-only | Number of slaves detected on the network | |
Slaves | List<Slave> | Read-only | Slave list (index starts at 0) | |
IsDisposed | bool | Read-only | Whether the master has been disposed | |
| Network and link | PrimaryNetworkInfo | NetworkInfo | Read-only | Primary network adapter information |
RedundantNetworkInfo | NetworkInfo | Read-only | Redundant network adapter information | |
LinkState | EcLinkState | Read-only | Network link state | |
| Error codes | ErrorCode | EcALState | Read-only | Automatic alarm error code on a fault |
| Slave grouping | Groups | SlaveGroupAccessor | Read-only | Group indexer — Groups[g] gets the slave list of that group, Groups[g][i] gets the i-th slave in the group |
ActiveGroupCount | byte | Read-only | Number of active groups (valid after mapping) | |
| I/O mapping | Obytes | uint | Read-only | Total output bytes |
Ibytes | uint | Read-only | Total input bytes | |
Obits | ushort | Read-only | Total output bits | |
Ibits | ushort | Read-only | Total input bits | |
| DC | HasDC | bool | Read-only | Whether the network contains any slave that supports DC. |
| Runtime | IsAsyncOperationInProgress | bool | Read-only | Whether an async operation is currently queued or running (for diagnostics only; not for control flow) |
EcLinkState enum values
public enum EcLinkState : byte
{
Disconnected = 0, // confirmed down: both configured ports are explicitly DOWN
Connected = 1, // both the primary and the redundant NIC are connected
PrimaryOnly = 3, // only the primary NIC is connected
SecondaryOnly = 4, // only the redundant NIC is connected
Unknown = 5 // unknown: not initialized / runtime state not readable yet / PHY has not reported yet
}
Disconnected means only "confirmed down"; when the physical link cannot be read, Unknown is returned. It does not mean disconnected, so the UI should show "unknown" rather than "link down".
EcALState enum values
public enum EcALState : int
{
NoError = 0x0000, // no error
UnspecifiedError = 0x0001, // unspecified error
NoMemory = 0x0002, // out of memory
InvalidDeviceSetup = 0x0003, // ETG.1020: invalid device setup (for example a bus coupler with no physical module connected)
InvalidRevision = 0x0004, // ETG.1020: output/input mapping does not match the hardware or software revision
SiiEepromMismatch = 0x0006, // ETG.1020: SII/EEPROM information (process data description or revision number) does not match the firmware
FirmwareUpdateFailed = 0x0007, // ETG.1020: firmware update did not succeed; the old firmware is still running
LicenseError = 0x000E, // ETG.1020: invalid license / evaluation period expired (contact the slave vendor to activate the license)
InvalidStateChange = 0x0011, // invalid state change
UnknownRequestedState = 0x0012, // unknown state requested
BootstrapNotSupported = 0x0013, // Bootstrap not supported
NoValidFirmware = 0x0014, // no valid firmware
InvalidMailboxConfig = 0x0015, // ETG.1020: invalid mailbox configuration in BOOT state
InvalidMailBoxConfig = 0x0016, // ETG.1020: invalid mailbox configuration in PreOp state
InvalidSyncManagerConfig = 0x0017, // invalid Sync Manager configuration
NoValidInputs = 0x0018, // no valid inputs
NoValidOutputs = 0x0019, // no valid outputs
SyncError = 0x001A, // synchronization error
SyncManagerWatchdog = 0x001B, // Sync Manager watchdog
InvalidSyncManagerTypes = 0x001C, // invalid Sync Manager types
InvalidOutputConfig = 0x001D, // invalid output configuration
InvalidInputConfig = 0x001E, // invalid input configuration
InvalidWatchdogConfig = 0x001F, // invalid watchdog configuration
NeedsColdStart = 0x0020, // cold start required
NeedsInit = 0x0021, // Init state required
NeedsPreOp = 0x0022, // PreOp state required
NeedsSafeOp = 0x0023, // SafeOp state required
InvalidInputMapping = 0x0024, // invalid input mapping
InvalidOutputMapping = 0x0025, // invalid output mapping
InconsistentSettings = 0x0026, // inconsistent settings
FreerunNotSupported = 0x0027, // free run not supported
SyncNotSupported = 0x0028, // synchronization not supported
FreerunNeeds3Buffer = 0x0029, // free run needs triple buffering
BackgroundWatchdog = 0x002A, // background watchdog
NoValidIO = 0x002B, // no valid I/O
FatalSyncError = 0x002C, // fatal synchronization error
NoSyncError = 0x002D, // sync not received (SAFEOP waits for the first Sync0/Sync1 and refuses SO→OP); the literal name "No sync error" does not mean error-free
CycleTimeTooSmall = 0x002E, // ETG.1020: cycle time too small (master cycle < the minimum cycle the slave supports)
InvalidDcSyncConfig = 0x0030, // invalid DC synchronization configuration
InvalidDcLatch = 0x0031, // invalid DC latch
PllError = 0x0032, // PLL error
DcSyncIOError = 0x0033, // DC synchronization I/O error
DcSyncTimeout = 0x0034, // DC synchronization timeout
InvalidDcSyncCycle = 0x0035, // invalid DC synchronization cycle
InvalidSync0Cycle = 0x0036, // invalid SYNC0 cycle
InvalidSync1Cycle = 0x0037, // invalid SYNC1 cycle
MailboxAoe = 0x0041, // mailbox AoE error
MailboxEoe = 0x0042, // mailbox EoE error
MailboxCoe = 0x0043, // mailbox CoE error
MailboxFoe = 0x0044, // mailbox FoE error
MailboxSoe = 0x0045, // mailbox SoE error
MailboxVoe = 0x004F, // mailbox VoE error
EepromNoAccess = 0x0050, // EEPROM not accessible
EepromError = 0x0051, // EEPROM error
ExternalHardwareNotReady = 0x0052, // ETG.1020: external hardware not ready (external connection or signal missing)
SlaveRestarted = 0x0060, // slave restarted
DeviceIdUpdated = 0x0061, // device ID updated
ModuleIdentListMismatch = 0x0070, // ETG.1020: the detected module identity list does not match the configuration
SupplyVoltageTooLow = 0x0080, // ETG.1020: supply voltage too low
SupplyVoltageTooHigh = 0x0081, // ETG.1020: supply voltage too high
TemperatureTooLow = 0x0082, // ETG.1020: temperature too low
TemperatureTooHigh = 0x0083, // ETG.1020: temperature too high
AppControllerAvailable = 0x00F0, // application controller available
Unknown = 0xFFFF // unknown error
}
NetworkInfo.Desc
public string Desc { get; }
The human-readable description of the NIC (the adapter description reported by the system); an empty string when it cannot be obtained.
GetNetworkInfo() / GetBoundAdapters() return this type; SetNetwork(...) matches the port by Name or Desc, and the NIC selection UI and logs display this property directly. The Description of the NetworkAdapterInfo returned by the selection entry point GetNetworkAdapters() is the same description; see NICs and scanning.
Example:
foreach (var nic in DarraEtherCAT.GetNetworkInfo(needSlavesNum: false))
Console.WriteLine($"{nic.Desc} ({nic.Name}) MAC={nic.Mac}");
State machine management
State
Current EtherCAT state (read-only). To change states, call SetState(...).
EcState
Related structures:
public enum EcState : byte
{
None = 0x00,
Init = 0x01,
PreOp = 0x02,
Boot = 0x03,
SafeOp = 0x04,
OP = 0x08,
Ack = 0x10,
Error = 0x10
}
Related properties:
public EcState BaseState { get; } // base state = State & 0x0F (Init/PreOp/SafeOp/OP)
public bool IsError { get; } // AL Error bit = (State & 0x10) != 0
public EcState AggregatedState { get; } // authoritative aggregate for display: lowest base state across all slaves plus the aggregated Error bit; returns Unknown (None) when no slave takes part in the aggregation and never falls back to the master-state cache (the count of participating slaves is internal-only)
public bool IsRealOp { get; } // real OP = State==OP and the PDO cycle is running
Example:
if (master.State == EcState.OP)
Console.WriteLine("主站处于运行状态"); // Master is running
- All state machine switching methods in the SDK follow the standard EtherCAT state machine sequence; the protocol layer handles it automatically.
- Import or set the correct configuration before starting.
- For a more detailed error message, use the
SetState(state, out string err)overload.
SetState(EcState state)
public bool SetState(EcState state)
Switch the master to the target state. Internally the call walks the ETG state machine chain (Init↔PreOp↔SafeOp↔OP) and covers multiple levels in one go, applying the startup parameters of each step. Entering SafeOp/OP starts the PDO thread automatically. Each step timeout is computed from the workload implied by the startup parameters; a timeout fails that step.
Parameters:
state(EcState) — target state
Return value:
bool—trueon success,falseon failure
The SDK retries automatically when a state change fails, to absorb occasional hardware jitter (PHY PLL jitter and similar). You do not need to wrap retry logic yourself.
When switching to SafeOp, the SDK configures the synchronization cycle-count threshold and the Sync Manager synchronization type (FreeRun as fallback) for non-DC slaves per the ETG standard; application code does not need to write them.
DC slaves skip this automatic configuration (to avoid conflicting with the DC time base). To use a custom synchronization policy, override it after switching to SafeOp. Write failures are tolerated and do not block the SafeOp transition.
Example:
if (!master.SetState(EcState.OP))
Console.WriteLine("状态切换失败"); // State transition failed
Async variants (do not block the calling thread):
public Task<bool> SetStateAsync(EcState state, IProgress<string>? progress = null, CancellationToken cancellationToken = default)
public Task<(bool success, string error)> SetStateWithErrorAsync(
EcState state, IProgress<string>? progress = null, CancellationToken cancellationToken = default)
The async entry points are optional and do not block the calling thread. Async operations on the same master are queued serially by the SDK (only one operation talks to the bus at any moment); they support a progress callback (raised on a background thread) and a cancellation token, and behave like the synchronous version for automatic retry and the SafeOp automatic SDOs. To get the failure reason across an await, use SetStateWithErrorAsync (an out parameter cannot cross an await); if you only need success/failure, use SetStateAsync.
SetState(EcState state, out string error)
public bool SetState(EcState state, out string error)
Switch the master to the target state and return the failure reason through error (for diagnostics). On success error is null. Retry and SafeOp automatic SDO behavior are the same as above.
Parameters:
state(EcState) — target stateerror(out string) — error description on failure (returned in Chinese),nullon success
Return value:
bool—trueon success,falseon failure
Besides "retries exhausted / still not at the target on re-check", error also appends 实测聚合State=... (SDK output, = measured aggregate State=...) and, for every slave that did not reach the target, a readable per-slave reason list (up to 16 slaves; beyond that it ends with +N 站未列出 (SDK output, = +N slaves not listed)). Each entry gives the state the slave is stuck in, its index and the AL code, for example 停留在 安全操作 (Safe-Operational) 的从站 3, AL=0x001F (看门狗配置无效) (SDK output, = "slave 3 stuck in Safe-Operational, AL=0x001F (watchdog configuration invalid)"); when the AL code cannot be read it says AL 未知(无应答) (SDK output, = AL unknown (no response)) — that means the status was not obtained, which is a different case from the slave actually reporting an AL code and must not be read as a refusal by the slave; a slave that reports no valid state (base state 0x00) is shown as 从站 3 无应答/未上报状态 (SDK output, = "slave 3 no response / no state reported"), and a per-slave read failure is shown as 从站 3 状态读取失败(<异常类型>) (SDK output, = slave 3 state read failed(<exception type>)). That lets you tell these cases apart directly: the aggregated master state never moved, a specific slave explicitly refused with an AL status, or the check itself said no.
Example:
if (!master.SetState(EcState.OP, out string err))
Console.WriteLine($"状态切换失败: {err}"); // State transition failed: {err}
Async variant: see "Async variants (do not block the calling thread)" in the previous section; get the failure reason with SetStateWithErrorAsync(...).
SetSlaveState(int slaveNum, EcState state, uint timeoutMs = 5000)
public bool SetSlaveState(int slaveNum, EcState state, uint timeoutMs = 5000)
Switch the state of a single slave only. Other slaves are not affected, and the master's own state does not change. A typical use is switching one slave to Boot before a firmware transfer and back to PreOp afterwards.
Parameters:
slaveNum(int) — slave index (1-based, matching the configuration)state(EcState) — target statetimeoutMs(uint) — timeout for switching this one slave (ms), default5000
Return value:
bool—true= the slave has reached the target state;false= the switch failed or the call threw (the reason is written to the log)
This method touches one slave only; the master state is still handled by SetState(...). To move the whole bus through the state machine, use SetState — do not assemble a master state by calling this method slave by slave.
Example:
// Switch only station 3 to Boot for the firmware transfer, leave the other slaves as they are
if (!master.SetSlaveState(3, EcState.Boot, timeoutMs: 10000))
Console.WriteLine("从站 3 未能进入 Boot,原因见日志"); // Slave 3 did not reach Boot, see the log for the reason
Start()
public bool Start()
Start the PDO cycle and asynchronous notification delivery. Symmetric with Stop(): returns true on success, false on failure, and never throws (the reason goes to the log).
It only starts and stops the PDO cycle and asynchronous notification delivery; it does not change host timer, GC or process scheduling state, and it does not perform a state transition — entering SafeOp / OP is still the job of SetState(EcState). Repeated calls are idempotent: when already started it returns true and does not start again. C# Start(), C Start(mi), C++ Master::Start() and Java / Python / Rust start() behave the same across the six SDKs.
Return value:
bool—true= the PDO / async notify owner has been established;false= establishment failed (the master is closed or not initialized; the reason is logged)
Example:
master.SetState(EcState.OP); // state transitions are handled by SetState; Start does not transition
// complete the state transition first, then start the cycle; an owner already established by SetState makes this call succeed idempotently
if (!master.Start())
Console.WriteLine("PDO owner 建立失败,原因见日志"); // PDO owner setup failed, see the log for the reason
// ... run ...
master.Stop(); // switch back to PRE_OP
Stop()
public bool Stop()
Stop the master and switch to the PRE_OP state.
Abort()
public static void Abort()
Abort all blocking operations in the protocol layer (such as SetState(), or SetNetwork inside Build()). Safe to call from any thread.
Example:
// interrupt an in-progress state change when the user clicks Cancel
DarraEtherCAT.Abort();
WaitForState(EcState state, int timeoutMs = 10000, int pollIntervalMs = 50)
public bool WaitForState(EcState state, int timeoutMs = 10000, int pollIntervalMs = 50)
Poll until the master reaches the given state. It does not initiate a state change; it only waits for a transition that was already requested to complete, or confirms that the PDO stream is stable. Typical uses are the confirmation window after SetState was triggered asynchronously, or a short wait for OP to settle after the PDO starts.
Parameters:
state(EcState) — target statetimeoutMs(int) — maximum wait time (ms), default 10000mspollIntervalMs(int) — polling interval (ms), default 50ms
Return value:
bool—trueif the target state is reached before the timeout
Example:
master.SetState(EcState.OP);
// wait up to 5s for the master to enter OP
if (!master.WaitForState(EcState.OP, timeoutMs: 5000))
{
Console.WriteLine("主站未在 5s 内进入 OP"); // Master did not reach OP within 5 s
}
WaitForSlaveState(int slaveNum, EcState state, int timeoutMs = 10000, int pollIntervalMs = 50)
public bool WaitForSlaveState(int slaveNum, EcState state, int timeoutMs = 10000, int pollIntervalMs = 50)
Poll until a single slave reaches the given state. Useful for confirming the state of critical slaves after the PDO starts.
Parameters:
slaveNum(int) — slave index (1-based)state(EcState) — target statetimeoutMs(int) — maximum wait time (ms), default 10000mspollIntervalMs(int) — polling interval (ms), default 50ms
Return value:
bool—trueif the target state is reached before the timeout
Example:
// wait up to 3s for slave 3 to enter OP
if (!master.WaitForSlaveState(3, EcState.OP, timeoutMs: 3000))
{
Console.WriteLine($"从站 3 当前: {master.Slaves[2].State}"); // Slave 3 currently: {master.Slaves[2].State}
}
GetTransitionTimeoutMs(EcState from, EcState to)
public int GetTransitionTimeoutMs(EcState from, EcState to)
Query the recommended maximum wait time (ms) for a state transition. It falls back to the ESI / configuration / ETG.1020 default; upper layers can read the value for custom progress hints or test assertions.
Parameters:
from(EcState) — source stateto(EcState) — target state
Return value:
int— recommended timeout (ms)
Example:
int initToPreOp = master.GetTransitionTimeoutMs(EcState.Init, EcState.PreOp);
Console.WriteLine($"Init→PreOp 推荐超时: {initToPreOp}ms"); // Recommended Init→PreOp timeout: {initToPreOp}ms
State transitions and error classification
Whether a transition is legal, its default timeout, and how AL errors are classified are all defined by the SDK per the ETG standard. Application code normally uses them only in diagnostics or pre-checks:
| Category | Method | Returns | Use | Key rules |
|---|---|---|---|---|
| Legality | DarraEtherCAT.IsLegalEsmTransition(EcState from, EcState to) | bool | Check whether a state transition is legal | Level-by-level upgrade/downgrade, multi-level downgrade from OP/OI/SI, Boot transitions and same-state transitions are legal; level-skipping upgrades such as Init→SafeOp, Init→OP and PreOp→OP are illegal |
| Timeout | DarraEtherCAT.GetEsmDefaultTimeoutMs(EcState from, EcState to) | uint | Look up the ETG.1020 default timeout (ms) for a transition | IP=3000, PS/SO=10000, OS/SP=200, PI/SI/OP/OI=5000, IB=10000, BI=5000; same state 100; illegal transition 0 |
| Classification | DarraEtherCAT.ClassifyAlStatusCode(ushort alStatusCode) | ALErrorCategory | Classify an AL Status Code and decide whether an automatic retry is possible | None / Transient / Configuration / Hardware / Unknown; the code table is maintained by the SDK, and Unknown is returned when no classification is available |
Typical use: call IsLegalEsmTransition before a state change to reject illegal targets; when a slave drops out of OP, classify the AL Status Code value — Transient means the state change can be retried, while Configuration / Hardware mean reconfiguration or manual intervention is required.
EsmTimeouts.SdoTimeout (3000) / MailboxTimeout (5000) / StateStabilizeDelay (100) are communication-side constants; the 8 transition properties on EsmTimeouts (InitToPreOp and so on) simply pass through GetEsmDefaultTimeoutMs, and EsmTimeouts.GetTransitionTimeout(from, to) returns the same values.
Process data watchdog
SetAllSlaveWatchdog(uint timeoutMs)
public BatchWatchdogResult SetAllSlaveWatchdog(uint timeoutMs)
Set the process data watchdog timeout for all slaves in one call.
Parameters:
timeoutMs(uint) — timeout (ms); 0 = disabled; maximum 6553ms
Return value:
Written(int) — number of slaves written (including slaves written with their actual value after the safety floor raised the request);-1= the master is disposed / unavailable (semantically different from "0 slaves were configured"; do not conflate the two)Raised(bool) —true= at least one slave in this batch had its requested value raised by the safety floor (branch slaves 5000 ms / PDO slaves on the ring 400 ms), so the actual value sent differs from the requested one
Written > 0 does not mean "everything was sent as requested": when Raised == true, the actual milliseconds per slave are in the Warning log of that call, or check them with slave.GetWatchdogConfig().
Related structures:
public readonly struct BatchWatchdogResult
{
public int Written { get; } // number of slaves written (including those written with the raised actual value); -1 = the master is disposed / unavailable
public bool Raised { get; } // true = a slave in this batch was raised by the safety floor (always false for the PDI batch)
}
For the watchdog configuration of a single slave, use slave.SetWatchdog().
Example:
var r = master.SetAllSlaveWatchdog(100);
if (r.Written < 0)
Console.WriteLine("主站已释放,未执行设置"); // Master has been released, no settings applied
else if (r.Raised)
Console.WriteLine($"已写入 {r.Written} 个从站,其中有站被安全下限抬升,实际值与请求不同"); // Written to {r.Written} slaves; some were raised to the safety floor, so the actual values differ from the request
else
Console.WriteLine($"已按请求写入 {r.Written} 个从站看门狗超时为 100ms"); // Requested watchdog timeout of 100 ms written to {r.Written} slaves
SetAllSlavePdiWatchdog(uint timeoutMs)
public BatchWatchdogResult SetAllSlavePdiWatchdog(uint timeoutMs)
Set the PDI watchdog timeout for all slaves in one call.
Parameters:
timeoutMs(uint) — timeout (ms); 0 = disabled; maximum 6553ms
Return value:
Written(int) — number of slaves written;-1= the master is disposed / unavailable (semantically different from "0 slaves were configured")Raised(bool) — the PDI batch has no safety-floor raise path; alwaysfalse
For the watchdog configuration of a single slave, use slave.SetPdiWatchdog().
Example:
var r = master.SetAllSlavePdiWatchdog(100);
if (r.Written < 0)
Console.WriteLine("主站已释放,未执行设置"); // Master has been released, no settings applied
else
Console.WriteLine($"已写入 {r.Written} 个从站 PDI 看门狗超时为 100ms"); // PDI watchdog timeout of 100 ms written to {r.Written} slaves
Diagnostic control methods
ResetSlavePortErrorCounters(ushort slaveIndex)
public bool ResetSlavePortErrorCounters(ushort slaveIndex)
Reset the port error counters of the given slave.
Parameters:
slaveIndex(ushort) — slave index (1-based)
Return value:
bool—trueon success
master.Diagnostics.Reset() resets the master diagnostic statistics, the port error counters of all slaves and the PDO frame-loss statistics at the same time.
AutoRecoverNic()
public int AutoRecoverNic()
Run one automatic recovery on the bound NIC: stop the transmit/receive path and bring it back up, which has the same effect as unplugging and replugging the NIC in software. Use it when the NIC needs its transmit/receive path rebuilt after a fault.
Return value:
int—1= recovery succeeded;0= recovery failed, or the call was rejected because a state transition window is in progress (a disposed master also returns0)
After recovery the transmit/receive path is new, so run SetNetwork / the scan again before continuing; do not expect the previous master state to resume by itself.
Example:
if (master.AutoRecoverNic() != 1)
{
Console.WriteLine("网口自动恢复未成功,检查链路与占用后重新扫描"); // Automatic port recovery did not succeed; check the link and what is holding it, then scan again
return;
}
var slaves = DarraEtherCAT.ScanSlaves(adapterName, null, out var outcome);
Runtime status queries
Read-only runtime observation entry points; they do not change any control flow.
IsAsyncOperationInProgress
public bool IsAsyncOperationInProgress { get; }
Whether an async operation is currently queued or running. Async operations on the same master are queued serially by the SDK, and only one operation talks to the bus at any moment; this property reads the occupancy of that serial queue.
Return value:
bool—true= an operation is running or waiting;false= idle
It suits an "operation in progress" indicator in the UI, or a wait criterion before closing. It is an observation only: do not use it in place of await, and do not treat it as a synchronization primitive for control flow — a new operation can arrive at any time after you read false.
Example:
if (master.IsAsyncOperationInProgress)
Console.WriteLine("有异步操作在跑,稍候再关闭"); // An async operation is still running, close it later
GetActiveGroupCount(ushort masterIndex = 1)
public static byte GetActiveGroupCount(ushort masterIndex = 1)
Get the number of slave groups currently active on that master. Empty groups (groups with no slaves) are not counted.
Parameters:
masterIndex(ushort) — master index (≥1), default1
Return value:
byte— number of active groups
Same meaning as the instance property master.ActiveGroupCount; only the entry point differs: this method takes a master index, which suits diagnostic or UI code that has no master instance reference at hand.
Example:
byte groups = DarraEtherCAT.GetActiveGroupCount(master.MasterNumber);
Console.WriteLine($"活跃组: {groups}"); // Active groups: {groups}
GetRingSlaveCount()
public static int GetRingSlaveCount()
Get the number of slaves on the ring as measured by the last on-site topology calibration (the return-point probe run during station setup / configuration apply).
Return value:
int— number of slaves on the ring;0if a topology calibration has never run
This is a cached calibration result; an ordinary scan does not overwrite it. To find out "how many slaves this scan saw", use the return value of ScanSlaves / out nativeCode; to read the topology ring count for a master precisely, use master.Diagnostics.TopoMeasuredRingCount. Do not use this property to decide whether any slave is currently on the bus.
Example:
int ring = DarraEtherCAT.GetRingSlaveCount();
Console.WriteLine(ring > 0 ? $"标定时环上 {ring} 站" : "尚未做过拓扑标定"); // {ring} slaves on the ring at calibration time / topology has not been calibrated yet
EnsureRtIsolation(bool elevated = false)
public static bool EnsureRtIsolation(bool elevated = false)
Read-only check of whether real-time core isolation is configured on this machine. It changes no system settings: it raises no permission prompt, runs no optimization script, and writes no boot / power / service / interrupt configuration.
Parameters:
elevated(bool) — kept only for compatibility with old callers; it no longer makes any behavioral difference, defaultfalse
Return value:
bool—true= isolation is configured;false= not configured (the SDK logs a warning; the caller should guide the user to configure it as part of the installation procedure)
This method answers "does the isolation configuration exist", not "is this session already running on isolated cores". For the actual state of this session, read IsolationStatus / HardRealtimeActive / SoftRealtimeActive / PinCore, and the alarm text RtAlarmMessage shown when hard real time is not active.
Example:
if (!DarraEtherCAT.EnsureRtIsolation())
Console.WriteLine("实时核隔离未配置,按安装流程配置后重试"); // Real-time core isolation is not configured; configure it per the install procedure and retry
Hot-plug self-recovery
When a slave is powered off and replugged, or replaced, the SDK detects the identity mismatch automatically and enters a protected state, so a wrong device is never pulled into the control cycle by mistake.
AcknowledgeSlaveReplacement(int slaveNum)
public bool AcknowledgeSlaveReplacement(int slaveNum)
Confirm that the slave replacement is finished; this triggers the EtherCAT identification state machine to probe that slave again.
When to call: subscribe to master.Events.SlaveIdentityMismatch, and once the identity-mismatch alarm arrives and the operator has finished checking or replacing the device, call this method so the SDK probes again.
Behavior:
- If the identity is now correct (the right device is back, or the same model with a newer revision) → it recovers automatically and raises the
SlaveOnlineevent - If the identity still does not match →
SlaveIdentityMismatchis raised again and the slave returns to theIDENT_REJECTEDstate
Parameters:
slaveNum(int) — slave index (1-based, matching the configuration)
Return value:
bool—true= accepted and the FSM reset;false= the argument is invalid, or the slave is not currently inIDENT_REJECTED/FAILED(a call before theSlaveIdentityMismatchevent arrives returnsfalse)
Calling this method before the SlaveIdentityMismatch event fires has no effect. While the slave has not entered the protected state the SDK keeps probing normally; no manual confirmation is needed.
Example:
master.Events.SlaveIdentityMismatch += (sender, args) =>
{
Console.WriteLine($"从站 {args.SlaveIndex} 身份不符: " + // Slave {args.SlaveIndex} identity mismatch:
$"期望 Vendor=0x{args.ExpectedVendor:X8}, 实际 Vendor=0x{args.ActualVendor:X8}"); // expected Vendor=0x{args.ExpectedVendor:X8}, actual Vendor=0x{args.ActualVendor:X8}
// UI dialog: "check the device of slave N; click confirm once the correct model is back"
if (ShowReplacementDialog(args.SlaveIndex))
{
bool ok = master.AcknowledgeSlaveReplacement(args.SlaveIndex);
if (!ok)
Console.WriteLine("确认失败: 从站不在 IDENT_REJECTED 状态"); // Acknowledge failed: slave is not in the IDENT_REJECTED state
}
};
SlaveOffline— the slave lost power or the cable (identity still matches); recovery is automatic and raisesSlaveOnlineSlaveIdentityMismatch— the slave identity changed (wrong device, i.e. Vendor + Product do not match the configuration; the revision is not part of the identity check); callAcknowledgeSlaveReplacementmanually