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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vaclab
anselm
Commits
1283d4f9
Commit
1283d4f9
authored
Sep 11, 2018
by
wactbprot
Browse files
Options
Downloads
Patches
Plain Diff
loop, single works
parent
c976be33
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
anselm.py
+15
-5
15 additions, 5 deletions
anselm.py
anselm/system.py
+1
-2
1 addition, 2 deletions
anselm/system.py
anselm/worker.py
+29
-18
29 additions, 18 deletions
anselm/worker.py
with
45 additions
and
25 deletions
anselm.py
+
15
−
5
View file @
1283d4f9
...
...
@@ -63,12 +63,13 @@ class Anselm(System):
self
.
result_col
=
1
self
.
line_heigth
=
28
self
.
long_line
=
350
self
.
win
=
QWidget
()
self
.
win
.
closeEvent
=
self
.
closeEvent
self
.
grid
=
QGridLayout
(
self
.
win
)
add_device_bttn
=
QPushButton
(
"
add device
"
,
self
.
win
)
add_device_bttn
.
setFixedSize
(
450
,
self
.
line_heigth
)
add_device_bttn
.
setFixedSize
(
self
.
long_line
,
self
.
line_heigth
)
add_device_bttn
.
clicked
.
connect
(
self
.
add_device_line
)
self
.
add_widget_to_grid
(
add_device_bttn
,
self
.
current_grid_line
,
self
.
add_device_btn_col
)
...
...
@@ -83,6 +84,7 @@ class Anselm(System):
self
.
draw_grid
()
def
add_widget_to_grid
(
self
,
widget
,
line
,
col
):
#old_widget_item = self.grid.itemAtPosition (line, col)
...
...
@@ -135,7 +137,7 @@ class Anselm(System):
l
=
widget_item
.
widget
()
else
:
l
=
QPlainTextEdit
(
self
.
win
)
l
.
setFixedSize
(
450
,
self
.
line_heigth
*
2
)
l
.
setFixedSize
(
self
.
long_line
,
self
.
line_heigth
*
3
)
result
=
self
.
aget
(
'
result
'
,
line
)
if
result
:
...
...
@@ -246,7 +248,15 @@ class Anselm(System):
self
.
aset
(
'
year
'
,
0
,
year
)
self
.
log
.
info
(
"
select year {}
"
.
format
(
year
))
def
closeEvent
(
self
,
event
):
self
.
log
.
info
(
"
flush redis database
"
)
self
.
r
.
flushdb
()
if
True
:
event
.
accept
()
else
:
event
.
ignore
()
if
__name__
==
'
__main__
'
:
app
=
QApplication
(
sys
.
argv
)
ex
=
Anselm
()
Anselm
()
sys
.
exit
(
app
.
exec_
())
This diff is collapsed.
Click to expand it.
anselm/system.py
+
1
−
2
View file @
1283d4f9
...
...
@@ -8,8 +8,7 @@ import redis
class
System
:
"""
"""
max_arg_len
=
40
expire_time
=
5000
#ms
expire_time
=
10000
#ms
log_fmt
=
'
%(asctime)s,%(msecs)03d %(hostname)s %(filename)s:%(lineno)s %(levelname)s %(message)s
'
log_level
=
"
DEBUG
"
...
...
This diff is collapsed.
Click to expand it.
anselm/worker.py
+
29
−
18
View file @
1283d4f9
...
...
@@ -16,7 +16,7 @@ class Worker(System):
def
run
(
self
):
"""
The mem
e
ber worko
m
line is set ba anselm
"""
The member worko
n
line is set ba anselm
before the thread is start.
"""
if
self
.
work_on_line
:
...
...
@@ -26,36 +26,44 @@ class Worker(System):
acc
=
task
[
'
Action
'
]
if
acc
==
"
TCP
"
:
start_new_thread
(
self
.
relay_worker
,
(
task
,
line
))
worker
=
self
.
relay_worker
if
acc
==
"
VXI11
"
:
start_new_thread
(
self
.
relay_worker
,
(
task
,
line
))
worker
=
self
.
relay_worker
if
acc
==
"
wait
"
:
start_new_thread
(
self
.
wait_worker
,
(
task
,
line
))
worker
=
self
.
wait_worker
start_new_thread
(
worker
,
(
task
,
line
))
self
.
work_on_line
=
None
else
:
self
.
log
.
error
(
"
member work_on_line not set
"
)
self
.
log
.
error
(
"
member
var:
work_on_line not set
"
)
def
relay_worker
(
self
,
task
,
line
):
repeat
=
True
while
repeat
:
req
=
requests
.
post
(
self
.
relay_url
,
data
=
json
.
dumps
(
task
),
headers
=
self
.
headers
)
res
=
req
.
json
()
if
'
Result
'
in
res
:
self
.
aset
(
'
result
'
,
line
,
res
[
'
Result
'
],
expire
=
Tru
e
)
self
.
aset
(
'
result
'
,
line
,
res
[
'
Result
'
],
expire
=
Fals
e
)
if
'
ToExchange
'
in
res
:
self
.
aset
(
'
exchange
'
,
line
,
res
[
'
ToExchange
'
],
expire
=
Tru
e
)
self
.
aset
(
'
exchange
'
,
line
,
res
[
'
ToExchange
'
],
expire
=
Fals
e
)
self
.
r
.
publish
(
'
io
'
,
line
)
time
.
sleep
(
self
.
expire_time
/
1000
*
(
1
+
0.1
))
self
.
log
.
debug
(
"
values written
"
)
self
.
r
.
publish
(
'
io
'
,
line
)
run_kind
=
self
.
aget
(
'
run_kind
'
,
line
)
self
.
log
.
debug
(
"
run_kind is {}
"
.
format
(
run_kind
))
if
run_kind
==
'
loop
'
:
repeat
=
True
else
:
repeat
=
False
break
def
wait_worker
(
self
,
task
,
line
):
time
.
sleep
(
5
)
self
.
aset
(
'
result
'
,
line
,
[{
'
completed
'
:
True
}],
expire
=
True
)
self
.
r
.
publish
(
'
io
'
,
line
)
time
.
sleep
(
self
.
expire_time
/
1000
*
(
1
+
0.1
))
self
.
r
.
publish
(
'
io
'
,
line
)
...
...
@@ -63,3 +71,6 @@ class Worker(System):
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