# `EtherCAT.Simulator.Slave`
[🔗](https://github.com/sid2baker/ethercat/blob/main/lib/ethercat/simulator/slave.ex#L1)

Device and signal-level API for simulated EtherCAT slaves.

Use this module to hydrate simulated devices from real
`EtherCAT.Slave.Driver` modules and to inspect or override named signal
values on a running simulator.

`from_driver/2` can hydrate a simulated device from a real
`EtherCAT.Slave.Driver` plus an optional simulator-side companion module such
as `MyDriver.Simulator`.

# `device`

```elixir
@type device() :: EtherCAT.Simulator.Slave.Definition.t()
```

# `driver`

```elixir
@type driver() :: module()
```

# `signal_ref`

```elixir
@type signal_ref() :: {atom(), atom()}
```

# `connect`

```elixir
@spec connect(signal_ref(), signal_ref()) ::
  :ok | {:error, :not_found | :unknown_signal | :invalid_value}
```

# `connections`

```elixir
@spec connections() :: {:ok, [map()]} | {:error, :not_found | :timeout}
```

# `disconnect`

```elixir
@spec disconnect(signal_ref(), signal_ref()) :: :ok | {:error, :not_found}
```

# `from_driver`

```elixir
@spec from_driver(
  driver(),
  keyword()
) :: device()
```

# `get_value`

```elixir
@spec get_value(atom(), atom()) ::
  {:ok, term()} | {:error, :not_found | :unknown_signal}
```

# `set_value`

```elixir
@spec set_value(atom(), atom(), term()) ::
  :ok | {:error, :not_found | :unknown_signal | :invalid_value}
```

# `signal_definitions`

```elixir
@spec signal_definitions(device()) :: %{optional(atom()) =&gt; map()}
@spec signal_definitions(atom()) ::
  {:ok, %{optional(atom()) =&gt; map()}} | {:error, :not_found}
```

# `signals`

```elixir
@spec signals(device()) :: [atom()]
@spec signals(atom()) :: {:ok, [atom()]} | {:error, :not_found}
```

# `subscribe`

```elixir
@spec subscribe(atom()) :: :ok | {:error, :not_found}
```

# `subscribe`

```elixir
@spec subscribe(atom(), atom() | :all) :: :ok | {:error, :not_found}
```

# `subscribe`

```elixir
@spec subscribe(atom(), atom() | :all, pid()) :: :ok | {:error, :not_found}
```

# `unsubscribe`

```elixir
@spec unsubscribe(atom()) :: :ok | {:error, :not_found}
```

# `unsubscribe`

```elixir
@spec unsubscribe(atom(), atom() | :all) :: :ok | {:error, :not_found}
```

# `unsubscribe`

```elixir
@spec unsubscribe(atom(), atom() | :all, pid()) :: :ok | {:error, :not_found}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
