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
256e16f2
Commit
256e16f2
authored
6 years ago
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
paris
parent
8e72424b
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
+31
-6
31 additions, 6 deletions
anselm.py
anselm/config.json
+1
-1
1 addition, 1 deletion
anselm/config.json
anselm/system.py
+6
-20
6 additions, 20 deletions
anselm/system.py
anselm/worker.py
+3
-3
3 additions, 3 deletions
anselm/worker.py
with
41 additions
and
30 deletions
anselm.py
+
31
−
6
View file @
256e16f2
...
@@ -5,13 +5,13 @@ from threading import Thread
...
@@ -5,13 +5,13 @@ from threading import Thread
from
anselm.system
import
System
# pylint: disable=E0611
from
anselm.system
import
System
# pylint: disable=E0611
from
anselm.db
import
DB
# pylint: disable=E0611
from
anselm.db
import
DB
# pylint: disable=E0611
from
anselm.worker
import
Worker
# pylint: disable=E0611
from
anselm.worker
import
Worker
# pylint: disable=E0611
from
PyQt5.QtWidgets
import
QWidget
,
QDesktopWidget
,
QApplication
,
QPushButton
,
QComboBox
,
QGridLayout
from
PyQt5.QtWidgets
import
QWidget
,
QDesktopWidget
,
QApplication
,
QPushButton
,
QComboBox
,
QGridLayout
,
QLineEdit
import
sys
import
sys
class
Anselm
(
System
):
class
Anselm
(
System
):
state
=
{}
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
...
@@ -30,8 +30,12 @@ class Anselm(System):
...
@@ -30,8 +30,12 @@ class Anselm(System):
add_device_bttn
=
QPushButton
(
"
add device
"
,
self
.
win
)
add_device_bttn
=
QPushButton
(
"
add device
"
,
self
.
win
)
add_device_bttn
.
clicked
.
connect
(
self
.
add_device_line
)
add_device_bttn
.
clicked
.
connect
(
self
.
add_device_line
)
self
.
add_widget_to_grid
(
add_device_bttn
,
1
,
2
)
std_select
=
[
"
SE3
"
,
"
CE3
"
,
"
FRS5
"
,
"
DKM_PPC4
"
]
std_select_combo
=
self
.
make_combo
(
std_select
,
first_item
=
None
)
self
.
add_widget_to_grid
(
std_select_combo
,
1
,
1
)
self
.
add_widget_to_grid
(
add_device_bttn
,
1
,
2
)
std_select_combo
.
currentIndexChanged
.
connect
(
lambda
:
self
.
std_selected
(
std_select_combo
))
self
.
draw_grid
()
self
.
draw_grid
()
def
add_device_line
(
self
):
def
add_device_line
(
self
):
...
@@ -59,7 +63,13 @@ class Anselm(System):
...
@@ -59,7 +63,13 @@ class Anselm(System):
run_device_bttn
.
clicked
.
connect
(
lambda
:
self
.
run_device
(
line
))
run_device_bttn
.
clicked
.
connect
(
lambda
:
self
.
run_device
(
line
))
return
run_device_bttn
return
run_device_bttn
def
make_result_textbox
(
self
,
line
):
result_textbox
=
QLineEdit
(
self
.
win
)
result_textbox
.
resize
(
280
,
40
)
return
result_textbox
def
make_run_kind_combo
(
self
,
line
):
def
make_run_kind_combo
(
self
,
line
):
run_kinds
=
[
"
single
"
,
"
loop
"
]
run_kinds
=
[
"
single
"
,
"
loop
"
]
...
@@ -67,7 +77,15 @@ class Anselm(System):
...
@@ -67,7 +77,15 @@ class Anselm(System):
combo
.
currentIndexChanged
.
connect
(
lambda
:
self
.
run_kind_selected
(
combo
,
line
))
combo
.
currentIndexChanged
.
connect
(
lambda
:
self
.
run_kind_selected
(
combo
,
line
))
return
combo
return
combo
def
make_calib_id_combo
(
self
,
line
):
run_kinds
=
[
"
single
"
,
"
loop
"
]
combo
=
self
.
make_combo
(
run_kinds
,
first_item
=
None
)
combo
.
currentIndexChanged
.
connect
(
lambda
:
self
.
run_kind_selected
(
combo
,
line
))
return
combo
def
make_auxobj_combo
(
self
,
line
):
def
make_auxobj_combo
(
self
,
line
):
aux_obj_ids
=
self
.
db
.
get_auxobj_ids
()
aux_obj_ids
=
self
.
db
.
get_auxobj_ids
()
...
@@ -111,6 +129,8 @@ class Anselm(System):
...
@@ -111,6 +129,8 @@ class Anselm(System):
self
.
state
[
line_key
][
'
task
'
]
=
task
self
.
state
[
line_key
][
'
task
'
]
=
task
self
.
log
.
debug
(
"
task: {}
"
.
format
(
task
))
self
.
log
.
debug
(
"
task: {}
"
.
format
(
task
))
self
.
make_result_textbox
(
line
)
def
auxobj_selected
(
self
,
combo
,
line
):
def
auxobj_selected
(
self
,
combo
,
line
):
doc_id
=
combo
.
currentText
()
doc_id
=
combo
.
currentText
()
line_key
=
self
.
get_line_key
(
line
)
line_key
=
self
.
get_line_key
(
line
)
...
@@ -139,6 +159,7 @@ class Anselm(System):
...
@@ -139,6 +159,7 @@ class Anselm(System):
for
item
in
item_list
:
for
item
in
item_list
:
combo
.
addItem
(
item
)
combo
.
addItem
(
item
)
return
combo
return
combo
def
get_line_key
(
self
,
line
):
def
get_line_key
(
self
,
line
):
return
'
line_{}
'
.
format
(
line
)
return
'
line_{}
'
.
format
(
line
)
...
@@ -153,8 +174,12 @@ class Anselm(System):
...
@@ -153,8 +174,12 @@ class Anselm(System):
else
:
else
:
self
.
log
.
error
(
"
no task selected at line {}
"
.
format
(
line
))
self
.
log
.
error
(
"
no task selected at line {}
"
.
format
(
line
))
if
task
:
if
task
:
self
.
log
.
debug
(
"
task is: {}
"
.
format
(
task
))
Thread
(
target
=
self
.
worker
.
run
,
args
=
(
task
,
)).
start
()
Thread
(
target
=
self
.
worker
.
run
,
args
=
(
task
,
)).
start
()
def
std_selected
(
self
,
combo
):
self
.
state
[
'
standard
'
]
=
combo
.
currentText
()
self
.
log
.
info
(
"
select standard {}
"
.
format
(
self
.
state
.
get
(
'
standard
'
)))
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
anselm/config.json
+
1
−
1
View file @
256e16f2
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
}
}
},
},
"relay"
:{
"relay"
:{
"host"
:
"
i75419.berlin.ptb.de
"
,
"host"
:
"
localhost
"
,
"port"
:
55555
"port"
:
55555
},
},
"loglevel"
:
"DEBUG"
"loglevel"
:
"DEBUG"
...
...
This diff is collapsed.
Click to expand it.
anselm/system.py
+
6
−
20
View file @
256e16f2
...
@@ -11,6 +11,7 @@ class System:
...
@@ -11,6 +11,7 @@ class System:
"""
"""
max_arg_len
=
40
max_arg_len
=
40
log_fmt
=
'
%(asctime)s,%(msecs)03d %(hostname)s %(filename)s:%(lineno)s %(levelname)s %(message)s
'
log_fmt
=
'
%(asctime)s,%(msecs)03d %(hostname)s %(filename)s:%(lineno)s %(levelname)s %(message)s
'
log_level
=
"
DEBUG
"
state
=
{}
state
=
{}
def
__init__
(
self
):
def
__init__
(
self
):
"""
"""
...
@@ -23,28 +24,13 @@ class System:
...
@@ -23,28 +24,13 @@ class System:
self
.
init_log
()
self
.
init_log
()
def
init_log
(
self
):
def
init_log
(
self
):
log_level
=
self
.
config
.
get
(
'
loglevel
'
)
self
.
log
=
logging
.
getLogger
()
self
.
log
=
logging
.
getLogger
()
coloredlogs
.
install
(
fmt
=
self
.
log_fmt
,
level
=
self
.
config
[
"
loglevel
"
],
logger
=
self
.
log
)
if
log_level
is
None
:
log_level
=
self
.
log_level
self
.
log
.
info
(
"
logging system online
"
)
coloredlogs
.
install
(
fmt
=
self
.
log_fmt
,
level
=
log_level
,
logger
=
self
.
log
)
def
now
(
self
):
def
now
(
self
):
return
datetime
.
datetime
.
now
().
isoformat
().
replace
(
'
T
'
,
'
'
)
return
datetime
.
datetime
.
now
().
isoformat
().
replace
(
'
T
'
,
'
'
)
def
parse_body
(
self
,
body
):
do
,
pl
=
None
,
None
try
:
res
=
json
.
loads
(
body
)
except
ValueError
as
error
:
raise
ParseError
(
error
)
if
'
do
'
in
res
:
do
=
res
[
'
do
'
]
if
'
payload
'
in
res
:
pl
=
res
[
'
payload
'
]
return
do
,
pl
This diff is collapsed.
Click to expand it.
anselm/worker.py
+
3
−
3
View file @
256e16f2
...
@@ -19,15 +19,15 @@ class Worker(System):
...
@@ -19,15 +19,15 @@ class Worker(System):
if
acc
==
"
TCP
"
:
if
acc
==
"
TCP
"
:
self
.
relay_worker
(
task
)
self
.
relay_worker
(
task
)
if
acc
==
"
VXI11
"
:
self
.
relay_worker
(
task
)
def
relay_worker
(
self
,
task
):
def
relay_worker
(
self
,
task
):
req
=
requests
.
post
(
self
.
relay_url
,
data
=
json
.
dumps
(
task
),
headers
=
self
.
headers
)
req
=
requests
.
post
(
self
.
relay_url
,
data
=
json
.
dumps
(
task
),
headers
=
self
.
headers
)
res
=
req
.
json
()
res
=
req
.
json
()
if
'
Result
'
in
res
:
if
'
Result
'
in
res
:
print
(
res
[
'
Result
'
])
print
(
res
[
'
Result
'
])
print
(
self
.
state
)
print
(
"
dddddddddddddddddd
"
)
if
'
ToExchange
'
in
res
:
if
'
ToExchange
'
in
res
:
print
(
res
[
'
ToExchange
'
])
print
(
res
[
'
ToExchange
'
])
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