Move contents of extensions to the root package directory.
This commit is contained in:
@@ -26,15 +26,6 @@ FC = FormatChoices
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args["unsafe"]:
|
||||
AuDaGe.safe = False
|
||||
print(
|
||||
"You have chosen the option `unsafe`. Be aware (BEWARE!) that this "
|
||||
"allows execution of arbitrary, possibly unsafe code from files "
|
||||
"external to the AuDaGe module. Do not specify this option unless "
|
||||
"you are familiar with the contents of the specified configuration "
|
||||
"files."
|
||||
)
|
||||
frame = load_input_file(args)
|
||||
dump_output_file(frame, args)
|
||||
|
||||
@@ -55,7 +46,17 @@ def parse_args():
|
||||
)
|
||||
parser.add_argument("output_file", type=pathlib.Path, help="")
|
||||
parser.add_argument("--unsafe", action="store_true")
|
||||
return parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
if args.unsafe:
|
||||
AuDaGe.safe = False
|
||||
print(
|
||||
"You have chosen the option `unsafe`. Be aware (BEWARE!) that this "
|
||||
"allows execution of arbitrary, possibly unsafe code from files "
|
||||
"external to the AuDaGe module. Do not specify this option unless "
|
||||
"you are familiar with the contents of the specified configuration "
|
||||
"files."
|
||||
)
|
||||
return args
|
||||
|
||||
|
||||
def load_input_file(args):
|
||||
|
||||
@@ -348,45 +348,3 @@ class Converter:
|
||||
return pd.Series(frame[translator.columns[0]])
|
||||
# Else, run the operations.
|
||||
return translator.translate(frame)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plcs = ("WA3252_PLC_001_1",)
|
||||
tags = ("caption", "desc", "message", "tagname", "unit")
|
||||
for plc in plcs:
|
||||
for tag in tags:
|
||||
substitutions = {"$extension$": tag.title(), "$plc$": plc}
|
||||
kep_converter = Converter(
|
||||
f"extensions/kepserver/strings/{tag}_csv.yaml",
|
||||
substitutions=substitutions,
|
||||
)
|
||||
kep = kep_converter.from_file(
|
||||
f"C:/Users/j.lucas/OneDrive - Prime Controls/Customers/NTMWD/"
|
||||
f"Engineering/Leonard (North) Water Treatment Plant/Programs/PLC/"
|
||||
f"WA3252-PLC-001-1 Raw Water PS/{plc}.csv"
|
||||
)
|
||||
af = kep_converter.to_AF(kep)
|
||||
kep2 = kep_converter.from_AF(af)
|
||||
kep_converter.to_file(kep2, f"tests/output/{plc}_strings_{tag}.csv")
|
||||
af2 = kep_converter.to_AF(kep2)
|
||||
macro_converter = Converter(
|
||||
f"extensions/factorytalk/macro/{tag}_macro.yaml",
|
||||
substitutions=substitutions,
|
||||
)
|
||||
macro = macro_converter.from_AF(af2)
|
||||
macro_converter.to_file(macro, f"tests/output/{plc}_{tag}.mcr")
|
||||
kep_converter = Converter("extensions/kepserver/modbus/csv.yaml")
|
||||
kep = kep_converter.from_file(
|
||||
f"C:/Users/j.lucas/OneDrive - Prime Controls/Customers/NTMWD/"
|
||||
f"Engineering/Leonard (North) Water Treatment Plant/Programs/PLC/"
|
||||
f"WA3252-PLC-001-1 Raw Water PS/{plc}.csv"
|
||||
)
|
||||
af = kep_converter.to_AF(kep)
|
||||
macro_converter = Converter(
|
||||
"extensions/factorytalk/macro/alarm_severity_macro.yaml",
|
||||
substitutions={"$plc$": plc},
|
||||
)
|
||||
macro = macro_converter.from_AF(af)
|
||||
macro_converter.to_file(
|
||||
macro, f"tests/output/{plc}_alarm_severities.mcr"
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
raise DeprecationWarning(
|
||||
"This module is deprecated. Please use the extension framework for "
|
||||
"converting to/from Kepserver formats."
|
||||
)
|
||||
@@ -207,7 +207,7 @@ class Frame(pd.DataFrame, metaclass=MetaFrame):
|
||||
self.to_csv(path_or_buf=path, index=False)
|
||||
|
||||
|
||||
class AuDaGeColumns(BetterStrEnum):
|
||||
class AuDaGeMandatoryColumns(BetterStrEnum):
|
||||
"""Enum of columns required by AuDaGeFrame."""
|
||||
|
||||
TAGNAME = "tagname"
|
||||
@@ -216,7 +216,18 @@ class AuDaGeColumns(BetterStrEnum):
|
||||
COMMENT = "comment"
|
||||
|
||||
|
||||
class AuDaGeFrame(Frame, mandatory_columns=AuDaGeColumns.values()):
|
||||
class AuDaGeOptionalColumns(BetterStrEnum):
|
||||
PARENT = "parent"
|
||||
|
||||
|
||||
class AuDaGeColumns:
|
||||
Mandatory = AuDaGeMandatoryColumns
|
||||
Optional = AuDaGeOptionalColumns
|
||||
M = Mandatory
|
||||
O = Optional
|
||||
|
||||
|
||||
class AuDaGeFrame(Frame, mandatory_columns=AuDaGeColumns.Mandatory.values()):
|
||||
"""DataFrame that enforces the presence of columns matching the names in
|
||||
`AuDaGeColumns`. Used as intermediate format for converting between other
|
||||
data formats.
|
||||
|
||||
@@ -48,6 +48,7 @@ from math import ceil, prod
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from AuDaGe.frame import AuDaGeColumns as AC
|
||||
from AuDaGe.frame import AuDaGeFrame
|
||||
|
||||
from .iec_common import *
|
||||
@@ -212,16 +213,16 @@ class IECType:
|
||||
all_indices = pd.DataFrame(dim_indices)
|
||||
continue
|
||||
columns = {
|
||||
"name": all_indices.apply(
|
||||
AC.M.TAGNAME: all_indices.apply(
|
||||
lambda row: f"{name}[{','.join(str(dim) for dim in row)}]",
|
||||
axis=1,
|
||||
),
|
||||
"type": str(self.array_type),
|
||||
"address": [
|
||||
AC.M.TYPE: str(self.array_type),
|
||||
AC.M.ADDRESS: [
|
||||
self.array_type.length * i for i in range(len(all_indices))
|
||||
],
|
||||
"comment": comment,
|
||||
"parent": self.name.upper(),
|
||||
AC.M.COMMENT: comment,
|
||||
AC.O.PARENT: self.name.upper(),
|
||||
}
|
||||
return AuDaGeFrame(columns)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user