Commit 87d867d9 authored by liyuanhong's avatar liyuanhong

优化

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