Builder API for EtherCAT.Simulator.inject_fault/1.
This keeps the public fault surface readable without changing the simulator's internal tuple representation.
Typical usage:
alias EtherCAT.Simulator.Fault
EtherCAT.Simulator.inject_fault(Fault.drop_responses())
EtherCAT.Simulator.inject_fault(
Fault.disconnect(:outputs)
|> Fault.next(30)
)
EtherCAT.Simulator.inject_fault(
Fault.script([
Fault.drop_responses(),
Fault.wait_for(Fault.healthy_polls(:outputs, 10)),
Fault.retreat_to_safeop(:outputs)
])
)
Fault.describe(Fault.disconnect(:outputs) |> Fault.next(3))
Summary
Types
@type effect() :: :drop_responses | {:wkc_offset, integer()} | {:command_wkc_offset, atom(), integer()} | {:logical_wkc_offset, atom(), integer()} | {:disconnect, atom()} | {:retreat_to_safeop, atom()} | {:power_cycle, atom()} | {:latch_al_error, atom(), non_neg_integer()} | {:mailbox_abort, atom(), non_neg_integer(), non_neg_integer(), non_neg_integer(), mailbox_step() | nil} | {:mailbox_protocol_fault, atom(), non_neg_integer(), non_neg_integer(), mailbox_step(), term()} | {:nested, t() | raw_fault()} | {:script, [t()]} | {:wait_for_milestone, milestone()}
@type mailbox_step() ::
:request | :upload_init | :upload_segment | :download_init | :download_segment
@type milestone() :: {:healthy_exchanges, pos_integer()} | {:healthy_polls, atom(), pos_integer()} | {:mailbox_step, atom(), mailbox_step(), pos_integer()}
@type raw_fault() :: EtherCAT.Simulator.fault() | EtherCAT.Simulator.immediate_fault() | EtherCAT.Simulator.fault_script_step()
@type schedule() :: :immediate | {:next_exchange, pos_integer()} | {:after_ms, non_neg_integer()} | {:after_milestone, milestone()}
Functions
@spec after_ms(t(), non_neg_integer()) :: t()
@spec drop_responses() :: t()
@spec healthy_exchanges(pos_integer()) :: milestone()
@spec healthy_polls(atom(), pos_integer()) :: milestone()
@spec latch_al_error(atom(), non_neg_integer()) :: t()
@spec mailbox_abort( atom(), non_neg_integer(), non_neg_integer(), non_neg_integer(), keyword() ) :: t()
@spec mailbox_protocol_fault( atom(), non_neg_integer(), non_neg_integer(), mailbox_step(), term() ) :: t()
@spec mailbox_step(atom(), mailbox_step(), pos_integer()) :: milestone()
@spec next(t(), pos_integer()) :: t()