update
This commit is contained in:
parent
67d610ada4
commit
17ae017821
|
@ -1,7 +1,13 @@
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from device import device_name
|
import subprocess
|
||||||
|
|
||||||
|
p = subprocess.Popen(['cat /home/pi/device_name'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
out, err = p.communicate()
|
||||||
|
# 设备名称,必须要有
|
||||||
|
device_name = out.decode('utf-8').strip()
|
||||||
|
|
||||||
|
# 读取配置
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
# 读取公共配置
|
# 读取公共配置
|
||||||
config.read('conf/main/common.conf')
|
config.read('conf/main/common.conf')
|
||||||
|
@ -9,6 +15,7 @@ config.read('conf/main/common.conf')
|
||||||
broker = config.get("broker", "host")
|
broker = config.get("broker", "host")
|
||||||
# 端口,这里必须是int类型
|
# 端口,这里必须是int类型
|
||||||
port = config.getint("broker", "port")
|
port = config.getint("broker", "port")
|
||||||
|
|
||||||
# 读取设备配置
|
# 读取设备配置
|
||||||
config.read('conf/device/device.conf')
|
config.read('conf/device/device.conf')
|
||||||
# 订阅的主题
|
# 订阅的主题
|
||||||
|
|
|
@ -3,7 +3,6 @@ import time
|
||||||
from api import add
|
from api import add
|
||||||
from db.base import Base, engine
|
from db.base import Base, engine
|
||||||
from db.models.lot_data_model import LOT_DATA
|
from db.models.lot_data_model import LOT_DATA
|
||||||
from device import device_name
|
|
||||||
|
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
try:
|
try:
|
||||||
|
@ -22,8 +21,7 @@ try:
|
||||||
'rainfall': -1,
|
'rainfall': -1,
|
||||||
'wind_speed': -1,
|
'wind_speed': -1,
|
||||||
'wind_direction': -1,
|
'wind_direction': -1,
|
||||||
'create_time': int(time.time()),
|
'create_time': int(time.time())
|
||||||
'device_name': 'test'
|
|
||||||
}
|
}
|
||||||
t2 = LOT_DATA(**data)
|
t2 = LOT_DATA(**data)
|
||||||
add(t2)
|
add(t2)
|
||||||
|
|
|
@ -5,7 +5,6 @@ from db.base import Base
|
||||||
|
|
||||||
|
|
||||||
class LOT_DATA(BaseModel):
|
class LOT_DATA(BaseModel):
|
||||||
device_name: str = Field(None, description='设备编号')
|
|
||||||
create_time: int = Field(None, description='创建时间(时间戳) ')
|
create_time: int = Field(None, description='创建时间(时间戳) ')
|
||||||
wind_speed: float = Field(None, description='风速:(0到30)m/s ')
|
wind_speed: float = Field(None, description='风速:(0到30)m/s ')
|
||||||
wind_direction: float = Field(None, description='风向:0~360°')
|
wind_direction: float = Field(None, description='风向:0~360°')
|
||||||
|
@ -30,7 +29,6 @@ class LOT_DATA_MODEL(Base):
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'LOT_DATA_MODEL'
|
__tablename__ = 'LOT_DATA_MODEL'
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True, comment='ID')
|
id = Column(Integer, primary_key=True, autoincrement=True, comment='ID')
|
||||||
device_name = Column(String(50), comment="设备编号")
|
|
||||||
create_time = Column(Integer, comment="创建时间")
|
create_time = Column(Integer, comment="创建时间")
|
||||||
wind_speed = Column(Float, comment='风速:(0到30)m/s ')
|
wind_speed = Column(Float, comment='风速:(0到30)m/s ')
|
||||||
wind_direction = Column(Float, comment='风向:0~360°')
|
wind_direction = Column(Float, comment='风向:0~360°')
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import subprocess
|
|
||||||
|
|
||||||
p = subprocess.Popen(['cat /home/pi/device_name'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
out, err = p.communicate()
|
|
||||||
device_name = out.decode('utf-8').strip()
|
|
|
@ -5,7 +5,6 @@ import serial
|
||||||
|
|
||||||
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
|
||||||
from device import device_name
|
|
||||||
|
|
||||||
|
|
||||||
def local():
|
def local():
|
||||||
|
@ -182,8 +181,7 @@ def local():
|
||||||
'rainfall': rainfall_data,
|
'rainfall': rainfall_data,
|
||||||
'wind_speed': speedwind_data,
|
'wind_speed': speedwind_data,
|
||||||
'wind_direction': winddirection_data,
|
'wind_direction': winddirection_data,
|
||||||
'create_time': int(time.time()),
|
'create_time': int(time.time())
|
||||||
'device_name': device_name
|
|
||||||
}
|
}
|
||||||
t = LOT_DATA(**data)
|
t = LOT_DATA(**data)
|
||||||
add(t)
|
add(t)
|
||||||
|
@ -212,8 +210,7 @@ def test():
|
||||||
'rainfall': 1,
|
'rainfall': 1,
|
||||||
'wind_speed': 1,
|
'wind_speed': 1,
|
||||||
'wind_direction': 1,
|
'wind_direction': 1,
|
||||||
'create_time': int(time.time()),
|
'create_time': int(time.time())
|
||||||
'device_name': device_name
|
|
||||||
}
|
}
|
||||||
t2 = LOT_DATA(**data)
|
t2 = LOT_DATA(**data)
|
||||||
add(t2)
|
add(t2)
|
||||||
|
|
2
tool.py
2
tool.py
|
@ -7,7 +7,7 @@ import requests
|
||||||
|
|
||||||
mp4_path = '/home/pi/mp4'
|
mp4_path = '/home/pi/mp4'
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/home/pi/lot_manager/conf/main/config.conf')
|
config.read('/home/pi/lot_manager/conf/main/common.conf')
|
||||||
|
|
||||||
|
|
||||||
def push_stream(client):
|
def push_stream(client):
|
||||||
|
|
Loading…
Reference in New Issue