Skip to content
Snippets Groups Projects
Commit 2360f318 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

ethercat object doesn't need to know its terminals

especially if we want to assign terminals dynamically, we cannot assing
terminals to loops at creation time.
parent 15f78085
No related branches found
No related tags found
No related merge requests found
...@@ -342,15 +342,15 @@ class EtherCatBase: ...@@ -342,15 +342,15 @@ class EtherCatBase:
for (i, t) in enumerate(self.terminals)]) for (i, t) in enumerate(self.terminals)])
class SimpleEtherCat(EtherCatBase, EtherCat): class SimpleEtherCat(EtherCat):
pass pass
class FastEtherCat(SimpleEtherCat): class FastEtherCat(SimpleEtherCat):
MAX_PROGS = 64 MAX_PROGS = 64
def __init__(self, network, terminals): def __init__(self, network):
super().__init__(network, terminals) super().__init__(network)
self.programs = create_map(MapType.PROG_ARRAY, 4, 4, self.MAX_PROGS) self.programs = create_map(MapType.PROG_ARRAY, 4, 4, self.MAX_PROGS)
self.sync_groups = {} self.sync_groups = {}
......
...@@ -413,6 +413,8 @@ class EtherCat(Protocol): ...@@ -413,6 +413,8 @@ class EtherCat(Protocol):
class Terminal: class Terminal:
"""Represent one terminal ("slave") in the loop""" """Represent one terminal ("slave") in the loop"""
def __init__(self, ethercat):
self.ec = ethercat
async def initialize(self, relative, absolute): async def initialize(self, relative, absolute):
"""Initialize the terminal """Initialize the terminal
......
...@@ -52,8 +52,7 @@ async def info(): ...@@ -52,8 +52,7 @@ async def info():
for i, t in zip(terminals, terms))) for i, t in zip(terminals, terms)))
else: else:
free = await ec.find_free_address() free = await ec.find_free_address()
term = Terminal() term = Terminal(ec)
term.ec = ec
await term.initialize(-args.terminal, free) await term.initialize(-args.terminal, free)
terms = [term] terms = [term]
...@@ -128,8 +127,7 @@ async def eeprom(): ...@@ -128,8 +127,7 @@ async def eeprom():
await ec.roundtrip(ECCmd.FPRW, 7, 0x10, "H", 0) await ec.roundtrip(ECCmd.FPRW, 7, 0x10, "H", 0)
terminals = [args.terminal] terminals = [args.terminal]
t = Terminal() t = Terminal(ec)
t.ec = ec
await t.initialize(-args.terminal, 7) await t.initialize(-args.terminal, 7)
if args.read or args.check is not None: if args.read or args.check is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment