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
e15a8807
Commit
e15a8807
authored
Sep 26, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.1
parent
e07c2698
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
9 deletions
+14
-9
db.sqlite3
database/db.sqlite3
+0
-0
views.py
device_communication/views.py
+0
-1
docker-compose.yml
docker-compose.yml
+6
-3
dockerfile
dockerfile
+0
-1
mqtt.py
mqtt/mqtt.py
+5
-4
settings.py
vue_django/settings.py
+3
-0
No files found.
database/db.sqlite3
0 → 100644
View file @
e15a8807
File added
device_communication/views.py
View file @
e15a8807
...
...
@@ -75,7 +75,6 @@ def set_communication_to_devinfo_table(request):
communications
=
DeviceCommunicationParameter
.
objects
.
all
()
# 清空设备信息表
# TODO:实际开始用的时候,需要将这个注释打开
TableXproAllDevinfo
.
objects
.
all
()
.
delete
()
TableXproAllDevinfo
.
objects
.
bulk_create
(
...
...
docker-compose.yml
View file @
e15a8807
version
:
'
3'
services
:
device_web
:
image
:
device_web
#
build: .
#
image: device_web
build
:
.
command
:
daphne vue_django.asgi:application --port 8000 --bind 0.0.0.0
network_mode
:
"
host"
volumes
:
-
.:/app
-
./database:/app/database
-
./protocol_raw_files:/app/protocol_raw_files
-
./vue_django/settings.py:/app/vue_django/settings.py
-
./start.sh:/app/start.sh
ports
:
-
"
8000:8000"
nginx
:
...
...
dockerfile
View file @
e15a8807
...
...
@@ -24,4 +24,3 @@ RUN poetry config virtualenvs.create false && poetry install --no-interaction --
EXPOSE
8000
CMD
["daphne", "vue_django.asgi:application", "--port", "8000", "--bind", "0.0.0.0"]
mqtt/mqtt.py
View file @
e15a8807
...
...
@@ -9,10 +9,7 @@ from device_data_op.models import TableXproAllDevinfo
def
on_connect
(
mqtt_client
,
userdata
,
flags
,
rc
):
if
rc
==
0
:
print
(
'Connected successfully'
)
# TODO: 不能一次性订阅这么多,检测哪个站就订阅哪个站,不然往下27行报错
mqtt_client
.
subscribe
([(
'/1/0/0/6'
,
2
),
(
'/1/1/0/6'
,
2
),
(
'/1/1/1/6'
,
2
)])
mqtt_client
.
subscribe
(
settings
.
MQTT_SUBSCRIBE_LIST
)
else
:
print
(
'Bad connection. Code:'
,
rc
)
...
...
@@ -36,6 +33,10 @@ def send_message(data: dict, device_name: str):
send_websocket_message
(
data
)
dev_info
=
TableXproAllDevinfo
.
objects
.
filter
(
dev_name
=
device_name
)
.
first
()
if
dev_info
is
None
:
print
(
'dev_info is None'
)
return
if
"TCP"
in
dev_info
.
comunitate_mode
.
upper
():
name
=
dev_info
.
tcp_port
elif
"UDP"
in
dev_info
.
comunitate_mode
.
upper
():
...
...
vue_django/settings.py
View file @
e15a8807
...
...
@@ -153,6 +153,9 @@ MQTT_PORT = 1883
MQTT_KEEPALIVE
=
60
MQTT_USER
=
""
MQTT_PASSWORD
=
""
MQTT_SUBSCRIBE_LIST
=
[(
'/1/0/0/6'
,
2
),
(
'/1/1/0/6'
,
2
),
(
'/1/1/1/6'
,
2
)]
# channel 的 websocket 设置
CHANNEL_LAYERS
=
{
...
...
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