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
c70e0a29
Commit
c70e0a29
authored
6 years ago
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
working next target pressure
parent
1063cd2b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
anselm.py
+2
-4
2 additions, 4 deletions
anselm.py
anselm/db.py
+22
-18
22 additions, 18 deletions
anselm/db.py
anselm/test_db.py
+2
-2
2 additions, 2 deletions
anselm/test_db.py
srv.py
+44
-14
44 additions, 14 deletions
srv.py
with
70 additions
and
38 deletions
anselm.py
+
2
−
4
View file @
c70e0a29
...
...
@@ -158,10 +158,7 @@ class Anselm(System):
def
end_task
(
self
,
line
):
self
.
add_widget_to_grid
(
self
.
make_result_label
(
line
=
line
),
line
,
self
.
result_col
)
if
self
.
aget
(
'
save
'
,
0
)
==
"
yes
"
:
self
.
db
.
save_results
()
self
.
db
.
save_results
()
self
.
log
.
info
(
"
end task at line {}
"
.
format
(
line
))
def
add_device_line
(
self
):
...
...
@@ -388,6 +385,7 @@ class Anselm(System):
self
.
aset
(
'
year
'
,
0
,
year
)
self
.
log
.
info
(
"
select year {}
"
.
format
(
year
))
self
.
add_widget_to_grid
(
self
.
make_add_device_button
(),
self
.
add_device_btn_line
,
self
.
add_device_btn_col
)
def
default_change
(
self
,
edit_widget
,
label_val
,
line
):
self
.
log
.
debug
(
label_val
)
defaults
=
self
.
dget
(
'
defaults
'
,
line
)
...
...
This diff is collapsed.
Click to expand it.
anselm/db.py
+
22
−
18
View file @
c70e0a29
...
...
@@ -180,21 +180,25 @@ class DB(System):
self
.
log
.
error
(
"
line {} contains no doc_id
"
)
def
save_results
(
self
):
lines
=
self
.
get_lines
(
'
cal_id
'
)
for
line
in
lines
:
doc_path
=
self
.
aget
(
"
doc_path
"
,
line
)
results
=
self
.
dget
(
"
result
"
,
line
)
cal_id
=
self
.
aget
(
"
cal_id
"
,
line
)
if
cal_id
and
doc_path
and
results
:
doc
=
self
.
get_doc
(
cal_id
)
self
.
log
.
debug
(
"
try to save results: {}
"
.
format
(
results
))
for
result
in
results
:
self
.
log
.
debug
(
"
components are cal_id {}, doc_path_array: {}, result: {} saved
"
.
format
(
cal_id
,
doc_path
,
result
))
self
.
doc_write_result
(
doc
,
doc_path
,
result
)
self
.
adelete
(
"
result
"
,
line
)
self
.
log
.
debug
(
"
deleted result of line {} from mem
"
.
format
(
line
))
self
.
set_doc
(
doc
)
if
self
.
aget
(
'
save
'
,
0
)
==
"
yes
"
:
lines
=
self
.
get_lines
(
'
cal_id
'
)
for
line
in
lines
:
doc_path
=
self
.
aget
(
"
doc_path
"
,
line
)
results
=
self
.
dget
(
"
result
"
,
line
)
cal_id
=
self
.
aget
(
"
cal_id
"
,
line
)
if
cal_id
and
doc_path
and
results
:
doc
=
self
.
get_doc
(
cal_id
)
self
.
log
.
debug
(
"
try to save results: {}
"
.
format
(
results
))
for
result
in
results
:
self
.
log
.
debug
(
"
components are cal_id {}, doc_path_array: {}, result: {} saved
"
.
format
(
cal_id
,
doc_path
,
result
))
self
.
doc_write_result
(
doc
,
doc_path
,
result
)
self
.
adelete
(
"
result
"
,
line
)
self
.
log
.
debug
(
"
deleted result of line {} from mem
"
.
format
(
line
))
self
.
set_doc
(
doc
)
else
:
self
.
log
.
warn
(
"
save entry is not [yes]
"
)
def
doc_write_result
(
self
,
doc
,
doc_path
,
result
):
#
# last entry is something like Pressure (Type, Value and Unit)
...
...
@@ -257,10 +261,10 @@ class DB(System):
return
result
def
get_last_target_pressure
(
self
,
doc
):
value
=
None
unit
=
None
value
=
0
unit
=
self
.
unit
if
doc
:
pressure
=
doc
.
get
(
'
Calibration
'
,
{}).
get
(
'
Measurement
'
,
{}).
get
(
'
Values
'
,
{}).
get
(
'
Pressure
'
,
None
)
pressure
=
doc
.
get
(
'
Calibration
'
,
{}).
get
(
'
Measurement
'
,
{}).
get
(
'
Values
'
,
{}).
get
(
'
Pressure
'
)
if
pressure
:
for
entr
in
pressure
:
ok
=
[
...
...
This diff is collapsed.
Click to expand it.
anselm/test_db.py
+
2
−
2
View file @
c70e0a29
...
...
@@ -69,8 +69,8 @@ class TestDB(unittest.TestCase):
def
test_last_target_pressure_1
(
self
):
doc
=
{}
v
,
u
=
self
.
db
.
get_last_target_pressure
(
doc
)
self
.
assertEqual
(
v
,
None
)
self
.
assertEqual
(
u
,
None
)
self
.
assertEqual
(
v
,
0
)
self
.
assertEqual
(
u
,
'
Pa
'
)
def
test_last_target_pressure_2
(
self
):
...
...
This diff is collapsed.
Click to expand it.
srv.py
+
44
−
14
View file @
c70e0a29
...
...
@@ -13,7 +13,7 @@ db = DB()
def
home
():
return
jsonify
({
"
routes
"
:[
{
"
route
"
:
"
/cal_ids
"
,
"
method
"
:[
'
GET
'
]},
{
"
route
"
:
"
/
next_
target_pressure
"
,
"
method
"
:[
'
GET
'
]},
{
"
route
"
:
"
/target_pressure
"
,
"
method
"
:[
'
GET
'
,
'
POST
'
],
"
data
"
:[
'
DocPath
'
]},
{
"
route
"
:
"
/dut_max
"
,
"
method
"
:[
'
GET
'
]},
{
"
route
"
:
"
/save_dut_branch
"
,
"
method
"
:[
'
POST
'
],
"
data
"
:[
'
DocPath
'
]},
{
"
route
"
:
"
/target_pressures
"
,
"
method
"
:[
'
GET
'
]},
...
...
@@ -33,37 +33,66 @@ def calids():
return
jsonify
({
"
ids
"
:
cal_ids
})
@app.route
(
'
/next_target_pressure
'
,
methods
=
[
'
GET
'
])
def
next_target_pressure
():
cal_ids
=
[]
line
=
s
.
get_lines
(
'
cal_id
'
)
@app.route
(
'
/target_pressure
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
target_pressure
():
if
request
.
method
==
'
POST
'
:
s
.
aset
(
'
save
'
,
0
,
"
yes
"
)
req
=
request
.
get_json
()
last_pressure
=
0
lines
=
s
.
get_lines
(
'
cal_id
'
)
todo_pressures_acc
=
[]
for
line
in
lines
:
cal_id
=
s
.
aget
(
'
cal_id
'
,
line
)
doc
=
db
.
get_doc
(
cal_id
)
last_pressure
=
db
.
get_last_target_pressure
(
doc
)
s
.
log
.
info
(
"
check calibration {}
"
.
format
(
cal_id
))
todo_pressures_acc
,
todo_unit
=
db
.
acc_todo_pressure
(
todo_pressures_acc
,
doc
,
s
.
unit
)
test_pressure
,
test_unit
=
db
.
get_last_target_pressure
(
doc
)
if
test_pressure
>
last_pressure
and
test_unit
==
s
.
unit
:
last_pressure
=
test_pressure
for
todo_pressure
in
todo_pressures_acc
:
if
float
(
todo_pressure
)
>
last_pressure
:
break
if
'
DocPath
'
in
req
:
doc_path
=
req
.
get
(
'
DocPath
'
)
for
line
in
lines
:
s
.
aset
(
"
result
"
,
line
,
[{
'
Type
'
:
'
target_pressure
'
,
'
Value
'
:
float
(
todo_pressure
),
'
Unit
'
:
todo_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
({
"
ids
"
:
cal_ids
})
return
jsonify
({
'
ToExchange
'
:{
'
Target_pressure.Selected
'
:
float
(
todo_pressure
)
}
})
@app.route
(
'
/save_dut_branch
'
,
methods
=
[
'
POST
'
])
def
save_dut_branch
():
s
.
aset
(
'
save
'
,
0
,
"
yes
"
)
if
request
.
method
==
'
POST
'
:
s
.
aset
(
'
save
'
,
0
,
"
yes
"
)
s
.
log
.
info
(
"
request and save dut branch
"
)
res
=
{
"
ok
"
:
True
}
req
=
request
.
get_json
()
if
'
DocPath
'
in
req
:
doc_path
=
req
.
get
(
'
DocPath
'
)
lines
=
s
.
get_lines
(
"
cal_id
"
)
for
line
in
lines
:
s
.
aset
(
"
result
"
,
line
,
[
s
.
aget
(
"
dut_branch
"
,
line
)])
s
.
aset
(
"
doc_path
"
,
line
,
doc_path
)
db
.
save_results
()
db
.
save_results
()
else
:
msg
=
"
missing DocPath
"
res
[
'
error
'
]
=
msg
s
.
log
.
error
(
msg
)
s
.
aset
(
'
save
'
,
0
,
"
no
"
)
return
jsonify
(
res
)
...
...
@@ -120,7 +149,7 @@ def dut_max():
return
jsonify
(
res
)
@app.route
(
'
/target_pressures
'
,
methods
=
[
'
GET
'
])
def
target_pressure
():
def
target_pressure
s
():
s
.
log
.
info
(
"
request to target pressures
"
)
res
=
{
...
...
@@ -158,8 +187,9 @@ def target_pressure():
@app.route
(
'
/offset_sequences
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
offset_sequences
():
s
.
aset
(
'
save
'
,
0
,
"
yes
"
)
if
request
.
method
==
'
POST
'
:
s
.
aset
(
'
save
'
,
0
,
"
yes
"
)
s
.
log
.
info
(
"
request to offset sequence
"
)
lines
=
s
.
get_lines
(
'
offset_all_sequence
'
)
seq_array
=
[]
...
...
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