Skip to content
Snippets Groups Projects
Commit 987a8b48 authored by Susanna Weber's avatar Susanna Weber
Browse files

Merge branch 'events_n_functions' of...

Merge branch 'events_n_functions' of https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/iop-ws-a.i/soil-opc-ua into events_n_functions
parents 56aaae6e 4bccf146
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:
...@@ -78,7 +84,7 @@ def dimensionchange(string): ...@@ -78,7 +84,7 @@ def dimensionchange(string):
string.update(newdimension) string.update(newdimension)
return string return string
#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:
...@@ -88,7 +94,7 @@ def getdatatypes(argarray): ...@@ -88,7 +94,7 @@ def getdatatypes(argarray):
else: else:
return None return None
#switches range into the right format
def changerange(obj): def changerange(obj):
if iskeythere(obj, "range"): if iskeythere(obj, "range"):
if obj["datatype"] == "enum": if obj["datatype"] == "enum":
...@@ -102,7 +108,7 @@ def getunit(string): ...@@ -102,7 +108,7 @@ def getunit(string):
string["unit"] = "UNITLESS" string["unit"] = "UNITLESS"
return string return 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:
...@@ -113,7 +119,7 @@ def getobjnames(argarray): ...@@ -113,7 +119,7 @@ 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-Mode # extracts the measurements of a Json-Mode
parameterobj = [] parameterobj = []
...@@ -131,7 +137,7 @@ def getParameters(parametersDict): ...@@ -131,7 +137,7 @@ def getParameters(parametersDict):
print(parameterobj) print(parameterobj)
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:
...@@ -147,7 +153,7 @@ def getMeasurements(measurementsDict): ...@@ -147,7 +153,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:
...@@ -340,6 +346,7 @@ def main(): ...@@ -340,6 +346,7 @@ def main():
jsoncomponents.append(obj) jsoncomponents.append(obj)
elif obj["elementType"] == "interface": elif obj["elementType"] == "interface":
jsoninterfaces.append(obj) jsoninterfaces.append(obj)
elif obj["elementType"] == "enum": elif obj["elementType"] == "enum":
jsonenums.append(obj) jsonenums.append(obj)
typesdict = buildComponents({}, jsoninterfaces, jsoncomponents, jsonmeasurements, jsonparameters, jsonfunctions, []) typesdict = buildComponents({}, jsoninterfaces, jsoncomponents, jsonmeasurements, jsonparameters, jsonfunctions, [])
......
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