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
f020cfcf
Commit
f020cfcf
authored
6 years ago
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
endpoints / and /target_pressures
parent
78ccb68a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
anselm.py
+12
-12
12 additions, 12 deletions
anselm.py
anselm/db.py
+2
-2
2 additions, 2 deletions
anselm/db.py
srv.py
+68
-6
68 additions, 6 deletions
srv.py
with
82 additions
and
20 deletions
anselm.py
+
12
−
12
View file @
f020cfcf
...
...
@@ -25,18 +25,18 @@ class Observe(QThread, System):
class
Anselm
(
System
):
fullscale_list
=
[
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
SRG
"
,
"
Value
"
:
0
.0
2
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
0.1mbar
"
,
"
Value
"
:
0.
1
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
0.25mbar
"
,
"
Value
"
:
0.
25
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
1mbar
"
,
"
Value
"
:
1
.
0
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
10mbar
"
,
"
Value
"
:
10.0
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
100mbar
"
,
"
Value
"
:
100
.
0
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
1000mbar
"
,
"
Value
"
:
1000.0
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
0.1Torr
"
,
"
Value
"
:
0.
133
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
1Torr
"
,
"
Value
"
:
1
.
33
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
10Torr
"
,
"
Value
"
:
13
.
3
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
100Torr
"
,
"
Value
"
:
133.0
},
{
"
Unit
"
:
"
mbar
"
,
"
Display
"
:
"
1000Torr
"
,
"
Value
"
:
1330.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
SRG
"
,
"
Value
"
:
2
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
0.1mbar
"
,
"
Value
"
:
1
0.
0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
0.25mbar
"
,
"
Value
"
:
25
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
1mbar
"
,
"
Value
"
:
1
0
0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
10mbar
"
,
"
Value
"
:
10
00
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
100mbar
"
,
"
Value
"
:
1000
0.
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
1000mbar
"
,
"
Value
"
:
1000
00
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
0.1Torr
"
,
"
Value
"
:
13
.
3
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
1Torr
"
,
"
Value
"
:
133
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
10Torr
"
,
"
Value
"
:
133
0.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
100Torr
"
,
"
Value
"
:
133
00
.0
},
{
"
Unit
"
:
"
Pa
"
,
"
Display
"
:
"
1000Torr
"
,
"
Value
"
:
1330
00
.0
},
]
std_select
=
[
"
SE3
"
,
"
CE3
"
,
"
FRS5
"
,
"
DKM_PPC4
"
]
year_select
=
[
"
2019
"
,
"
2018
"
,
"
2017
"
]
...
...
This diff is collapsed.
Click to expand it.
anselm/db.py
+
2
−
2
View file @
f020cfcf
...
...
@@ -86,14 +86,14 @@ class DB(System):
self
.
log
.
error
(
"
no doc with id {}
"
.
format
(
doc_id
))
return
[]
def
get_
auxobj
(
self
,
id
):
def
get_
doc
(
self
,
id
):
doc
=
self
.
db
[
id
]
if
doc
:
return
doc
else
:
self
.
log
.
error
(
"
document with id: {} does not exist
"
.
format
(
id
))
return
None
def
replace_defaults
(
self
,
task
,
defaults
):
strtask
=
json
.
dumps
(
task
)
if
isinstance
(
defaults
,
dict
):
...
...
This diff is collapsed.
Click to expand it.
srv.py
+
68
−
6
View file @
f020cfcf
from
flask
import
Flask
,
jsonify
,
request
from
anselm.system
import
System
from
anselm.db
import
DB
app
=
Flask
(
__name__
)
s
=
System
()
db
=
DB
()
@app.route
(
'
/calids
'
)
@app.route
(
'
/
'
)
def
home
():
return
jsonify
({
"
routes
"
:[
"
/cal_ids
"
,
"
/dut_max
"
,
"
/target_pressures
"
,
]
})
@app.route
(
'
/cal_ids
'
)
def
calids
():
keys
=
s
.
r
.
keys
(
'
calid@*
'
)
calids
=
[]
...
...
@@ -20,25 +29,24 @@ def calids():
def
dut_max
():
s
.
log
.
info
(
"
request max values for dut branchs
"
)
keys
=
s
.
r
.
keys
(
'
calid@*
'
)
res
=
{
"
Dut_A
"
:
{
"
Value
"
:
0.0
,
"
Type
"
:
"
dut_max_a
"
,
"
Unit
"
:
"
mbar
"
"
Unit
"
:
"
Pa
"
},
"
Dut_B
"
:
{
"
Value
"
:
0.0
,
"
Type
"
:
"
dut_max_b
"
,
"
Unit
"
:
"
mbar
"
"
Unit
"
:
"
Pa
"
},
"
Dut_C
"
:
{
"
Value
"
:
0.0
,
"
Type
"
:
"
dut_max_c
"
,
"
Unit
"
:
"
mbar
"
"
Unit
"
:
"
Pa
"
}
}
keys
=
s
.
r
.
keys
(
'
calid@*
'
)
for
key
in
keys
:
calid
=
s
.
r
.
get
(
key
)
_
,
line
=
key
.
split
(
s
.
keysep
)
...
...
@@ -71,3 +79,57 @@ def dut_max():
return
jsonify
({
'
ToExchange
'
:
res
})
else
:
return
jsonify
(
res
)
@app.route
(
'
/target_pressures
'
,
methods
=
[
'
GET
'
])
def
target_pressure
():
s
.
log
.
info
(
"
request to target pressures
"
)
res
=
{
"
Pressure_target
"
:
{
"
Caption
"
:
"
target pressure
"
,
"
Selected
"
:
"
1
"
,
"
Select
"
:
[]
}
}
keys
=
s
.
r
.
keys
(
'
calid@*
'
)
target_pressure_values
=
[]
target_pressure_unit
=
"
Pa
"
for
key
in
keys
:
calid
=
s
.
r
.
get
(
key
)
caldoc
=
db
.
get_doc
(
calid
)
todo_pressure
=
caldoc
.
get
(
'
Calibration
'
,
{}).
get
(
'
ToDo
'
,{}).
get
(
'
Values
'
,{}).
get
(
'
Pressure
'
)
if
todo_pressure
:
if
todo_pressure
.
get
(
'
Unit
'
)
==
"
mbar
"
:
conv_factor
=
100
if
todo_pressure
.
get
(
'
Unit
'
)
==
"
Pa
"
:
conv_factor
=
1
for
v
in
todo_pressure
.
get
(
'
Value
'
):
val
=
float
(
v
)
*
conv_factor
if
not
val
in
target_pressure_values
:
target_pressure_values
.
append
(
val
)
else
:
s
.
log
.
warn
(
"
calibration {} contains no target pressures
"
.
format
(
calid
))
if
len
(
target_pressure_values
)
>
0
:
first
=
True
for
v
in
sorted
(
target_pressure_values
):
formated_val
=
'
{:.1e}
'
.
format
(
v
)
if
first
:
res
[
'
Pressure_target
'
][
'
Selected
'
]
=
formated_val
first
=
False
res
[
'
Pressure_target
'
][
'
Select
'
].
append
({
'
value
'
:
formated_val
,
'
display
'
:
"
{} Pa
"
.
format
(
formated_val
)
})
else
:
msg
=
"
no target values found
"
s
.
log
.
error
(
msg
)
res
[
'
error
'
]
=
msg
if
not
'
error
'
in
res
:
return
jsonify
({
'
ToExchange
'
:
res
})
else
:
return
jsonify
(
res
)
\ No newline at end of file
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