IEC 60870-5-104 Slave / Server (cs104_slave.c).
Supports:
- TCP and TLS (
:ssl) listening sockets - Three redundancy modes:
:single_redundancy_group(default: single shared low/high priority queue; only one active connection at a time):connection_is_redundancy_group(each connection has its own independent low/high priority queue):multiple_redundancy_groups(connections are grouped by IP intoRedundancyGroups, each with its own queues and single active connection)
- Low-priority event queue (with ring-buffer overflow replacement and unconfirmed requeue on failover)
- High-priority response queue
- Standard application callbacks:
interrogation_handler:fn conn_pid, asdu, qoi -> boolean() endcounter_interrogation_handler:fn conn_pid, asdu, qcc -> boolean() endread_handler:fn conn_pid, asdu, ioa -> boolean() endclock_sync_handler:fn conn_pid, asdu, cp56time2a -> boolean() | {:ok, CP56Time2a.t()} endreset_process_handler:fn conn_pid, asdu, qrp -> boolean() enddelay_acquisition_handler:fn conn_pid, asdu, delay_ms -> boolean() endasdu_handler:fn conn_pid, asdu -> boolean() endconnection_request_handler:fn {ip_str, port} -> boolean() endconnection_event_handler:fn conn_pid, event -> any() endis_ca_allowed_handler:fn ca -> boolean() end
Summary
Functions
Adds a RedundancyGroup to the Slave (CS104_Slave_addRedundancyGroup).
Returns a specification to start this module under a supervisor.
Enqueues a spontaneous/periodic ASDU into the low-priority transmission queue(s).
Matches CS104_Slave_enqueueASDU in cs104_slave.c.
Enqueues an ASDU into the transmission queue(s). Convenience alias for enqueue_asdu/2.
Returns the number of entries in the low-priority ASDU queue (CS104_Slave_getNumberOfQueueEntries).
If redundancy_group is nil, returns the count for the default queue (or first redundancy group).
Returns the number of currently open client connections.
Returns the actual local TCP port the server is listening on (useful when started with port: 0).
Checks whether the Slave server is currently listening for connections (CS104_Slave_isRunning).
Starts a CS104.Slave server process.
By default starts listening immediately unless auto_start: false is passed.
Types
Functions
@spec add_redundancy_group(GenServer.server(), IEC60870.CS104.RedundancyGroup.t()) :: :ok
Adds a RedundancyGroup to the Slave (CS104_Slave_addRedundancyGroup).
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec enqueue_asdu(GenServer.server(), IEC60870.ASDU.t()) :: :ok
Enqueues a spontaneous/periodic ASDU into the low-priority transmission queue(s).
Matches CS104_Slave_enqueueASDU in cs104_slave.c.
@spec enqueue_user_data(GenServer.server(), IEC60870.ASDU.t()) :: :ok
Enqueues an ASDU into the transmission queue(s). Convenience alias for enqueue_asdu/2.
@spec get_apci_parameters(GenServer.server()) :: IEC60870.APCIParameters.t()
@spec get_app_layer_parameters(GenServer.server()) :: IEC60870.AppLayerParameters.t()
@spec get_number_of_queue_entries( GenServer.server(), IEC60870.CS104.RedundancyGroup.t() | non_neg_integer() | nil ) :: non_neg_integer()
Returns the number of entries in the low-priority ASDU queue (CS104_Slave_getNumberOfQueueEntries).
If redundancy_group is nil, returns the count for the default queue (or first redundancy group).
@spec get_open_connections(GenServer.server()) :: non_neg_integer()
Returns the number of currently open client connections.
@spec get_port(GenServer.server()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the actual local TCP port the server is listening on (useful when started with port: 0).
@spec is_running?(GenServer.server()) :: boolean()
Checks whether the Slave server is currently listening for connections (CS104_Slave_isRunning).
@spec start(GenServer.server()) :: :ok | {:error, term()}
Starts a CS104.Slave server process.
By default starts listening immediately unless auto_start: false is passed.
@spec stop(GenServer.server()) :: :ok