Skip to content
Snippets Groups Projects
Commit c4667891 authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

Erklärungen

parent 8f63f0a7
No related branches found
No related tags found
No related merge requests found
......@@ -15,18 +15,12 @@ DEVHUB_HOST = 'localhost' # 'localhost'
DEVHUB_PORT = 9009
DEVHUB_URL = 'http://{}:{}/'.format(DEVHUB_HOST, DEVHUB_PORT)
devhub_data = {
'Action':'TCP', 'Host':LAN_RS232_HOST, 'Port':LAN_RS232_PORT,
'Timeout':LAN_RS232_TIMEOUT, 'Value': CORVUS_GETPOS,
'PostProcessing': [
'var Result = _.extractCorvusArray(_x)[1];'
]
}
"""
Zum PostProcessing: Parameter ist ein String-Array. Jeder String wird als
JavaScript-Code interpretiert. Über die spezielle Variable "_" hat man Zugriff
auf vordefinierte Funktionen, wie in diesem Beispiel "extractCorvusArray". Ihre
Definition findet man in der Datei "resources/j/add-CORVUS.js".
Zum PostProcessing (JAVASCRIPT): Parameter ist ein String-Array. Jeder String
wird als JavaScript-Code interpretiert. Über die spezielle Variable "_" hat
man Zugriff auf vordefinierte Funktionen, wie in diesem Beispiel
"extractCorvusArray". Ihre Definition findet man in der Datei
"resources/js/add-CORVUS.js".
Die folgende Abfrage gibt einen ungefähren Überblick, an welchen Stellen der
Datenbankdokumente "PostProcessing" verwendet wird:
......@@ -38,8 +32,18 @@ Die Schlüsselworte "PostScript" (für Closure-Code) und "PostScriptPy"
(für Python-Code) haben eine ähnliche Funktion wie "PostProcessing".
"""
print()
print('='*78)
print('\n*** JSON-Auftrag an DEVHUB ***')
print('*** Postprocessing per JAVASCRIPT-Code ***')
devhub_data = {
'Action':'TCP', 'Host':LAN_RS232_HOST, 'Port':LAN_RS232_PORT,
'Timeout':LAN_RS232_TIMEOUT, 'Value': CORVUS_GETPOS,
'PostProcessing': [
'var Result = _.extractCorvusArray(_x)[1];'
]
}
print(devhub_data)
response = requests.post(DEVHUB_URL, json=devhub_data)
......@@ -49,6 +53,8 @@ data = response.json() # erzeugt aus JSON eine Dictionary-Variable
print('\n*** JSON-Antwort von DEVHUB ***')
print(data)
# enthält die Angaben des JSON-Auftrags ergänzt um die Antwortdaten wie
# "_x", "_t_start", "_t_stop", "req-id" und ggf. "Result" aus dem Postprocessing.
print('\n*** Rohdaten der Geräteantwort ***')
print(data.get('_x'))
......@@ -56,21 +62,17 @@ print(data.get('_x'))
print('\n*** Ergebnis des Postprocessings (Position Motor 2, Index 1) ***')
print(data.get('Result'))
print()
print('='*78)
print('*** Postprocessing per Python-Code ***')
devhub_data = {
'Action':'TCP', 'Host':LAN_RS232_HOST, 'Port':LAN_RS232_PORT,
'Timeout':LAN_RS232_TIMEOUT, 'Value': CORVUS_GETPOS,
'PostScriptPy': 'print(json.dumps({ "Result": 17 })'
}
print('\n*** JSON-Auftrag an DEVHUB ***')
print('*** Postprocessing per Python-Code ***')
devhub_data = {
'Action':'TCP', 'Host':LAN_RS232_HOST, 'Port':LAN_RS232_PORT,
'Timeout':LAN_RS232_TIMEOUT, 'Value': CORVUS_GETPOS,
'PostScriptPy': 'corvus', 'PostScriptInput': {'Index':1}
}
print(devhub_data)
response = requests.post(DEVHUB_URL, json=devhub_data)
data = response.json()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment