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
class Format(ABC):

View File

@@ -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,