Remove unnecessary imports and other cleanup.

This commit is contained in:
Silcantar
2026-09-10 16:02:48 -05:00
parent eaf0f1da4d
commit 5d981986ea
2 changed files with 12 additions and 9 deletions

View File

@@ -1,4 +1,3 @@
import typing
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
class Format(ABC): class Format(ABC):

View File

@@ -1,23 +1,26 @@
""" """
Definitions for IEC 61131 programming paradigms. Definitions for IEC 61131 programming paradigms.
""" """
import dataclasses # import dataclasses
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, IntEnum from enum import Enum, IntEnum
from math import ceil
import pandas as pd import pandas as pd
WORD_LENGTH = 16
@dataclass @dataclass
class DataType: class DataType:
"""Class for IEC 61131-3 data types.""" """Class for IEC 61131-3 data types."""
def __init__( def __init__(
self, self,
length_bits: int, length_bits: int,
word_length = 16, word_length = WORD_LENGTH,
): ):
self.length_bits = length_bits self.length_bits = length_bits
self.length_bytes = length_bits // 8 self.length_bytes = ceil(length_bits / 8)
self.length_words = length_bits // word_length self.length_words = ceil(length_bits / word_length)
# DataTypes = { # DataTypes = {
# "BOOL": 1, # "BOOL": 1,
@@ -34,7 +37,8 @@ class DataType:
# "TIME": 32, # "TIME": 32,
# "UDINT": 32 # "UDINT": 32
# } # }
# class DataTypes(DataType, Enum): # @dataclass
# class DataTypes:
# BOOL = DataType(1) # BOOL = DataType(1)
# BYTE = DataType(8) # BYTE = DataType(8)
# CHAR = DataType(8) # CHAR = DataType(8)
@@ -49,7 +53,7 @@ class DataType:
# TIME = DataType(32) # TIME = DataType(32)
# UDINT = DataType(32) # UDINT = DataType(32)
class DataTypes(int, Enum): class DataTypes(IntEnum):
BOOL = 1 BOOL = 1
BYTE = 8 BYTE = 8
CHAR = 8 CHAR = 8
@@ -96,8 +100,8 @@ def iec_definitions() -> pd.DataFrame:
return pd.DataFrame( return pd.DataFrame(
data={ data={
"name": empty, "name": empty,
"parent": DataTypes.__members__, "parent": empty,
"type": empty, "type": DataTypes.__members__,
"address": empty, "address": empty,
"bitrank": empty, "bitrank": empty,
"save": empty, "save": empty,