Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
0237384b
Commit
0237384b
authored
Sep 28, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改通信表规则,channel使用redis,web控制device容器,页面不被注销
parent
e15a8807
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
314 additions
and
34 deletions
+314
-34
.gitignore
.gitignore
+2
-0
README.md
README.md
+2
-0
xdc.sqlite
database/xdc.sqlite
+0
-0
urls.py
device_communication/urls.py
+1
-0
views.py
device_communication/views.py
+33
-0
App.vue
frontend/src/App.vue
+40
-3
CommunicationTab.vue
.../src/components/device_communication/CommunicationTab.vue
+32
-7
Chat.vue
frontend/src/components/home/Chat.vue
+3
-1
protocolNames.ts
frontend/src/stores/protocolNames.ts
+1
-1
DeviceCommunication.vue
frontend/src/views/DeviceCommunication.vue
+7
-5
manage.spec
manage.spec
+43
-0
poetry.lock
poetry.lock
+116
-1
pyproject.toml
pyproject.toml
+1
-0
settings.py
vue_django/settings.py
+14
-10
urls.py
vue_django/urls.py
+6
-5
views.py
vue_django/views.py
+13
-1
No files found.
.gitignore
View file @
0237384b
...
...
@@ -3,3 +3,5 @@ __pycache__
.idea
assets
*.tar
dist
build
README.md
View file @
0237384b
...
...
@@ -85,3 +85,4 @@ ps:以上步骤在 windows 环境和 ubuntu 20.04 下都测试过,都能正
*
如果是在远程的情况下,需要将 vue_django 目录中 urls.py 文件中的
`mqtt`
和
`chat`
url 给注释了,否则启动不成功
*
!
[
1692841883700
](
image/README/1692841883700.png
)
*
使用 pyinstaller 打包之后的可执行文件需要在 runserver 后加上 --noreload
\ No newline at end of file
database/xdc.sqlite
View file @
0237384b
No preview for this file type
device_communication/urls.py
View file @
0237384b
...
...
@@ -10,6 +10,7 @@ router.register('device_communication/simulate_communicate',
urlpatterns
=
[
re_path
(
r'^device_communication/$'
,
views
.
get_protocol_names
),
re_path
(
r'^device_communication/init/$'
,
views
.
init
),
re_path
(
r'^device_communication/protocol_performance/(?P<protocol_name>.+)/$'
,
views
.
get_protocol_field_names
),
re_path
(
r'^device_communication/performance/(?P<type>.+)/(?P<protocol_name>.+)/$'
,
views
.
get_checked_field_names
),
...
...
device_communication/views.py
View file @
0237384b
...
...
@@ -24,6 +24,39 @@ def get_protocol_names(request):
return
Response
(
data
=
res_data
,
status
=
status
.
HTTP_200_OK
)
@api_view
([
'POST'
])
def
init
(
request
):
"""
通信参数初始化,移除了 device_info 中与 udp 组播相关的参数
多 performance_fields 字段
"""
device_infos
=
TableXproAllDevinfo
.
objects
.
all
()
device_communication_manager
=
DeviceCommunicationParameter
.
objects
.
all
()
# 如果设备信息表中有数据,而设备通信参数表中没有数据,
# 则将设备信息表中的数据添加到设备通信参数表中
if
(
len
(
device_infos
)
!=
0
and
len
(
device_communication_manager
)
==
0
):
DeviceCommunicationParameter
.
objects
.
bulk_create
(
[
DeviceCommunicationParameter
(
station_id
=
device_info
.
sta_id
,
device_id
=
device_info
.
dev_id
,
device_name
=
device_info
.
dev_name
,
device_name_chn
=
device_info
.
dev_name_chn
,
protocol_name
=
device_info
.
protocol_name
,
communicate_mode
=
device_info
.
comunitate_mode
,
tcp_ip
=
device_info
.
tcp_ip
,
tcp_port
=
device_info
.
tcp_port
,
udp_ip_src
=
device_info
.
udp_ip_src
,
udp_port_src
=
device_info
.
udp_port_src
,
udp_ip_dst
=
device_info
.
udp_ip_dst
,
udp_port_dst
=
device_info
.
udp_port_dst
,
performance_fields
=
json
.
dumps
([]))
for
device_info
in
device_infos
])
return
Response
(
status
=
status
.
HTTP_200_OK
)
@api_view
([
'GET'
])
def
get_protocol_field_names
(
request
,
protocol_name
):
"""
...
...
frontend/src/App.vue
View file @
0237384b
...
...
@@ -14,13 +14,14 @@
</el-menu-item>
</el-menu>
</el-header>
<el-button
type=
"primary"
@
click=
"restartDevice"
>
重启device
</el-button>
<el-main>
<
router-view
/
>
<
!--
<
router-view
v-slot=
"
{ Component }">
<
!--
<router-view
/>
--
>
<router-view
v-slot=
"
{ Component }">
<keep-alive>
<component
:is=
"Component"
/>
</keep-alive>
</router-view>
-->
</router-view>
</el-main>
</el-container>
</div>
...
...
@@ -33,6 +34,8 @@ import { DeviceProtocol, ProtocolCmd } from "@/dao/device";
import
{
GetProtocolVersion
,
GetCurrentVersion
}
from
'@/dao/protocol'
;
import
{
useProtocolInfoStore
}
from
'./stores/protocolInfo'
;
import
{
useProtocolVersionStore
}
from
'@/stores/allProtocolVersion'
;
import
{
ElMessage
,
ElMessageBox
}
from
'element-plus'
import
request
from
'@/plugins/axios/requests'
const
store
=
useProtocolVersionStore
()
const
protocolStore
=
useProtocolInfoStore
()
...
...
@@ -55,6 +58,40 @@ onMounted(async () => {
protocolStore
.
protocolCmd
=
res
.
data
})
})
const
restartDevice
=
()
=>
{
ElMessageBox
.
confirm
(
'确定要重启 device 模块吗?'
,
'警告'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
,
}
)
.
then
(()
=>
{
request
.
post
(
'/api/restart_device/'
)
.
then
(()
=>
{
ElMessage
({
type
:
'success'
,
message
:
'重启成功'
,
})
})
.
catch
(()
=>
{
ElMessage
({
type
:
'error'
,
message
:
'重启失败'
,
})
})
})
.
catch
(()
=>
{
ElMessage
({
type
:
'info'
,
message
:
'取消成功'
,
})
})
}
</
script
>
<
style
>
...
...
frontend/src/components/device_communication/CommunicationTab.vue
View file @
0237384b
...
...
@@ -40,6 +40,7 @@ import useClipboard from 'vue-clipboard3'
import
DeviceInfoCard
from
'@/components/device_communication/DeviceInfoCard'
import
type
{
DeviceInfo
}
from
'@/components/device_communication/types'
import
EditDialog
from
'@/components/device_communication/EditDialog'
;
import
request
from
'@/plugins/axios/requests'
;
type
propType
=
{
tabType
:
string
...
...
@@ -49,15 +50,39 @@ const props = defineProps<propType>()
const
device_infos
=
ref
<
Record
<
string
,
DeviceInfo
[]
>>
({})
// 获取当前选择的页面
onMounted
(()
=>
{
axios
.
get
(
'/api/device_communication/'
+
props
.
tabType
+
'/'
)
// props.tabType 的值为 communicate 或者 simulate_communicate
request
.
get
<
string
>
(
'/api/device_communication/'
+
props
.
tabType
+
'/'
)
.
then
(
res
=>
{
// console.log(res.data);
// console.log(res.data); // string 类型
let
data
:
DeviceInfo
[]
=
JSON
.
parse
(
res
.
data
!
)
// 将数据按照不同的 station_id 分组
for
(
let
i
=
0
;
i
<
res
.
data
.
length
;
i
++
)
{
if
(
device_infos
.
value
[
res
.
data
[
i
].
station_id
]
!==
undefined
)
{
device_infos
.
value
[
res
.
data
[
i
].
station_id
].
push
(
res
.
data
[
i
])
}
else
{
device_infos
.
value
[
res
.
data
[
i
].
station_id
]
=
[
res
.
data
[
i
]]
if
(
data
.
length
===
0
)
{
// 如果返回的数据为空,则初始化
request
.
post
(
'/api/device_communication/init/'
)
// 重新获取数据
request
.
get
<
string
>
(
'/api/device_communication/'
+
props
.
tabType
+
'/'
)
.
then
(
res
=>
{
let
data
:
DeviceInfo
[]
=
JSON
.
parse
(
res
.
data
!
)
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
device_infos
.
value
[
data
[
i
].
station_id
]
!==
undefined
)
{
device_infos
.
value
[
data
[
i
].
station_id
].
push
(
data
[
i
])
}
else
{
device_infos
.
value
[
data
[
i
].
station_id
]
=
[
data
[
i
]]
}
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
})
}
else
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
device_infos
.
value
[
data
[
i
].
station_id
]
!==
undefined
)
{
device_infos
.
value
[
data
[
i
].
station_id
].
push
(
data
[
i
])
}
else
{
device_infos
.
value
[
data
[
i
].
station_id
]
=
[
data
[
i
]]
}
}
}
})
...
...
frontend/src/components/home/Chat.vue
View file @
0237384b
...
...
@@ -129,7 +129,9 @@ onMounted(() => {
// // 将字节流转换为字符串或其他格式进行处理
// const message = byteArray.toString();
// items.value.push(JSON.stringify(e.data));
items
.
value
.
push
(
decodeURIComponent
(
e
.
data
));
let
message
=
decodeURIComponent
(
e
.
data
)
// TODO 处理数据,看是否有是被检测的设备
items
.
value
.
push
(
message
);
flag
.
value
=
!
flag
.
value
};
...
...
frontend/src/stores/protocolNames.ts
View file @
0237384b
import
{
defineStore
}
from
'pinia'
import
{
ref
}
from
'vue'
type
ProtocolName
=
{
export
type
ProtocolName
=
{
label
:
string
value
:
string
}
...
...
frontend/src/views/DeviceCommunication.vue
View file @
0237384b
...
...
@@ -14,20 +14,22 @@
</
template
>
<
script
lang=
"ts"
setup
>
import
axios
from
'axios'
;
import
{
onMounted
,
ref
}
from
'vue'
import
{
useProtocolNamesStore
}
from
'@/stores/protocolNames'
import
{
useProtocolNamesStore
,
ProtocolName
}
from
'@/stores/protocolNames'
import
CommunicationTab
from
"@/components/device_communication/CommunicationTab"
;
import
request
from
"@/plugins/axios/requests"
// tab 相关
const
activeName
=
ref
<
string
>
(
'simulate_device'
)
// 默认为设备界面
const
activeName
=
ref
<
string
>
(
'device'
)
onMounted
(()
=>
{
axios
.
get
(
'/api/device_communication/'
)
// 获取协议名
request
.
get
<
ProtocolName
[]
>
(
'/api/device_communication/'
)
.
then
((
res
)
=>
{
const
store
=
useProtocolNamesStore
()
store
.
protocolNames
.
push
(...
res
.
data
)
store
.
protocolNames
.
push
(...
res
.
data
!
)
})
})
...
...
manage.spec
0 → 100644
View file @
0237384b
# -*- mode: python ; coding: utf-8 -*-
a
=
Analysis
(
[
'manage.py'
],
pathex
=
[],
binaries
=
[],
datas
=
[],
hiddenimports
=
[],
hookspath
=
[],
hooksconfig
=
{},
runtime_hooks
=
[],
excludes
=
[],
noarchive
=
False
,
)
pyz
=
PYZ
(
a
.
pure
)
exe
=
EXE
(
pyz
,
a
.
scripts
,
[],
exclude_binaries
=
True
,
name
=
'manage'
,
debug
=
False
,
bootloader_ignore_signals
=
False
,
strip
=
False
,
upx
=
False
,
console
=
True
,
disable_windowed_traceback
=
False
,
argv_emulation
=
False
,
target_arch
=
None
,
codesign_identity
=
None
,
entitlements_file
=
None
,
)
coll
=
COLLECT
(
exe
,
a
.
binaries
,
a
.
datas
,
strip
=
False
,
upx
=
False
,
upx_exclude
=
[],
name
=
'manage'
,
)
poetry.lock
View file @
0237384b
...
...
@@ -18,6 +18,17 @@ typing-extensions = {version = ">=4", markers = "python_version < \"3.11\""}
tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"]
[[package]]
name = "async-timeout"
version = "4.0.3"
description = "Timeout context manager for asyncio programs"
optional = false
python-versions = ">=3.7"
files = [
{file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"},
{file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"},
]
[[package]]
name = "attrs"
version = "23.1.0"
description = "Classes Without Boilerplate"
...
...
@@ -178,6 +189,27 @@ daphne = ["daphne (>=4.0.0)"]
tests = ["async-timeout", "coverage (>=4.5,<5.0)", "pytest", "pytest-asyncio", "pytest-django"]
[[package]]
name = "channels-redis"
version = "4.1.0"
description = "Redis-backed ASGI channel layer implementation"
optional = false
python-versions = ">=3.7"
files = [
{file = "channels_redis-4.1.0-py3-none-any.whl", hash = "sha256:3696f5b9fe367ea495d402ba83d7c3c99e8ca0e1354ff8d913535976ed0abf73"},
{file = "channels_redis-4.1.0.tar.gz", hash = "sha256:6bd4f75f4ab4a7db17cee495593ace886d7e914c66f8214a1f247ff6659c073a"},
]
[package.dependencies]
asgiref = ">=3.2.10,<4"
channels = "*"
msgpack = ">=1.0,<2.0"
redis = ">=4.5.3"
[package.extras]
cryptography = ["cryptography (>=1.3.0)"]
tests = ["async-timeout", "cryptography (>=1.3.0)", "pytest", "pytest-asyncio", "pytest-timeout"]
[[package]]
name = "constantly"
version = "15.1.0"
description = "Symbolic constants in Python"
...
...
@@ -363,6 +395,71 @@ files = [
]
[[package]]
name = "msgpack"
version = "1.0.6"
description = "MessagePack serializer"
optional = false
python-versions = ">=3.8"
files = [
{file = "msgpack-1.0.6-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f4321692e7f299277e55f322329b2c972d93bb612d85f3fda8741bec5c6285ce"},
{file = "msgpack-1.0.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1f0e36a5fa7a182cde391a128a64f437657d2b9371dfa42eda3436245adccbf5"},
{file = "msgpack-1.0.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b5c8dd9a386a66e50bd7fa22b7a49fb8ead2b3574d6bd69eb1caced6caea0803"},
{file = "msgpack-1.0.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9f85200ea102276afdd3749ca94747f057bbb868d1c52921ee2446730b508d0f"},
{file = "msgpack-1.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a006c300e82402c0c8f1ded11352a3ba2a61b87e7abb3054c845af2ca8d553c"},
{file = "msgpack-1.0.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:33bbf47ea5a6ff20c23426106e81863cdbb5402de1825493026ce615039cc99d"},
{file = "msgpack-1.0.6-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:04450e4b5e1e662e7c86b6aafb7c230af9334fd0becf5e6b80459a507884241c"},
{file = "msgpack-1.0.6-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b06a5095a79384760625b5de3f83f40b3053a385fb893be8a106fbbd84c14980"},
{file = "msgpack-1.0.6-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3910211b0ab20be3a38e0bb944ed45bd4265d8d9f11a3d1674b95b298e08dd5c"},
{file = "msgpack-1.0.6-cp310-cp310-win32.whl", hash = "sha256:1dc67b40fe81217b308ab12651adba05e7300b3a2ccf84d6b35a878e308dd8d4"},
{file = "msgpack-1.0.6-cp310-cp310-win_amd64.whl", hash = "sha256:885de1ed5ea01c1bfe0a34c901152a264c3c1f8f1d382042b92ea354bd14bb0e"},
{file = "msgpack-1.0.6-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:099c3d8a027367e1a6fc55d15336f04ff65c60c4f737b5739f7db4525c65fe9e"},
{file = "msgpack-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9b88dc97ba86c96b964c3745a445d9a65f76fe21955a953064fe04adb63e9367"},
{file = "msgpack-1.0.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:00ce5f827d4f26fc094043e6f08b6069c1b148efa2631c47615ae14fb6cafc89"},
{file = "msgpack-1.0.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd6af61388be65a8701f5787362cb54adae20007e0cc67ca9221a4b95115583b"},
{file = "msgpack-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:652e4b7497825b0af6259e2c54700e6dc33d2fc4ed92b8839435090d4c9cc911"},
{file = "msgpack-1.0.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5b08676a17e3f791daad34d5fcb18479e9c85e7200d5a17cbe8de798643a7e37"},
{file = "msgpack-1.0.6-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:229ccb6713c8b941eaa5cf13dc7478eba117f21513b5893c35e44483e2f0c9c8"},
{file = "msgpack-1.0.6-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:95ade0bd4cf69e04e8b8f8ec2d197d9c9c4a9b6902e048dc7456bf6d82e12a80"},
{file = "msgpack-1.0.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5b16344032a27b2ccfd341f89dadf3e4ef6407d91e4b93563c14644a8abb3ad7"},
{file = "msgpack-1.0.6-cp311-cp311-win32.whl", hash = "sha256:55bb4a1bf94e39447bc08238a2fb8a767460388a8192f67c103442eb36920887"},
{file = "msgpack-1.0.6-cp311-cp311-win_amd64.whl", hash = "sha256:ae97504958d0bc58c1152045c170815d5c4f8af906561ce044b6358b43d0c97e"},
{file = "msgpack-1.0.6-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:7ecf431786019a7bfedc28281531d706627f603e3691d64eccdbce3ecd353823"},
{file = "msgpack-1.0.6-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a635aecf1047255576dbb0927cbf9a7aa4a68e9d54110cc3c926652d18f144e0"},
{file = "msgpack-1.0.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:102cfb54eaefa73e8ca1e784b9352c623524185c98e057e519545131a56fb0af"},
{file = "msgpack-1.0.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c5e05e4f5756758c58a8088aa10dc70d851c89f842b611fdccfc0581c1846bc"},
{file = "msgpack-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:68569509dd015fcdd1e6b2b3ccc8c51fd27d9a97f461ccc909270e220ee09685"},
{file = "msgpack-1.0.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bf652839d16de91fe1cfb253e0a88db9a548796939533894e07f45d4bdf90a5f"},
{file = "msgpack-1.0.6-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:14db7e1b7a7ed362b2f94897bf2486c899c8bb50f6e34b2db92fe534cdab306f"},
{file = "msgpack-1.0.6-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:159cfec18a6e125dd4723e2b1de6f202b34b87c850fb9d509acfd054c01135e9"},
{file = "msgpack-1.0.6-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:6a01a072b2219b65a6ff74df208f20b2cac9401c60adb676ee34e53b4c651077"},
{file = "msgpack-1.0.6-cp312-cp312-win32.whl", hash = "sha256:e36560d001d4ba469d469b02037f2dd404421fd72277d9474efe9f03f83fced5"},
{file = "msgpack-1.0.6-cp312-cp312-win_amd64.whl", hash = "sha256:5e7fae9ca93258a956551708cf60dc6c8145574e32ce8c8c4d894e63bcb04341"},
{file = "msgpack-1.0.6-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:40b801b768f5a765e33c68f30665d3c6ee1c8623a2d2bb78e6e59f2db4e4ceb7"},
{file = "msgpack-1.0.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:da057d3652e698b00746e47f06dbb513314f847421e857e32e1dc61c46f6c052"},
{file = "msgpack-1.0.6-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f75114c05ec56566da6b55122791cf5bb53d5aada96a98c016d6231e03132f76"},
{file = "msgpack-1.0.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:61213482b5a387ead9e250e9e3cb290292feca39dc83b41c3b1b7b8ffc8d8ecb"},
{file = "msgpack-1.0.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bae6c561f11b444b258b1b4be2bdd1e1cf93cd1d80766b7e869a79db4543a8a8"},
{file = "msgpack-1.0.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:619a63753ba9e792fe3c6c0fc2b9ee2cfbd92153dd91bee029a89a71eb2942cd"},
{file = "msgpack-1.0.6-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:70843788c85ca385846a2d2f836efebe7bb2687ca0734648bf5c9dc6c55602d2"},
{file = "msgpack-1.0.6-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:fb4571efe86545b772a4630fee578c213c91cbcfd20347806e47fd4e782a18fe"},
{file = "msgpack-1.0.6-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bbb4448a05d261fae423d5c0b0974ad899f60825bc77eabad5a0c518e78448c2"},
{file = "msgpack-1.0.6-cp38-cp38-win32.whl", hash = "sha256:5cd67674db3c73026e0a2c729b909780e88bd9cbc8184256f9567640a5d299a8"},
{file = "msgpack-1.0.6-cp38-cp38-win_amd64.whl", hash = "sha256:a1cf98afa7ad5e7012454ca3fde254499a13f9d92fd50cb46118118a249a1355"},
{file = "msgpack-1.0.6-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:d6d25b8a5c70e2334ed61a8da4c11cd9b97c6fbd980c406033f06e4463fda006"},
{file = "msgpack-1.0.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:88cdb1da7fdb121dbb3116910722f5acab4d6e8bfcacab8fafe27e2e7744dc6a"},
{file = "msgpack-1.0.6-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3b5658b1f9e486a2eec4c0c688f213a90085b9cf2fec76ef08f98fdf6c62f4b9"},
{file = "msgpack-1.0.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76820f2ece3b0a7c948bbb6a599020e29574626d23a649476def023cbb026787"},
{file = "msgpack-1.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c780d992f5d734432726b92a0c87bf1857c3d85082a8dea29cbf56e44a132b3"},
{file = "msgpack-1.0.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e0ed35d6d6122d0baa9a1b59ebca4ee302139f4cfb57dab85e4c73ab793ae7ed"},
{file = "msgpack-1.0.6-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:32c0aff31f33033f4961abc01f78497e5e07bac02a508632aef394b384d27428"},
{file = "msgpack-1.0.6-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:35ad5aed9b52217d4cea739d0ea3a492a18dd86fecb4b132668a69f27fb0363b"},
{file = "msgpack-1.0.6-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:47275ff73005a3e5e146e50baa2378e1730cba6e292f0222bc496a8e4c4adfc8"},
{file = "msgpack-1.0.6-cp39-cp39-win32.whl", hash = "sha256:7baf16fd8908a025c4a8d7b699103e72d41f967e2aee5a2065432bcdbd9fd06e"},
{file = "msgpack-1.0.6-cp39-cp39-win_amd64.whl", hash = "sha256:fc97aa4b4fb928ff4d3b74da7c30b360d0cb3ede49a5a6e1fd9705f49aea1deb"},
{file = "msgpack-1.0.6.tar.gz", hash = "sha256:25d3746da40f3c8c59c3b1d001e49fd2aa17904438f980d9a391370366df001e"},
]
[[package]]
name = "packaging"
version = "23.1"
description = "Core utilities for Python packages"
...
...
@@ -534,6 +631,24 @@ files = [
]
[[package]]
name = "redis"
version = "5.0.1"
description = "Python client for Redis database and key-value store"
optional = false
python-versions = ">=3.7"
files = [
{file = "redis-5.0.1-py3-none-any.whl", hash = "sha256:ed4802971884ae19d640775ba3b03aa2e7bd5e8fb8dfaed2decce4d0fc48391f"},
{file = "redis-5.0.1.tar.gz", hash = "sha256:0dab495cd5753069d3bc650a0dde8a8f9edde16fc5691b689a566eda58100d0f"},
]
[package.dependencies]
async-timeout = {version = ">=4.0.2", markers = "python_full_version <= \"3.11.2\""}
[package.extras]
hiredis = ["hiredis (>=1.0.0)"]
ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"]
[[package]]
name = "service-identity"
version = "23.1.0"
description = "Service identity verification for pyOpenSSL & cryptography."
...
...
@@ -757,4 +872,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
content-hash = "
dc39740cb0c5a8a0aaf331b94d4c7f16ae4196fd04e4dc5618b40f68d9b4d6c3
"
content-hash = "
f03bd10694d8d24815526c83734f8fdc4d30f488ad767d3384affc45e716994d
"
pyproject.toml
View file @
0237384b
...
...
@@ -14,6 +14,7 @@ drf-yasg = "^1.21.7"
paho-mqtt
=
"^1.6.1"
protobuf
=
"3.20.1"
daphne
=
"^4.0.0"
channels-redis
=
"^4.1.0"
[build-system]
...
...
vue_django/settings.py
View file @
0237384b
...
...
@@ -32,10 +32,12 @@ ALLOWED_HOSTS = ['*']
INSTALLED_APPS
=
[
'daphne'
,
'chat'
,
#
'chat',
'device_data_op'
,
'protocol_version_manage'
,
'device_communication'
,
'mqtt'
,
'simulate_device_manager'
,
'django.contrib.admin'
,
'django.contrib.auth'
,
...
...
@@ -157,17 +159,19 @@ MQTT_SUBSCRIBE_LIST = [('/1/0/0/6', 2),
(
'/1/1/0/6'
,
2
),
(
'/1/1/1/6'
,
2
)]
DEVICE_CONTAINER_NAME
=
'hydev_111'
# channel 的 websocket 设置
CHANNEL_LAYERS
=
{
'default'
:
{
'BACKEND'
:
'channels.layers.InMemoryChannelLayer'
,
}
#
"default": {
#
"BACKEND": "channels_redis.core.RedisChannelLayer",
#
"CONFIG": {
#
"hosts": [("127.0.0.1", 6379)],
#
},
#
},
#
'default': {
#
'BACKEND': 'channels.layers.InMemoryChannelLayer',
#
}
"default"
:
{
"BACKEND"
:
"channels_redis.core.RedisChannelLayer"
,
"CONFIG"
:
{
"hosts"
:
[(
"127.0.0.1"
,
6379
)],
},
},
}
CORS_ALLOW_CREDENTIALS
=
True
...
...
vue_django/urls.py
View file @
0237384b
...
...
@@ -16,7 +16,7 @@ Including another URLconf
import
os
from
django.contrib
import
admin
from
django.urls
import
path
,
include
,
re_path
from
.views
import
index
,
test
,
upload
,
download
from
.views
import
index
,
test
,
upload
,
download
,
restart_device
from
django.conf
import
settings
from
django.views.static
import
serve
...
...
@@ -35,12 +35,13 @@ schema_view = get_schema_view(
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
"test/upload/"
,
upload
),
path
(
"test/download/"
,
download
),
# path("test/upload/", upload),
# path("test/download/", download),
path
(
"api/restart_device/"
,
restart_device
),
path
(
"api/mqtt/"
,
include
(
"mqtt.urls"
)),
path
(
"chat/"
,
include
(
"chat.urls"
)),
#
path("chat/", include("chat.urls")),
path
(
"api/"
,
include
(
"device_data_op.urls"
)),
path
(
"api/"
,
include
(
"download_db.urls"
)),
#
path("api/", include("download_db.urls")),
path
(
"api/"
,
include
(
"protocol_version_manage.urls"
)),
path
(
"api/"
,
include
(
"device_communication.urls"
)),
path
(
"api/"
,
include
(
"simulate_device_manager.urls"
)),
...
...
vue_django/views.py
View file @
0237384b
import
os
import
urllib.parse
import
subprocess
from
django.conf
import
settings
from
django.http
import
FileResponse
...
...
@@ -10,7 +11,6 @@ from rest_framework.parsers import MultiPartParser
from
rest_framework
import
status
def
index
(
request
):
return
render
(
request
,
'index.html'
)
...
...
@@ -57,3 +57,14 @@ def download(request):
return
response
return
Response
(
status
=
status
.
HTTP_200_OK
)
@api_view
([
'POST'
])
def
restart_device
(
request
):
try
:
subprocess
.
Popen
(
f
'sudo docker restart {settings.DEVICE_CONTAINER_NAME}'
,
shell
=
True
)
except
Exception
as
e
:
print
(
e
)
return
Response
(
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
return
Response
(
status
=
status
.
HTTP_200_OK
)
\ No newline at end of file
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