Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Python-Beispiele
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vaclab
Python-Beispiele
Commits
65c74aa0
Commit
65c74aa0
authored
2 years ago
by
Rolf Niepraschk
Browse files
Options
Downloads
Patches
Plain Diff
Zuordnung und Daten der Ventile
parent
dcbd876e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DevHub/ce3-preset.py
+26
-15
26 additions, 15 deletions
DevHub/ce3-preset.py
with
26 additions
and
15 deletions
DevHub/ce3-preset.py
+
26
−
15
View file @
65c74aa0
...
@@ -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_E
OL
=
'
\r
'
CORVUS_E
TX
=
'
\r
'
CORVUS_GETPOS
=
'
pos{E
OL
}
'
.
format
(
E
OL
=
CORVUS_E
OL
)
CORVUS_GETPOS
=
'
pos{E
TX
}
'
.
format
(
E
TX
=
CORVUS_E
TX
)
#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{E
OL
}{VEL} sv{E
OL}0.0 0.0 {DIST} r{EOL}1 getpitch{EOL
}
'
CORVUS_MOVEREL
=
'
clean{E
TX
}{VEL} sv{E
TX}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
(
'
\n
Ende!
'
)
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
(
'
\n
Ventil
{} 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment