Commit 87d867d9 authored by liyuanhong's avatar liyuanhong

优化

parent c85a8ca2
......@@ -3,3 +3,4 @@ globalCon:
cameraParam:
host: 10.100.11.125
port: 1078
devCode: 868142043390091
\ No newline at end of file
......@@ -189,12 +189,17 @@ class StreamH264Flv():
# 获取视频播放地址
####################################################
def getPlayUrl(self,mobile,channel):
try:
res = requests.post(self.getGetPlayUrl, data=json.dumps({'devId': mobile,'chan': str(channel)})).text
res = json.loads(res)
url = res["data"]["url"]
# url = self.replaceHost(res["data"]["url"],"video-test.vandyo.com:")
wx.CallAfter(pub.sendMessage, "showLog" + str(self.channel), msg="播放地址:" + url + "\n")
# print("播放地址:" + url)
except:
traceback.print_exc()
curTime = self.getCurTime()
print(curTime + "获取播放地址失败!!!")
####################################################
# 替换url的host
......
......@@ -34,8 +34,7 @@ class ClientWebSocket():
def on_message(self, message):
# print("收到消息:" + message)
curTime = self.getCurTime()
wx.CallAfter(pub.sendMessage, "msgRev", msg=curTime + message)
wx.CallAfter(pub.sendMessage, "msgRev", msg=message)
def on_error(self, error):
print(error)
......
......@@ -13,10 +13,19 @@ class EventAndOtherArea():
def create(self):
self.mainPanel = wx.Panel(self.frame)
boxSizer = wx.BoxSizer(wx.VERTICAL)
gpsPannel= wx.Panel(self.mainPanel)
gpsPannelSizer = wx.BoxSizer(wx.VERTICAL)
gpsPannel.SetBackgroundColour("RED")
aaa = wx.StaticBox(gpsPannel,-1,"gps数据")
gpsPannelSizer.Add(aaa, 1, flag=wx.EXPAND | wx.ALL)
wx.Button(aaa, label="设置设备号", pos=(610, 5))
topPanel = wx.Panel(self.mainPanel)
topPanel.SetBackgroundColour("GREEN")
bottomPanel = wx.Panel(self.mainPanel)
boxSizer.Add(gpsPannel, 1, flag=wx.EXPAND | wx.ALL)
boxSizer.Add(topPanel,1,flag=wx.EXPAND | wx.ALL)
boxSizer.Add(bottomPanel,2, flag=wx.EXPAND | wx.TOP , border=5)
self.mainPanel.SetSizer(boxSizer)
return self.mainPanel
\ No newline at end of file
......@@ -6,6 +6,7 @@ import threading
import time
import wx
import yaml
from pubsub import pub
from lib.socket.ClientWebSocket import ClientWebSocket
......@@ -19,8 +20,9 @@ class HomeArea():
self.devCode = "868142043390091" # 设备id
self.ws = None
self.mainPanel = None
self.heartBeatTime = 60 # 心跳时间
self.heartBeatTime = 30 # 心跳时间
self.isHeartBeat = 1 # 是否开启心跳 0:不开启 1:开启
self.ignt = 1 # 点熄火状态 0:熄火 1:点火
self.wsUrlText = None # webSocket 连接地址文本框
self.devCodeText = None # 设备号文本框
......@@ -29,6 +31,11 @@ class HomeArea():
self.logTextCtr = None # 日志显示框
with open("config/config.yaml", 'r', encoding="utf-8") as fi:
fi_data = fi.read()
data = yaml.load(fi_data,Loader=yaml.FullLoader)
self.devCode = str(data["cameraParam"]["devCode"])
def setWsUrl(self,data):
......@@ -184,6 +191,7 @@ class HomeArea():
skey = m.hexdigest()
msg = {}
msg["data"] = {}
msg["data"]["ignt"] = self.ignt
msg["skey"] = skey
msg["type"] = "9" # 心跳指令上报
msg = json.dumps(msg)
......@@ -216,15 +224,30 @@ class HomeArea():
####################################################
def processRevCmd(self,msg):
self.setLogRedirect()
curTime = self.getCurTime()
self.logTextCtr.WriteText(curTime + "收到消息:" + msg + "\n")
msgJson = json.loads(msg)
msgType = msgJson["type"]
rSkey = msgJson["skey"]
replyMsg = {}
replyMsg["skey"] = rSkey
if msgType == "1":
if msgType == "1": # 请求直播
self.processStream(msgJson, replyMsg)
elif msgType == "3": # 视频抓拍
pass
elif msgType == "4": # 图片抓拍
pass
elif msgType == "5": # 视频回看
pass
elif msgType == "7": # 紧急救援
pass
####################################################
# 处理直播请求
####################################################
def processStream(self,msgJson,replyMsg):
cam = msgJson["data"]["cam"]
if cam == 1:
if globalParams.camera_1.getPushObj() == None :
if globalParams.camera_1.getPushObj() == None:
globalParams.camera_1.doConnect()
globalParams.camera_1.startPush(None)
replyMsg["type"] = "0"
......@@ -275,6 +298,7 @@ class HomeArea():
curTime = self.getCurTime()
self.logTextCtr.WriteText(curTime + "回复消息:" + replyMsg + "\n")
####################################################
# 日志重定向到日志框
####################################################
......
......@@ -68,7 +68,7 @@ class MainWindow():
page5 = eventAndOtherArea.create()
nodeBook.AddPage(page5, "告警与其他功能")
boxSizer.Add(nodeBook, 1, flag=wx.EXPAND | wx.ALL)
nodeBook.SetSelection(1)
nodeBook.SetSelection(0) # 设置当前选中的标签页面
mainPanel.SetSizer(boxSizer)
......
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