stlehmann / pyads

Python wrapper for TwinCAT ADS
MIT License
264 stars 96 forks source link

make StructureDef type available as import? #204

Closed chrisbeardy closed 3 years ago

chrisbeardy commented 3 years ago

The custome type def StructureDef:

StructureDef = Tuple[
    Union[Tuple[str, Type, int], Tuple[str, Type, int, Optional[int]]], ...
]

Would this make sense to add it so that users can import it and do this?

from pyads import StructureDef

COMMAND_STRUCTURE: StructureDef = (
     ("actionID", pyads.PLCTYPE_UINT, 1),
     ("commandID", pyads.PLCTYPE_UINT, 1),  # Change to trigger command input
)

def _amend_def_var(var, original_def: StructureDef) -> StructureDef:
    return tuple(((var + "." + i[0]),) + tuple(i[1:]) for i in original_def)
stlehmann commented 3 years ago

That's nice. We can do that.

stlehmann commented 3 years ago

@chrisbeardy thanks for taking care of it