From 5d981986ea9016cfb5680be4637c76c5a592464d Mon Sep 17 00:00:00 2001 From: Silcantar <1491897+Silcantar@users.noreply.github.com> Date: Thu, 10 Sep 2026 16:02:48 -0500 Subject: [PATCH] Remove unnecessary imports and other cleanup. --- src/AuDaGe/format.py | 1 - src/AuDaGe/iec.py | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/AuDaGe/format.py b/src/AuDaGe/format.py index 5f63db3..5b63348 100644 --- a/src/AuDaGe/format.py +++ b/src/AuDaGe/format.py @@ -1,4 +1,3 @@ -import typing from abc import ABC, abstractmethod class Format(ABC): diff --git a/src/AuDaGe/iec.py b/src/AuDaGe/iec.py index ef92564..9cffc3f 100644 --- a/src/AuDaGe/iec.py +++ b/src/AuDaGe/iec.py @@ -1,23 +1,26 @@ """ Definitions for IEC 61131 programming paradigms. """ -import dataclasses +# import dataclasses from dataclasses import dataclass from enum import Enum, IntEnum +from math import ceil import pandas as pd +WORD_LENGTH = 16 + @dataclass class DataType: """Class for IEC 61131-3 data types.""" def __init__( self, length_bits: int, - word_length = 16, + word_length = WORD_LENGTH, ): self.length_bits = length_bits - self.length_bytes = length_bits // 8 - self.length_words = length_bits // word_length + self.length_bytes = ceil(length_bits / 8) + self.length_words = ceil(length_bits / word_length) # DataTypes = { # "BOOL": 1, @@ -34,7 +37,8 @@ class DataType: # "TIME": 32, # "UDINT": 32 # } -# class DataTypes(DataType, Enum): +# @dataclass +# class DataTypes: # BOOL = DataType(1) # BYTE = DataType(8) # CHAR = DataType(8) @@ -49,7 +53,7 @@ class DataType: # TIME = DataType(32) # UDINT = DataType(32) -class DataTypes(int, Enum): +class DataTypes(IntEnum): BOOL = 1 BYTE = 8 CHAR = 8 @@ -96,8 +100,8 @@ def iec_definitions() -> pd.DataFrame: return pd.DataFrame( data={ "name": empty, - "parent": DataTypes.__members__, - "type": empty, + "parent": empty, + "type": DataTypes.__members__, "address": empty, "bitrank": empty, "save": empty,