# ExIEC60870 v0.1.0 - API Reference

## Modules

- Core &amp; Application Layer
  - [IEC60870](IEC60870.md): Pure Elixir implementation of IEC 60870-5-101 and IEC 60870-5-104 (Master & Slave, Balanced & Unbalanced,
full Information Objects, and bidirectional File Transfer Service), modeled after `lib60870-C`.
  - [IEC60870.ASDU](IEC60870.ASDU.md): Application Service Data Unit (ASDU) shared by IEC 60870-5-101 and IEC 60870-5-104.
Matches `cs101_asdu.c` in `lib60870-C`.
  - [IEC60870.AppLayerParameters](IEC60870.AppLayerParameters.md): Application layer parameters shared by IEC 60870-5-101 and IEC 60870-5-104.
Corresponds to `sCS101_AppLayerParameters` in `lib60870-C`.

  - [IEC60870.InformationObject](IEC60870.InformationObject.md): Unified dispatcher and helper functions for all IEC 60870-5-101/104 Information Objects.

  - [IEC60870.InformationObject.RawObject](IEC60870.InformationObject.RawObject.md): Fallback representation for custom or security ASDU payloads.

  - [IEC60870.Telemetry](IEC60870.Telemetry.md): Telemetry integration for IEC 60870 protocol events and metrics.

- Monitoring Information Objects
  - [IEC60870.IO.Monitoring](IEC60870.IO.Monitoring.md): Monitoring direction Information Objects (TypeIDs 1..21, 30..41, 70).
Matches `cs101_information_objects.c` in `lib60870-C`.

  - [IEC60870.IO.Monitoring.BitString32](IEC60870.IO.Monitoring.BitString32.md): 32-bit bitstring value with quality and optional timestamp (M_BO_NA_1, M_BO_TA_1, M_BO_TB_1).

  - [IEC60870.IO.Monitoring.DoublePointInformation](IEC60870.IO.Monitoring.DoublePointInformation.md): Double point information with quality (:off, :on, etc.) and optional timestamp (M_DP_NA_1, M_DP_TA_1, M_DP_TB_1).

  - [IEC60870.IO.Monitoring.EndOfInitialization](IEC60870.IO.Monitoring.EndOfInitialization.md): End of initialization indicator with cause of initialization (M_EI_NA_1, TypeID 70).

  - [IEC60870.IO.Monitoring.EventOfProtectionEquipment](IEC60870.IO.Monitoring.EventOfProtectionEquipment.md): Event of protection equipment with relative elapsed time (M_EP_TA_1, M_EP_TD_1).

  - [IEC60870.IO.Monitoring.IntegratedTotals](IEC60870.IO.Monitoring.IntegratedTotals.md): Integrated totals / counter value (BinaryCounterReading BCR) (M_IT_NA_1, M_IT_TA_1, M_IT_TB_1).

  - [IEC60870.IO.Monitoring.IntegratedTotalsForSecurityStatistics](IEC60870.IO.Monitoring.IntegratedTotalsForSecurityStatistics.md): Security statistics totals with sequence number (S_IT_TC_1, TypeID 41).

  - [IEC60870.IO.Monitoring.MeasuredValueNormalized](IEC60870.IO.Monitoring.MeasuredValueNormalized.md): Normalized measured value (-1.0..+1.0 / -32768..32767) (M_ME_NA_1, M_ME_TA_1, M_ME_TD_1, M_ME_ND_1).

  - [IEC60870.IO.Monitoring.MeasuredValueScaled](IEC60870.IO.Monitoring.MeasuredValueScaled.md): 16-bit scaled integer measured value (-32768..32767) (M_ME_NB_1, M_ME_TB_1, M_ME_TE_1).

  - [IEC60870.IO.Monitoring.MeasuredValueShort](IEC60870.IO.Monitoring.MeasuredValueShort.md): IEEE 754 32-bit single precision floating point measured value (M_ME_NC_1, M_ME_TC_1, M_ME_TF_1).

  - [IEC60870.IO.Monitoring.PackedOutputCircuitInfo](IEC60870.IO.Monitoring.PackedOutputCircuitInfo.md): Packed output circuit information of protection equipment (M_EP_TC_1, M_EP_TF_1).

  - [IEC60870.IO.Monitoring.PackedSinglePointWithSCD](IEC60870.IO.Monitoring.PackedSinglePointWithSCD.md): Packed single-point information with status change detection (M_PS_NA_1, TypeID 20).

  - [IEC60870.IO.Monitoring.PackedStartEventsOfProtectionEquipment](IEC60870.IO.Monitoring.PackedStartEventsOfProtectionEquipment.md): Packed start events of protection equipment (M_EP_TB_1, M_EP_TE_1).

  - [IEC60870.IO.Monitoring.SinglePointInformation](IEC60870.IO.Monitoring.SinglePointInformation.md): Single point information with quality and optional timestamp (M_SP_NA_1, M_SP_TA_1, M_SP_TB_1).

  - [IEC60870.IO.Monitoring.StepPositionInformation](IEC60870.IO.Monitoring.StepPositionInformation.md): Step position information with transient state and quality (M_ST_NA_1, M_ST_TA_1, M_ST_TB_1).

- Control Information Objects
  - [IEC60870.IO.Control](IEC60870.IO.Control.md): Control direction Process Command Information Objects (TypeIDs 45..51, 58..64).
Matches `cs101_information_objects.c` in `lib60870-C`.

  - [IEC60870.IO.Control.Bitstring32Command](IEC60870.IO.Control.Bitstring32Command.md): 32-bit bitstring command (C_BO_NA_1, C_BO_TA_1).

  - [IEC60870.IO.Control.DoubleCommand](IEC60870.IO.Control.DoubleCommand.md): Double command (C_DC_NA_1, C_DC_TA_1).

  - [IEC60870.IO.Control.SetpointCommandNormalized](IEC60870.IO.Control.SetpointCommandNormalized.md): Normalized setpoint command (C_SE_NA_1, C_SE_TA_1).

  - [IEC60870.IO.Control.SetpointCommandScaled](IEC60870.IO.Control.SetpointCommandScaled.md): Scaled setpoint command (C_SE_NB_1, C_SE_TB_1).

  - [IEC60870.IO.Control.SetpointCommandShort](IEC60870.IO.Control.SetpointCommandShort.md): Short floating point setpoint command (C_SE_NC_1, C_SE_TC_1).

  - [IEC60870.IO.Control.SingleCommand](IEC60870.IO.Control.SingleCommand.md): Single command (C_SC_NA_1, C_SC_TA_1).

  - [IEC60870.IO.Control.StepCommand](IEC60870.IO.Control.StepCommand.md): Regulating step command (C_RC_NA_1, C_RC_TA_1).

- System Information Objects
  - [IEC60870.IO.System](IEC60870.IO.System.md): System Command Information Objects in Control Direction (TypeIDs 100..107).
Matches `cs101_information_objects.c` in `lib60870-C`.

  - [IEC60870.IO.System.ClockSynchronizationCommand](IEC60870.IO.System.ClockSynchronizationCommand.md): Clock synchronization command with CP56Time2a (C_CS_NA_1, TypeID 103).

  - [IEC60870.IO.System.CounterInterrogationCommand](IEC60870.IO.System.CounterInterrogationCommand.md): Counter interrogation command (C_CI_NA_1, TypeID 101).

  - [IEC60870.IO.System.DelayAcquisitionCommand](IEC60870.IO.System.DelayAcquisitionCommand.md): Delay acquisition command (C_CD_NA_1, TypeID 106).

  - [IEC60870.IO.System.InterrogationCommand](IEC60870.IO.System.InterrogationCommand.md): General interrogation command (C_IC_NA_1, TypeID 100).

  - [IEC60870.IO.System.ReadCommand](IEC60870.IO.System.ReadCommand.md): Read command (C_RD_NA_1, TypeID 102).

  - [IEC60870.IO.System.ResetProcessCommand](IEC60870.IO.System.ResetProcessCommand.md): Reset process command (C_RP_NA_1, TypeID 105).

  - [IEC60870.IO.System.TestCommand](IEC60870.IO.System.TestCommand.md): Test command (C_TS_NA_1, TypeID 104).

  - [IEC60870.IO.System.TestCommandWithCP56Time2a](IEC60870.IO.System.TestCommandWithCP56Time2a.md): Test command with CP56Time2a timestamp (C_TS_TA_1, TypeID 107).

- Parameter Information Objects
  - [IEC60870.IO.Parameter](IEC60870.IO.Parameter.md): Parameter Information Objects in Control Direction (TypeIDs 110..113).
Matches `cs101_information_objects.c` in `lib60870-C`.

  - [IEC60870.IO.Parameter.ParameterActivation](IEC60870.IO.Parameter.ParameterActivation.md): Parameter activation command (P_AC_NA_1, TypeID 113).

  - [IEC60870.IO.Parameter.ParameterFloatValue](IEC60870.IO.Parameter.ParameterFloatValue.md): Short float parameter (P_ME_NC_1, TypeID 112).

  - [IEC60870.IO.Parameter.ParameterNormalizedValue](IEC60870.IO.Parameter.ParameterNormalizedValue.md): Normalized value parameter (P_ME_NA_1, TypeID 110).

  - [IEC60870.IO.Parameter.ParameterScaledValue](IEC60870.IO.Parameter.ParameterScaledValue.md): Scaled value parameter (P_ME_NB_1, TypeID 111).

- File Information Objects
  - [IEC60870.IO.File](IEC60870.IO.File.md): File Transfer Information Objects (TypeIDs 120..127 and extended TypeID 210).
Matches `cs101_information_objects.c` in `lib60870-C`.

  - [IEC60870.IO.File.ExtendedFilePacket](IEC60870.IO.File.ExtendedFilePacket.md): Extended file packet for domestic 210 file transfer.

  - [IEC60870.IO.File.FileACK](IEC60870.IO.File.FileACK.md): File transfer acknowledgement (F_AF_NA_1, TypeID 124).

  - [IEC60870.IO.File.FileCallOrSelect](IEC60870.IO.File.FileCallOrSelect.md): Call directory, select file, call file, call section (F_SC_NA_1, TypeID 122).

  - [IEC60870.IO.File.FileDirectory](IEC60870.IO.File.FileDirectory.md): Directory information response (F_DR_TA_1, TypeID 126).

  - [IEC60870.IO.File.FileLastSegmentOrSection](IEC60870.IO.File.FileLastSegmentOrSection.md): Last section or last segment confirmation (F_LS_NA_1, TypeID 123).

  - [IEC60870.IO.File.FileReady](IEC60870.IO.File.FileReady.md): File ready message (F_FR_NA_1, TypeID 120, and domestic F_FR_NA_2, TypeID 210).

  - [IEC60870.IO.File.FileSegment](IEC60870.IO.File.FileSegment.md): File data segment (F_SG_NA_1, TypeID 125).

  - [IEC60870.IO.File.QueryLog](IEC60870.IO.File.QueryLog.md): Query log / directory by time range (F_SC_NB_1, TypeID 127).

  - [IEC60870.IO.File.SectionReady](IEC60870.IO.File.SectionReady.md): Section ready message (F_SR_NA_1, TypeID 121).

- Types &amp; Qualifiers
  - [IEC60870.Types.BCR](IEC60870.Types.BCR.md): Binary Counter Reading (`BinaryCounterReading`, 5 bytes) according to IEC 60870-5-101 7.2.6.9.
Matches `cs101_bcr.c`.
  - [IEC60870.Types.COT](IEC60870.Types.COT.md): Cause of Transmission (`CS101_CauseOfTransmission`).

  - [IEC60870.Types.CPTime](IEC60870.Types.CPTime.md): Binary time types `CP16Time2a` (2 bytes), `CP24Time2a` (3 bytes),
`CP32Time2a` (4 bytes), and `CP56Time2a` (7 bytes).
Matches `cpXXtime2a.c` in `lib60870-C`.

  - [IEC60870.Types.CPTime.CP16Time2a](IEC60870.Types.CPTime.CP16Time2a.md): 2-byte binary time: elapsed time in milliseconds (`0..65535`).

  - [IEC60870.Types.CPTime.CP24Time2a](IEC60870.Types.CPTime.CP24Time2a.md): 3-byte binary time: millisecond (0..999), second (0..59), minute (0..59),
substituted flag (`0x40`), invalid flag (`0x80`).

  - [IEC60870.Types.CPTime.CP32Time2a](IEC60870.Types.CPTime.CP32Time2a.md): 4-byte binary time: millisecond, second, minute, substituted, invalid, hour (0..23), summer_time.

  - [IEC60870.Types.CPTime.CP56Time2a](IEC60870.Types.CPTime.CP56Time2a.md): 7-byte binary time (`CP56Time2a`) according to IEC 60870-5-101 7.2.6.18.
Matches `CP56Time2a_*` functions in `cpXXtime2a.c`.

  - [IEC60870.Types.Qualifiers](IEC60870.Types.Qualifiers.md): Quality descriptors, qualifiers, and value scaling helpers for IEC 60870-5-101/104.
Matches `cs101_information_objects.h` and `cs101_information_objects.c`.

  - [IEC60870.Types.TypeID](IEC60870.Types.TypeID.md): IEC 60870-5 ASDU Type Identifications (`IEC60870_5_TypeID`).
Supports bidirectional conversion between integer codes (1..255) and descriptive atoms,
as well as element byte size lookup and single-IO validation.

- IEC 60870-5-104 (Network)
  - [IEC60870.APCIParameters](IEC60870.APCIParameters.md): APCI (Application Protocol Control Information) parameters for IEC 60870-5-104.
Corresponds to `sCS104_APCIParameters` in `lib60870-C`.
  - [IEC60870.CS104.Connection](IEC60870.CS104.Connection.md): IEC 60870-5-104 Client / Master Connection (`GenServer`), equivalent to `cs104_connection.c`.
  - [IEC60870.CS104.Frame](IEC60870.CS104.Frame.md): IEC 60870-5-104 APCI frame codec and stream deframer (`cs104_frame.c`).
  - [IEC60870.CS104.MasterConnection](IEC60870.CS104.MasterConnection.md): Represents a connected Master (Client) peer on a `CS104.Slave` server (`MasterConnection` in `cs104_slave.c`).
  - [IEC60870.CS104.RedundancyGroup](IEC60870.CS104.RedundancyGroup.md): Configuration for a CS104 redundancy group (`CS104_RedundancyGroup` in `cs104_slave.c`).
  - [IEC60870.CS104.Slave](IEC60870.CS104.Slave.md): IEC 60870-5-104 Slave / Server (`cs104_slave.c`).

- IEC 60870-5-101 (Serial)
  - [IEC60870.CS101.Frame](IEC60870.CS101.Frame.md): IEC 60870-5-101 FT 1.2 frame codec and stream deframer (`serial_transceiver_ft_1_2.c` & `link_layer.c`).
  - [IEC60870.CS101.LinkLayer](IEC60870.CS101.LinkLayer.md): IEC 60870-5-101 Link Layer state machines (`link_layer.c`), supporting:
- `SecondaryUnbalanced` (Slave in `:unbalanced` mode)
- `PrimaryUnbalanced` (Master in `:unbalanced` mode, supporting multiple slaves)
- `Balanced` (Full-duplex Primary + Secondary for both Master and Slave in `:balanced` mode)

  - [IEC60870.CS101.Master](IEC60870.CS101.Master.md): IEC 60870-5-101 Master (`cs101_master.c`), supporting both `:balanced` and `:unbalanced` link layer modes.
  - [IEC60870.CS101.Queue](IEC60870.CS101.Queue.md): FIFO Queue for CS101 ASDUs (`cs101_queue.c`).
Used for Class 1 / Class 2 queues in `CS101.Slave` and user data queue in `CS101.Master`.

  - [IEC60870.CS101.Slave](IEC60870.CS101.Slave.md): IEC 60870-5-101 Slave (`cs101_slave.c`), supporting both `:unbalanced` and `:balanced` link layer modes.
  - [IEC60870.CS101.Transport](IEC60870.CS101.Transport.md): Transport abstraction for IEC 60870-5-101 serial / virtual links.
  - [IEC60870.CS101.Transport.UART](IEC60870.CS101.Transport.UART.md): Adapter for `Circuits.UART` hardware serial ports.
  - [IEC60870.CS101.Transport.VirtualBus](IEC60870.CS101.Transport.VirtualBus.md): In-memory virtual serial bus (RS-232 / RS-485 bus simulator) for CS101 Master & Slave.
  - [IEC60870.LinkLayerParameters](IEC60870.LinkLayerParameters.md): Serial link layer parameters for IEC 60870-5-101.
Corresponds to `sLinkLayerParameters` in `lib60870-C`.

- File Transfer Service
  - [IEC60870.FileService.Client](IEC60870.FileService.Client.md): IEC 60870-5-101 / 104 File Transfer Client for Master stations.
  - [IEC60870.FileService.Receiver](IEC60870.FileService.Receiver.md): Accumulator for receiving multi-section / multi-segment files during IEC 60870-5-101/104
file transfers (`CS101_IFileReceiver` in `cs101_file_service.h`).

  - [IEC60870.FileService.Receiver.Memory](IEC60870.FileService.Receiver.Memory.md): In-memory file receiver container (`CS101_IFileReceiver` memory receiver).

  - [IEC60870.FileService.Server](IEC60870.FileService.Server.md): IEC 60870-5-101 / 104 File Transfer Server (`file_server.c`) for Slave stations.
  - [IEC60870.FileService.TransparentFile](IEC60870.FileService.TransparentFile.md): Represents a file composed of one or more binary sections for IEC 60870-5-101/104 File Transfer
(`CS101_IFileProvider` / `CS101_TransparentFile` in `cs101_file_service.h`).

