Commit cfee6b52 authored by liyuanhong's avatar liyuanhong

优化了界面

parent dfa94919
[socket]
host = v.vandyo.cn
port = 9018
host = 10.100.11.20
port = 9001
......@@ -82,9 +82,6 @@ class MessageBase(Base):
retain = 0 #保留位
data = msgBodyLen + encryptionType + subPkg + retain
dataHex = self.int2hexStringByBytes(data,2)
print(encryptionType)
print(subPkg)
print(dataHex)
return dataHex
#获取消息封装项
......
......@@ -29,7 +29,7 @@ class MessageSimulaterService():
self.timeout = 1 #socket的超时时间
self.gpsLine = [] #GPS 轨迹
self.gpsLineIndex = 0 #GPS 轨迹索引
self.travelStatus = 0 #0,表示为行驶,1表示开始行驶
self.travelStatus = 0 #0,表示为行驶,1表示开始行驶同时开启了接收消息服务,2表示值开启了接收消息的服务
self.carId = "" #车机号
self.sn = 0 #消息流水号
self.travelDirection = 0 #行驶方向,0表示正向行驶,1表示反向行驶
......@@ -98,8 +98,15 @@ class MessageSimulaterService():
def fireOn(self):
fireOnParams = {"msgID": "0200", "phoneNum": "13146201119", "msgWaterCode": "1", "encryptionType": "0", "subPkg": "0",
"pkgCounts": "0", "baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.40268, "longtitude": 106.54041,
"elevation": "521", "speed": "66", "directionAngle": "59",
"elevation": "521", "speed": "0", "directionAngle": "59",
"infoTime": "2020-04-21 18:03:49"}, "extraInfo": {"FA": {"ignition": "on"}}}
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
fireOnParams["phoneNum"] = self.data["phoneNum"]
print(self.data["phoneNum"])
fireOnParams["msgWaterCode"] = self.sn
fireOnParams["baseInfo"]["infoTime"] = curTime
msgObj = Location_msg()
msg = msgObj.generateMsg_GUI(fireOnParams)
self.sendMsg(msg)
......@@ -108,14 +115,35 @@ class MessageSimulaterService():
self.websocket.send(info)
self.sn = self.sn + 1
########################################################
#车机行驶服务
########################################################
def serviceTrave(self):
while self.serviceStatus == 1:
gpsMsg = ""
OBDMsg = ""
if self.travelStatus == 0:
latitude = self.gpsLine[self.gpsLineIndex]["lat"]
longitude = self.gpsLine[self.gpsLineIndex]["lng"]
gpsObj = Location_msg()
gpsMsg = self.genGPSMsg(latitude,longitude)
elif self.travelStatus == 1:
pass
########################################################
#车机熄火
########################################################
def fireOff(self):
fireOffParams = {"msgID": "0200", "phoneNum": "13146201119", "msgWaterCode": "1", "encryptionType": "0", "subPkg": "0",
"pkgCounts": "0", "baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.40268, "longtitude": 106.54041,
"elevation": "521", "speed": "66", "directionAngle": "59",
"elevation": "521", "speed": "0", "directionAngle": "59",
"infoTime": "2020-04-21 18:09:34"}, "extraInfo": {"FA": {"flameout": "on"}}}
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
fireOffParams["phoneNum"] = self.data["phoneNum"]
fireOffParams["msgWaterCode"] = self.sn
fireOffParams["baseInfo"]["infoTime"] = curTime
msgObj = Location_msg()
msg = msgObj.generateMsg_GUI(fireOffParams)
self.sendMsg(msg)
......@@ -139,11 +167,15 @@ class MessageSimulaterService():
def serviceRev(self):
self.serviceStatus = 2 #2代表只启动了接收消息的进程,1代表了接收和发送都启动了
while self.serviceStatus != 0:
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
self.socket.setTimeOut(self.timeout)
d = self.revMsg()
d = str(binascii.b2a_hex(d))[2:][:-1]
type = self.getMsgFunId(d)
info = type + "<<<<:" + d
time.sleep(0.5)
self.websocket.send(info)
self.doResponse(d)
......
......@@ -32,7 +32,7 @@ class ProtocolSimulaterService():
self.timeout = 1 #socket的超时时间
self.gpsLine = [] #GPS 轨迹
self.gpsLineIndex = 0 #GPS 轨迹索引
self.travelStatus = 0 #0,表示为行驶,1表示开始行驶
self.travelStatus = 0 #0,表示为行驶,1表示开始行驶同时开启了接收消息服务,2表示值开启了接收消息的服务
self.carId = "" #车机号
self.sn = 0 #消息流水号
self.travelDirection = 0 #行驶方向,0表示正向行驶,1表示反向行驶
......
......@@ -17,7 +17,8 @@
{% block top %}
<div class="top_nav">
<div style="background:#222222;height:50px;">
<a href="http://10.100.11.5/liyuanhong/new-socketemulator"><img style="height: 40px;position: absolute;right: 20px;margin-top: 5px;" src="../../static/img/gitlab.png"></a>
<a href="#" style="color: #eeeeee;font-size:18px;position: absolute;left: 10px;margin-top: 5px;text-decoration:none;"><img style="height:40px;" src="../../static/img/victory.png"><b>测试工具平台</b></a>
<a style="position: absolute;right: 20px;margin-top: 5px;" href="http://10.100.11.5/liyuanhong/new-socketemulator"><img style="height: 40px;" src="../../static/img/gitlab.png"></a>
</div>
<div style="width: 70%;margin: 0 auto">
<ul class="nav nav-tabs" style="font-size:18px;">
......
......@@ -39,7 +39,7 @@
{% block content_1 %}
<div id="container3" style="width:100%;min-height:750px;float:left;_background:green;margin-top:10px;_border-top: 1px solid #eee;">
<div style="width:100%;padding-bottom:10px;border-bottom: 1px solid #eee;">
<label>终端手机号:</label><input id="phoneNum" type="text" class="form-control" value="13146201119" style="width:150px;">
<label>车机号:</label><input id="phoneNum" type="text" class="form-control" value="012201500010" style="width:150px;">
<label>上报间隔:</label><input id="durTime" type="text" class="form-control" value="5" style="width:80px;" />
<label>设置超时时间:</label><input id="timeout" type="text" class="form-control" value="3600" style="width:80px;" />
</div>
......@@ -126,6 +126,10 @@
<button id="searchCarData" type="button" class="btn btn-primary" id="saveSetting">查询</button>
</span>
</div>
<H3 style="border-bottom: 1px solid #eee;">返回信息:</H3>
<div style="width:100%;padding:5px;margin-top:10px;">
<textarea id="searchCardataShow" style="width:100%;padding:5px;" rows="8"></textarea>
</div>
</div>
{% endblock %}
</div>
......@@ -145,6 +149,7 @@ function carLogin(){
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/porcessLogin";
sendHttpMsg(data,url);
$("#curStatus").val("登录");
}
//点火
function fireOn(){
......@@ -152,6 +157,7 @@ function fireOn(){
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/porcessFireOn";
sendHttpMsg(data,url);
$("#curStatus").val("点火");
}
//熄火
function fireOff(){
......@@ -159,6 +165,7 @@ function fireOff(){
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/porcessFireOff";
sendHttpMsg(data,url);
$("#curStatus").val("熄火");
}
//断网
function disConnect(){
......@@ -166,6 +173,7 @@ function disConnect(){
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/porcessDisconnect";
sendHttpMsg(data,url);
$("#curStatus").val("断网");
}
//清空日志
function clearlog(){
......@@ -177,7 +185,7 @@ function sendHttpMsg(data,url){
var data = data;
var url = url;
var host = window.location.host;
console.log(data);
//console.log(data);
$.ajax({
url:url,
......
......@@ -130,7 +130,7 @@ def porcessFireOff():
params = json.loads(params.decode("utf-8"))
data = {}
try:
connects[0]["service"].fireOn()
connects[0]["service"].fireOff()
data["status"] = "200"
data["message"] = "熄火成功!"
except BaseException as e:
......
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