Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
3b42d302
Commit
3b42d302
authored
Aug 14, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for 'resolver' argument when data is send by POST
parent
884f0c85
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
main.py
comm/client/main.py
+2
-3
adc2018solver.py
solver/adc2018solver.py
+21
-14
No files found.
comm/client/main.py
View file @
3b42d302
...
@@ -42,18 +42,17 @@ def start():
...
@@ -42,18 +42,17 @@ def start():
qstr
=
request
.
form
[
"question"
]
qstr
=
request
.
form
[
"question"
]
qname
=
request
.
form
[
"qname"
]
qname
=
request
.
form
[
"qname"
]
qseed
=
request
.
form
[
"qseed"
]
qseed
=
request
.
form
[
"qseed"
]
req_id
=
request
.
form
[
"req_id"
]
boardstr
=
BoardStr
.
conv_boardstr
(
qstr
.
split
(
'
\n
'
),
'random'
,
int
(
qseed
))
boardstr
=
BoardStr
.
conv_boardstr
(
qstr
.
split
(
'
\n
'
),
'random'
,
int
(
qseed
))
option
=
{
option
=
{
"name"
:
qname
,
"name"
:
qname
,
"host"
:
args
[
'host'
],
"host"
:
args
[
'host'
],
"client"
:
client_baseurl
,
"client"
:
client_baseurl
,
"req_id"
:
req_id
"req_id"
:
request
.
form
[
'req_id'
],
"resolver"
:
request
.
form
[
'resolver'
]
}
}
pynqrouter
.
start_solver
(
boardstr
,
qseed
,
option
)
pynqrouter
.
start_solver
(
boardstr
,
qseed
,
option
)
# pynq_thread = pynqrouter.start_solver(boardstr, qseed, option)
# 実行だけ開始する
# 実行だけ開始する
ans
[
"status"
]
=
"Processing"
ans
[
"status"
]
=
"Processing"
...
...
solver/adc2018solver.py
View file @
3b42d302
...
@@ -78,6 +78,15 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -78,6 +78,15 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
print
(
seed
)
print
(
seed
)
print
(
''
)
print
(
''
)
res
=
{
'client'
:
option
[
'client'
],
'qname'
:
option
[
'name'
],
'solution'
:
''
,
'cputime'
:
-
1.0
,
'req_id'
:
option
[
'req_id'
],
'solved'
:
False
}
# LINE数を数えてコンフィグするbitstreamを分岐
# LINE数を数えてコンフィグするbitstreamを分岐
line_num
=
boardstr
.
count
(
'L'
)
line_num
=
boardstr
.
count
(
'L'
)
if
line_num
<
127
:
if
line_num
<
127
:
...
@@ -89,7 +98,9 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -89,7 +98,9 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
else
:
else
:
solver_thread
.
stopped
()
solver_thread
.
stopped
()
solver_thread
=
None
solver_thread
=
None
return
{
'solved'
:
False
,
'solution'
:
''
,
'elapsed'
:
-
1.0
}
if
"host"
in
option
:
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
return
res
# ボード文字列から X, Y, Z を読んでくる
# ボード文字列から X, Y, Z を読んでくる
size_x
=
(
ord
(
boardstr
[
1
])
-
ord
(
'0'
))
*
10
+
(
ord
(
boardstr
[
2
])
-
ord
(
'0'
))
size_x
=
(
ord
(
boardstr
[
1
])
-
ord
(
'0'
))
*
10
+
(
ord
(
boardstr
[
2
])
-
ord
(
'0'
))
...
@@ -137,7 +148,9 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -137,7 +148,9 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
if
(
solver_thread
is
not
None
)
and
(
not
solver_thread
.
is_running
()):
if
(
solver_thread
is
not
None
)
and
(
not
solver_thread
.
is_running
()):
solver_thread
.
stopped
()
solver_thread
.
stopped
()
solver_thread
=
None
solver_thread
=
None
return
{
'solved'
:
False
,
'solution'
:
''
,
'elapsed'
:
-
1.0
}
if
"host"
in
option
:
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
return
res
# 完了の確認
# 完了の確認
print
(
'Done!'
)
print
(
'Done!'
)
...
@@ -154,14 +167,6 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -154,14 +167,6 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
# 解けなかったらLEDを消す
# 解けなかったらLEDを消す
mmio_led
.
write
(
0
,
0
)
mmio_led
.
write
(
0
,
0
)
sys
.
stderr
.
write
(
'Cannot solve it!
\n
'
)
sys
.
stderr
.
write
(
'Cannot solve it!
\n
'
)
res
=
{
'client'
:
option
[
'client'
],
'qname'
:
option
[
'name'
],
'solution'
:
''
,
'cputime'
:
-
1.0
,
'req_id'
:
option
[
'req_id'
],
'solved'
:
False
}
if
"host"
in
option
:
if
"host"
in
option
:
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
solver_thread
=
None
solver_thread
=
None
...
@@ -193,9 +198,6 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -193,9 +198,6 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
solution
+=
str
(
boards
[
i
])
# 普通に表示
solution
+=
str
(
boards
[
i
])
# 普通に表示
solution
+=
'
\n
'
solution
+=
'
\n
'
if
solver_thread
is
not
None
:
solver_thread
.
stopped
()
res
=
{
res
=
{
'client'
:
option
[
'client'
],
'client'
:
option
[
'client'
],
'qname'
:
option
[
'name'
],
'qname'
:
option
[
'name'
],
...
@@ -204,8 +206,13 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
...
@@ -204,8 +206,13 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()):
'req_id'
:
option
[
'req_id'
],
'req_id'
:
option
[
'req_id'
],
'solved'
:
True
'solved'
:
True
}
}
if
"host"
in
option
:
if
"resolver"
in
option
:
r
=
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'resolver'
]),
data
=
res
)
elif
"host"
in
option
:
r
=
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
r
=
requests
.
post
(
"http://{}/post"
.
format
(
option
[
'host'
]),
data
=
res
)
if
solver_thread
is
not
None
:
solver_thread
.
stopped
()
solver_thread
=
None
solver_thread
=
None
return
res
return
res
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment