Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
董杰
/
induction_shelf
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9cde76cd
由
董杰
编写于
2021-08-18 11:16:20 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
与服务器通信接口调整
1 个父辈
0222438c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
12 行删除
smartshelf/app/induction_post.py
smartshelf/app/induction_post.py
查看文件 @
9cde76c
...
@@ -70,6 +70,7 @@ def startpost():
...
@@ -70,6 +70,7 @@ def startpost():
@app.route
(
'/getauto'
,
methods
=
[
'POST'
])
@app.route
(
'/getauto'
,
methods
=
[
'POST'
])
def
get_auto_state
():
def
get_auto_state
():
global
autostate
global
autostate
# print (autostate)
return
json
.
dumps
({
'msg'
:
autostate
[
'state'
]})
return
json
.
dumps
({
'msg'
:
autostate
[
'state'
]})
...
@@ -112,6 +113,7 @@ def origin_location_init():
...
@@ -112,6 +113,7 @@ def origin_location_init():
global
is_start
global
is_start
url
=
ip_config
[
'ip'
]
+
'/service/store/sensorShelf/hasReelPosList'
url
=
ip_config
[
'ip'
]
+
'/service/store/sensorShelf/hasReelPosList'
data
=
{
"cid"
:
ip_config
[
'cid'
]}
data
=
{
"cid"
:
ip_config
[
'cid'
]}
init_msg
=
''
try
:
try
:
# dataaddrs = read_addrs()
# dataaddrs = read_addrs()
# addrs=dataaddrs.split('@')
# addrs=dataaddrs.split('@')
...
@@ -120,7 +122,7 @@ def origin_location_init():
...
@@ -120,7 +122,7 @@ def origin_location_init():
response
=
requests
.
get
(
url
,
params
=
data
,
timeout
=
2
)
response
=
requests
.
get
(
url
,
params
=
data
,
timeout
=
2
)
in_location
=
response
.
json
()
in_location
=
response
.
json
()
# print ('-----------locations',in_location['data'])
# print ('-----------locations',in_location['data'])
if
in_location
[
'
msg'
]
==
'ok'
:
if
in_location
[
'
code'
]
==
0
:
dataaddrs
=
read_addrs
()
dataaddrs
=
read_addrs
()
addrs
=
dataaddrs
.
split
(
'@'
)
addrs
=
dataaddrs
.
split
(
'@'
)
for
line_addr
in
addrs
:
for
line_addr
in
addrs
:
...
@@ -194,6 +196,7 @@ def server_post(seq):
...
@@ -194,6 +196,7 @@ def server_post(seq):
response
=
requests
.
post
(
url
,
data
=
json
.
dumps
(
body
),
headers
=
headers
,
timeout
=
2
)
response
=
requests
.
post
(
url
,
data
=
json
.
dumps
(
body
),
headers
=
headers
,
timeout
=
2
)
# response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content")
# response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content")
ele_json
=
response
.
json
()
ele_json
=
response
.
json
()
print
(
'ele_json:{}'
.
format
(
ele_json
))
ip_config
[
'post'
]
=
'success'
ip_config
[
'post'
]
=
'success'
resolve_data
(
ele_json
)
resolve_data
(
ele_json
)
if
ele_json
[
'data'
]:
if
ele_json
[
'data'
]:
...
@@ -213,7 +216,8 @@ def resolve_data(datajson):
...
@@ -213,7 +216,8 @@ def resolve_data(datajson):
for
stock
in
openstock
:
for
stock
in
openstock
:
single
=
stock
.
split
(
"="
)
single
=
stock
.
split
(
"="
)
if
locations
.
get
(
single
[
0
]):
if
locations
.
get
(
single
[
0
]):
locations
[
single
[
0
]][
'color'
]
=
single
[
1
]
print
(
single
[
1
]
.
lower
())
locations
[
single
[
0
]][
'color'
]
=
single
[
1
]
.
lower
()
locations
[
single
[
0
]][
'action'
]
=
True
locations
[
single
[
0
]][
'action'
]
=
True
else
:
else
:
logging
.
warning
(
"未找到库位配置:{}"
.
format
(
single
[
0
]))
logging
.
warning
(
"未找到库位配置:{}"
.
format
(
single
[
0
]))
...
@@ -251,8 +255,10 @@ def compare_detail(cur_dict):
...
@@ -251,8 +255,10 @@ def compare_detail(cur_dict):
locnumber
=
led_add_loc
.
split
(
'@'
)[
2
]
locnumber
=
led_add_loc
.
split
(
'@'
)[
2
]
if
oldsensor
!=
cursensors
[
i
]
and
oldsensor
==
'0'
:
if
oldsensor
!=
cursensors
[
i
]
and
oldsensor
==
'0'
:
in_loc
.
append
(
locnumber
)
in_loc
.
append
(
locnumber
)
print
(
'compare in_loc:{}'
.
format
(
locnumber
))
elif
oldsensor
!=
cursensors
[
i
]
and
oldsensor
==
'1'
:
elif
oldsensor
!=
cursensors
[
i
]
and
oldsensor
==
'1'
:
out_loc
.
append
(
locnumber
)
out_loc
.
append
(
locnumber
)
print
(
'compare out_loc:{}'
.
format
(
locnumber
))
detail_dict
[
addr
]
=
cursensors
detail_dict
[
addr
]
=
cursensors
# print ('--------------------in_lock',in_loc)
# print ('--------------------in_lock',in_loc)
# print ('--------------------out_loc',out_loc)
# print ('--------------------out_loc',out_loc)
...
@@ -292,8 +298,10 @@ def send_loc_server(in_loc,out_loc):
...
@@ -292,8 +298,10 @@ def send_loc_server(in_loc,out_loc):
data
=
{
"cid"
:
ip_config
[
'cid'
],
"hasReelPosList"
:
in_loc
,
"noReelPosList"
:
out_loc
}
data
=
{
"cid"
:
ip_config
[
'cid'
],
"hasReelPosList"
:
in_loc
,
"noReelPosList"
:
out_loc
}
try
:
try
:
response
=
requests
.
post
(
url
,
data
=
data
,
headers
=
headers
,
timeout
=
2
)
response
=
requests
.
post
(
url
,
data
=
data
,
headers
=
headers
,
timeout
=
2
)
print
(
'send_loc_server send_data:{}'
.
format
(
data
))
rec_data
=
response
.
json
()
rec_data
=
response
.
json
()
if
rec_data
[
'msg'
]
==
'ok'
:
print
(
'send_loc_server rec_data:{}'
.
format
(
rec_data
))
if
rec_data
[
'code'
]
==
0
:
in_ok
=
rec_data
[
'data'
][
"inOkList"
]
in_ok
=
rec_data
[
'data'
][
"inOkList"
]
out_ok
=
rec_data
[
'data'
][
"outOkList"
]
out_ok
=
rec_data
[
'data'
][
"outOkList"
]
in_ng
=
rec_data
[
'data'
][
"inNgList"
]
in_ng
=
rec_data
[
'data'
][
"inNgList"
]
...
@@ -303,10 +311,10 @@ def send_loc_server(in_loc,out_loc):
...
@@ -303,10 +311,10 @@ def send_loc_server(in_loc,out_loc):
update_to_location
(
in_ok
,
flag
=
1
)
update_to_location
(
in_ok
,
flag
=
1
)
update_to_location
(
out_ok
,
flag
=
2
)
update_to_location
(
out_ok
,
flag
=
2
)
# show_response(in_leds,out_leds,ng_leds)
# show_response(in_leds,out_leds,ng_leds)
#
print ('--------------------in_ok',in_ok)
print
(
'--------------------in_ok'
,
in_ok
)
#
print ('--------------------out_ok',out_ok)
print
(
'--------------------out_ok'
,
out_ok
)
#
print ('--------------------in_ng',in_ng)
print
(
'--------------------in_ng'
,
in_ng
)
#
print ('--------------------out_ng',out_ng)
print
(
'--------------------out_ng'
,
out_ng
)
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
warning
(
"send_loc_server error:{}"
.
format
(
e
))
logging
.
warning
(
"send_loc_server error:{}"
.
format
(
e
))
...
@@ -439,6 +447,7 @@ def update_locations(blink_leds,addr,color,led_index):
...
@@ -439,6 +447,7 @@ def update_locations(blink_leds,addr,color,led_index):
def
blink_convert
(
blink_leds
):
def
blink_convert
(
blink_leds
):
print
(
"blink_leds:{}"
.
format
(
blink_leds
))
if
blink_leds
:
if
blink_leds
:
# texts = ""
# texts = ""
texts
=
[]
texts
=
[]
...
@@ -490,7 +499,7 @@ def show_tower():
...
@@ -490,7 +499,7 @@ def show_tower():
def
update_tower
(
blinks
,
ngs
):
def
update_tower
(
blinks
,
ngs
):
global
tower_state
global
tower_state
#
print (blinks,ngs)
print
(
blinks
,
ngs
)
if
blinks
:
if
blinks
:
if
tower_state
[
'2@5'
][
'status'
]
==
'off'
:
if
tower_state
[
'2@5'
][
'status'
]
==
'off'
:
tower_state
[
'2@5'
][
'action'
]
=
True
tower_state
[
'2@5'
][
'action'
]
=
True
...
@@ -510,13 +519,10 @@ def update_tower(blinks,ngs):
...
@@ -510,13 +519,10 @@ def update_tower(blinks,ngs):
# print ('---------------------------------tower_state',tower_state)
# print ('---------------------------------tower_state',tower_state)
def
reset_tower
():
def
reset_tower
():
try
:
command_dicts
=
{
"ADDR"
:
"0"
,
"lightoff"
:[
1
,
2
,
3
,
4
,
5
,
6
]}
command_dicts
=
{
"ADDR"
:
"0"
,
"lightoff"
:[
1
,
2
,
3
,
4
,
5
,
6
]}
maincommand
=
str
(
json
.
dumps
(
command_dicts
))
+
'
\n
'
maincommand
=
str
(
json
.
dumps
(
command_dicts
))
+
'
\n
'
print
(
maincommand
)
print
(
maincommand
)
ser
.
send_data
(
maincommand
)
ser
.
send_data
(
maincommand
)
except
Exception
as
e
:
logging
.
warning
(
'重置灯塔失败:{}'
.
format
(
e
))
# 开机启动
# 开机启动
...
@@ -525,7 +531,7 @@ def auto_start():
...
@@ -525,7 +531,7 @@ def auto_start():
if
state
==
'on'
:
if
state
==
'on'
:
confirm_state
(
'off'
)
confirm_state
(
'off'
)
time
.
sleep
(
2
)
time
.
sleep
(
2
)
logging
.
warning
(
"
11111111111
"
)
logging
.
warning
(
"
开机自启动
"
)
startpost
()
startpost
()
auto_start
()
auto_start
()
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论