Continue development of XSY import module.

This commit is contained in:
2026-01-27 17:15:38 -06:00
parent 386262da3d
commit 2b6b024971
2 changed files with 99 additions and 6 deletions

57
iec.py Normal file
View File

@@ -0,0 +1,57 @@
"""
Definitions for IEC 61131 programming paradigms.
"""
class DataType:
"""Class for IEC 61131-3 data types."""
def __init__(
self,
name: str,
length_bits: int,
word_length = 16,
):
self.name = name
self.length_bits = length_bits
self.length_bytes = length_bits // 8
self.length_words = length_bits // word_length
datatypes = {
'bool': DataType('bool', 1),
'byte': DataType('byte', 8),
'char': DataType('char', 8),
'int': DataType('int', 16),
'uint': DataType('uint', 16),
'word': DataType('word', 16),
'date': DataType('date', 32),
'dt': DataType('dt', 32),
'dint': DataType('dint', 32),
'real': DataType('real', 32),
'time': DataType('time', 32),
'udint': DataType('udint', 32),
}
class ElementaryVariable:
""""""
def __init__(
self,
name: str,
type: str,
address: str,
comment: str,
):
self.name = name
self.type = type
self.address = address
self.comment = comment
class UDT:
""""""
def __init__(
self,
name: str,
comment: str,
variables: dict,
):
self.name = name
self.comment = comment
self.variables = variables