Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
anselm
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
Container registry
Model registry
Operate
Environments
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
anselm
Commits
d216bd0d
Commit
d216bd0d
authored
6 years ago
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
detect measurement complete, anselm talks to bot channel
parent
5912f341
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bot.py
+7
-3
7 additions, 3 deletions
bot.py
srv.py
+41
-27
41 additions, 27 deletions
srv.py
with
48 additions
and
30 deletions
bot.py
+
7
−
3
View file @
d216bd0d
...
@@ -12,7 +12,7 @@ class Bot(System):
...
@@ -12,7 +12,7 @@ class Bot(System):
MENTION_REGEX
=
"
^<@(|[WU].+?)>(.*)
"
MENTION_REGEX
=
"
^<@(|[WU].+?)>(.*)
"
RTM_READ_DELAY
=
1
RTM_READ_DELAY
=
1
OUT_CHANNEL
=
"
bot
"
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
channel_list
=
None
channel_list
=
None
...
@@ -30,7 +30,7 @@ class Bot(System):
...
@@ -30,7 +30,7 @@ class Bot(System):
if
channel_list
and
'
channels
'
in
channel_list
:
if
channel_list
and
'
channels
'
in
channel_list
:
for
channel
in
channel_list
.
get
(
'
channels
'
):
for
channel
in
channel_list
.
get
(
'
channels
'
):
if
channel
.
get
(
'
name
'
)
==
'
allgemein
'
:
if
channel
.
get
(
'
name
'
)
==
'
bot
'
:
self
.
log
.
info
(
"
git info channel id
"
)
self
.
log
.
info
(
"
git info channel id
"
)
self
.
info_channel_id
=
channel
.
get
(
'
id
'
)
self
.
info_channel_id
=
channel
.
get
(
'
id
'
)
break
break
...
@@ -56,6 +56,10 @@ class Bot(System):
...
@@ -56,6 +56,10 @@ class Bot(System):
if
command
.
startswith
(
'
ga
'
):
if
command
.
startswith
(
'
ga
'
):
ok
=
True
ok
=
True
self
.
post
(
channel
,
"
calibration gas is {}
"
.
format
(
self
.
aget
(
'
gas
'
,
0
)))
self
.
post
(
channel
,
"
calibration gas is {}
"
.
format
(
self
.
aget
(
'
gas
'
,
0
)))
if
command
.
startswith
(
'
ch
'
):
ok
=
True
self
.
post
(
channel
,
"
I send my infos to channel #{}
"
.
format
(
self
.
OUT_CHANNEL
))
if
command
.
startswith
(
'
id
'
):
if
command
.
startswith
(
'
id
'
):
ok
=
True
ok
=
True
...
@@ -73,7 +77,7 @@ class Bot(System):
...
@@ -73,7 +77,7 @@ class Bot(System):
if
command
.
startswith
(
'
he
'
):
if
command
.
startswith
(
'
he
'
):
ok
=
True
ok
=
True
self
.
post
(
channel
,
"
Available commands are *he[lp]* *ga[s]*, *fu[llscales]* or *id[s]*.
"
)
self
.
post
(
channel
,
"
Available commands are *he[lp]*
, *ch[annel]*,
*ga[s]*, *fu[llscales]* or *id[s]*.
"
)
if
not
ok
:
if
not
ok
:
self
.
post
(
channel
,
"
Not sure what you mean. Try *help* command.
"
)
self
.
post
(
channel
,
"
Not sure what you mean. Try *help* command.
"
)
...
...
This diff is collapsed.
Click to expand it.
srv.py
+
41
−
27
View file @
d216bd0d
...
@@ -53,7 +53,10 @@ def target_pressure():
...
@@ -53,7 +53,10 @@ def target_pressure():
lines
=
s
.
get_lines
(
'
cal_id
'
)
lines
=
s
.
get_lines
(
'
cal_id
'
)
todo_pressures_acc
=
[]
todo_pressures_acc
=
[]
repeat_over_rating
=
7.0
repeat_over_rating
=
7.0
continue_measurement
=
True
epsilon
=
0.01
highest_rating
=
0
# start value
highest_rating
=
0
# start value
for
line
in
lines
:
for
line
in
lines
:
cal_id
=
s
.
aget
(
'
cal_id
'
,
line
)
cal_id
=
s
.
aget
(
'
cal_id
'
,
line
)
doc
=
db
.
get_doc
(
cal_id
)
doc
=
db
.
get_doc
(
cal_id
)
...
@@ -70,42 +73,53 @@ def target_pressure():
...
@@ -70,42 +73,53 @@ def target_pressure():
last_unit
=
test_unit
last_unit
=
test_unit
# let's find next pressure
for
todo_pressure
in
todo_pressures_acc
:
if
highest_rating
<
repeat_over_rating
:
for
todo_pressure
in
todo_pressures_acc
:
if
float
(
todo_pressure
)
>
last_pressure
:
if
float
(
todo_pressure
)
>
last_pressure
:
break
break
point_no
=
todo_pressures_acc
.
index
(
todo_pressure
)
+
1
points_total
=
len
(
todo_pressures_acc
)
measurement_complete
=
last_pressure
/
float
(
todo_pressures_acc
[
-
1
])
-
1
<
epsilon
if
highest_rating
<
repeat_over_rating
:
# next pressure with ok rating
if
not
measurement_complete
:
next_pressure
,
next_unit
=
todo_pressure
,
todo_unit
continue_measurement
=
True
# next pressure with ok rating
next_pressure
,
next_unit
=
todo_pressure
,
todo_unit
s
.
r
.
publish
(
'
info
'
,
"
The last measurement point has a rating of *{}* of [0..9]. This is ok.
"
.
format
(
highest_rating
))
s
.
r
.
publish
(
'
info
'
,
"
Next pressure point (No.: {} of {} in total) will be *{} {}*
"
.
format
(
point_no
+
1
,
points_total
,
next_pressure
,
next_unit
))
else
:
continue_measurement
=
False
s
.
r
.
publish
(
'
info
'
,
"
The last measurement point has a rating of *{}* of [0..9]. This is ok.
"
.
format
(
highest_rating
))
s
.
r
.
publish
(
'
info
'
,
"
It was the *last measurement point*.
"
)
s
.
r
.
publish
(
'
info
'
,
"""
last measurement point has a rating of: *{}*. This is ok. Next pressure point will be *{} {}*
"""
.
format
(
highest_rating
,
todo_pressure
,
todo_unit
))
if
highest_rating
>
repeat_over_rating
:
if
highest_rating
>
repeat_over_rating
:
s
.
r
.
publish
(
'
info
'
,
"""
continue_measurement
=
True
last measurement point has a rating of *{}*. This is *not ok*. Repeat last pressure point *{} {}*
"""
.
format
(
highest_rating
,
todo_pressure
,
todo_unit
))
# next pressure with ok rating not ok
# next pressure with ok rating not ok
next_pressure
,
next_unit
=
last_pressure
,
last_unit
next_pressure
,
next_unit
=
last_pressure
,
last_unit
if
'
DocPath
'
in
req
:
s
.
r
.
publish
(
'
info
'
,
"
The last measurement point has a rating of *{}*. This is *not ok*.
"
.
format
(
highest_rating
))
doc_path
=
req
.
get
(
'
DocPath
'
)
s
.
r
.
publish
(
'
info
'
,
"
Repeat the last pressure point (No.: {} of {} in total) *{} {}*.
"
.
format
(
point_no
,
points_total
,
next_pressure
,
next_unit
))
for
line
in
lines
:
s
.
aset
(
"
result
"
,
line
,
[{
'
Type
'
:
'
target_pressure
'
,
'
Value
'
:
float
(
next_pressure
),
'
Unit
'
:
next_unit
}])
s
.
aset
(
"
doc_path
"
,
line
,
doc_path
)
db
.
save_results
()
else
:
msg
=
"
missing DocPath
"
res
[
'
error
'
]
=
msg
s
.
log
.
error
(
msg
)
s
.
aset
(
'
save
'
,
0
,
"
no
"
)
s
.
log
.
info
(
"
check calibration {}
"
.
format
(
cal_id
))
return
jsonify
({
'
ToExchange
'
:{
'
Target_pressure.Selected
'
:
float
(
next_pressure
)
,
'
Target_pressure.Unit
'
:
next_unit
}})
if
continue_measurement
:
if
'
DocPath
'
in
req
:
doc_path
=
req
.
get
(
'
DocPath
'
)
for
line
in
lines
:
s
.
aset
(
"
result
"
,
line
,
[{
'
Type
'
:
'
target_pressure
'
,
'
Value
'
:
float
(
next_pressure
),
'
Unit
'
:
next_unit
}])
s
.
aset
(
"
doc_path
"
,
line
,
doc_path
)
db
.
save_results
()
else
:
msg
=
"
missing DocPath
"
res
[
'
error
'
]
=
msg
s
.
log
.
error
(
msg
)
s
.
aset
(
'
save
'
,
0
,
"
no
"
)
return
jsonify
({
'
ToExchange
'
:{
'
Target_pressure.Selected
'
:
float
(
next_pressure
)
,
'
Target_pressure.Unit
'
:
next_unit
,
'
Continue_mesaurement.Bool
'
:
continue_measurement
}})
else
:
return
jsonify
({
'
ToExchange
'
:{
'
Continue_mesaurement.Bool
'
:
continue_measurement
}})
@app.route
(
'
/save_dut_branch
'
,
methods
=
[
'
POST
'
])
@app.route
(
'
/save_dut_branch
'
,
methods
=
[
'
POST
'
])
def
save_dut_branch
():
def
save_dut_branch
():
...
...
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