update
This commit is contained in:
parent
1c441b0d0a
commit
82ff013919
|
@ -1,4 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# 这里千万不要使用set -e
|
# 这里千万不要使用set -e
|
||||||
|
sleep 5
|
||||||
supervisorctl stop sensor_to_local
|
supervisorctl stop sensor_to_local
|
||||||
|
sleep 5
|
||||||
supervisorctl start sensor_to_server
|
supervisorctl start sensor_to_server
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
sleep 5
|
||||||
supervisorctl stop sensor_to_server
|
supervisorctl stop sensor_to_server
|
||||||
|
sleep 5
|
||||||
supervisorctl start sensor_to_local
|
supervisorctl start sensor_to_local
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[device]
|
||||||
|
name=lihai_lot_walnutpi_dev_6
|
|
@ -26,3 +26,8 @@ publish_topic = config.get(device_name, "publish_topic")
|
||||||
username = config.get(device_name, "username")
|
username = config.get(device_name, "username")
|
||||||
# 密码
|
# 密码
|
||||||
password = config.get(device_name, "password")
|
password = config.get(device_name, "password")
|
||||||
|
|
||||||
|
|
||||||
|
# 特殊配置
|
||||||
|
config.read('conf/zhanguan/topic.conf')
|
||||||
|
zhanguan_device_name = config.get("device", "name")
|
||||||
|
|
|
@ -3,6 +3,7 @@ import time
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
|
from config import subscribe_topic, zhanguan_device_name
|
||||||
from db.models.lot_data_model import LOT_DATA
|
from db.models.lot_data_model import LOT_DATA
|
||||||
from api import add
|
from api import add
|
||||||
|
|
||||||
|
@ -45,8 +46,8 @@ def local():
|
||||||
# 二进制转换为16进制:010304010802307b79
|
# 二进制转换为16进制:010304010802307b79
|
||||||
return_data_hex = str(return_data.hex())
|
return_data_hex = str(return_data.hex())
|
||||||
# 对返回的数据进行解析,获取温度和湿度数据
|
# 对返回的数据进行解析,获取温度和湿度数据
|
||||||
airtemp_data = int(return_data_hex[6:10], 16) / 10
|
airhumi_data = int(return_data_hex[6:10], 16) / 10
|
||||||
airhumi_data = int(return_data_hex[10:14], 16) / 10
|
airtemp_data= int(return_data_hex[10:14], 16) / 10
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
ser.write(co2_send)
|
ser.write(co2_send)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -162,7 +163,11 @@ def local():
|
||||||
return_data_hex = str(return_data.hex())
|
return_data_hex = str(return_data.hex())
|
||||||
# print('返回的数据转换为16进制:', return_data_hex)
|
# print('返回的数据转换为16进制:', return_data_hex)
|
||||||
# print("当前风向为:", int(return_data_hex[10:14], 16))#单位mm
|
# print("当前风向为:", int(return_data_hex[10:14], 16))#单位mm
|
||||||
winddirection_data = int(return_data_hex[10:14], 16)
|
# 6号设备是8方位
|
||||||
|
if subscribe_topic == zhanguan_device_name:
|
||||||
|
winddirection_data = int(return_data_hex[10:14], 16)
|
||||||
|
else:
|
||||||
|
winddirection_data = int(return_data_hex[6:10], 16) / 10
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
# print('{"name":"%d","name1":"%d"}', 123,456)
|
# print('{"name":"%d","name1":"%d"}', 123,456)
|
||||||
# data = [{'ngvhgv': airtemp_data}, {'nvjgvjvj':airhumi_data}]
|
# data = [{'ngvhgv': airtemp_data}, {'nvjgvjvj':airhumi_data}]
|
||||||
|
|
|
@ -8,10 +8,11 @@ import paho.mqtt.client as mqtt
|
||||||
from api import add
|
from api import add
|
||||||
from db.models.lot_data_model import LOT_DATA
|
from db.models.lot_data_model import LOT_DATA
|
||||||
|
|
||||||
from config import broker, port, subscribe_topic, publish_topic, username, password
|
from config import broker, port, subscribe_topic, publish_topic, username, password, zhanguan_device_name
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
|
||||||
temp_send = '06 03 01 F4 00 02 85 B2 ' # 温湿度查询指令
|
temp_send = '06 03 01 F4 00 02 85 B2 ' # 温湿度查询指令
|
||||||
co2_send = '06 03 01 F7 00 02 75 B2 ' # 二氧化碳查询指令
|
co2_send = '06 03 01 F7 00 02 75 B2 ' # 二氧化碳查询指令
|
||||||
pressure_send = '06 03 01 F9 00 02 14 71 ' # 气压查询指令
|
pressure_send = '06 03 01 F9 00 02 14 71 ' # 气压查询指令
|
||||||
|
@ -167,7 +168,7 @@ def get_data():
|
||||||
# print('返回的数据转换为16进制:', return_data_hex)
|
# print('返回的数据转换为16进制:', return_data_hex)
|
||||||
# print("当前风向为:", int(return_data_hex[10:14], 16) ) #单位mm
|
# print("当前风向为:", int(return_data_hex[10:14], 16) ) #单位mm
|
||||||
# 6号设备是8方位
|
# 6号设备是8方位
|
||||||
if subscribe_topic == 'lihai_lot_walnutpi_dev_6':
|
if subscribe_topic == zhanguan_device_name:
|
||||||
winddirection_data = int(return_data_hex[10:14], 16)
|
winddirection_data = int(return_data_hex[10:14], 16)
|
||||||
else:
|
else:
|
||||||
winddirection_data = int(return_data_hex[6:10], 16) / 10
|
winddirection_data = int(return_data_hex[6:10], 16) / 10
|
||||||
|
|
Loading…
Reference in New Issue