Skip to content

Commit

Permalink
made tcp client somewhat available, added most basic documentation ex…
Browse files Browse the repository at this point in the history
…amples
  • Loading branch information
engineerjoe440 authored Dec 26, 2023
1 parent 5cf9f08 commit 75f1887
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
59 changes: 59 additions & 0 deletions docsource/client_examples/simple_autoconfiguration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Performing Automatic Configuration with an SEL Relay

SEL Protocol operates in a self-describing manner wherein the relay or intelligent electronic
device provides a standard interface for binary messages to describe the layout of specific
data regions. This makes it possible for the relay to describe the methods in which a user may
query the device for data, send control operations, or otherwise interact with the relay.

SELProtoPy provides mechanisms for the client objects to negotiate the automatic configuration
process with a device to establish the devices capabilities.

## Autoconfiguration with a Serially-Connected Device

The following example assumes a Linux environment using a USB-to-serial adapter (thus the
`/dev/ttyUSB1`) in use.

```python
# Import the serial client object from SELProtoPy
from selprotopy.client import SerialSELClient

# Define the connection parameters
PORT = '/dev/ttyUSB1'
BAUD = 9600

# Establish the connection - this will NOT start the autoconfiguration
client = SerialSELClient(port=PORT, baudrate=BAUD)

# Start the Automatic Configuration process
client.autoconfigure()

# If no exceptions are raised, the configuration process has succeeded

# Poll the relay using fast-meter
client.poll_fast_meter()
```

## Autoconfiguration with a Ethernet-Connected Device

The following example uses a raw TCP socket connection (does not use `telnetlib`) to
establish a connection with the relay.

```python
# Import the TCP client object from SELProtoPy
from selprotopy.client import TCPSELClient

# Define the connection parameters
IP = '192.168.1.100'
TCP_PORT = 23

# Establish the connection - this will NOT start the autoconfiguration
client = TCPSELClient(ip_address=IP, port=TCP_PORT)

# Start the Automatic Configuration process
client.autoconfigure()

# If no exceptions are raised, the configuration process has succeeded

# Poll the relay using fast-meter
client.poll_fast_meter()
```
24 changes: 24 additions & 0 deletions docsource/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Examples of SELProtoPy in Action

SELProtoPy may be used for a variety of standard interactions with SEL relays. The following
references are a variety of example use-cases or implementations of the SELProtoPy package.
Do not mistake them as recommendations, they are provided here as a support for education
surrounding this tool.

```{toctree}
---
maxdepth: 1
---
examples/*
```

```{note}
It's important to acknowledge that although SEL Protocol is largely standardized, this library
has only been used on, or tested against a limited set of SEL intelligent electronic devices.
As such you may encounter errors where such devices do not behave in an expected fashion.
In such cases, it is requested that an issue is opened on
[GitHub](https://github.com/engineerjoe440/selprotopy/issues) to make maintainers aware of the
problem.
```
1 change: 1 addition & 0 deletions docsource/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ maxdepth: 1
---
selprotopy
examples
```

```{warning}
Expand Down
2 changes: 1 addition & 1 deletion selprotopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from selprotopy.support import telnet

# Describe Package for External Interpretation
__version__ = "0.1.3"
__version__ = "0.1.4"

# `telnetlib` Discards Null Characters, but SEL Protocol Requires them
telnetlib.Telnet.process_rawq = telnet.process_rawq
6 changes: 5 additions & 1 deletion selprotopy/client/ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"""
################################################################################

from typing import Optional

from selprotopy.client.base import SELClient

__all__ = ["TCPSELClient"]
Expand Down Expand Up @@ -81,10 +83,12 @@ class TCPSELClient(SELClient):

def __init__(
self,
ip_address: str,
port: Optional[int] = 23,
**kwargs
):
"""Connect over Serial to the SEL Protocol Device."""
# Establish a TCP Connection
connection=None # TODO
connection = socket.create_connection((ip_address, port))
# Attach Super Object
super().__init__(connApi=connection, **kwargs)

0 comments on commit 75f1887

Please sign in to comment.