Connector
TecoRoute EPSNET connector.
Connector creates meaningful log messages down to the logging.DEBUG level.
Please do not open more than one connector per second. If there are many requests for the TecoRoute service at one time, it may stuck for all customers.
Example of Connector operation:
from asyncio import gather, run
from logging import INFO, basicConfig
from tecoroute.connector import Connector
basicConfig(level=INFO)
async def handle_communication(connector):
await connector.send(epsnet_request)
epsnet_response = await connector.receive()
connector.close()
async def main():
connector = Connector(username='BroukPytlik', password='ferda1', plc='AB_1234')
await gather(connector.run(), handle_communication(connector))
run(main())
Example of UdpConnector operation:
from asyncio import run
from logging import INFO, basicConfig
from tecoroute.connector import UdpConnector
basicConfig(level=INFO)
async def main():
connector = UdpConnector(username='BroukPytlik', password='ferda1',
plc='AB_1234')
await connector.run()
run(main())
- class tecoroute.connector.BaseConnector(username: str, password: str, plc: str, application: str = 'Mosaic', tecoroute_host: str = 'route.tecomat.com', tecoroute_port: int = 61682, latency_threshold: float = 0.8, latency_count: int = 2, name: str = '')[source]
Base connector class. Not intended for direct use, use inherited classes.
- Parameters
username – TecoRoute username.
password – TecoRoute password.
plc – PLC to connect.
application – TecoRoute application name.
tecoroute_host – TecoRoute service host.
tecoroute_port – TecoRoute service port.
latency_threshold – Maximum latency in seconds.
latency_count – Maximum number of latency errors.
name – Connector name.
- property name: str
Connector name.
- property http_time: Optional[float]
Last response time from TecoRoute service (latency) in seconds.
- property is_running: bool
Return True if connector is running.
- class tecoroute.connector.Connector(*args: Any, **kwargs: Any)[source]
Connector that can be used to communicate with the PLC directly in code.
The class in derived from
BaseConnector, shares all parent’s attributes and methods.All constructor’s arguments are passed to
BaseConnector.
- class tecoroute.connector.UdpConnector(host: str = '0.0.0.0', port: int = 61682, *args: Any, **kwargs: Any)[source]
Connector that opens the UDP port for EPSNET communication with the PLC.
The connector on the UDP port accepts only one client, more precisely the connector responds to the address of the last request.
The class in derived from
BaseConnector, shares all parent’s attributes and methods.- Parameters
host – Host to listen on.
port – Port to listen on.
All other constructor’s arguments are passed to
BaseConnector.
- exception tecoroute.connector.ConnectorError[source]
The base class for connector exceptions. Inherited from Exception.
- exception tecoroute.connector.ConnectorUserError[source]
Unsuccessful authentication of the user to the TecoRoute service.
- property error_code: str
Error code from TecoRoute service.
- exception tecoroute.connector.ConnectorPlcError[source]
Unsuccessful connection to the PLC.
- property error_code: str
Error code from TecoRoute service.