DC synchronization
Slave-level Distributed Clocks (DC) configuration. Accessed through slave.DC().
In most scenarios, use master.configureDCAll() to configure all DC slaves in one call.
Slave-level methods are for scenarios where individual slaves need different parameters.
Read-only properties
| Category | Method | Type | Read/write | Description |
|---|---|---|---|---|
| DC state | hasDC() | boolean | read-only | Whether DC is supported |
| DC state | hasEsiDcSync() | boolean | read-only | Whether the ESI declares that this slave uses DC synchronization (conservatively degrades to hasDC() when no ESI is bound) |
| DC state | esiDcSyncMode() | int | read-only | DC synchronization tier declared by the ESI: 3 = DC-Sync0 + SYNC1; 2 = DC-Sync0 only; 0 = not declared / cannot be determined |
| dcActive() | int | read-only | Landed value of 0x0980: 0 = not active. A value other than 0 only means the DC register has been written; it does not mean armed, and still less does not mean synchronized; for armed state check slave.DC().sync0Armed(), for synchronization check dcSyncWindow().inSync | |
| DC time | dcCycle0() | int | read-only | Current SYNC0 cycle (ns) |
| dcCycle1() | int | read-only | Current SYNC1 cycle (ns) | |
| dcShift() | int | read-only | Current phase shift (ns) | |
| propagationDelay() | int | read-only | Propagation delay of a frame from the master to this slave (ns) | |
| Topology compatibility | dcParentPort() | int | read-only | Compatibility entry for parentPort(): 0..3 = parent port, -1 = unknown or invalid parameter |
DC state and time properties are accessed directly through slave.*() (for example slave.hasDC(), slave.dcActive()); the propagation delay is accessed through slave.DC().propagationDelay().
hasDC()
public boolean hasDC()
Returns the ESC hardware bit, indicating whether the slave ESC declares DC support. It reflects hardware capability only, not "DC enabled / synchronized".
DcSyncMode.FreeRun can be queried, but it is the slave's local clock: it is not DC enabled and not synchronized. DC synchronization = SYNC0 armed (slave.DC().sync0Armed() is true) and the sync window dcSyncWindow().inSync is true. 0x0980 in 0x0300 is only a common landed value and cannot serve as the synchronization criterion. InSync is always false under FreeRun.
The reference clock itself: 0x092C (the time difference) is N/A for it by definition, and the lower layer no longer synthesizes an in-sync value. When this station is the reference clock and SYNC0 is armed,
getDCDiagnostics().IsInSync(the boolean contract for "can it be treated as synchronized") returnstrue— there is no desynchronization between the reference clock and itself, and this is the only decidable conclusion (non-reference clocks still use the sync window criterion). Thattrueonly means "can be treated as synchronized"; it does not mean a measured deviation exists, and it does not mean the whole network clock has converged either; the sync windowSyncWindowStatus.inSync/dcSyncWindow()still report the raw lower-layer values (N/A for the reference clock itself).
dcSyncModeFromEsi()
public int dcSyncModeFromEsi()
Query the DC synchronization mode declared by this slave's ESI description file.
Returns:
-2— invalid parameter / the slave is not bound to an ESI Device (callers should degrade tohasDC())-1— the ESI does not declare a<Dc>node (the slave does not use DC and should run FreeRun)0— the ESI<Dc>exists but has no OpMode → FreeRun1— SM-Sync (SM enabled but AssignActivate has no 0x100)2— DC-Sync0 (EL7041-1000 / Ezi-SERVO2, etc.)3— DC-Sync01
You must first import the ESI directory with setEsiFiles(). build() loads the ESI directory/files and automatically matches the device. Returns -2 when not bound.
esiDcSyncMode()
public int esiDcSyncMode()
The DC synchronization tier the ESI declares for this station (the normalized external reading), used by upper layers to decide "can SYNC1 be enabled":
| Value | Meaning | Typical ESI |
|---|---|---|
3 | ESI declares DC-Sync0 + SYNC1: AssignActivate contains the SYNC1 enable bit 0x0400 (e.g. #x700) | Beckhoff EL7411 |
2 | ESI declares DC-Sync0 only: AssignActivate is non-zero but does not contain 0x0400 (e.g. #x300) | EL7041 / Ezi-SERVO2 |
0 | ESI does not declare DC, or it cannot be determined (ESI unbound / unreadable) | EK1100 / EK1110 / EL6022 / GCAN-8200 |
There is only one rule: DC-Sync01 can be requested only when the value is 3; with the value 2 only DC-Sync0 is possible. Using 2 as 3 (forcing SYNC1 on) makes a slave that declares only Sync0 refuse to enter OP, and it does not necessarily report an AL status code.
ESI-declared value ≠ landed value: slave.DC().esiDcAssignActivate() returns the raw 16-bit SYNC0 <Dc><OpMode><AssignActivate> declared in the ESI AssignActivate (null = not declared in the ESI / ESI not bound / unreadable). It is not the landed value written into the slave's 0x0980 — read slave.dcActive() for that.
How it divides work with dcSyncModeFromEsi() / hasEsiDcSync():
dcSyncModeFromEsi()is the raw lower-layer reading and keeps negative values such as-1(the ESI has no<Dc>) /-2(ESI unbound), for callers that need to distinguish "explicitly does not use DC" from "ESI not bound";hasEsiDcSync()is a boolean capability judgment; when the lower layer returns-2it conservatively degrades tohasDC(), preferring to think one step further rather than wrongly turning off a station that really can run DC;esiDcSyncMode()is the normalized external reading; negative numbers and0/1all collapse to0, and negative values are not exposed. Use it uniformly for external decisions and do not parse the raw reading yourself.
Example:
DC dc = slave.DC();
int mode = dc.esiDcSyncMode();
if (dc.hasDC() && dc.hasEsiDcSync()) {
if (mode == 3) {
// ESI declares DC-Sync0 + SYNC1 DC-Sync01 can be requested
dc.configureDC(DC.DcSyncMode.DcSynchron01, 1_000_000, 1_000_000, DC.DC_SHIFT_UNSPECIFIED);
} else {
// Declares DC-Sync0 only: do not turn SYNC1 on
dc.configureDC(DC.DcSyncMode.DcSynchron, 1_000_000, 0, DC.DC_SHIFT_UNSPECIFIED);
}
}
hasEsiDcSync()
public boolean hasEsiDcSync()
Returns whether the ESI description file declares the use of DC synchronization. Decision rule: only dcSyncModeFromEsi() >= 2 (DC-Sync0/01) counts as the ESI really declaring DC; 0/1 (FreeRun/SM-Sync) and -1 (the ESI has no <Dc>) are treated as no; when unbound (-2) it degrades to hasDC() so it conservatively does not wrongly turn a station off.
Since 2.5.x, hasEsiDcSync() reads the DC OpMode actually declared by the ESI through the lower-layer interface (it previously looked it up in an SDK-side cache, which was always empty and therefore always degraded to hasDC()).
Purpose: Filter out devices whose ESC hardware declares DC support but which do not actually need DC synchronization (for example gateways such as the EL6022 / EK1110 / GCAN-8200), avoiding invalid SYNC0/1 register writes during SafeOp→Op that cause AL 0x002C/0x0030.
Typical usage:
DC dc = slave.DC();
if (dc.hasDC() && dc.hasEsiDcSync()) {
// The application layer needs to configure DC for this slave
dc.configureDC(1_000_000, 0, DC.DC_SHIFT_UNSPECIFIED);
}
Configuration methods
configureDC(int sync0CycleNs, int sync1CycleNs, int shiftNs)
public boolean configureDC(int sync0CycleNs, int sync1CycleNs, int shiftNs)
Configure slave DC synchronization in one call. All parameter units: nanoseconds (ns).
Parameters:
sync0CycleNs(int) — SYNC0 cycle (ns), 0 means disarm SYNC0 (back to FreeRun)sync1CycleNs(int) — SYNC1 increment time (ns), 0 means SYNC0 onlyshiftNs(int) — phase shift (ns), always an explicit user phase:0is literally 0 phase (SYNC0 falls on the cycle boundary), and negative values are likewise sent as-is. "Unspecified" has exactly one sentinel,DC.DC_SHIFT_UNSPECIFIED(Integer.MIN_VALUE); passingconfigureDC(int, int, Integer)to thenulloverload is equivalent
Example:
slave.DC().configureDC(1_000_000, 0, DC.DC_SHIFT_UNSPECIFIED); // SYNC0 = 1ms, phase resolved by default
slave.DC().configureDC(1_000_000, 0, 0); // SYNC0 = 1ms, phase 0 ns
- Only when the phase is "unspecified" (
DC.DC_SHIFT_UNSPECIFIED/nullpassed to the overload) is it resolved by precedence: ESIShiftTimeSync0not 0 → explicit usershiftNs→ default 「1 cycle + 70%」sync0CycleNs * 70 / 100(1 ms → 700 µs). - The phase is only a phase shift and does not add software propagation delay compensation; the propagation delay is corrected by the ESC in hardware according to
0x0928. shiftNs = 0is literally 0 phase, not "unspecified", and does not fall back to 70%; to get the default 70% passDC.DC_SHIFT_UNSPECIFIED.sync0CycleNs = 0disarms SYNC0 (FreeRun), not a 「0 ns cycle」. A station with PDO then writes0x1C32:01/0x1C33:01back to 0, clearing leftovers from the previous session (otherwise the SafeOp transition may report AL=0x002D); when SM2/SM3 are not mapped, the write is deferred until mapping completes.- During hot-plug recovery the SDK automatically re-arms the DC start point and activates SYNC0 (the start point is based on the re-read slave DC time); the phase comes from the same source as the first arming (same resolution result, phase only) and does not jump on re-arming; the reference clock is re-selected immediately if it fails.
configureDC(DC.DcSyncMode mode, int sync0CycleNs, int sync1CycleNs, int shiftNs)
public boolean configureDC(DC.DcSyncMode mode, int sync0CycleNs, int sync1CycleNs, int shiftNs)
Configure DC according to the synchronization mode (ETG.1020). The SM synchronization type is configured automatically.
Parameters:
mode(DC.DcSyncMode) — DC synchronization modesync0CycleNs(int) — SYNC0 cycle (ns), used only in DcSynchron modesync1CycleNs(int) — SYNC1 cycle (ns), used only in DcSynchron modeshiftNs(int) — phase shift (ns), used only in DcSynchron mode; always an explicit user phase (0= literally 0 phase), useDC.DC_SHIFT_UNSPECIFIED/nullpassed to the overload for "unspecified"
Related structures:
DC.configureDC uses the DC nested in the DcSyncMode class (PascalCase members, including DcSynchron01). The SDK has another com.darra.ethercat.data.EtherCATTypes.DcSyncMode (UPPER_SNAKE members FREE_RUN/SM_SYNCHRON/DC_SYNCHRON, no DcSynchron01) that cannot be passed to this method. Make sure the import is com.darra.ethercat.slave.DC.DcSyncMode (or write DC.DcSyncMode.XXX directly).
// Enum nested in the DC class — this is what DC.configureDC(DcSyncMode, ...) uses
public enum DcSyncMode {
FreeRun(0), // Free run (local clock, not DC synchronization)
SmSynchron(1), // SM synchronization - triggered by SM events
DcSynchron(2), // DC synchronization - SYNC0 signal only
DcSynchron01(3); // DC synchronization - SYNC0 + SYNC1 signals
}
Example:
slave.DC().configureDC(DC.DcSyncMode.DcSynchron, 1_000_000, 0, DC.DC_SHIFT_UNSPECIFIED); // DC SYNC0 = 1ms
slave.DC().configureDC(DC.DcSyncMode.SmSynchron, 0, 0, 0); // SM synchronization mode
slave.DC().configureDC(DC.DcSyncMode.FreeRun, 0, 0, 0); // Free run
currentDcSyncMode()
public DC.DcSyncMode currentDcSyncMode()
Get the current synchronization mode. FreeRun / SmSynchron can be queried but are not DC synchronization. DC synchronization is only DcSynchron / DcSynchron01; whether it is really synchronizing is determined by slave.DC().sync0Armed() and dcSyncWindow().inSync, not by the numeric value of dcActive().
Returns:
DC.DcSyncMode— current synchronization mode (DCclass nested enum, see the note above)
Example:
DC.DcSyncMode mode = slave.DC().currentDcSyncMode();
System.out.printf("当前 DC 同步模式: %s%n", mode); // Current DC sync mode: %s%n
disableDC()
public void disableDC()
Disable DC synchronization for this slave.
Sync window diagnostics
getSyncWindowStatus()
public DC.SyncWindowStatus getSyncWindowStatus()
Get the detailed status of the slave DC sync window. Returns null when DC is not supported or the read fails.
Returns:
SyncWindowStatus— sync window status
Related structures:
public static class SyncWindowStatus { // Nested in DC, written as DC.SyncWindowStatus
public final int DiffNs; // Current time difference (ns)
public final int MaxDiffNs; // Maximum time difference (ns)
public final int MinDiffNs; // Minimum time difference (ns)
public final boolean InSync; // Whether inside the DC SYNC0 sync window. Always false under FreeRun; must not be treated as synchronized
public final long OutOfSyncCount; // Number of times outside the sync window (lower-layer uint32 expanded to long as unsigned)
}
Example:
DC.SyncWindowStatus status = slave.DC().getSyncWindowStatus();
if (status != null) {
System.out.printf("同步差=%dns, 同步=%b, 最大=%dns%n", // Sync diff=%dns, synced=%b, max=%dns%n
status.DiffNs, status.InSync, status.MaxDiffNs);
}
resetSyncWindowStats()
public void resetSyncWindowStats()
Reset the sync window statistics for this slave (max/min time difference, out-of-sync count, etc.).
DC diagnostics (per slave)
The methods below answer separately: "can DC be done", "is it armed", "is it really inside the sync window", and "are the readings frozen". All of them read only local caches (lower-layer station structure, sync state, arming mask); they do not read registers and do not send bus frames, so they can be called directly from a diagnostics thread or UI thread.
| Category | Method | Returns | Read/write | Description |
|---|---|---|---|---|
| DC diagnostics | dcCapability() | DcCapability | read-only | Capability tier = ESC capability bits + highest tier declared by the ESI. UNKNOWN = the slave snapshot cannot be read / ESI unbound, not "no capability" |
| DC diagnostics | dcArmOutcome() | DcArmResult | read-only | Final state of the auto-startup arming policy. Java always returns UNKNOWN |
| DC diagnostics | dcAssignActivate() | Integer | read-only | Landed mirror of 0x0980 (write-then-read-back proven). null = no DC / cannot read; 0 = DC capable but currently not active |
| DC diagnostics | dcSync0CycleNs() | Integer | read-only | Landed mirror of 0x09A0. 0 = no cycle landed in the lower layer (not armed / FreeRun), not a 「0 ns cycle」 |
| DC diagnostics | dcSync1CycleNs() | Integer | read-only | Landed mirror of 0x09A4, same semantics as dcSync0CycleNs() |
| DC diagnostics | dcPropagationDelayNs() | Integer | read-only | Landed value of 0x0928 (ns). null = no DC / cannot read / lower-layer value is negative |
| DC diagnostics | dcPropagationDelaySource() | DcPropagationDelayOrigin | read-only | Propagation delay source tier. ZERO_NS_AMBIGUOUS = domain root or not measured (the lower layer does not distinguish), not fabricated |
| DC diagnostics | dcSyncWindow() | DcSyncWindowInfo | read-only | Per-slave sync window: applicable / notApplicableReason / inSync / readingUnchanged / unchangedStreak / sampledAtUtc, etc. |
| DC diagnostics | dcConvergenceMs() | Integer | read-only | Convergence time (first "armed but not in window" → first entry into the window, 2-second sampling granularity). null = no complete transition observed |
| DC diagnostics | dcJitter() | DcJitterStats | read-only | Steady-state quality (σ / peak-to-peak / maximum adjacent change). null when fewer than 2 samples |
| DC diagnostics | sync0Armed() | Boolean | read-only | SYNC0 arming tri-state: true / false / null (the lower layer cannot answer). Defined on DC, call it as slave.DC().sync0Armed() |
Seven states (sync window)
The seven states describe only "defined sync window states". Read failures and "armed but outside the window" are not among these seven.
| Category | State | Java predicate | Meaning | Read/write |
|---|---|---|---|---|
| DC diagnostics | No capability | dcSyncWindow().notApplicableReason == NO_DC_CAPABILITY | No SYNC0 cycle unit, so synchronization error does not exist | read-only |
| DC diagnostics | Not armed | notApplicableReason == SYNC0_NOT_ARMED | Known not to take part in DC synchronization; 0x092C is undefined | read-only |
| DC diagnostics | Reference clock itself | notApplicableReason == REFERENCE_CLOCK_ITSELF | This station is the time base, so synchronization error does not exist by definition | read-only |
| DC diagnostics | Armed but readings frozen | applicable == true and readingUnchanged == Boolean.TRUE | All four 0x092C items stayed completely unchanged across several consecutive samples (a frozen-proxy bit, not the lower-layer 1:1 ramp decision) | read-only |
| DC diagnostics | Truly in window | applicable == true and inSync == Boolean.TRUE | Armed and measured inside the sync window | read-only |
| DC diagnostics | Arming unknown | notApplicableReason == ARMED_UNKNOWN | The lower layer cannot answer; participation or non-participation cannot be asserted | read-only |
| DC diagnostics | Never sampled | notApplicableReason == NOT_SAMPLED | All four items are 0 and not in window; 0 is not "perfectly synchronized" | read-only |
Read-failure family (not among the seven states; applicable is likewise false and the reason is readable separately):
| Category | Reason | Meaning | Read/write |
|---|---|---|---|
| DC diagnostics | SLAVE_READ_FAILED | The slave snapshot cannot be read; even the capability cannot be determined | read-only |
| DC diagnostics | REFERENCE_CLOCK_UNKNOWN | The reference clock station number cannot be read, so whether this station is the time base cannot be determined | read-only |
| DC diagnostics | WINDOW_READ_FAILED | Armed and not the reference clock, but the measured window read failed (lower-layer failure / context generation change) | read-only |
"Armed but outside the window" is also none of the seven: here applicable == true, inSync == false (and not frozen). Callers must handle the real conclusion and must not treat it as "not armed" or "unknown".
Tri-state (use null when unavailable)
| Category | Conclusion | When there is no conclusion | Java type | Read/write |
|---|---|---|---|---|
| DC diagnostics | Whether all are in window | No confirmed participant → unknown, not true | Boolean | read-only |
| DC diagnostics | Maximum sync difference | No usable window → unknown, not 0 | Integer | read-only |
| DC diagnostics | SYNC0 armed | The lower layer cannot answer → unknown, not false | Boolean | read-only |
"Not applicable" is never written as 0: the reference clock itself, not armed, no DC, and never sampled all produce no 0 ns.
Arming final state: always unavailable in Java
dcArmOutcome() always returns DcArmResult.UNKNOWN. The final state is decided and accounted for by the SDK auto-startup policy; the lower layer provides no equivalent query primitive, so Java can only obtain the live runtime state (sync0Armed()) and cannot reconstruct final-state branches such as "trial arming failed and rolled back / kept per user intent / deferred until after-map / capability evidence exception".
Therefore the documentation and UI must describe it as unavailable + reason: UNKNOWN means "this language does not have that accounting", not "not armed yet" and not "arming failed". To judge whether SYNC0 is produced right now use slave.DC().sync0Armed(); for the capability tier use dcCapability().
The legacy two-state summary surface cannot serve as tri-state
isAllSlavesInSync(int) (boolean, may be true when there is no DC) and getMaxSyncDifference() (int, -1 on failure) are default-value conventions of the lower-layer summary surface and cannot be used as tri-state. For tri-state read the master-level 2-second snapshot master.diagnostics().dcDiagnostics().
Reference clock and time base
- Reference clock: the master selects, in chain order, the first slave on the link with active DC (real SYNC0); when no station is armed it falls back to the first DC-capable station in the chain. The whole bus has exactly this one time base.
- Single start point: the reference domain has exactly one start instant (the same physical moment); the master converts it per the time domain each station sits in and writes it to
0x0990; it is not measured separately per station. - Reference clock handover (slave loss / hot-plug / capability change): every
0x0920written in the old clock's time domain becomes invalid. In chain order, the master re-reads0x0920for each DC station that is not in OP, not lost, and not the reference clock itself, proves it with a read-back, then rewrites that station's0x0990in the new time domain; stations in OP are not interrupted in their SYNC0 and the error is corrected by online adjustment. - Phase only:
0x0928is corrected in hardware by the ESC when generating SYNC0;shiftNsis only a phase shift and contains no propagation delay compensation. - Diagnostics: the current SDK does not expose read-only properties for
0x0990/0x0920; register-level evidence can be found in the DC diagnostics lines inevents.log.
DC receive timestamps
The receive instants of ports A/B/C/D are timestamps taken by the ESC when it receives a frame, recorded once per port. In foldback / ring topologies, how the readings of one slave's ports relate to each other directly reflects which direction the frame came in from, and is one of the original bases for judging path direction and the foldback window. All four are accessed directly through slave.*() and belong to the same family as dcParentPort().
| Category | Property | Type | Read/write | Description |
|---|---|---|---|---|
| DC receive timestamps | dcReceiveTimeB() | int | read-only | Port B receive time (ns) |
| dcReceiveTimeC() | int | read-only | Port C receive time (ns) | |
| dcReceiveTimeD() | int | read-only | Port D receive time (ns) |
dcReceiveTimeB()
public int dcReceiveTimeB()
Receive timestamp of port B (ns).
Returns:
int— the receive time of that port (ns). It is carried as a 32-bit signed value, so the nanosecond count may be negative when it wraps; useInteger.toUnsignedLong(...)when an unsigned interpretation is needed
The reading is undefined (usually 0) when the port is not connected or the slave does not support DC; do not take it as 「the receive instant is exactly 0 ns」. To judge DC capability use slave.hasDC(); to judge synchronization use slave.DC().sync0Armed() and dcSyncWindow().inSync.
dcReceiveTimeC()
public int dcReceiveTimeC()
Receive timestamp of port C (ns). The semantics and failure conventions are the same as dcReceiveTimeB().
Returns:
int— the receive time of that port (ns)
dcReceiveTimeD()
public int dcReceiveTimeD()
Receive timestamp of port D (ns). The semantics and failure conventions are the same as dcReceiveTimeB().
Returns:
int— the receive time of that port (ns)
Example:
System.out.printf("B=%d ns, C=%d ns, D=%d ns%n",
slave.dcReceiveTimeB(), slave.dcReceiveTimeC(), slave.dcReceiveTimeD());
Auto-startup rollback
During the transition to OP, auto-startup tries to arm SYNC0; on failure it has to take the station back to FreeRun, and it must not record that attempt as "the user asked for free run", otherwise the station permanently loses its eligibility for later automatic re-arming. The rollback and the verification that follows share the same per-slave evidence.
| Category | Method | Type/returns | Read/write | Description |
|---|---|---|---|---|
| Auto-startup rollback | rollbackDcFreeRunForAutoStartup() | int | call | Takes the station back to FreeRun without writing a user intent; tri-state 0 / -1 / -2 |
| Rollback evidence | setPdContributed(Boolean) | SlaveRealOpEvidence | call | Per-slave process data contribution evidence: TRUE / FALSE / null |
rollbackDcFreeRunForAutoStartup()
public int rollbackDcFreeRunForAutoStartup()
Dedicated rollback entry after a failed auto-startup arming: it takes the station back to FreeRun (clears 0x0980 and the synchronization type in the object dictionary in both directions) and does not record a user free-run intent, so the station keeps its eligibility for later automatic re-arming. That is exactly where it differs from disableDC() — disableDC() records a user intent.
Returns:
int—0= the intent has been cleared and the0x0980withdrawal has been dispatched;-1= the master / station number is unavailable (the intent is unchanged);-2= the intent has been cleared, but the hardware write was deferred by the configuration write gate (only the hardware side is unproven)
Example:
int rc = slave.rollbackDcFreeRunForAutoStartup();
switch (rc) {
case 0: System.out.println("已收回 FreeRun"); break; // FreeRun reclaimed
case -1: System.out.println("主站/站号不可用, 意图未改动"); break; // Master/slave index unavailable, intent unchanged
case -2: System.out.println("意图已清除, 硬件写延后"); break; // Intent cleared, hardware write deferred
default: System.out.println("未知返回: " + rc); break; // Unknown return:
}
setPdContributed(Boolean value)
public SlaveRealOpEvidence setPdContributed(Boolean value)
The "process data contribution" bit of the per-slave evidence, used when rolling back a failed auto-startup arming and when verifying a real OP. This field belongs to the chainable assembly interface of SlaveRealOpEvidence.
Parameters:
value(Boolean) —TRUE= confirmed contributing;FALSE= confirmed not contributing;null= unknown (cannot be read / the contract is not ready)
Returns:
SlaveRealOpEvidence— the current object (this), for chainable assembly
null is a valid value and must be preserved. Writing "cannot read" as FALSE makes the verification treat that station as "confirmed not contributing" and misjudge it as abnormal; writing TRUE hides a real station loss. Pass FALSE only when "not contributing" was really read in this round.
Sync-loss event injection
triggerDCSyncLost(int diffNs)
public void triggerDCSyncLost(int diffNs)
Delivers one DC synchronization loss to the SlaveEvents.DCSyncLostListener registered for this slave. This is the local injection entry: it does not read registers and does not send frames, and is meant for self-tests and assertions; loss of lock on a real bus is still routed in by the master event system at delivery time.
Parameters:
diffNs(int) — DC deviation (ns)
Returns:
- none (
void)
Example:
slave.events().addDCSyncLostListener(diffNs ->
System.out.printf("从站 %d DC 失锁: %d ns%n", slave.SlaveNum, diffNs)); // Slave %d DC lost lock: %d ns%n
slave.events().triggerDCSyncLost(250_000);
Full example
Slave slave = master.getSlave(1);
if (slave.hasDC()) {
// Query the current synchronization mode
DC.DcSyncMode currentMode = slave.DC().currentDcSyncMode();
System.out.printf("当前同步模式: %s%n", currentMode); // Current sync mode: %s%n
// Configure DC synchronization
slave.DC().configureDC(DC.DcSyncMode.DcSynchron, 1_000_000, 0, DC.DC_SHIFT_UNSPECIFIED); // SYNC0 = 1ms
System.out.printf("DCActive=%d, DCCycle0=%dns, DCShift=%dns%n",
slave.dcActive(), slave.dcCycle0(), slave.dcShift());
System.out.printf("传播延迟=%dns%n", slave.DC().propagationDelay()); // Propagation delay=%dns%n
// Detailed sync window status
DC.SyncWindowStatus status = slave.DC().getSyncWindowStatus();
if (status != null) {
System.out.printf("同步差=%dns, 同步=%b, 最大=%dns, 最小=%dns%n", // Sync diff=%dns, synced=%b, max=%dns, min=%dns%n
status.DiffNs, status.InSync, status.MaxDiffNs, status.MinDiffNs);
System.out.printf("超出同步窗口次数=%d%n", status.OutOfSyncCount); // Sync window exceeded count=%d%n
}
// Reset the sync window statistics
slave.DC().resetSyncWindowStats();
// Switch to SM synchronization mode
// slave.DC().configureDC(DC.DcSyncMode.SmSynchron, 0, 0, 0);
// Disable DC
// slave.DC().disableDC();
}