Remove deprecated modules.

This commit is contained in:
2026-11-17 12:32:26 -06:00
parent a1c1a18864
commit 4aa7a65d0f
4 changed files with 0 additions and 288 deletions

View File

@@ -1,4 +0,0 @@
raise DeprecationWarning(
"This module is deprecated. Please use the extension framework for "
"converting to/from Kepserver formats."
)

View File

@@ -1,82 +0,0 @@
"""
AuDaGe FactoryTalk Alarm & Events XML module
name: XML.py
by: Josh Lucas
date: 2026-10-20
desc: AuDaGe module for handling FactoryTalk Alarm & Events XML files.
"""
from importlib import resources
from importlib.resources.abc import Traversable
import pandas as pd
import assets
from AuDaGe import frame, iec
from AuDaGe.better_enum import BetterStrEnum
class Columns(BetterStrEnum):
A_NAME = "@name"
A_LATCHED = "@latched"
A_ACKREQUIRED = "@ackRequired"
A_STYLE = "@style"
DATAITEM = "DataItem"
STYLE = "Style"
SEVERITY = "Severity"
DELAYINTERVAL = "DelayInterval"
ENABLETAG = "EnableTag"
USERDATA = "UserData"
RSVCMD = "RSVCmd"
ALARMCLASS = "AlarmClass"
GROUPID = "GroupID"
INALARM = "InAlarmDataItem"
DISABLED = "DisabledDataItem"
ACKEDDATAITEM = "AckedDataItem"
SUPPRESSED = "SuppressedDataItem"
SHELVED = "ShelvedDataItem"
ACKALL = "RemoteAckAllDataItem"
ACKALL_RESET = "RemoteAckAllDataItem@AutoReset"
DISABLE = "RemoteDisableDataItem"
DISABLE_RESET = "RemoteDisableDataItem@AutoReset"
ENABLE = "RemoteEnableDataItem"
ENABLE_RESET = "RemoteEnableDataItem@AutoReset"
SUPPRESS = "RemoteSuppressDataItem"
SUPPRESS_RESET = "RemoteSuppressDataItem@AutoReset"
UNSUPPRESS = "RemoteUnSuppressDataItem"
UNSUPPRESS_RESET = "RemoteUnSuppressDataItem@AutoReset"
SHELVEALL = "RemoteShelveAllDataItem"
SHELVEALL_RESET = "RemoteShelveAllDataItem@AutoReset"
UNSHELVE = "RemoteShelveDataItem"
UNSHELVE_RESET = "RemoteShelveDataItem@AutoReset"
SHELVEDURATION = "RemoteShelveDuration"
MESSAGEID = "MessageID"
PARAMS = "Params"
class TranslatorsFromAF:
"""Class for organizing static methods for converting from an AuDaGeFrame to
a FactoryTalk Alarm & Events frame.
"""
class TranslatorsToAF:
"""Class for organizing static methods for converting from a FactoryTalk
Alarm & Events frame to an AuDaGeFrame.
"""
class Frame(frame.Frame):
"""DataFrame for FTAE XML."""
class XMLReader(frame.Reader):
"""Class for reading and writing to FactoryTalk Alarm & Events XML files."""
def read(self, path: Traversable):
pass
def write(self, path: Traversable):
pass

View File

@@ -1,4 +0,0 @@
raise DeprecationWarning(
"This module is deprecated. Please use the extension framework for "
"converting to/from Kepserver formats."
)

View File

@@ -1,198 +0,0 @@
"""
AuDaGe Kepserver CSV module
name: csv.py
by: Josh Lucas
date: 2026-10-12
desc: AuDaGe module for handling Kepserver CSV files.
"""
import re
from importlib.resources.abc import Traversable
import pandas as pd
from numpy import nan
from AuDaGe import frame, iec
from AuDaGe.better_enum import BetterStrEnum
AC = frame.AuDaGeColumns
REMOVE_BRACKETS = False
class Columns(BetterStrEnum):
TAG_NAME = "Tag Name"
ADDRESS = "Address"
DATA_TYPE = "Data Type"
RESPECT_DATA_TYPE = "Respect Data Type"
CLIENT_ACCESS = "Client Access"
SCAN_RATE = "Scan Rate"
SCALING = "Scaling"
RAW_LOW = "Raw Low"
RAW_HIGH = "Raw High"
SCALED_LOW = "Scaled Low"
SCALED_HIGH = "Scaled High"
SCALED_DATA_TYPE = "Scaled Data Type"
CLAMP_LOW = "Clamp Low"
CLAMP_HIGH = "Clamp High"
ENG_UNITS = "Eng Units"
DESCRIPTION = "Description"
KC = Columns
class ClientAccess(BetterStrEnum):
"""Allowable values for the `Client Access` column of a Kepserver CSV file."""
R = "R"
W = "W"
RW = "R/W"
class OPCUAType(BetterStrEnum):
"""Allowable values for the `Data Type` and `Scaled Type` columns of a
Kepserver CSV file.
"""
NONE = ""
BOOLEAN = "Boolean"
CHAR = "Char"
BYTE = "Byte"
SHORT = "Short"
WORD = "Word"
LONG = "Long"
DWORD = "DWord"
LONGLONG = "LongLong"
QWORD = "QWord"
FLOAT = "Float"
DOUBLE = "Double"
STRING = "String"
class Scaling(BetterStrEnum):
"""Allowable values for the `Scaling` column of a Kepserver CSV file."""
NONE = ""
LINEAR = "Linear"
SQUARE_ROOT = "Square Root"
class TranslatorsFromAF:
"""Class for organizing static methods for converting from an AuDaGeFrame to
a Kepserver CSV frame.
"""
@staticmethod
def tag_name(
row: pd.Series, remove_brackets: bool = REMOVE_BRACKETS
) -> str:
name = row[AC.TAGNAME]
# Remove brackets, then replace characters other than letters +
# underscore (\w), numbers (\d), and period (\.) with "_".
if remove_brackets:
name = name.replace("[", "").replace("]", "")
pattern = r"[^\w\d\.]"
else:
pattern = r"[^\w\d\.\[\]]"
return re.sub(pattern, "_", name)
@staticmethod
def address(row: pd.Series) -> str:
address = row[AC.ADDRESS]
try:
return iec.Address.from_string(address).to_modbus()
# InvalidSpecError is raised if `address` is not an IEC address (most
# likely it's already Modbus), so return it as-is.
except iec.InvalidSpecError:
return address
# ValueError is raised if `address` is blank.
except ValueError:
return ""
@staticmethod
def data_type(row: pd.Series) -> str:
return iec.IECType.from_string(row[AC.TYPE]).to_opcua()
class TranslatorsToAF:
"""Class for organizing static methods for converting from a Kepserver CSV
frame to an AuDaGeFrame.
"""
@staticmethod
def type(row: pd.Series) -> str:
return str(iec.IECType.from_opcua(row[KC.DATA_TYPE]))
@staticmethod
def address(row: pd.Series) -> str:
address = row[KC.ADDRESS]
try:
return iec.Address.from_modbus(address).to_string()
except iec.InvalidSpecError:
return address
translators_from_af = {
KC.TAG_NAME: TranslatorsFromAF.tag_name,
KC.ADDRESS: TranslatorsFromAF.address,
KC.DATA_TYPE: TranslatorsFromAF.data_type,
KC.RESPECT_DATA_TYPE: 1,
KC.CLIENT_ACCESS: ClientAccess.RW,
KC.SCAN_RATE: 1000,
KC.SCALING: Scaling.NONE,
KC.RAW_LOW: nan,
KC.RAW_HIGH: nan,
KC.SCALED_LOW: nan,
KC.SCALED_HIGH: nan,
KC.SCALED_DATA_TYPE: OPCUAType.NONE,
KC.CLAMP_LOW: nan,
KC.CLAMP_HIGH: nan,
KC.ENG_UNITS: "",
KC.DESCRIPTION: AC.COMMENT,
}
translators_to_af = {
AC.TAGNAME: KC.TAG_NAME,
AC.TYPE: TranslatorsToAF.type,
AC.ADDRESS: TranslatorsToAF.address,
AC.COMMENT: KC.DESCRIPTION,
}
class Frame(
frame.Frame,
mandatory_columns=Columns.values(),
translators_from_af=translators_from_af,
translators_to_af=translators_to_af,
dropna_columns=KC.ADDRESS,
):
"""Dataframe for Kepserver CSV."""
@classmethod
def from_file(cls, path: Traversable) -> Frame:
"""Read Kepserver CSV file into a dataframe. Custom processing consists
of adding leading zeroes the decimal part of boolean addresses.
"""
def add_leading_zeroes(a: str) -> str:
"""Add a leading zero the decimal part of bit-packed boolean
addresses. E.g. change ".3" to ".03". This is important mainly to
differentiate ".1" (which is changed to ".01") from ".10" in case
the trailing zero of the latter gets dropped.
"""
PATTERN = ( # Match:
r"\." # Decimal point,
r"(\d\"?,?)" # then capture one digit and an optional comma
r"$" # at the end of the address string
)
SUB = ( # Replace with
r".0" # decimal point, zero,
"\1" # and the captured digit and maybe comma.
)
return re.sub(PATTERN, SUB, a)
converters = {"Address": add_leading_zeroes}
return cls(pd.read_csv(filepath_or_buffer=path, converters=converters))