Remove unnecessary imports and other cleanup.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import typing
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
class Format(ABC):
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user