diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4f4661b8784b39f13615c5ee9b5f4b09a7fcb11f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# syntax=docker/dockerfile:1 +FROM python:3.10 +# install app dependencies +#python vorpackage +WORKDIR /app + +RUN ./requirements.txt . + +RUN pip3 install -r requirements.txt + +COPY * /app + +CMD ["python", "newmodeljsonparse.py", "robot.json"] diff --git a/newmodeljsonparse.py b/newmodeljsonparse.py index f157e582e146eb88e7081d3d449552fbac2818cb..5daea21cd67512b2a04394813a6170378699009c 100644 --- a/newmodeljsonparse.py +++ b/newmodeljsonparse.py @@ -4,19 +4,20 @@ import sys import writefile as wf from collections import namedtuple - +#creates the constructor for the measurement-object with corresponding parameters def measurementJsonDecod(measurementdict): return namedtuple('Measurement', measurementdict.keys())(*measurementdict.values()) - +#creates the constructor for the parameter-object with corresponding parameters def parameterJsonDecod(parameterdict): return namedtuple('Parameter', parameterdict.keys())(*parameterdict.values()) - +#creates the constructor for the function-object with corresponding parameters def functionJsonDecod(functiondict): return namedtuple('Function', functiondict.keys())(*functiondict.values()) +#Measurement class that can be instantiated using JsonDecod functions class Measurement: def __init__(self, name, description, datatype, value, dimension, unit=None, range=None): self.name = name @@ -31,7 +32,7 @@ class Measurement: else: self.value = value - +#Parameter class that can be instantiated using JsonDecod functions class Parameter: def __init__(self, name, description, datatype, dimension, value, rangevar=None, unit=None, default=None, constant=False): self.name = name @@ -59,6 +60,9 @@ class Parameter: # self.value = self.datatype(default) + + +#Function class that can be instantiated using JsonDecod functions class Function: def __init__(self, name, description, inargsdatatypes = None, outargsdatatypes = None): self.name = name @@ -67,6 +71,8 @@ class Function: self.outargsdatatypes = outargsdatatypes + +#switches the dimension into the right format def dimensionchange(string): dimarr = string["dimension"] if type(dimarr) == list: @@ -78,7 +84,7 @@ def dimensionchange(string): string.update(newdimension) return string - +#gets the datatypes of functions to set for opcua def getdatatypes(argarray): returnarr = [] if len(argarray) > 0: @@ -88,7 +94,7 @@ def getdatatypes(argarray): else: return None - +#switches range into the right format def changerange(obj): if iskeythere(obj, "range"): if obj["datatype"] == "enum": @@ -102,7 +108,7 @@ def getunit(string): string["unit"] = "UNITLESS" return string - +#gets the objectnames for arguments of the function def getobjnames(argarray): returnarr = [] if len(argarray) > 0: @@ -113,7 +119,7 @@ def getobjnames(argarray): else: return None - +#returns a list of all the parameters as objects def getParameters(parametersDict): # extracts the measurements of a Json-Mode parameterobj = [] @@ -131,7 +137,7 @@ def getParameters(parametersDict): print(parameterobj) return parameterobj - +#returns a list of all the measurements as objects def getMeasurements(measurementsDict): measurementobj = [] if len(measurementsDict) > 0: @@ -147,7 +153,7 @@ def getMeasurements(measurementsDict): measurementobj.append(measurementobji) return measurementobj - +#returns a list of all the functions as objects def getFunctions(functionsDict, jsonmeasurements, jsonparameters): functionobj = [] if len(functionsDict) > 0: @@ -340,6 +346,7 @@ def main(): jsoncomponents.append(obj) elif obj["elementType"] == "interface": jsoninterfaces.append(obj) + elif obj["elementType"] == "enum": jsonenums.append(obj) typesdict = buildComponents({}, jsoninterfaces, jsoncomponents, jsonmeasurements, jsonparameters, jsonfunctions, []) diff --git a/requirements.txt b/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..867b021efc6a45973bfba201ac6f033f8c3c6613 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,5 @@ +asyncua +tomli +toml +numpy +opcua-client \ No newline at end of file