ExCEP. Model. Parser
(ex_cep v0.1.1)
Copy Markdown
Strict JSON parser, semantic validator, and serializer for CSG CEP TS2.1 Simplified Device Model files (Section 8.3, Tables 27–28, Section 9.2, Appendix B).
Validation Rules Enforced (TS2.1 Section 9.2)
- Syntax: valid UTF-8 JSON object with exact hierarchy (
schema,profile,services). - Key Whitelist: rejects unknown keys or keys placed at the wrong nesting level across
root,
profile,services[], andDOs[]. - Naming & Constraints:
profile.modelmatches<mfg(1..6)>_<devType(1..12)>_<I|J>_V<x.xx>serviceIdis one ofparameter | analog | discrete | control | accumulatorLDnameis 1..6 ASCII characters;LNinstis a positive integer string ("1","2", ...)datatypeis a valid TS2.1 Table 27 datatypedeadzonetypeis"","0", or"1"- Computed
DataRefer(LDname.LNtype.LNinst.DOname) is unique within each service
- Filename Check (
parse_file/2): whencheck_filename: true(default), verifies the filename matches<profile.model>.json.
Summary
Functions
Parses and validates a TS2.1 simplified model .json file from disk.
Parses and validates a TS2.1 simplified model JSON binary into %ExCEP.Model{}.
Serializes %ExCEP.Model{} into a TS2.1 Appendix B compliant JSON binary.
Performs TS2.1 Section 9.2.2 semantic validation on %ExCEP.Model{}.
Functions
@spec parse_file(Path.t(), keyword()) :: {:ok, ExCEP.Model.t()} | {:error, term()}
Parses and validates a TS2.1 simplified model .json file from disk.
Options
:check_filename- verify filename matches<profile.model>.json(defaulttrue):strict_keys- reject undefined keys per TS2.1 Section 9.2.2 (defaulttrue)
@spec parse_json(binary(), keyword()) :: {:ok, ExCEP.Model.t()} | {:error, term()}
Parses and validates a TS2.1 simplified model JSON binary into %ExCEP.Model{}.
Options
:strict_keys- reject undefined keys per TS2.1 Section 9.2.2 (defaulttrue)
@spec to_json(ExCEP.Model.t(), keyword()) :: {:ok, binary()} | {:error, term()}
Serializes %ExCEP.Model{} into a TS2.1 Appendix B compliant JSON binary.
@spec validate(ExCEP.Model.t()) :: :ok | {:error, term()}
Performs TS2.1 Section 9.2.2 semantic validation on %ExCEP.Model{}.