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

Zuordnung und Daten der Ventile

parent dcbd876e
No related branches found
No related tags found
No related merge requests found
...@@ -13,16 +13,17 @@ LAN_RS232_HOST = 'e75491' ...@@ -13,16 +13,17 @@ LAN_RS232_HOST = 'e75491'
LAN_RS232_TIMEOUT = 10000 # ms LAN_RS232_TIMEOUT = 10000 # ms
DATA_TEMPLATE = { 'Action':'TCP', 'Host':LAN_RS232_HOST } DATA_TEMPLATE = { 'Action':'TCP', 'Host':LAN_RS232_HOST }
CORVUS_EOL = '\r' CORVUS_ETX = '\r'
CORVUS_GETPOS = ' pos{EOL}'.format(EOL=CORVUS_EOL) CORVUS_GETPOS = ' pos{ETX}'.format(ETX=CORVUS_ETX)
#CORVUS_MOVEREL = "clean\r1.2 sv\r0.0 0.0 -8 r\r1 getpitch\r" #CORVUS_MOVEREL = 'clean\r1.2 sv\r0.0 0.0 -8 r\r1 getpitch\r'
CORVUS_MOVEREL = 'clean{EOL}{VEL} sv{EOL}0.0 0.0 {DIST} r{EOL}1 getpitch{EOL}' CORVUS_MOVEREL = 'clean{ETX}{VEL} sv{ETX}0 {R1} {R2} r{ETX}'
VALVE = { VALVE = {
'DV1': { 'Port':10001, 'Index':0, 'Velocity':1.2 }, 'grLW': { 'Port':10001, 'Index':0, 'Velocity':1.2 },
'DV2': { 'Port':10001, 'Index':1, 'Velocity':1.2 }, 'klLW': { 'Port':10001, 'Index':1, 'Velocity':1.2 },
'DVG1': { 'Port':10003, 'Index':0, 'Velocity':1.2 } 'DVG1': { 'Port':10003, 'Index':0, 'Velocity':1.2 },
'Verdränger': { 'Port':10003, 'Index':1, 'Velocity':0.8 }
} }
PROMPT = 'J/N ? ' PROMPT = 'J/N ? '
...@@ -55,18 +56,21 @@ getch = _find_getch() ...@@ -55,18 +56,21 @@ getch = _find_getch()
def y_n_input(prompt, true_chars): def y_n_input(prompt, true_chars):
print (prompt, end='', flush=True) print (prompt, end='', flush=True)
x = getch() x = getch()
if ord(x) == 3: # "Strg C"
print('\nEnde!')
sys.exit(1)
return x in true_chars return x in true_chars
def is_movement_needed(n, pos): def is_movement_needed(n, pos):
x = False x = False
print('Position des Ventils »{}«: {}mm'.format(n, pos)) print('Position »{}«: {}mm'.format(n, pos))
if pos != 0: if pos != 0:
corr = -pos corr = -pos
print('Soll Ventil »{}« um {}mm zur Nullposition gefahren werden?' print('Soll »{}« um {}mm zur Nullposition gefahren werden?'
.format(n, corr)) .format(n, corr))
x = y_n_input(PROMPT, ['j','J']) x = y_n_input(PROMPT, ['j','J'])
else: else:
print('Ventil »{}« ist bereits auf Nullposition. Es ist nichts zu tun.' print('»{}« ist bereits auf Nullposition. Es ist nichts zu tun.'
.format(n)) .format(n))
print() print()
return x return x
...@@ -84,9 +88,10 @@ def get_pos(n): ...@@ -84,9 +88,10 @@ def get_pos(n):
d['Value'] = CORVUS_GETPOS d['Value'] = CORVUS_GETPOS
print('==> get_pos: ' + json.dumps(d)) print('==> get_pos: ' + json.dumps(d))
res = call_devhub(d) res = call_devhub(d)
print('==> _x: {}'.format(res['_x']))
a = res['_x'].split() a = res['_x'].split()
print('==> result: ' + a[idx]) print('==> result: ' + a[idx])
pos = 8 pos = 8 # dummy
return pos return pos
def move_rel(n, dist): def move_rel(n, dist):
...@@ -95,11 +100,17 @@ def move_rel(n, dist): ...@@ -95,11 +100,17 @@ def move_rel(n, dist):
vel = VALVE[n]['Velocity'] vel = VALVE[n]['Velocity']
d = DATA_TEMPLATE.copy() d = DATA_TEMPLATE.copy()
d['Port'] = port d['Port'] = port
d['Value'] = CORVUS_MOVEREL.format(EOL=CORVUS_EOL, VEL=vel, DIST=dist) r1 = 0
# TODO: devhub-Kommunikation r2 = 0
if idx == 0:
r1 = dist
elif idx == 1:
r2 = dist
d['Value'] = CORVUS_MOVEREL.format(ETX=CORVUS_ETX, VEL=vel, R1=r1, R2=r2)
# res = call_devhub(d) # res = call_devhub(d)
print('==> move: ' + json.dumps(d)) print('==> move: ' + json.dumps(d))
pos = 0 ###pos = get_pos(n)
pos = 0 # dummy
return pos return pos
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
...@@ -114,7 +125,7 @@ for name in VALVE: ...@@ -114,7 +125,7 @@ for name in VALVE:
mov = is_movement_needed(name, pos) mov = is_movement_needed(name, pos)
if mov: if mov:
corr = -pos corr = -pos
print('\nVentil {} wird um {}mm bewegt ...'.format(name, corr)) print('\n{} wird um {}mm bewegt ...'.format(name, corr))
res = move_rel(name, corr) res = move_rel(name, corr)
print('Resultat: {}mm'.format(res)) print('Resultat: {}mm'.format(res))
print('='*64) print('='*64)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment