Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tour_business
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏强
tour_business
Commits
5f03ddad
Commit
5f03ddad
authored
Aug 13, 2020
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改onenet为全国平台+江苏平台
parent
8f178132
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
9 deletions
+28
-9
Config/common_config.py
+10
-0
Controller/ToolController.py
+9
-3
Libs/Onenet/OneNet.py
+6
-2
Libs/Onenet/OneNetApi.py
+3
-4
No files found.
Config/common_config.py
View file @
5f03ddad
...
...
@@ -2,11 +2,21 @@
import
os
is_prod
=
os
.
getenv
(
"RUN_ENV"
,
"test"
)
==
'prod'
ONENET_CONFIG
=
{
"encoding_AES_key"
:
"XzHtYS3PbRiCDErEaztV286Cf4QmmL21T77tEY4Yb2m"
,
"he_cloud_token"
:
"suishenwanonenettesttokenhecloud"
,
"url"
:
'http://api.js.cmcconenet.com'
,
}
NEW_ONENET_CONFIG
=
{
"encoding_AES_key"
:
"XzHtYS3PbRiCDErEaztV286Cf4QmmL21T77tEY4Yb2m"
,
"he_cloud_token"
:
"suishenwanonenettesttokenhecloud"
,
"url"
:
"http://api.heclouds.com"
,
"api_key"
:
"tu61pm=W3WgckJWqwiokfc066iA="
if
is_prod
else
'MYbymxp2GNuEQ95RRulstC4duwo='
,
"he_cloud_device_id"
:
[
"617584147"
]
}
if
is_prod
:
ONENET_CONFIG
[
'api_key'
]
=
"aFpHq1TkvggQrHkTgMlTKA2pXAI="
else
:
...
...
Controller/ToolController.py
View file @
5f03ddad
...
...
@@ -10,6 +10,7 @@ from Model.Base import db
from
Model.Machine.MachineModel
import
Machine
from
Model.Power.PowerModel
import
Power
from
Service.ToolService
import
ToolService
from
Config.common_config
import
NEW_ONENET_CONFIG
as
new_onenet_config
,
ONENET_CONFIG
as
onenet_config
route_tool
=
Blueprint
(
'tool'
,
__name__
)
...
...
@@ -50,8 +51,10 @@ def take_out():
return
jsonify
(
MACHINE_NOT_ONLINE
)
command_message
=
CommandMessage
(
machine_info
.
he_cloud_device_id
,
chr
(
0x46
),
str
(
hatch_no
-
1
))
one_api
=
OneNetApi
()
if
machine_info
.
he_cloud_device_id
in
new_onenet_config
[
"he_cloud_device_id"
]:
one_api
=
OneNetApi
(
new_onenet_config
[
"api_key"
],
new_onenet_config
[
"url"
])
else
:
one_api
=
OneNetApi
(
onenet_config
[
"api_key"
],
onenet_config
[
"url"
])
result
=
one_api
.
send_data_to_edp
(
command_message
.
get_device_id
(),
1
,
0
,
command_message
.
pack
())
if
"errno"
in
result
.
keys
()
and
result
[
'errno'
]
==
0
:
if
result
[
'error'
]
==
'succ'
:
...
...
@@ -82,7 +85,10 @@ def take_out_multiple():
data
=
{}
for
i
in
hatch_no_list
:
command_message
=
CommandMessage
(
machine_info
.
he_cloud_device_id
,
chr
(
0x46
),
str
(
i
-
1
))
one_api
=
OneNetApi
()
if
machine_info
.
he_cloud_device_id
in
new_onenet_config
[
"he_cloud_device_id"
]:
one_api
=
OneNetApi
(
new_onenet_config
[
"api_key"
],
new_onenet_config
[
"url"
])
else
:
one_api
=
OneNetApi
(
onenet_config
[
"api_key"
],
onenet_config
[
"url"
])
result
=
one_api
.
send_data_to_edp
(
command_message
.
get_device_id
(),
1
,
0
,
command_message
.
pack
())
if
'errno'
in
result
.
keys
()
and
result
[
'errno'
]
==
0
:
if
result
[
'error'
]
==
'succ'
:
...
...
Libs/Onenet/OneNet.py
View file @
5f03ddad
...
...
@@ -2,13 +2,17 @@
from
Libs.Onenet.Message.Message
import
CommandMessage
from
Libs.Onenet.OneNetApi
import
OneNetApi
from
Config.common_config
import
NEW_ONENET_CONFIG
as
new_onenet_config
,
ONENET_CONFIG
as
onenet_config
class
OneNet
(
object
):
@staticmethod
def
open
(
machine
,
position
):
command_message
=
CommandMessage
(
machine
.
he_cloud_device_id
,
chr
(
0x46
),
str
(
position
-
1
))
one_api
=
OneNetApi
()
if
machine
.
he_cloud_device_id
in
new_onenet_config
[
"he_cloud_device_id"
]:
one_api
=
OneNetApi
(
new_onenet_config
[
"api_key"
],
new_onenet_config
[
"url"
])
else
:
one_api
=
OneNetApi
(
onenet_config
[
"api_key"
],
onenet_config
[
"url"
])
result
=
one_api
.
send_data_to_edp
(
command_message
.
get_device_id
(),
1
,
0
,
command_message
.
pack
())
if
not
result
or
result
.
get
(
"error"
,
None
)
is
not
None
:
return
False
...
...
Libs/Onenet/OneNetApi.py
View file @
5f03ddad
...
...
@@ -10,7 +10,7 @@ from Config.common_config import ONENET_CONFIG as config, LIUYUAN_CONFIG
class
OneNetApi
(
object
):
_key
=
None
_base_url
=
'http://api.heclouds.com'
_base_url
=
None
_raw_response
=
''
_http_code
=
200
_error_no
=
0
...
...
@@ -19,7 +19,6 @@ class OneNetApi(object):
def
__init__
(
self
,
key
=
None
,
base_url
=
None
):
self
.
_key
=
key
if
base_url
:
self
.
_base_url
=
base_url
def
get_raw_response
(
self
):
...
...
@@ -35,7 +34,7 @@ class OneNetApi(object):
return
self
.
_http_code
def
get_cur_api_key
(
self
):
return
config
[
"api_key"
]
return
self
.
_key
def
get_liuyuan_api_key
(
self
):
return
LIUYUAN_CONFIG
...
...
@@ -400,7 +399,7 @@ class OneNetApi(object):
if
url
[
0
]
!=
'/'
:
url
=
'/'
+
url
return
config
[
"url"
]
+
url
return
self
.
_base_url
+
url
def
_beforeCall
(
self
,
ch
,
url
,
method
,
data
):
pass
...
...
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