ExDlt645.Query (ex_dlt645 v0.1.0)

Copy Markdown View Source

Inspection, diagnostic, and query tools for DL/T 645-2007.

Provides utilities for protocol inspection and diagnosis:

  • Query metadata for any Data Identifier (DI)
  • Search DIs by keyword (e.g. "电压", "电流", "有功", "需量")
  • Detailed inspection and visual formatting of raw hex frames

Summary

Functions

Returns metadata info for the given Data Identifier (number, hex string, or binary).

Inspects and decodes a raw frame binary or hex string, printing a human-readable breakdown with parsed frame headers, data identifier info, and payload content.

Searches standard DL/T 645 Data Identifiers matching a keyword.

Prints formatted metadata for the given Data Identifier to the console.

Functions

info(di)

@spec info(non_neg_integer() | binary() | String.t()) ::
  {:ok, ExDlt645.DataId.Info.t()} | {:error, :unknown_di}

Returns metadata info for the given Data Identifier (number, hex string, or binary).

inspect_frame(input)

@spec inspect_frame(binary() | String.t()) ::
  {:ok, ExDlt645.Frame.t()} | {:error, term()}

Inspects and decodes a raw frame binary or hex string, printing a human-readable breakdown with parsed frame headers, data identifier info, and payload content.

search(keyword)

@spec search(String.t()) :: [map()]

Searches standard DL/T 645 Data Identifiers matching a keyword.

Examples

iex> ExDlt645.Query.search("电压")
[
  %{di: 0x02010100, name: "A相电压", unit: "V", format: :xxx_x},
  %{di: 0x02010200, name: "B相电压", unit: "V", format: :xxx_x},
  ...
]

show_info(di)

@spec show_info(non_neg_integer() | binary() | String.t()) ::
  :ok | {:error, :unknown_di}

Prints formatted metadata for the given Data Identifier to the console.