Commit e15a8807 by 周田

1.1

parent e07c2698
......@@ -75,7 +75,6 @@ def set_communication_to_devinfo_table(request):
communications = DeviceCommunicationParameter.objects.all()
# 清空设备信息表
# TODO:实际开始用的时候,需要将这个注释打开
TableXproAllDevinfo.objects.all().delete()
TableXproAllDevinfo.objects.bulk_create(
......
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:
......
......@@ -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"]
......@@ -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():
......
......@@ -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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment