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
6176a7c3
Commit
6176a7c3
authored
6 years ago
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
next: overwrite on len(Value) > 1
parent
99434d1b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
anselm.py
+42
-38
42 additions, 38 deletions
anselm.py
anselm/config.json
+2
-2
2 additions, 2 deletions
anselm/config.json
anselm/db.py
+13
-8
13 additions, 8 deletions
anselm/db.py
anselm/system.py
+5
-0
5 additions, 0 deletions
anselm/system.py
with
62 additions
and
48 deletions
anselm.py
+
42
−
38
View file @
6176a7c3
...
...
@@ -4,9 +4,10 @@ import json
from
anselm.system
import
System
# pylint: disable=E0611
from
anselm.db
import
DB
# pylint: disable=E0611
from
anselm.worker
import
Worker
# pylint: disable=E0611
from
PyQt5.QtWidgets
import
QWidget
,
QDesktopWidget
,
QApplication
,
QPushButton
,
QComboBox
,
QGridLayout
,
QPlainTextEdit
,
QLabel
,
QLineEdit
from
PyQt5.QtWidgets
import
QWidget
,
QDesktopWidget
,
QApplication
,
QPushButton
from
PyQt5.QtWidgets
import
QComboBox
,
QGridLayout
,
QPlainTextEdit
,
QLabel
,
QLineEdit
from
PyQt5.QtCore
import
QThread
,
pyqtSignal
,
Qt
import
sys
class
Observe
(
QThread
,
System
):
signal
=
pyqtSignal
(
'
PyQt_PyObject
'
)
...
...
@@ -40,7 +41,7 @@ class Anselm(System):
cal_id_col
=
2
fullscale_col
=
3
dut_branch_col
=
4
custobj
_col
=
5
devices
_col
=
5
task_col
=
6
run_btn_col
=
7
result_col
=
1
...
...
@@ -66,6 +67,14 @@ class Anselm(System):
{
"
Unit
"
:
self
.
unit
,
"
Display
"
:
"
100Torr
"
,
"
Value
"
:
13300.0
},
{
"
Unit
"
:
self
.
unit
,
"
Display
"
:
"
1000Torr
"
,
"
Value
"
:
133000.0
},
]
self
.
range_exprs
=
{
'
fullscale
'
:
1
,
'
fullscale/10
'
:
0.1
,
'
fullscale/100
'
:
0.01
,
'
fullscale/10000
'
:
0.0001
,
'
fullscale/100000
'
:
0.00001
}
self
.
db
=
DB
()
self
.
worker
=
Worker
()
self
.
observer_thread
=
Observe
()
...
...
@@ -164,7 +173,7 @@ class Anselm(System):
line
=
self
.
current_grid_line
self
.
add_widget_to_grid
(
self
.
make_cal_id_combo
(
line
=
line
),
line
,
self
.
cal_id_col
)
self
.
add_widget_to_grid
(
self
.
make_
custobj
_combo
(
line
=
line
),
line
,
self
.
custobj
_col
)
self
.
add_widget_to_grid
(
self
.
make_
device
_combo
(
line
=
line
),
line
,
self
.
devices
_col
)
self
.
add_widget_to_grid
(
self
.
make_fullscale_combo
(
line
=
line
),
line
,
self
.
fullscale_col
)
self
.
add_widget_to_grid
(
self
.
make_dut_branch_combo
(
line
=
line
),
line
,
self
.
dut_branch_col
)
self
.
add_widget_to_grid
(
self
.
make_result_label
(
line
=
line
),
line
,
self
.
result_col
)
...
...
@@ -230,55 +239,50 @@ class Anselm(System):
return
c
def
make_
custobj
_combo
(
self
,
line
):
def
make_
device
_combo
(
self
,
line
):
cust_obj
_ids
=
self
.
db
.
get_
custobj
_ids
()
device
_ids
=
self
.
db
.
get_
device
_ids
()
self
.
log
.
debug
(
"
found following
custobj
ids {}
"
.
format
(
cust_obj
_ids
))
self
.
log
.
debug
(
"
found following
devices
ids {}
"
.
format
(
device
_ids
))
c
=
self
.
make_combo
(
cust_obj
_ids
,
first_item
=
"
select read out device
"
,
last_item
=
False
)
c
.
currentIndexChanged
.
connect
(
lambda
:
self
.
custobj
_selected
(
c
,
line
))
c
=
self
.
make_combo
(
device
_ids
,
first_item
=
"
select read out device
"
,
last_item
=
False
)
c
.
currentIndexChanged
.
connect
(
lambda
:
self
.
device
_selected
(
c
,
line
))
return
c
def
make_task_combo
(
self
,
doc_id
,
line
):
ok
=
False
tasks
=
self
.
db
.
get_tasks
(
doc_id
=
doc_id
)
self
.
log
.
debug
(
"
found {} tasks
"
.
format
(
len
(
tasks
)))
ok
=
self
.
evaluate_auto_tasks
(
tasks
,
line
)
if
tasks
:
self
.
log
.
debug
(
"
found {} tasks
"
.
format
(
len
(
tasks
)))
ok
=
self
.
evaluate_auto_tasks
(
tasks
,
line
)
if
ok
:
first_item
=
"
tasks ok
"
if
ok
:
first_item
=
"
tasks ok
"
c
=
self
.
make_combo
([
task
.
get
(
'
TaskName
'
)
for
task
in
tasks
],
first_item
=
first_item
,
last_item
=
False
)
c
.
currentIndexChanged
.
connect
(
lambda
:
self
.
task_selected
(
c
,
line
))
else
:
first_item
=
"
task name problem
"
c
=
self
.
make_combo
([
task
.
get
(
'
TaskName
'
)
for
task
in
tasks
],
first_item
=
first_item
,
last_item
=
False
)
else
:
first_item
=
"
task name problem
"
c
=
self
.
make_combo
([
task
.
get
(
'
TaskName
'
)
for
task
in
tasks
],
first_item
=
first_item
,
last_item
=
False
)
c
.
currentIndexChanged
.
connect
(
lambda
:
self
.
task_selected
(
c
,
line
))
c
=
self
.
make_combo
([],
first_item
=
first_item
,
last_item
=
False
)
return
c
def
get_pressure_from_range_expr
(
self
,
range_expr
,
line
):
value
=
None
unit
=
None
q
=
{
'
@fullscale
'
:
1
,
'
@fullscale/10
'
:
0.1
,
'
@fullscale/100
'
:
0.01
,
'
@fullscale/1000
'
:
0.001
,
'
@fullscale/10000
'
:
0.0001
,
'
@fullscale/100000
'
:
0.00001
}
if
range_expr
in
q
:
value
=
self
.
fget
(
"
fullscale_value
"
,
line
)
*
q
[
range_expr
]
unit
=
self
.
aget
(
"
fullscale_unit
"
,
line
)
self
.
log
.
debug
(
"
replaced {} {}
"
.
format
(
value
,
unit
))
value
=
self
.
fget
(
"
fullscale_value
"
,
line
)
unit
=
self
.
aget
(
"
fullscale_unit
"
,
line
)
if
unit
and
value
and
range_expr
in
self
.
range_exprs
:
value
=
value
*
self
.
range_exprs
[
range_expr
]
self
.
log
.
debug
(
"
found {} {}
"
.
format
(
value
,
unit
))
return
value
,
unit
else
:
msg
=
"
unknown range expression
"
self
.
log
.
error
(
msg
)
return
value
,
unit
return
None
,
None
def
evaluate_auto_tasks
(
self
,
tasks
,
line
):
offset_all_sequence
=
[]
...
...
@@ -333,7 +337,7 @@ class Anselm(System):
self
.
log
.
info
(
"
task with name {} selected at line {}
"
.
format
(
task_name
,
line
))
def
custobj
_selected
(
self
,
combo
,
line
):
def
device
_selected
(
self
,
combo
,
line
):
doc_id
=
combo
.
currentText
()
self
.
aset
(
'
doc_id
'
,
line
,
doc_id
)
...
...
This diff is collapsed.
Click to expand it.
anselm/config.json
+
2
−
2
View file @
6176a7c3
...
...
@@ -2,9 +2,9 @@
"couchdb"
:
{
"host"
:
"localhost"
,
"port"
:
5984
,
"database"
:
"vl_db"
,
"database"
:
"vl_db
_work
"
,
"view"
:
{
"
custobj
"
:
"share/
CustomerObject
"
,
"
devices
"
:
"share/
DeviceClass
"
,
"calids"
:
"share/Year_Standard-Type_Certificate_Issue"
}
},
"redis"
:{
...
...
This diff is collapsed.
Click to expand it.
anselm/db.py
+
13
−
8
View file @
6176a7c3
...
...
@@ -32,14 +32,14 @@ class DB(System):
self
.
db
.
save
(
doc
)
def
get_
custobj
_ids
(
self
):
view_con
=
self
.
db_dict
.
get
(
'
view
'
).
get
(
'
custobj
'
)
def
get_
device
_ids
(
self
):
view_con
=
self
.
db_dict
.
get
(
'
view
'
).
get
(
'
devices
'
)
try
:
view
=
self
.
db
.
view
(
view_con
)
res
=
[
doc
.
get
(
'
id
'
)
for
doc
in
view
]
except
Exception
as
inst
:
self
.
log
.
error
(
"
cust
view does not work: {}
"
.
format
(
inst
))
res
=
[
"
dummy
cust
"
]
self
.
log
.
error
(
"
device
view does not work: {}
"
.
format
(
inst
))
res
=
[
"
dummy
device
"
]
self
.
log
.
warn
(
"
return dummy value
"
)
return
res
...
...
@@ -67,6 +67,9 @@ class DB(System):
if
'
CustomerObject
'
in
doc
:
red_doc
=
doc
.
get
(
'
CustomerObject
'
)
if
'
DeviceClass
'
in
doc
:
red_doc
=
doc
.
get
(
'
DeviceClass
'
)
if
'
CalibrationObject
'
in
doc
:
red_doc
=
doc
.
get
(
'
CalibrationObject
'
)
else
:
...
...
@@ -95,6 +98,7 @@ class DB(System):
def
get_task
(
self
,
doc_id
,
task_name
):
doc
=
self
.
get_red_doc
(
doc_id
)
if
doc
and
'
Task
'
in
doc
:
tasks
=
doc
.
get
(
'
Task
'
)
for
task
in
tasks
:
...
...
@@ -170,20 +174,22 @@ class DB(System):
_
,
line
=
cal_key
.
split
(
self
.
keysep
)
doc_path
=
self
.
aget
(
"
doc_path
"
,
line
)
results
=
self
.
dget
(
"
result
"
,
line
)
self
.
log
.
debug
(
"
try to save results: {}
"
.
format
(
results
))
if
doc_path
and
results
:
self
.
log
.
debug
(
"
try to save results: {}
"
.
format
(
results
))
cal_id
=
self
.
aget
(
"
cal_id
"
,
line
)
doc
=
self
.
get_doc
(
cal_id
)
for
result
in
results
:
self
.
log
.
debug
(
"
save components are cal_id {}, doc_path_array: {}, result: {}
"
.
format
(
cal_id
,
doc_path
,
result
))
self
.
doc_write_result
(
doc
,
doc_path
,
result
)
self
.
log
.
debug
(
"
components are cal_id {}, doc_path_array: {}, result: {} saved
"
.
format
(
cal_id
,
doc_path
,
result
))
self
.
adelete
(
"
result
"
,
line
)
self
.
log
.
debug
(
"
deleted result of line {} from mem
"
.
format
(
line
))
self
.
set_doc
(
doc
)
def
doc_write_result
(
self
,
doc
,
doc_path
,
result
):
#
# last entry is something like Pressure (Type, Value and Unit)
# or (!) OperationKind
#
doc_path_array
=
doc_path
.
split
(
"
.
"
)
last_entr
=
doc_path_array
[
-
1
]
...
...
@@ -215,7 +221,6 @@ class DB(System):
if
not
found
:
result
=
self
.
ensure_result_struct
(
result
)
doc
[
last_entr
].
append
(
result
)
else
:
result
=
self
.
ensure_result_struct
(
result
)
doc
[
last_entr
]
=
result
...
...
This diff is collapsed.
Click to expand it.
anselm/system.py
+
5
−
0
View file @
6176a7c3
...
...
@@ -62,6 +62,11 @@ class System:
keys
=
self
.
get_keys
(
key_prefix
)
return
[
key
.
split
(
self
.
keysep
)[
1
]
for
key
in
keys
]
def
adelete
(
self
,
key_prefix
,
line
):
k
=
self
.
gen_key
(
key_prefix
,
line
)
self
.
r
.
delete
(
k
)
def
aset
(
self
,
key_prefix
,
line
,
value
,
expire
=
False
):
...
...
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