Commit 03819733 authored by liyuanhong's avatar liyuanhong

增加了附加属性的js代码

parent f21d3a19
......@@ -12,12 +12,18 @@ templates:存放网页模板文件 html
views:存放网页端操作的后台处理逻辑,以及页面的展示逻辑
run.py:启动项目图形操作界面主程序,访问:127.0.0.1:5000 即可
requirements.txt:设置项目需要的依赖库
### (二)、安装部署
1、机器上安装了python3 和 pip包管理工具
2、进入项目根目录,编辑requirements.txt, 删除第一行wxPython==4.0.7.post2
3、使用 :pip install -r requirement.txt 安装依赖库
4、python3 run.py 运行项目
5、访问 host:5000 即可进入模拟器页面
### ()、文档目录
### ()、文档目录
[1、lib使用库说明](doc/lib_details.md)
[2、如何使用web图形操作界面](https://www.baidu.com/)
### ()、图形界面展示
### ()、图形界面展示
#### m500操作界面:
![alt text](doc/img/m500_1.png "Title Text")
#### 车安优操作界面:
......
......@@ -18,12 +18,12 @@ class SendMultMsgThread():
self.msg = msg
self.timeOut = 30 #socket超时时间
self.BUF_SIZE = 1024 #接收消息缓存
self.threadCount = 10000 #并发线程数
self.threadCount = 1000 #并发线程数
self.totalTime = 0 #所有线程的运行总和
self.threadArr = {} #保存每个线程的信息
self.failThreadCount = 0 #失败线程数
self.durThreads = [] #持续发送线程数组,当数组为空,表示所有线程已经结束
dt = 1 * 20 * 60
dt = 1 * 10 * 60
self.durTime = dt #线程持续时间
self.connectTimeoutNum = 0 #连接超时线程数
self.sendTimeoutNum = 0 #发送超时线程数
......
......@@ -36,11 +36,10 @@ class Location_msg(MessageBase):
return msg
# 生成一条完整的消息,针对图形界面,可传递参数
def generateMsg_GUI(self,msgID="0200",phoneNum="13146201119",msgWaterCode=1,encryptionType=0,subPkg=0, \
):
def generateMsg_GUI(self,params):
msg = ""
msgHeader = self.getMsgHeader_GUI(msgID,phoneNum,msgWaterCode,encryptionType,subPkg)
msgBody = self.getMsgBody_GUI()
msgHeader = self.getMsgHeader_GUI(params["msgID"],int(params["phoneNum"]),int(params["msgWaterCode"]),int(params["encryptionType"]),int(params["subPkg"]))
msgBody = self.getMsgBody_GUI(params)
checkCode = self.getCheckCode(msgHeader + msgBody)
msg = msg + self.IDENTIFY
info = msgHeader + msgBody + checkCode
......@@ -78,10 +77,14 @@ class Location_msg(MessageBase):
return msg
# 获取消息体,针对图形界面,可传递参数
def getMsgBody_GUI(self,baseInfo,extraInfo):
def getMsgBody_GUI(self,params):
msg = ""
locationBaseInfo = self.getLocationBaseInfo_GUI(baseInfo) #位置基本信息
locationExtraInfo = self.getLocationExtraInfo_GUI(extraInfo) #位置附加信息
locationBaseInfo = self.getLocationBaseInfo_GUI(params["baseInfo"]) #位置基本信息
locationExtraInfo = ""
if params["extraInfo"] == {}:
pass
else:
locationExtraInfo = self.getLocationExtraInfo_GUI(params["extraInfo"]) #位置附加信息
msg = locationBaseInfo + locationExtraInfo
return msg
# 获取消息体,数据随机产生
......@@ -112,13 +115,13 @@ class Location_msg(MessageBase):
# 获取位置基本信息,针对图形界面,可传递参数
def getLocationBaseInfo_GUI(self,baseInfo):
msg = ""
alarmFlag = self.int2hexStringByBytes(baseInfo["alarmFlag"],4) #报警标志
status = self.int2hexStringByBytes(baseInfo["status"],4) #状态
latitude = self.getLatitude(baseInfo["latitude"]) #纬度
longtitude = self.getLongtitude(baseInfo["longtitude"]) #经度
elevation = self.getElevation(baseInfo["elevation"]) #海拔高度
speed = self.getSpeed(baseInfo["speed"]) #速度
directionAngle = self.getDirectionAngle(baseInfo["directionAngle"]) #获取方向角度
alarmFlag = self.int2hexStringByBytes(int(baseInfo["alarmFlag"]),4) #报警标志
status = self.int2hexStringByBytes(int(baseInfo["status"]),4) #状态
latitude = self.getLatitude(float(baseInfo["latitude"])) #纬度
longtitude = self.getLongtitude(float(baseInfo["longtitude"])) #经度
elevation = self.getElevation(int(baseInfo["elevation"])) #海拔高度
speed = self.getSpeed(int(baseInfo["speed"])) #速度
directionAngle = self.getDirectionAngle(int(baseInfo["directionAngle"])) #获取方向角度
infoTime = self.getInfoTime(baseInfo["infoTime"]) #获取时间
msg = alarmFlag + status + latitude + longtitude + elevation + speed + directionAngle + infoTime
return msg
......@@ -182,7 +185,7 @@ class Location_msg(MessageBase):
# data = data +extra_FA
return data
def getLocationExtraInfo_GUI(self):
def getLocationExtraInfo_GUI(self,extraInfo):
data = ""
# 里程,DWORD,1 / 10km,对应车上里程表读数;不支持OBD时,为基于GPS车速统计的车辆累计行驶总里程。
extra_01 = "01" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(20202020,4)
......
......@@ -22,14 +22,14 @@ port = 9001
# msg = MessageBase().generateMsg()
# msg = TerminalCommonMsgRes_msg().generateMsg() #终端通用应答
msg = TerminalHeartbeat_msg().generateMsg() #终端心跳
# msg = TerminalHeartbeat_msg().generateMsg() #终端心跳
# msg = TerminalRegister_msg().generateMsg() #终端注册
# msg = TerminalCancle_msg().generateMsg() #终端注销
# msg = TerminalAuthenticate_msg().generateMsg() #终端鉴权
# msg = TerminalVersionInfo_msg().generateMsg() #终端版本信息上报
# msg = QueryTerminalParam_res().generateMsg() #查询终端参数应答
# msg = QueryTerminalProperty_res().generateMsg() #查询终端属性应答消息
# msg = Location_msg().generateMsg() #位置信息汇报
msg = Location_msg().generateMsg() #位置信息汇报
# msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息
# msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知
# msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传
......
#coding:utf-8
'''
处理json辅助类
'''
#####################################################
# 判断json中是否有值为空的项
#####################################################
def hasJsonDataIsNone(data):
for key,value in data.items():
if value == None or value == "":
return True
return False
if __name__ == "__main__":
data = {"a":1,"b":"bb","c":"s","d":123}
print(hasJsonDataIsNone(data))
\ No newline at end of file
......@@ -25,7 +25,7 @@ app.register_blueprint(message_process,url_prefix = "/messageTools/message_proce
@app.route('/')
def hello():
return redirect('/tab1/style')
return redirect('/messageTools/message_view/heartBeat_msg_page')
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0')
\ No newline at end of file
......@@ -4,6 +4,7 @@ from flask import Blueprint ,Response,request
from configparser import ConfigParser
from lib.protocol.message.DataUpstreamTransport_msg import DataUpstreamTransport_msg
from lib.protocol.message.Location_msg import Location_msg
from lib.protocol.message.TerminalHeartbeat_msg import TerminalHeartbeat_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg
......@@ -16,6 +17,8 @@ import json
import traceback
import binascii
from lib.util.jsonUtil import hasJsonDataIsNone
message_process = Blueprint('message_process', __name__)
##########################################
......@@ -458,3 +461,60 @@ def porcessDataUpstreamTransportMsg_F4():
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】地理位置上报消息
##########################################
@message_process.route("/porcessLocationMsg",methods=['POST'])
def porcessLocationMsg():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
# msgID = params["msgID"]
# phoneNum = params["phoneNum"]
# msgWaterCode = params["msgWaterCode"]
# encryptionType = params["encryptionType"]
# subPkg = params["subPkg"]
# pkgCounts = params["pkgCounts"]
# ########### 地理位置基础信息 #############
# baseInfo = params["baseInfo"]
# alarmFlag = baseInfo["alarmFlag"]
# status = baseInfo["status"]
# latitude = baseInfo["latitude"]
# longtitude = baseInfo["longtitude"]
# elevation = baseInfo["elevation"]
# speed = baseInfo["speed"]
# directionAngle = baseInfo["directionAngle"]
# infoTime = baseInfo["infoTime"]
# ########### 地理位置附加信息 #############
# extraInfo = params["extraInfo"]
data = {}
if (hasJsonDataIsNone(params)):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
conf_R = ConfigParser()
conf_R.read("config/messageTools/messageTools.conf")
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
obj = Location_msg()
msg = obj.generateMsg_GUI(params)
cliSocket.send(msg)
socRecv_1 = cliSocket.receive()
socRecv_2 = str(socRecv_1)
cliSocket.close()
data["status"] = "200"
data["message"] = "Sucess: "
data["original"] = msg
data["result"] = socRecv_2
msgP = PlatformCommon_res(socRecv_1)
data["resultH"] = msgP.getOriginalMsg()
data["parse"] = json.loads(msgP.getMsg())
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
\ No newline at end of file
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