Skip to content
Snippets Groups Projects
Commit 7d8ab000 authored by Oliver Rostig's avatar Oliver Rostig
Browse files

added comments and dockerfile

parent 0b027f0d
No related branches found
No related tags found
No related merge requests found
# 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"]
...@@ -4,19 +4,20 @@ import sys ...@@ -4,19 +4,20 @@ import sys
import writefile as wf import writefile as wf
from collections import namedtuple from collections import namedtuple
#creates the constructor for the measurement-object with corresponding parameters
def measurementJsonDecod(measurementdict): def measurementJsonDecod(measurementdict):
return namedtuple('Measurement', measurementdict.keys())(*measurementdict.values()) return namedtuple('Measurement', measurementdict.keys())(*measurementdict.values())
#creates the constructor for the parameter-object with corresponding parameters
def parameterJsonDecod(parameterdict): def parameterJsonDecod(parameterdict):
return namedtuple('Parameter', parameterdict.keys())(*parameterdict.values()) return namedtuple('Parameter', parameterdict.keys())(*parameterdict.values())
#creates the constructor for the function-object with corresponding parameters
def functionJsonDecod(functiondict): def functionJsonDecod(functiondict):
return namedtuple('Function', functiondict.keys())(*functiondict.values()) return namedtuple('Function', functiondict.keys())(*functiondict.values())
#Measurement class that can be instantiated using JsonDecod functions
class Measurement: class Measurement:
def __init__(self, name, description, datatype, value, dimension, unit=None, range=None): def __init__(self, name, description, datatype, value, dimension, unit=None, range=None):
self.name = name self.name = name
...@@ -31,7 +32,7 @@ class Measurement: ...@@ -31,7 +32,7 @@ class Measurement:
else: else:
self.value = value self.value = value
#Parameter class that can be instantiated using JsonDecod functions
class Parameter: class Parameter:
def __init__(self, name, description, datatype, dimension, value, rangevar=None, unit=None, default=None, constant=False): def __init__(self, name, description, datatype, dimension, value, rangevar=None, unit=None, default=None, constant=False):
self.name = name self.name = name
...@@ -59,6 +60,9 @@ class Parameter: ...@@ -59,6 +60,9 @@ class Parameter:
# self.value = self.datatype(default) # self.value = self.datatype(default)
#Function class that can be instantiated using JsonDecod functions
class Function: class Function:
def __init__(self, name, description, inargsdatatypes = None, outargsdatatypes = None): def __init__(self, name, description, inargsdatatypes = None, outargsdatatypes = None):
self.name = name self.name = name
...@@ -67,6 +71,8 @@ class Function: ...@@ -67,6 +71,8 @@ class Function:
self.outargsdatatypes = outargsdatatypes self.outargsdatatypes = outargsdatatypes
#switches the dimension into the right format
def dimensionchange(string): def dimensionchange(string):
dimarr = string["dimension"] dimarr = string["dimension"]
if type(dimarr) == list: if type(dimarr) == list:
...@@ -77,7 +83,7 @@ def dimensionchange(string): ...@@ -77,7 +83,7 @@ def dimensionchange(string):
newdimension = {"dimension": value} newdimension = {"dimension": value}
string.update(newdimension) string.update(newdimension)
#gets the datatypes of functions to set for opcua
def getdatatypes(argarray): def getdatatypes(argarray):
returnarr = [] returnarr = []
if len(argarray) > 0: if len(argarray) > 0:
...@@ -87,7 +93,7 @@ def getdatatypes(argarray): ...@@ -87,7 +93,7 @@ def getdatatypes(argarray):
else: else:
return None return None
#switches range into the right format
def changerange(string): def changerange(string):
if iskeythere(string, "range"): if iskeythere(string, "range"):
rangeval = string["range"] rangeval = string["range"]
...@@ -97,7 +103,7 @@ def changerange(string): ...@@ -97,7 +103,7 @@ def changerange(string):
string.update({"range": (None, None)}) string.update({"range": (None, None)})
# print(string) # print(string)
#gets the objectnames for arguments of the function
def getobjnames(argarray): def getobjnames(argarray):
returnarr = [] returnarr = []
if len(argarray) > 0: if len(argarray) > 0:
...@@ -108,9 +114,8 @@ def getobjnames(argarray): ...@@ -108,9 +114,8 @@ def getobjnames(argarray):
else: else:
return None return None
#returns a list of all the parameters as objects
def getParameters(parametersDict): def getParameters(parametersDict):
# extracts the measurements of a Json-Model
parameterobj = [] parameterobj = []
if len(parametersDict) > 0: if len(parametersDict) > 0:
for i in parametersDict: for i in parametersDict:
...@@ -122,7 +127,7 @@ def getParameters(parametersDict): ...@@ -122,7 +127,7 @@ def getParameters(parametersDict):
parameterobj.append(parameterobji) parameterobj.append(parameterobji)
return parameterobj return parameterobj
#returns a list of all the measurements as objects
def getMeasurements(measurementsDict): def getMeasurements(measurementsDict):
measurementobj = [] measurementobj = []
if len(measurementsDict) > 0: if len(measurementsDict) > 0:
...@@ -138,7 +143,7 @@ def getMeasurements(measurementsDict): ...@@ -138,7 +143,7 @@ def getMeasurements(measurementsDict):
measurementobj.append(measurementobji) measurementobj.append(measurementobji)
return measurementobj return measurementobj
#returns a list of all the functions as objects
def getFunctions(functionsDict, jsonmeasurements, jsonparameters): def getFunctions(functionsDict, jsonmeasurements, jsonparameters):
functionobj = [] functionobj = []
if len(functionsDict) > 0: if len(functionsDict) > 0:
...@@ -304,6 +309,7 @@ def main(): ...@@ -304,6 +309,7 @@ def main():
jsoncomponents.append(obj) jsoncomponents.append(obj)
elif obj["elementType"] == "interface": elif obj["elementType"] == "interface":
jsoninterfaces.append(obj) jsoninterfaces.append(obj)
typesdict = buildComponents({}, jsoninterfaces, jsoncomponents, jsonmeasurements, jsonparameters, jsonfunctions, []) typesdict = buildComponents({}, jsoninterfaces, jsoncomponents, jsonmeasurements, jsonparameters, jsonfunctions, [])
intantiateddict = instantiate(typesdict, jsoninterfaces, jsoncomponents) intantiateddict = instantiate(typesdict, jsoninterfaces, jsoncomponents)
......
asyncua
tomli
toml
numpy
opcua-client
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment