# `ExCEP.Model`

CSG CEP Plug-and-Play Device Model structure aligned with **TS2.1**
(Section 8, Tables 27–28, Section 9, Appendix B).

## Model Naming Convention (TS2.1 Section 8.1)
`<manufacturerId>_<devType>_<fileType>_<version>`
- `manufacturerId`: 1..6 ASCII alphanumeric/hyphen characters (no `_`)
- `devType`: 1..12 ASCII alphanumeric/hyphen characters (no `_`)
- `fileType`: `"I"` (DL/T 860 ICD) or `"J"` (simplified JSON)
- `version`: `"Vx.xx"` (e.g. `"V1.00"`)
- Example: `"AABB_ABC-1122C_J_V1.00"` -> file `"/data/app/model/AABB_ABC-1122C_J_V1.00.json"`

# `t`

```elixir
@type t() :: %ExCEP.Model{
  dev_type: String.t(),
  manufacturer_desc: String.t(),
  manufacturer_id: String.t(),
  model: String.t(),
  model_desc: String.t(),
  modify_time: String.t() | nil,
  schema: String.t(),
  services: [ExCEP.Model.Service.t()],
  version: String.t()
}
```

# `build_model_meta`

```elixir
@spec build_model_meta(t(), String.t(), binary()) :: map()
```

Builds the TS2.2 `GetModelResp` / `ModelChange` metadata map (`ModelName`, `ModifyTime`,
`FullPathFileName`, `FileCrc`) for a model and its serialized file binary.

# `default_model_dir`

```elixir
@spec default_model_dir() :: String.t()
```

Returns the default TS2.1 gateway model directory `"/data/app/model"`.

# `find_point`

```elixir
@spec find_point(t(), String.t(), String.t()) ::
  {:ok, ExCEP.Model.Point.t()} | {:error, :not_found}
```

Finds a `%Point{}` by `service_id` and its `DataRefer` (`"LDname.LNtype.LNinst.DOname"`)
or bare `DOname`.

# `list_points`

```elixir
@spec list_points(t(), String.t() | nil) :: [ExCEP.Model.Point.t()]
```

Lists all `%Point{}` entries for `service_id` (or across all services if `nil`).

# `standard_services`

```elixir
@spec standard_services() :: [String.t()]
```

Returns the 5 standard TS2.1 `serviceId` values.

# `validate_filename`

```elixir
@spec validate_filename(String.t()) :: :ok | {:error, :invalid_model_filename}
```

Validates a TS2.1 simplified model filename (`"<model>.json"`) or ICD filename (`"<model>.icd"`).

# `validate_model_name`

```elixir
@spec validate_model_name(String.t()) :: :ok | {:error, :invalid_model_name}
```

Validates a model name against TS2.1 Section 8.1:
`<mfg(1..6)>_<devType(1..12)>_<I|J>_V<x.xx>`.

---

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