Commit c6cea661 authored by liyuanhong's avatar liyuanhong

添加了M300模拟程序的导航

parent 2776862b
[socket]
host = 10.100.12.32
port = 9009
{"time": {"dateTime": "2020-05-19 11:09:47", "date": "2020-05-19", "time": "11:09:47"}, "curDayTravel": {"todayTotalMilleage": 40924, "todayTotalOil": 3769, "todayTotalTime": 2477, "theMilleage": 1452, "theOil": 132, "theTime": 88}, "travelData": {"totalMilleage": 324661, "totalOil": 30616, "totalTime": 19259}, "event": {"threeRapid": {"totalRapidlyAccelerate": 14, "totalSharpSlowdown": 13, "totalSharpTurn": 13}}}
\ No newline at end of file
{"time": {"dateTime": "2020-05-20 16:26:10", "date": "2020-05-20", "time": "16:26:10"}, "curDayTravel": {"todayTotalMilleage": 3845, "todayTotalOil": 350, "todayTotalTime": 233, "theMilleage": 3845, "theOil": 350, "theTime": 233}, "travelData": {"totalMilleage": 328506, "totalOil": 30966, "totalTime": 19492}, "event": {"threeRapid": {"totalRapidlyAccelerate": 14, "totalSharpSlowdown": 13, "totalSharpTurn": 13}}}
\ No newline at end of file
#encoding:utf-8
from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from lib.protocol.m300.M300Base import M300Base
from lib.protocol.m300.OBDCAN_protocol_m300 import OBDCAN_protocol_m300
'''
定义报警协议类
......@@ -9,6 +10,7 @@ from lib.protocol.m300.M300Base import M300Base
class Alarm_protocol_m300(M300Base):
def __init__(self,waterCode = 3,DEV_ID = "M121501010001",encryptionType=0,alarmType="0001",data = {}):
super().__init__() # 不执行该方法,无法使用父类里面定义的属性
self.data = data
self.waterCode = waterCode #消息流水号
self.DEV_ID = DEV_ID #设备Id
self.encryptionType = encryptionType # 消息属性里面的是否加密字段
......@@ -19,8 +21,18 @@ class Alarm_protocol_m300(M300Base):
self.GSMPkg = "0000000000"
self.CANStatus = "ffffffffffffffffffff00000000000000000000"
else:
pass
GPSData = data["GPSData"]
GSMData = data["GSMData"]
OBDData = data["OBDCANData"]
self.alarm = data["alarm"]
self.GPSPkg = GPS_protocol_m300(dateInfo=GPSData["dateInfo"],latitude=float(GPSData["latitude"]),longitude=float(GPSData["longitude"]) \
,positionStar=int(GPSData["positionStar"]),speed=float(GPSData["speed"]),direction=float(GPSData["direction"]), \
altitude=float(GPSData["altitude"]),ACCStatus=int(GPSData["ACCStatus"]),valtage=float(GPSData["valtage"]),OBDSpeed=float(GPSData["OBDSpeed"]), \
valid=int(GPSData["valid"]) ,tripMark=int(GPSData["tripMark"])).getMsgBody()
self.GSMPkg = self.getGSMPkg(operatorType=int(GSMData["operatorType"]),LAC=GSMData["LAC"],CellId=GSMData["CellId"])
self.CANStatus = OBDCAN_protocol_m300(statusMask=OBDData["statusMask"],safeStatus=int(OBDData["safeStatus"]),doorStatus=int(OBDData["doorStatus"]), \
lockStatus=int(OBDData["lockStatus"]),windowStatus=int(OBDData["windowStatus"]),lightStatus=int(OBDData["lightStatus"]), \
swichStatusA=int(OBDData["swichStatusA"]),swichStatusB=int(OBDData["swichStatusB"])).getMsgBody()[14:48] + "000000"
#################################################
# 生成消息
......@@ -30,7 +42,10 @@ class Alarm_protocol_m300(M300Base):
FUNID = "0021" #功能id
waterCode = self.int2hexStringByBytes(self.waterCode,2) #消息流水号
DEV_ID = self.devid2hexString(self.DEV_ID) #设备id
msgBody = self.getMsgBody() # 消息体
if len(self.data) == 0:
msgBody = self.getMsgBody() # 消息体
else:
msgBody = self.getMsgBody_GUI() # 消息体
msgLen = int(len(msgBody) / 2)
property = self.getMsgProperty(msgBodyLen=msgLen,encryptionType=self.encryptionType)
checkCode = self.getCheckCode(FUNID + waterCode + DEV_ID + property + msgBody)
......@@ -53,6 +68,33 @@ class Alarm_protocol_m300(M300Base):
alarmContent = "0002" + self.int2hexStringByBytes(int(len(extra)/2)) + extra
return GPSPkg + GSMPkg + CANStatus + alarmContent
def getMsgBody_GUI(self):
GPSPkg = self.GPSPkg
GSMPkg = self.GSMPkg
CANStatus = self.CANStatus
alarmContent = ""
if (list(self.alarm.keys())[0] == "0001"): #汽车点火上报
extra = ""
alarmContent = "0001" + self.int2hexStringByBytes(int(len(extra)/2)) + extra
elif (list(self.alarm.keys())[0] == "0002"): #汽车熄火上报
extra = ""
alarmContent = "0002" + self.int2hexStringByBytes(int(len(extra)/2)) + extra
return GPSPkg + GSMPkg + CANStatus + alarmContent
#################################################
# 获取GSM信息
##############################################
def getGSMPkg(self,operatorType=1,LAC="1234",CellId="5678"):
#运营商类别 1-移动 2-联通 3-电信
operatorType = self.int2hexStringByBytes(operatorType)
# u16 服务器 LAC + CellID,比如 1234 5678
# LAC和CellID各占两个字节
LAC = self.int2hexStringByBytes(int(LAC),2)
CellId = self.int2hexStringByBytes(int(CellId),2)
data = operatorType + LAC + CellId
return data
if __name__ == "__main__":
print(Alarm_protocol_m300().generateMsg())
......
......@@ -8,7 +8,7 @@ from lib.protocol.m300.M300Base import M300Base
class VersionInfo_protocol_m300(M300Base):
def __init__(self,waterCode = 3,DEV_ID = "M121501010001",encryptionType=0,SWVersion="VSTA000GV100",SWDate="2020-03-30",HWVersion="M1.0" \
,GSMType="GSM_type_123456",carType="150D",engineCode=1,VINCode="VIN_CODE_01234567890"):
,GSMType="GSM_type_123456",carType="150",engineCode=1,VINCode="VIN_CODE_01234567890"):
super().__init__() # 不执行该方法,无法使用父类里面定义的属性
self.waterCode = waterCode #消息流水号
self.DEV_ID = DEV_ID #设备Id
......@@ -18,7 +18,7 @@ class VersionInfo_protocol_m300(M300Base):
self.SWDate = SWDate #软件日期
self.HWVersion = HWVersion #硬件版本
self.GSMType = GSMType #GSM 型号
self.carType = carType #车系车型ID: 150D
self.carType = int(carType) #车系车型ID: 150D
self.engineCode = engineCode #发动机编码类别
self.VINCode = VINCode #汽车VIN码 或 发动机ECU编码
......@@ -47,7 +47,7 @@ class VersionInfo_protocol_m300(M300Base):
SWDate = self.str2Hex(self.SWDate)
HWVersion = self.str2Hex(self.HWVersion)
GSMType = self.str2Hex(self.GSMType)
carType = self.str2Hex(self.carType)
carType = self.int2hexStringByBytes(self.carType,2)
engineCode = self.int2hexStringByBytes(self.engineCode)
VINCode = self.str2Hex(self.VINCode)
data = SWVersion + SWDate + HWVersion + GSMType + carType + engineCode + VINCode
......
......@@ -12,8 +12,8 @@ class GPRS_protocol_response_m300(M300Base):
"username":"yuanhong","password":"123456"},{"serverIndex":"3","serverAddressType":0,"serverAddress":"10.100.12.31","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"}]
def __init__(self,waterCode = 3,DEV_ID = "M121501010001",encryptionType=0,data=[{"serverIndex":"1","serverAddressType":0,"serverAddress":"10.100.12.31","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"},{"serverIndex":"2","serverAddressType":0,"serverAddress":"10.100.12.31","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"},{"serverIndex":"3","serverAddressType":0,"serverAddress":"10.100.12.31","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"},{"serverIndex":"2","serverAddressType":0,"serverAddress":"10.100.12.32","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"},{"serverIndex":"3","serverAddressType":0,"serverAddress":"10.100.12.33","comPort":"9008","comType":0,"APN":"tnet", \
"username":"yuanhong","password":"123456"}]):
super().__init__() # 不执行该方法,无法使用父类里面定义的属性
self.waterCode = waterCode #消息流水号
......@@ -42,6 +42,8 @@ class GPRS_protocol_response_m300(M300Base):
#################################################
def getMsgBody(self):
dataHex = ""
lenHex = self.int2hexStringByBytes(len(self.data))
dataHex = dataHex + lenHex
for i in range(0,len(self.data)):
dataHex = dataHex + self.str2Hex(self.data[i]["serverIndex"]) #服务器索引号,从1开始
dataHex = dataHex + "2c" #逗号
......
......@@ -2,6 +2,7 @@
import binascii
import socket
from lib.protocol.m300.Alarm_protocol_m300 import Alarm_protocol_m300
from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from lib.protocol.m300.Heartbeat_protocol_300 import Heartbeat_protocol_300
from lib.protocol.m300.OBDCAN_protocol_m300 import OBDCAN_protocol_m300
......@@ -32,7 +33,8 @@ port = 9009
# msg = GPS_protocol_m300().generateMsg() #GPS报文
# msg = VersionInfo_protocol_m300().generateMsg() #终端版本报文
# msg = "7e000400e14d2019120315000000957e" #终端上报心跳协议
msg = OBDCAN_protocol_m300().generateMsg() #OBD CAN报文
# msg = OBDCAN_protocol_m300().generateMsg() #OBD CAN报文
msg = Alarm_protocol_m300().generateMsg() #OBD CAN报文
print(msg)
......
#coding:utf-8
'''
M300车机模拟服务类
'''
import binascii
import json
import math
import os
import threading
import time
import traceback
from time import sleep
from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from lib.protocol.m300.OBDCAN_protocol_m300 import OBDCAN_protocol_m300
from lib.protocol.message.Location_msg import Location_msg
from lib.protocol.message.TerminalCommonMsgRes_msg import TerminalCommonMsgRes_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg
from lib.socket.service.MessageSimulaterDataService import MessageSimulaterDataService
from lib.socket.service.websocket_service import Websocket_service
class M300SimulaterService():
def __init__(self):
self.data = {} #用来接收模拟器传过来的参数
self.carData = {} #保存车辆行驶数据
self.carDataObj = None #管理车辆行驶数据对象
self.socket = None
self.sendDur = 5 #设置默认多久发一条消息
self.serviceStatus = 0 #服务状态,0表示未启动,1表示启动
self.websocket = None #网页与服务的通信socket
self.websocketId = "" #当前连接的webSocketId
self.timeout = 1 #socket的超时时间
self.gpsLine = [] #GPS 轨迹
self.gpsLineIndex = 0 #GPS 轨迹索引
self.travelStatus = 0 #0,表示未行驶,1表示开始行驶同时开启了接收消息服务,2表示值开启了接收消息的服务
self.carId = "" #车机号
self.sn = 0 #消息流水号
self.travelDirection = 0 #行驶方向,0表示正向行驶,1表示反向行驶
self.directAngle = 60 #汽车方向角
'''
为0表示正常发送,type为1表示数据写入本地
# 用来控制发送消息的方式(是正常发送,还是将发送的数据保存到本地,不发送)
'''
self.sendType = 0
# 定义要发送的obd数据
self.OBDdata = {"fireStatus":1,"ACCStatus":0,"engineSpeed":300,"speed":0,"meterMileage":6000,"totailMileage":600,"totalOilExpen":30,"totalRunTime":10}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
self.OBDdataOri = {"fireStatus": 1, "ACCStatus": 0, "engineSpeed": 300, "speed": 0, "meterMileage": 6000,"totailMileage": 600, "totalOilExpen": 30, "totalRunTime": 10}
#设置套接字
def setSocket(self,data):
self.socket = data
def setSendDur(self,data):
self.sendDur = data
def setTimeout(self,data):
self.timeout = data
def setCarId(self,data):
self.carId = data
def setData(self,data):
self.data = data
def setWebsocketId(self):
sleep(0.1)
self.websocketId = self.websocket.getCurrentClientId()
def setWebsocket(self,data):
self.websocket = data
def setSn(self,data):
self.sn = data
def setCarData(self,data):
self.carData = data
def setServiceStatus(self,data):
self.serviceStatus = data
def setCarSpeed(self,data):
self.data["travelData"]["carSpeed"] = data
def setOilExpend(self,data):
self.data["travelData"]["oilExpend"] = data
def setSendDur(self,data):
self.sendDur = int(data)
def setSendType(self,data):
self.sendType = data
def getWebsocket(self):
return self.websocket
def getGpsLineIndex(self):
return self.gpsLineIndex
def getGpsLine(self):
return self.gpsLine
def getTravelStatus(self):
return self.travelStatus
def getSn(self):
return self.sn
def getCarData(self):
return self.carData
#######################################################
# type 为0表示正常发送,type为1表示数据写入本地
#######################################################
def sendMsg(self,msg):
if self.sendType == 0:
self.socket.setTimeOut(self.timeout)
self.socket.send(msg)
elif self.sendType == 1:
msgId = self.getMsgFunId(msg)
if msgId == "0021":
self.saveMsgLocal("event.txt",msg)
elif msgId == "0010":
self.saveMsgLocal("gps.txt",msg)
elif msgId == "0012":
self.saveMsgLocal("obd.txt",msg)
def revMsg(self):
self.socket.setTimeOut(self.timeout)
return self.socket.receive()
#发送消息,可指定消息的描述类型
def serviceSendMsg(self,msg,type): #type字段目前废掉没有实际意
self.sendMsg(msg)
type = self.getMsgFunId(msg)
self.websocket.sendMsgToClient(">>>>" + type + ":" + msg,self.websocketId)
def serviceSend(self):
while self.serviceStatus == 1:
gpsMsg = ""
OBDMsg = ""
if self.travelStatus == 0: #行驶服务未启动
latitude = self.gpsLine[self.gpsLineIndex]["lat"]
longitude = self.gpsLine[self.gpsLineIndex]["lng"]
gpsMsg = self.genGPSMsg(latitude,longitude)
elif self.travelStatus == 1: #行驶服务启动
if self.gpsLineIndex < len(self.gpsLine) and self.gpsLineIndex != -1: #如果正向行驶和反向行驶的轨迹点都没有跑完
OBDMsg = self.genOBDMsg(self.OBDdata["fireStatus"],self.OBDdata["ACCStatus"],self.OBDdata["engineSpeed"], \
self.OBDdata["speed"],self.OBDdata["meterMileage"],self.OBDdata["totailMileage"], \
self.OBDdata["totalOilExpen"],self.OBDdata["totalRunTime"])
self.OBDdata["engineSpeed"] = 3000
self.OBDdata["speed"] = int(self.data["travelData"]["carSpeed"])
self.OBDdata["meterMileage"] = self.OBDdata["meterMileage"] + int(self.sendDur * (self.OBDdata["speed"] * 1000 / 3600))
self.OBDdata["totailMileage"] = self.OBDdata["totailMileage"] + int(self.sendDur * (self.OBDdata["speed"] * 1000 / 3600))
oilExpend = int(self.data["travelData"]["oilExpend"])
self.OBDdata["totalOilExpen"] = self.OBDdata["totalOilExpen"] + int((self.sendDur * (self.OBDdata["speed"] * 1000 / 3600)) * (1000 / (oilExpend *1000)))
self.OBDdata["totalRunTime"] = self.OBDdata["totalRunTime"] + self.sendDur
latitude = self.gpsLine[self.gpsLineIndex]["lat"]
longitude = self.gpsLine[self.gpsLineIndex]["lng"]
# print("经度:" + str(longitude) + " 维度:" + str(latitude))
gpsMsg = self.genGPSMsg(latitude, longitude)
if self.travelDirection == 0:
self.gpsLineIndex = self.gpsLineIndex + 1 #正向行驶
else:
self.gpsLineIndex = self.gpsLineIndex - 1 #反向行驶
elif self.gpsLineIndex == len(self.gpsLine) or self.gpsLineIndex == -1: #如果反向行驶和反向行驶刚好跑完
if int(self.data["travelData"]["travelLoop"]) == 0: #没有设置循环行驶
self.gpsLineIndex = self.gpsLineIndex - 1
self.stopTravel()
self.websocket.sendMsgToClient("gps轨迹跑完,自动停止行驶!",self.websocketId)
else: #设置了循环行驶
if self.travelDirection == 0:
self.gpsLineIndex = self.gpsLineIndex - 1
self.travelDirection = 1
self.websocket.sendMsgToClient("gps轨迹正向行驶跑完,变换行驶方向......",self.websocketId)
else:
self.gpsLineIndex = self.gpsLineIndex + 1
self.travelDirection = 0
self.websocket.sendMsgToClient("gps轨迹反向行驶跑完,变换行驶方向......",self.websocketId)
OBDMsg = self.genOBDMsg(self.OBDdata["fireStatus"], self.OBDdata["ACCStatus"],self.OBDdata["engineSpeed"], \
self.OBDdata["speed"], self.OBDdata["meterMileage"],self.OBDdata["totailMileage"], \
self.OBDdata["totalOilExpen"], self.OBDdata["totalRunTime"])
self.OBDdata["engineSpeed"] = 3000
self.OBDdata["speed"] = int(self.data["travelData"]["carSpeed"])
self.OBDdata["meterMileage"] = self.OBDdata["meterMileage"] + int(self.sendDur * (self.OBDdata["speed"] * 1000 / 3600))
self.OBDdata["totailMileage"] = self.OBDdata["totailMileage"] + int(self.sendDur * (self.OBDdata["speed"] * 1000 / 3600))
oilExpend = int(self.data["travelData"]["oilExpend"])
self.OBDdata["totalOilExpen"] = self.OBDdata["totalOilExpen"] + int((self.sendDur * (self.OBDdata["speed"] * 1000 / 3600)) * (1000 / (oilExpend * 1000)))
self.OBDdata["totalRunTime"] = self.OBDdata["totalRunTime"] + self.sendDur
latitude = self.gpsLine[self.gpsLineIndex]["lat"]
longitude = self.gpsLine[self.gpsLineIndex]["lng"]
gpsMsg = self.genGPSMsg(latitude, longitude)
self.carDataObj.setTodayTotalMilleage(self.carData["curDayTravel"]["todayTotalMilleage"] + self.OBDdata["totailMileage"] - self.OBDdataOri["totailMileage"])
self.carDataObj.setTheMilleage(self.carData["curDayTravel"]["theMilleage"] + self.OBDdata["totailMileage"] -self.OBDdataOri["totailMileage"])
self.carDataObj.setTotalMilleage(self.carData["travelData"]["totalMilleage"] + self.OBDdata["totailMileage"] - self.OBDdataOri["totailMileage"])
temp = self.OBDdata["totailMileage"]
self.OBDdataOri["totailMileage"] = temp
self.carDataObj.setTodayTodayTotalOil(self.carData["curDayTravel"]["todayTotalOil"] + self.OBDdata["totalOilExpen"] - self.OBDdataOri["totalOilExpen"])
self.carDataObj.setTheOil(self.carData["curDayTravel"]["theOil"] + self.OBDdata["totalOilExpen"] - self.OBDdataOri["totalOilExpen"])
self.carDataObj.setTotalOil(self.carData["travelData"]["totalOil"] + self.OBDdata["totalOilExpen"] - self.OBDdataOri["totalOilExpen"])
self.OBDdataOri["totalOilExpen"] = self.OBDdata["totalOilExpen"]
self.carDataObj.setTodayTodayTotalTime(self.carData["curDayTravel"]["todayTotalTime"] + self.OBDdata["totalRunTime"] - self.OBDdataOri["totalRunTime"])
self.carDataObj.setTheTime(self.carData["curDayTravel"]["theTime"] + self.OBDdata["totalRunTime"] - self.OBDdataOri["totalRunTime"])
self.carDataObj.setTotalTime(self.carData["travelData"]["totalTime"] + self.OBDdata["totalRunTime"] - self.OBDdataOri["totalRunTime"])
self.OBDdataOri["totalRunTime"] = self.OBDdata["totalRunTime"]
if OBDMsg != "":
self.sendMsg(OBDMsg)
self.sn = self.sn + 1
type = self.getMsgFunId(OBDMsg)
info = type + ">>>>:" + OBDMsg
self.websocket.sendMsgToClient(info,self.websocketId)
if gpsMsg != "":
sleep(0.1)
self.sendMsg(gpsMsg)
self.sn = self.sn + 1
type = self.getMsgFunId(gpsMsg)
info = type + ">>>>:" + gpsMsg
self.websocket.sendMsgToClient(info,self.websocketId)
sleep(self.sendDur)
def serviceRev(self):
self.serviceStatus = 2 #2代表只启动了接收消息的进程,1代表了接收和发送都启动了
while self.serviceStatus != 0:
self.socket.setTimeOut(self.timeout)
d = self.revMsg()
d = str(binascii.b2a_hex(d))[2:][:-1]
type = self.getMsgFunId(d)
info = type + "<<<<:" + d
self.websocket.sendMsgToClient(info,self.websocketId)
self.doResponse(d)
#启动与页面交互的websockt服务
def websocketService(self):
self.websocket = Websocket_service()
self.websocket.setHost("0.0.0.0")
self.websocket.setPort(5005)
self.websocket.startWebsocketServer()
#启动定时发送消息和接收消息的服务
def startService(self):
self.serviceStatus = 1
t1 = threading.Thread(target=self.serviceSend,args=())
t1.start()
#启动与页面交互的websocket服务
def startWebsocketService(self):
if self.websocket == None:
t = threading.Thread(target=self.websocketService, args=())
t.start()
t2 = threading.Thread(target=self.serviceRev, args=())
t2.start()
t3 = threading.Thread(target=self.setWebsocketId, args=())
t3.start()
# 为websocket服务添加一个新的客户端连接
def addNewWebsocket(self):
t2 = threading.Thread(target=self.serviceRev, args=())
t2.start()
t3 = threading.Thread(target=self.setWebsocketId, args=())
t3.start()
#停止定时发送消息的服务
def stopService(self):
self.serviceStatus = 0
self.gpsLine = []
self.gpsLineIndex = 0
self.travelStatus = 0
def closeSocket(self):
try:
self.socket.close()
except BaseException as e:
# 打印异常信息
traceback.print_exc()
#停止websocket服务
def stopWebsocketService(self):
try:
self.websocket.close()
self.websocket = None
except BaseException as e:
# 打印异常信息
traceback.print_exc()
########################################################
# 开始行驶
########################################################
def startTravel(self):
self.travelStatus = 1
########################################################
# 停止行驶
########################################################
def stopTravel(self):
self.travelStatus = 0
self.serviceStatus = 0
#获取收到消息的功能id
def getMsgFunId(self,msg):
funId = msg[26:30]
return funId
#收到 某些类型的消息后执行回复操作
def doResponse(self,msg):
msgFunId = self.getMsgFunId(msg)
if msgFunId == "8205":
msg = Common_response(resId="8205").generateCommonMsg()
self.sendMsg(msg)
self.sn = self.sn + 1
type = self.getMsgFunId(msg)
self.websocket.sendMsgToClient(type + ">>>>设置GPSR通信参数应答:" + msg,self.websocketId)
elif msgFunId == "8206":
msg = Common_response(resId="8206").generateCommonMsg()
self.sendMsg(msg)
self.sn = self.sn + 1
type = self.getMsgFunId(msg)
self.websocket.sendMsgToClient(type + ">>>>设置车辆OBD适配信息应答:" + msg,self.websocketId)
elif msgFunId == "8300":
msg = Update_response().generateUpdateMsg()
self.sendMsg(msg)
self.sn = self.sn + 1
type = self.getMsgFunId(msg)
self.websocket.sendMsgToClient(type + ">>>>升级_平台通知终端远程升级应答:" + msg,self.websocketId)
#设置GPS轨迹
def setGpsLine(self,fileName):
with open("data/protocolTools/GPSLines/" + fileName,"r",encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
self.gpsLine = conJson["GPSLine"]
#点火,发送点火事件
def fireOn(self):
if not os.path.exists("data/protocolTools/carData/" + self.carId + ".json"):
psdsObj = ProtocolSimulaterDataService()
data = psdsObj.genDataTemplate()
psdsObj.writeToFile("data/protocolTools/carData/" + self.carId + ".json",data)
#读取车机行驶数据
with open("data/protocolTools/carData/" + self.carId + ".json", "r", encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
conJson["curDayTravel"]["theMilleage"] = 0 # 本次行驶总里程
conJson["curDayTravel"]["theOil"] = 0 # 本次行驶总油耗
conJson["curDayTravel"]["theTime"] = 0 # 本次行驶总时间
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
dateTimeM = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
dateM = time.strftime("%Y-%m-%d", timeArray)
timeM = time.strftime("%H:%M:%S", timeArray)
dataFile = self.carId + ".json"
self.carDataObj = ProtocolSimulaterDataService("data/protocolTools/carData/", dataFile)
self.carDataObj.setData(conJson)
if dateM == conJson["time"]["date"]:
self.OBDdata["totailMileage"] = conJson["travelData"]["totalMilleage"]
self.OBDdataOri["totailMileage"] = conJson["travelData"]["totalMilleage"]
self.OBDdata["totalOilExpen"] = conJson["travelData"]["totalOil"]
self.OBDdataOri["totalOilExpen"] = conJson["travelData"]["totalOil"]
self.OBDdata["totalRunTime"] = conJson["travelData"]["totalTime"]
self.OBDdataOri["totalRunTime"] = conJson["travelData"]["totalTime"]
else: #如果不是当天日期,则将日期设置为当天,并写入车辆数据文件
conJson["curDayTravel"]["todayTotalMilleage"] = 0 # 今日行驶总里程
conJson["curDayTravel"]["todayTotalOil"] = 0 # 今日行驶总油耗
conJson["curDayTravel"]["todayTotalTime"] = 0 # 今日行驶总时间
self.carDataObj.setTodayTotalMilleage(0)
self.carDataObj.setTodayTodayTotalOil(0)
self.carDataObj.setTodayTodayTotalTime(0)
self.carDataObj.setDateTime2file(dateTimeM)
self.carDataObj.setDate2file(dateM)
self.carDataObj.setTime2file(timeM)
self.OBDdata["totailMileage"] = conJson["travelData"]["totalMilleage"]
self.OBDdataOri["totailMileage"] = conJson["travelData"]["totalMilleage"]
self.OBDdata["totalOilExpen"] = conJson["travelData"]["totalOil"]
self.OBDdataOri["totalOilExpen"] = conJson["travelData"]["totalOil"]
self.OBDdata["totalRunTime"] = conJson["travelData"]["totalTime"]
self.OBDdataOri["totalRunTime"] = conJson["travelData"]["totalTime"]
self.carData = self.carDataObj.fixDataTemplate(conJson)
# fireOnEventObj = EventReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn)
# gpsData = self.genGPSData(self.gpsLine[0]["lat"], self.gpsLine[0]["lng"])
# fireOnEventObj.setGPSPkg(gpsData)
# fireOnEventObj.setEventType("0010")
# firOnEventMsg = fireOnEventObj.generateEventMsg()
# type = self.getMsgFunId(firOnEventMsg)
# self.sendMsg(firOnEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + firOnEventMsg,self.websocketId)
jdata = {"WATER_CODE": "0003", "DEV_ID": "M121501010001",
"gpsInfo": {"UTCTime": "2020-04-30 14:59:33", "latitude": "40.22077", "longitude": "116.23128",
"speed": "80.8", "directionAngle": "80.8", "elevation": "2999.9", "positionStar": "3",
"Pdop": "0.3", "Hdop": "0.4", "Vdop": "0.5", "statusBit": 162, "valtage": "36.9",
"OBDSpeed": "60.9", "engineSpeed": "3000", "GPSTotalMileage": "12800",
"totalOil": "100000",
"totalTime": "2020002", "GPSTimestamp": "1588229973"},
"securityData": {"securityStatus": 107, "doorStatus": 0, "lockStatus": 0, "windowStatus": 0,
"lightStatus": 0, "onoffStatusA": 0, "onoffStatusB": 112, "dataByte": 249}, "event": {
"0010": {"allRapidlyAccelerateCount": "5", "allSharpSlowdownCount": "6", "allSharpTurn": "4",
"dataProperty": "1"}}}
jdata["event"]["0010"]["allRapidlyAccelerateCount"] = self.carData["event"]["threeRapid"]["totalRapidlyAccelerate"]
jdata["event"]["0010"]["allSharpSlowdownCount"] = self.carData["event"]["threeRapid"]["totalSharpSlowdown"]
jdata["event"]["0010"]["allSharpTurn"] = self.carData["event"]["threeRapid"]["totalSharpTurn"]
jdata["DEV_ID"] = self.carId
obj = EventReport_protocol(data=jdata)
gpsData = self.genGPSData2()
obj.setGPSPkg(gpsData)
obj.setEventType("0010")
msg = obj.generateEventMsg()
type = self.getMsgFunId(msg)
self.sendMsg(msg)
self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + msg, self.websocketId)
sleep(0.1)
gpsMsg = self.genGPSMsg(self.gpsLine[0]["lat"],self.gpsLine[0]["lng"])
type = self.getMsgFunId(gpsMsg)
self.sendMsg(gpsMsg)
self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + gpsMsg,self.websocketId)
sleep(0.1)
OBDMsg = self.genOBDMsg(self.OBDdata["fireStatus"],1,self.OBDdata["engineSpeed"], \
self.OBDdata["speed"],self.OBDdata["meterMileage"],self.OBDdata["totailMileage"], \
self.OBDdata["totalOilExpen"],self.OBDdata["totalRunTime"])
type = self.getMsgFunId(OBDMsg)
self.sendMsg(OBDMsg)
self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + OBDMsg,self.websocketId)
# 熄火,发送熄火事件
def fireOff(self):
gpsLineIndex = self.gpsLineIndex
if gpsLineIndex >= len(self.gpsLine):
gpsLineIndex = gpsLineIndex - 1
# fireOffEventObj = EventReport_protocol(DEV_ID=self.carId)
# gpsData = self.genGPSData(self.gpsLine[gpsLineIndex]["lat"],self.gpsLine[gpsLineIndex]["lng"])
# fireOffEventObj.setGPSPkg(gpsData)
# fireOffEventObj.setEventType("0011")
# fireOffEventMsg = fireOffEventObj.generateEventMsg()
# type = self.getMsgFunId(fireOffEventMsg)
# self.sendMsg(fireOffEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + fireOffEventMsg,self.websocketId)
jdata = {"WATER_CODE": "0003", "DEV_ID": "M121501010001",
"gpsInfo": {"UTCTime": "2020-04-30 14:59:33", "latitude": "40.22077", "longitude": "116.23128",
"speed": "80.8", "directionAngle": "80.8", "elevation": "2999.9", "positionStar": "3",
"Pdop": "0.3", "Hdop": "0.4", "Vdop": "0.5", "statusBit": 162, "valtage": "36.9",
"OBDSpeed": "60.9", "engineSpeed": "3000", "GPSTotalMileage": "12800",
"totalOil": "100000",
"totalTime": "2020002", "GPSTimestamp": "1588229973"},
"securityData": {"securityStatus": 107, "doorStatus": 0, "lockStatus": 0, "windowStatus": 0,
"lightStatus": 0, "onoffStatusA": 0, "onoffStatusB": 112, "dataByte": 249}, "event": {
"0011": {"allRapidlyAccelerateCount": "5", "allSharpSlowdownCount": "6", "allSharpTurn": "4",
"dataProperty": "1"}}}
jdata["event"]["0011"]["allRapidlyAccelerateCount"] = self.carData["event"]["threeRapid"]["totalRapidlyAccelerate"]
jdata["event"]["0011"]["allSharpSlowdownCount"] = self.carData["event"]["threeRapid"]["totalSharpSlowdown"]
jdata["event"]["0011"]["allSharpTurn"] = self.carData["event"]["threeRapid"]["totalSharpTurn"]
jdata["DEV_ID"] = self.carId
obj = EventReport_protocol(data=jdata)
gpsData = self.genGPSData2()
obj.setGPSPkg(gpsData)
obj.setEventType("0011")
msg = obj.generateEventMsg()
type = self.getMsgFunId(msg)
self.sendMsg(msg)
self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + msg, self.websocketId)
sleep(0.1)
gpsMsg = self.genGPSMsg(self.gpsLine[gpsLineIndex]["lat"], self.gpsLine[gpsLineIndex]["lng"])
type = self.getMsgFunId(gpsMsg)
self.sendMsg(gpsMsg)
self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + gpsMsg,self.websocketId)
#根据特定参数,生成GPS消息
def genGPSMsg(self,latitude,longtitude):
gpsObj = GPS_protocol_m300(DEV_ID=self.carId,waterCode=self.sn)
gpsObj.setLatitude(latitude)
gpsObj.setLongitude(longtitude)
gpsObj.setDirection(self.getDirAngle())
timeS = int(time.time()) - 8 * 3600
timeArray = time.localtime(timeS)
UTCTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
gpsObj.setUTCTime(UTCTime)
msg = gpsObj.generateMsg()
return msg
#根据特定参数,生成GPS消息体,不包含消息头
def genGPSData(self,latitude,longtitude):
gpsObj = GPS_protocol_m300(DEV_ID=self.carId,waterCode=self.sn)
gpsObj.setLatitude(latitude)
gpsObj.setLongitude(longtitude)
gpsObj.setDirection(self.getDirAngle())
timeS = int(time.time()) - 8 * 3600
timeArray = time.localtime(timeS)
UTCTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
gpsObj.setDateInfo(UTCTime)
data = gpsObj.getMsgBody()
return data
#根据当前所在GPS点,生成GPS消息体,不包含消息头
def genGPSData2(self):
gpsObj = GPS_protocol_m300(DEV_ID=self.carId,waterCode=self.sn)
gpsObj.setLatitude(self.gpsLine[self.gpsLineIndex]["lat"])
gpsObj.setLongitude(self.gpsLine[self.gpsLineIndex]["lng"])
gpsObj.setDirection(self.getDirAngle())
timeS = int(time.time()) - 8 * 3600
timeArray = time.localtime(timeS)
UTCTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
gpsObj.setDateInfo(UTCTime)
data = gpsObj.generateGpsData()
return data
# 根据特定参数,生成OBD CAN消息
def genOBDMsg(self,fireStatus=1,ACCStatus=0,engineSpeed=300,speed=0,meterMileage=6000, \
totailMileage=600,totalOilExpend=30,totalRunTime=10):
OBDObj = OBDCAN_protocol_m300(DEV_ID=self.carId,waterCode=self.sn)
timeS = int(time.time()) - 8 * 3600
timeArray = time.localtime(timeS)
UTCTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
OBDObj.setTimeInfo(UTCTime)
OBDObj.setAccstatus(ACCStatus)
OBDObj.setEngineSpeed(engineSpeed) # 设置发动机转速
OBDObj.setSpeed(speed) # 设置车辆速度
OBDObj.setDashboardTotailMilleage(meterMileage) # 设置仪表里程值
OBDObj.setTotalMilleage(totailMileage) # 设置总里程值
OBDObj.setTotalOil(totalOilExpend) # 设置总耗油量
OBDObj.setCarTotalRunTime(totalRunTime) # 设置车辆运行时间
msg = OBDObj.generateOBDReportCANMsg()
return msg
###########################################################
#获取方向角
###########################################################
def getDirAngle(self):
dire = self.directAngle
if self.travelDirection == 0:
if self.gpsLineIndex == 0:
return int(self.directAngle)
lngCut = (float(self.gpsLine[self.gpsLineIndex]["lng"]) - float(self.gpsLine[self.gpsLineIndex - 1]["lng"])) * 1000000
latCut = (float(self.gpsLine[self.gpsLineIndex]["lat"]) - float(self.gpsLine[self.gpsLineIndex - 1]["lat"])) * 1000000
if latCut == 0: #除数维度不能为0
latCut = 1
if lngCut == 0 or latCut == 0:
return int(self.directAngle)
val = lngCut / latCut
dire = math.atan2(1, val) * 180 / math.pi
if lngCut > 0 and latCut > 0:
dire = 90 - dire
if lngCut < 0 and latCut > 0:
dire = 270 + 180 - dire
elif latCut < 0 and lngCut > 0:
dire = 270 - dire
elif lngCut < 0 and latCut < 0:
dire = 180 + 90 - dire
self.directAngle = dire
elif self.travelDirection == 1:
if self.gpsLineIndex == (len(self.gpsLine) - 1):
return int(self.directAngle)
lngCut = (float(self.gpsLine[self.gpsLineIndex]["lng"]) - float(self.gpsLine[self.gpsLineIndex + 1]["lng"])) * 1000000
latCut = (float(self.gpsLine[self.gpsLineIndex]["lat"]) - float(self.gpsLine[self.gpsLineIndex + 1]["lat"])) * 1000000
if latCut == 0: #除数维度不能为0
latCut = 1
if lngCut == 0 or latCut == 0:
return int(self.directAngle)
val = lngCut / latCut
dire = math.atan2(1, val) * 180 / math.pi
if lngCut > 0 and latCut > 0:
dire = 90 - dire
if lngCut < 0 and latCut > 0:
dire = 270 + 180 - dire
elif latCut < 0 and lngCut > 0:
dire = 270 - dire
elif lngCut < 0 and latCut < 0:
dire = 180 + 90 - dire
self.directAngle = dire
return int(dire)
###########################################################
# 将要发送的数据保存到本地
###########################################################
def saveMsgLocal(self,fName,data):
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
thePath = 'data/protocolTools/sendMsg'
if not os.path.exists(thePath):
os.makedirs(thePath)
thePath = thePath + "/" + self.carId + "/"
if not os.path.exists(thePath):
os.makedirs(thePath)
with open(thePath + fName, "a", encoding="utf-8") as fi:
fi.write("[" + curTime +"]" + data + "\n")
if __name__ == "__main__":
pass
#coding:utf-8
'''
M300车机模拟服务简易测试程序,用于做临时测试
'''
import binascii
import json
import math
import os
import threading
import time
import traceback
from time import sleep
from lib.protocol.m300.Alarm_protocol_m300 import Alarm_protocol_m300
from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from lib.protocol.m300.Login_protocol_m300 import Login_protocol_m300
from lib.protocol.m300.OBDCAN_protocol_m300 import OBDCAN_protocol_m300
from lib.protocol.m300.VersionInfo_protocol_m300 import VersionInfo_protocol_m300
from lib.protocol.m300.response.GPRS_protocol_response_m300 import GPRS_protocol_response_m300
from lib.protocol.message.Location_msg import Location_msg
from lib.protocol.message.TerminalCommonMsgRes_msg import TerminalCommonMsgRes_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg
from lib.socket.ClientSocket import ClientSocket
from lib.socket.service.M300SimulaterDataService import M300SimulaterDataService
from lib.socket.service.MessageSimulaterDataService import MessageSimulaterDataService
from lib.socket.service.websocket_service import Websocket_service
class M300SimulaterService():
def __init__(self):
self.data = {} #用来接收模拟器传过来的参数
self.carData = {} #保存车辆行驶数据
self.carDataObj = None #管理车辆行驶数据对象
self.socket = None
self.sendDur = 5 #设置默认多久发一条消息
self.serviceStatus = 0 #服务状态,0表示未启动,1表示启动
self.websocket = None #网页与服务的通信socket
self.websocketId = "" #当前连接的webSocketId
self.timeout = 3600 #socket的超时时间
self.gpsLine = [] #GPS 轨迹
self.gpsLineIndex = 0 #GPS 轨迹索引
self.travelStatus = 0 #0,表示未行驶,1表示开始行驶同时开启了接收消息服务,2表示值开启了接收消息的服务
self.carId = "M121501010001" #车机号
self.sn = 1 #消息流水号
self.travelDirection = 0 #行驶方向,0表示正向行驶,1表示反向行驶
self.directAngle = 60 #汽车方向角
#######################################################
# type 为0表示正常发送,type为1表示数据写入本地
#######################################################
def sendMsg(self,msg):
self.socket.setTimeOut(self.timeout)
self.socket.send(msg)
type = self.getMsgFunId(msg)
print("发送消息:" + type + ">>>>" + msg)
def revMsg(self):
self.socket.setTimeOut(self.timeout)
return self.socket.receive()
#发送消息,可指定消息的描述类型
def serviceSendMsg(self,msg,type): #type字段目前废掉没有实际意
self.sendMsg(msg)
def connect(self,host,port):
cliSocket = ClientSocket(host, port)
cliSocket.setTimeOut(self.timeout)
cliSocket.connect()
self.socket = cliSocket
self.startRevService()
def login(self):
loginObj = Login_protocol_m300(waterCode = self.sn,DEV_ID = self.carId,encryptionType=0)
loginMsg = loginObj.generateMsg()
self.sendMsg(loginMsg)
self.sn = self.sn +1
time.sleep(1)
versionObj = VersionInfo_protocol_m300(waterCode = self.sn,DEV_ID = self.carId,encryptionType=0,SWVersion="VSTA000GV100", \
SWDate="2020-03-30",HWVersion="M1.0",GSMType="GSM_type_123456",carType="150", \
engineCode=1,VINCode="VIN_CODE_01234567890")
versionMsg = versionObj.generateMsg()
self.sendMsg(versionMsg)
self.sn = self.sn + 1
time.sleep(1)
def serviceRev(self):
self.serviceStatus = 2 #2代表只启动了接收消息的进程,1代表了接收和发送都启动了
while self.serviceStatus != 0:
self.socket.setTimeOut(self.timeout)
d = self.revMsg()
d = str(binascii.b2a_hex(d))[2:][:-1]
type = self.getMsgFunId(d)
print("收到消息:" + type + "<<<<" + d)
self.doResponse(d)
#启动接收消息服务
def startRevService(self):
t2 = threading.Thread(target=self.serviceRev, args=())
t2.start()
#获取收到消息的功能id
def getMsgFunId(self,msg):
funId = msg[2:6]
return funId
#收到 某些类型的消息后执行回复操作
def doResponse(self,msg):
msgFunId = self.getMsgFunId(msg)
if msgFunId == "8104":
msg = GPRS_protocol_response_m300().generateMsg()
self.sendMsg(msg)
self.sn = self.sn + 1
if __name__ == "__main__":
service = M300SimulaterService()
service.connect("10.100.12.32",9009)
time.sleep(1)
service.login()
......@@ -71,7 +71,7 @@ class MessageSimulaterService():
def setData(self,data):
self.data = data
def setWebsocketId(self):
sleep(1)
sleep(0.1)
self.websocketId = self.websocket.getCurrentClientId()
def getWebsocket(self):
return self.websocket
......
......@@ -376,16 +376,6 @@ class ProtocolSimulaterService():
self.OBDdataOri["totalRunTime"] = conJson["travelData"]["totalTime"]
self.carData = self.carDataObj.fixDataTemplate(conJson)
# fireOnEventObj = EventReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn)
# gpsData = self.genGPSData(self.gpsLine[0]["lat"], self.gpsLine[0]["lng"])
# fireOnEventObj.setGPSPkg(gpsData)
# fireOnEventObj.setEventType("0010")
# firOnEventMsg = fireOnEventObj.generateEventMsg()
# type = self.getMsgFunId(firOnEventMsg)
# self.sendMsg(firOnEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + firOnEventMsg,self.websocketId)
jdata = {"WATER_CODE": "0003", "DEV_ID": "M121501010001",
"gpsInfo": {"UTCTime": "2020-04-30 14:59:33", "latitude": "40.22077", "longitude": "116.23128",
"speed": "80.8", "directionAngle": "80.8", "elevation": "2999.9", "positionStar": "3",
......@@ -432,16 +422,6 @@ class ProtocolSimulaterService():
if gpsLineIndex >= len(self.gpsLine):
gpsLineIndex = gpsLineIndex - 1
# fireOffEventObj = EventReport_protocol(DEV_ID=self.carId)
# gpsData = self.genGPSData(self.gpsLine[gpsLineIndex]["lat"],self.gpsLine[gpsLineIndex]["lng"])
# fireOffEventObj.setGPSPkg(gpsData)
# fireOffEventObj.setEventType("0011")
# fireOffEventMsg = fireOffEventObj.generateEventMsg()
# type = self.getMsgFunId(fireOffEventMsg)
# self.sendMsg(fireOffEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + fireOffEventMsg,self.websocketId)
jdata = {"WATER_CODE": "0003", "DEV_ID": "M121501010001",
"gpsInfo": {"UTCTime": "2020-04-30 14:59:33", "latitude": "40.22077", "longitude": "116.23128",
"speed": "80.8", "directionAngle": "80.8", "elevation": "2999.9", "positionStar": "3",
......
......@@ -10,6 +10,8 @@ from views.protocolTools.test_view import test_view
from views.m300Tools.P_m300Protocol_view import P_m300Protocol_view
from views.m300Tools.P_m300Protocol_process import P_m300Protocol_process
from views.m300Tools.M_m300Simulater_view import M_m300Simulater_view
from views.m300Tools.M_m300Simulater_process import M_m300Simulater_process
from views.messageTools.msgSetting_view import msgSetting_view
from views.messageTools.msgSetting_process import msgSetting_process
......@@ -29,6 +31,8 @@ app.register_blueprint(test_view,url_prefix = "/protocolTools/test_view")
app.register_blueprint(P_m300Protocol_view,url_prefix = "/m300Tools/P_m300Protocol_view")
app.register_blueprint(P_m300Protocol_process,url_prefix = "/m300Tools/P_m300Protocol_process")
app.register_blueprint(M_m300Simulater_view,url_prefix = "/m300Tools/M_m300Simulater_view")
app.register_blueprint(M_m300Simulater_process,url_prefix = "/m300Tools/M_m300Simulater_process")
app.register_blueprint(msgSetting_view,url_prefix = "/messageTools/msgSetting_view")
app.register_blueprint(msgSetting_process,url_prefix = "/messageTools/msgSetting_process")
......
/**
*m300simulater 页面顶部的tab切换
*/
function m300SimulaterTab(e){
var url = window.location.href;
var id = $(e).attr("id");
if(id == "m300simulater_tab"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/M_m300Simulater_view/M_m300Simulater_page");
}else if(id == "m300_setting_tab"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/M_m300Simulater_view/M_m300Setting_page");
}else{
alert(id)
}
}
\ No newline at end of file
......@@ -21,8 +21,8 @@
var id = $(e).attr("id")
if(id == "m300_msg_send"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/P_m300Protocol_view/P_heartBeat_m300_page");
}else if(id == "icon"){
$(location).attr('href', "http://" + window.location.host + "/tab1/icon");
}else if(id == "m300_simulater"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/M_m300Simulater_view/M_m300Simulater_page");
}
}
</script>
......@@ -33,7 +33,7 @@
<li id="m300_msg_send" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="P_m300Protocol_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span> m300单消息发送<span class="sr-only"></span></a></li>
</ul>
<ul class="nav nav-sidebar" style="margin-top:20px;">
<li><a><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 其他页面</a></li>
<li id="m300_simulater" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="M_m300Simulater_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> m300模拟器</a></li>
</ul>
</div>
{% endblock %}
......
{% extends "m300Tools/report/M_m300Simulater_page.html" %}
{% block title %}m300Setting_page{% endblock %}
{% 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="host" type="text" class="form-control" value="{{ arg['socket']['host']}}">
<label style="margin-left:10px;">端口:</label><input id="port" type="text" class="form-control" value="{{ arg['socket']['port']}}" style="width:100px;">
<button id="saveSocketSetting" type="button" class="btn btn-primary" id="saveSetting">保存</button>
</div>
</div>
<script>
$("#saveSocketSetting").click(function(){
var host = $("#host").val();
var port = $("#port").val();
var data = {};
data["host"] = host;
data["port"] = port;
var host = window.location.host;
$.ajax({
url:"http://" + host + "/m300Tools/M_m300Simulater_process/porcessSocketSetting",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
window.location.reload()
}else{
$("#showFeedback").val(data.message)
alert(data.message);
}
}
});
});
</script>
{% endblock %}
\ No newline at end of file
{% extends "m300Tools/index.html" %}
{% block title %}m300Simulater{% endblock %}
{% block content_01 %}
<script src="../../static/js/m300Tools/m300simulater.js"></script>
<style>
.nav-pills li {
margin-bottom:5px;
}
.form-control {
display:inline;
width:160px;
}
.protocol_content:after{
clear:both;
display:block;
content:" ";
}
.protocol_content li {
width:250px;
_background:yellow;
list-style:none;
margin-top:5px;
float:left;
}
.protocol_content label{
width:90px;
text-align:right;
}
</style>
<div id="container2" style="width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;">
{% block content_02 %}
<ul class="nav nav-pills" style="font-size:14px;">
<li role="presentation"><a id="m300_setting_tab" {% if arg.path[2]=="M_m300Setting_page" %} class="link-tab" {% endif %} onclick="m300SimulaterTab(this)">设置</b></a></li>
<li role="presentation"><a id="m300simulater_tab" {% if arg.path[2]=="M_m300Simulater_page" %} class="link-tab" {% endif %} onclick="m300SimulaterTab(this)">模拟器</b></a></li>
</ul>
{% endblock %}
{% 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;">
<span><label>车机Id:</label><input id="carId" type="text" class="form-control" value="M202003060540"></span>
<span><label>上报间隔(秒):</label><input id="durTime" style="width:60px;" type="text" class="form-control" value="5"></span>
<span><label>设置超时时间:</label><input style="width:80px;" id="timeout" type="text" class="form-control" value="36000"></span>
</div>
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>多人在线状态面板:</b></h5>-->
<!-- <span><label>我的id:</label><input disabled=disabled type="text" id="curSession" class="form-control" style="display:inline;width:200px;" value=""/></span>-->
<!-- <span><label>在线人数:</label><input disabled=disabled type="text" id="totalSessionNums" class="form-control" style="display:inline;width:80px;" value="1"/></span>-->
<!-- <button id="sessionRefresh" type="button" class="btn btn-primary" onclick="getAllUsers(this)">刷新</button><label style="font-size:10px;width:100px;">刷新后,可在控制台查看在线用户详细信息</label>-->
<!-- </div>-->
<!-- <div style="width:100%;_padding-bottom:10px;border-bottom: 1px solid #eee;">-->
<!--&lt;!&ndash; <h4>点击登录按钮发送报文:</h4>&ndash;&gt;-->
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>登录报文数据:</b>-->
<!-- <span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">-->
<!-- <label><input name="login" type="radio" value="0" checked="checked" onclick="isShowLoginArea(this)"/>隐藏</label>-->
<!-- <label style="margin-left:10px;"><input name="login" type="radio" value="1" onclick="isShowLoginArea(this)"/>显示</label>-->
<!-- </span>-->
<!-- </h5>-->
<!-- <div id="login_area" style="display:none;">-->
<!-- <ul class="protocol_content" style="padding:0px;">-->
<!-- <li style="width:320px;"><label>CPU-ID:</label><input style="width:220px;" id="cpuId" type="text" class="form-control" value="CPU-ID001122334455667788"></li>-->
<!-- <li><label style="word-break:break-all;font-size:12px;">SIM卡IMSI号:</label><input id="imsi" type="text" class="form-control" value="IMSI13145678902"></li>-->
<!-- <li style="width:300px;"><label style="word-break:break-all;font-size:12px;">SIM卡CCID号:</label><input style="width:200px;" id="ccid" type="text" class="form-control" value="CCID1122334455667788"></li>-->
<!-- <li><label style="word-break:break-all;font-size:10px;">GSM模块IMEI码:</label><input id="imei" type="text" class="form-control" value="IMEI12233445566"></li>-->
<!-- </ul>-->
<!-- <ul class="protocol_content" style="padding:0px;">-->
<!-- <li style="width:320px;"><label style="word-break:break-all;font-size:12px;">车机版本信息:</label><input style="width:220px;" id="verInfo" type="text" class="form-control" value="M100AB01010.0000"></li>-->
<!-- <li><label>编译日期:</label><input id="compileDate" type="text" class="form-control" value="2020-03-23"></li>-->
<!-- <li style="width:300px;"><label style="word-break:break-all;font-size:12px;">GSM模块型号:</label><input style="width:200px;" id="GSM" type="text" class="form-control" value="GSM_123456"></li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>GPS行驶轨迹设置:</b></h5>-->
<!-- <div class="input-group" style="width:380px;padding-bottom:10px;margin-left:10px;display:inline;">-->
<!-- <form id="form" enctype="multipart/form-data">-->
<!-- <input type="file" id="fileAttach" name="file" class="form-control" style="display:inline;width:250px;"/>-->
<!-- <input type="button" onclick="uploadFile()" value="上传" class="form-control" style="display:inline;width:80px;font-weight: bolder;"/>-->
<!-- </form>-->
<!-- </div>-->
<!-- <span style="margin-left:10px;"><label>选择轨迹:</label><select id="selectGPSLine" class="form-control" style="width:250px;">-->
<!-- {% for key,value in arg["gpsLines"].items() %}-->
<!-- <option value="{{ key }}">{{ value }}</option>-->
<!-- {% endfor %}-->
<!-- </select></span>-->
<!-- <a style="margin-left:10px;font-weight:bold;" onclick="download_sample()">下载示例轨迹</a>-->
<!--&lt;!&ndash; <label><input style="margin-left:30px;" type="checkbox" id="ignition" />轨迹管理</label>&ndash;&gt;-->
<!--&lt;!&ndash; <div style="display: block;margin:10px; width: 95%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!-- </div>-->
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>行驶参数设置:</b></h5>-->
<!-- <span><label>速度(Km/h):</label><input type="text" id="carSpeed" class="form-control" style="display:inline;width:80px;" value="60"/></span>-->
<!-- <span><label>油耗(Km/L):</label><input type="text" id="oilExpend" class="form-control" style="display:inline;width:80px;" value="10"/></span>-->
<!-- <span><label>是否循环行驶:</label><select style="width:80px;" id="travelLoop" class="form-control">-->
<!-- <option value="0">否</option>-->
<!-- <option value="1">是</option></select><label style="font-size:9px;width: 100px;">开启后会在所选择的轨迹上来回行驶</label></span>-->
<!-- </div>-->
<!-- <div style="width:100%;padding-bottom:10px;border-bottom: 1px solid #eee;">-->
<!-- <h3>操作:</h3>-->
<!-- <button id="connect_B" type="button" class="btn btn-primary" onclick="connect()">1、连网</button>-->
<!-- <button id="fire_B" type="button" class="btn btn-primary" onclick="login()">2、登录</button>-->
<!-- <button id="login_B" type="button" class="btn btn-primary" onclick="fire()">3、点火</button>-->
<!-- <button id="run_B" type="button" class="btn btn-primary" onclick="startTravel()">4、行驶</button>-->
<!-- <button id="stopRun_B" type="button" class="btn btn-primary" onclick="stopTravel()">5、停止行驶</button>-->
<!-- <button id="unFire_B" type="button" class="btn btn-primary" onclick="unFire()">6、熄火</button>-->
<!-- <button id="unConnect_B" type="button" class="btn btn-primary" onclick="stopConnect()">7、断网</button>-->
<!-- <button id="unConnectAll_B" type="button" class="btn btn-danger" onclick="reset()">复位</button>-->
<!-- <button id="clear_B" type="button" class="btn btn-warning" onclick="clearlog()">清空日志</button>-->
<!-- <span style="margin-left:20px;"><label>当前状态:</label><input id="curStatus" value="断网" disabled="disabled" class="form-control" style="font-weight: bold;width:85px;color:red;border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px;"></span>-->
<!-- <span style="width:80px;padding-left:10px;"><label style="width:70px"><input type="checkbox" id="ignition" onclick="isLogShow(this)"/>隐藏日志</label> </span>-->
<!-- </div>-->
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>事件发送:</b>-->
<!-- <span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">-->
<!-- <label><input name="eventshow" type="radio" value="0" checked="checked" onclick="isShowEventArea(this)"/>隐藏</label>-->
<!-- <label style="margin-left:10px;"><input name="eventshow" type="radio" value="1" onclick="isShowEventArea(this)"/>显示</label>-->
<!-- </span>-->
<!-- </h5>-->
<!-- <div id="event_area" style="display:none;">-->
<!-- <div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;">-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="insertAlarm_check" onclick="eventSelect(this)" checked />终端插入报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="lowVoltage_check" onclick="eventSelect(this)" checked />汽车电瓶低电压报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="powerOff_check" onclick="eventSelect(this)" checked />终端主电断电报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="rapidlyAccelerateEvent_check" onclick="eventSelect(this)" checked />急加速 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="sharpSlowdownEvent_check" onclick="eventSelect(this)" checked />急减速 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="sharpTurnEvent_check" onclick="eventSelect(this)" checked />急转弯 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="collisionAlarmEvent_check" onclick="eventSelect(this)" checked />碰撞报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="setUpDefencesEvent_check" onclick="eventSelect(this)" checked />设防 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="setDownDefencesEvent_check" onclick="eventSelect(this)" checked />撤防 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="lowGearHighSpeed_check" onclick="eventSelect(this)" checked />低档高速报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="highGearLowSpeed_check" onclick="eventSelect(this)" checked />高档低速报警 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="surplusOil_check" onclick="eventSelect(this)" checked />剩余油量异常告警 </label>-->
<!-- </div>-->
<!-- <div style="padding:10px;">-->
<!-- <span id="insertAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendInsertAlarmEvent(this)">终端插入报警</button></label></span>-->
<!-- <span id="lowVoltage_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendLowVoltageEvent(this)">汽车电瓶低电压报警</button></label></span>-->
<!-- <span id="powerOff_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendPowerOffEvent(this)">终端主电断电报警</button></label></span>-->
<!-- <span id="rapidlyAccelerateEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendRapidlyAccelerateEvent(this)">急加速</button></label></span>-->
<!-- <span id="sharpSlowdownEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSharpSlowdownEvent(this)">急减速</button></label></span>-->
<!-- <span id="sharpTurnEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSharpTurnEvent(this)">急转弯</button></label></span>-->
<!-- <span id="collisionAlarmEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendCollisionAlarmEvent(this)">碰撞报警</button></label></span>-->
<!-- <span id="setUpDefencesEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSetUpDefencesEvent(this)">设防</button></label></span>-->
<!-- <span id="setDownDefencesEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSetDownDefencesEvent(this)">撤防</button></label></span>-->
<!-- <span id="lowGearHighSpeed_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendLowGearHighSpeedEvent(this)">低挡高速</button></label></span>-->
<!-- <span id="highGearLowSpeed_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendHighGearLowSpeedEvent(this)">高档低速</button></label></span>-->
<!-- <span id="surplusOil_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSurplusOilAlarmEvent(this)">剩余油量异常</button></label></span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <h5><b>实时控制:</b>-->
<!-- <span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">-->
<!-- <label><input name="realtime" type="radio" value="0" checked="checked" onclick="isShowRealTimeCtrArea(this)"/>隐藏</label>-->
<!-- <label style="margin-left:10px;"><input name="realtime" type="radio" value="1" onclick="isShowRealTimeCtrArea(this)"/>显示</label>-->
<!-- </span>-->
<!-- </h5>-->
<!-- <div id="realTimeCtl_area" style="display:none;">-->
<!-- <div style="padding:10px;">-->
<!-- <span style="margin-left:10px"><label>车速度(Km/h):</label><input style="width:80px;margin-right:5px;" id="change_speed" type="text" class="form-control" value="60"><button type="button" class="btn btn-primary" onclick="changeSpeed()">改变车速</button></span>-->
<!-- <span style="margin-left:10px"><label>油耗(Km/L):</label><input style="width:80px;margin-right:5px;" id="change_oilExpend" type="text" class="form-control" value="10"><button type="button" class="btn btn-primary" onclick="changeOilExpend()">改变油耗</button></span>-->
<!-- <span style="margin-left:10px"><label>上报间隔(秒):</label><input style="width:80px;margin-right:5px;" id="change_durTime" type="text" class="form-control" value="5"><button type="button" class="btn btn-primary" onclick="changeDurTime()">改变上报间隔</button></span>-->
<!-- <span style="margin-left:10px;"><button title="点击后,将会把上报的消息存到本地,不上报消息;用来模拟车机无信号的情况" type="button" class="btn btn-primary" onclick="storeMsg()" id="storeMsgBut">存储上报消息</button><label style="color:red;" id="storeMsgLab">未存储...</label></span>-->
<!-- <span style="margin-top:10px;display:inline-block;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin-left:10px;">-->
<!-- <label><input name="GPSValie" value="1" type="radio" onclick="changeGPSValid(this)" checked="checked">GPS有效</label>-->
<!-- <label style="margin-left:10px;color:red;"><input name="GPSValie" value="0" type="radio" onclick="changeGPSValid(this)">GPS无效</label>-->
<!-- </span>-->
<!-- <span style="margin-top:10px;display:inline-block;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin-left:10px;">-->
<!-- <label><input name="lngLatIsOk" value="1" type="radio" onclick="changeLngLatIsOk(this)" checked="checked">经纬度正常</label>-->
<!-- <label style="margin-left:10px;color:red;"><input name="lngLatIsOk" value="0" type="radio" onclick="changeLngLatIsOk(this)">经纬度为0</label>-->
<!-- </span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div style="width:100%;padding-bottom:60px;border-bottom: 1px solid #eee;">
<h3>日志:</h3>
<textarea id="showFeedback" style="width:100%;padding:5px;padding-bottom:60px;" rows="10"></textarea>
</div>
<div style="width:100%;padding-bottom:10px;border-bottom: 1px solid #eee;">
<h4>查询今日车机行驶数据</h4>
<span>
<button id="searchCarData" type="button" class="btn btn-primary">查询</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>
<script>
//通过函数获取页面参数
function getPageData(){
var data = {};
var carId = $("#carId").val()
var WATER_CODE = $("#WATER_CODE").val()
var durTime = $("#durTime").val()
var timeout = $("#timeout").val()
data["carId"] = carId
data["WATER_CODE"] = WATER_CODE
data["durTime"] = durTime
data["timeout"] = timeout
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
//登录数据
data["login"] = {}
var cpuId = $("#cpuId").val()
var imsi = $("#imsi").val()
var ccid = $("#ccid").val()
var imei = $("#imei").val()
data["login"]["cpuId"] = cpuId
data["login"]["imsi"] = imsi
data["login"]["ccid"] = ccid
data["login"]["imei"] = imei
//版本数据
data["version"] = {}
var verInfo = $("#verInfo").val()
var compileDate = $("#compileDate").val()
var GSM = $("#GSM").val()
data["version"]["verInfo"] = verInfo
data["version"]["compileDate"] = compileDate
data["version"]["GSM"] = GSM
//GPS轨迹数据
var gpsLine = $("#selectGPSLine").val()
data["gpsLine"] = gpsLine
//行驶参数数据
data["travelData"] = {}
var carSpeed = $("#carSpeed").val()
var oilExpend = $("#oilExpend").val()
var travelLoop = $("#travelLoop").val()
data["travelData"]["carSpeed"] = carSpeed
data["travelData"]["oilExpend"] = oilExpend
data["travelData"]["travelLoop"] = travelLoop
return data;
}
//连接
function connect(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/createConect";
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
WebSocketTest()
$("#curStatus").val("连网")
var userNums = parseInt($("#totalSessionNums").val()) + 1
$("#totalSessionNums").val(userNums)
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}
//登录
function login(){
var data = getPageData()
$("#curStatus").val("登录")
url = "/protocolTools/M_carSimulater_process/login";
sendjson(data,url);
}
//点火
function fire(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/fire";
sendjson(data,url);
$("#curStatus").val("点火")
}
//行驶
function startTravel(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/startTravel";
sendjson(data,url);
$("#curStatus").val("行驶")
}
//停止行驶
function stopTravel(){
var data = getPageData();
url = "/protocolTools/M_carSimulater_process/stopTravel";
sendjson(data,url);
$("#curStatus").val("点火")
}
//熄火
function unFire(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/unFire";
sendjson(data,url);
$("#curStatus").val("熄火")
}
//断开连接
function stopConnect(){
var data = getPageData();
url = "/protocolTools/M_carSimulater_process/closeConect";
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
//endService()
$("#curStatus").val("断网")
var userNums = parseInt($("#totalSessionNums").val()) - 1
$("#totalSessionNums").val(userNums)
ws.close();
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}
//复位
function reset(){
var res;
res=confirm("复位后会影响其他在线用户的使用,你确定复位吗?");
if(res == true){
var data = getPageData();
url = "/protocolTools/M_carSimulater_process/reset";
sendjson(data,url);
$("#showFeedback").val("")
//endService()
$("#curStatus").val("断网")
$("#totalSessionNums").val(0)
ws.close();
}
}
//清空日志
function clearlog(){
$("#showFeedback").val("")
}
//非json方式发送数据
function send(data,url){
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}
//json方式发送数据
function sendjson(data,url){
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}
//控制登录数据区域的显示与隐藏
function isShowLoginArea(e){
var value = $(e).val()
if(value == "0"){
$("#login_area").css("display","none")
}else{
$("#login_area").css("display","block")
}
}
///////////////////////////////// websocket 代码开始 /////////////////////////////////
client = "0"
ws = null;
i = 1;
showLog = true; //设置日志是否显示
(function(){
ws = null;
i = 1;
})()
function WebSocketTest(){
if ("WebSocket" in window){
console.log("您的浏览器支持 WebSocket!");
var domain = document.domain;
ws = new WebSocket("ws://" + domain + ":5009");
ws.onopen = function(){
console.log("socket 已经连接上!")
};
ws.onmessage = function (evt) {
var received_msg = JSON.parse(evt.data)
var curTime = getCurTime();
if(received_msg["code"] == "0001"){ //0001代表连接消息通信
client = received_msg["client"]
}
var text = $("#showFeedback").val()
if(text == ""){
text = text + "[" + curTime + "] " + received_msg["msg"] + "\n";
}else{
text = text + "[" + curTime + "] " + received_msg["msg"] + "\n";
$('#showFeedback').scrollTop($('#showFeedback')[0].scrollHeight);
}
if(showLog){
$("#showFeedback").val(text);
}
};
ws.onclose = function(){
alert("连接已关闭..."); // 关闭 websocket
};
}else{
alert("您的浏览器不支持 WebSocket!"); // 浏览器不支持 WebSocket
}
}
function sendMsg(){
var msg = $("#sendMsg").val()
var data = {};
data["code"] = "0002"; //0002代表普通消息通信
data["client"] = client;
data["msg"] = msg;
data = JSON.stringify(data)
ws.send(data);
}
function endService(){
var msg = ""
var data = {};
data["code"] = "0003"; //0002代表普通消息通信
data["client"] = client;
data["msg"] = msg;
data = JSON.stringify(data)
ws.send(data);
}
function myclose(){
var data = {};
data["code"] = "0000"; //0000代表关闭服务器套接字程序
data["client"] = client;
data["msg"] = "";
data = JSON.stringify(data);
ws.send(data);
ws.close();
console.log("执行了socket服务的关闭操作...");
}
///////////////////////////////// websocket 代码结束 /////////////////////////////////
function uploadFile(){
var form = new FormData(document.getElementById("form"));
var host = window.location.host;
$.ajax({
url:"http://" + host + "/protocolTools/M_carSimulater_process/fileUplad",
type:"post",
data:form,
cache: false,
processData: false,
contentType: false,
success:function(data){
//提交成功
if (data.status == "200") {
$("#fileAttach").val("")
$("#selectGPSLine").prepend("<option value=" + data.file.filenameOri + ">" + data.file.filename + "</option>")
alert("sucess")
}else{
alert("fail")
}
},
error:function(data){
var result=document.getElementById("Result");
result.innerHTML="服务器错误";
}
});
}
function download_sample(){
var host = window.location.host;
window.location.href = "http://" + host + "/protocolTools/M_carSimulater_process/sampleDowload"
}
//查询车机今日行驶数据
$("#searchCarData").click(function(){
var carId = $("#carId").val();
var data = {};
data["carId"] = carId;
var host = window.location.host;
$.ajax({
url:"http://" + host + "/protocolTools/M_carSimulater_process/searchCarsimulaterData",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
msg = data.message
$("#searchCardataShow").val(msg)
}else{
$("#searchCardataShow").val(data.message)
alert(data.message);
}
}
});
});
//设置隐藏或显示日志
function isLogShow(e){
if($(e).is(':checked')){
showLog = false;
}else{
showLog = true;
}
}
// -------------------------------- session多人在线js代码-------------------------------------------
//获取水机session id
function getSessionId(){
var sessionNum = parseInt(Math.random() * 100000);
if(sessionNum < 100000){
sessionNum = sessionNum + 100000;
}
var sessionStr = ""
var strAll = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRETUVWXYZ";
var strAllLen = strAll.length;
for(var i = 0;i < 8;i++){
var wh = parseInt(Math.random() * 100);
if(wh >= strAllLen){
wh = wh - strAllLen
}
sessionStr = sessionStr + strAll.charAt(wh)
}
session = sessionStr + "_" + sessionNum
return session
}
//设置车机session Id
(function setSessionId(){
var sessionId = getSessionId()
$("#curSession").val(sessionId)
})()
//获取所有的使用用户
function getAllUsers(){
var data = {};
var host = window.location.host;
$.ajax({
url:"http://" + host + "/protocolTools/M_carSimulater_process/getConnects",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
obj = data.result
console.log(obj)
$("#totalSessionNums").val(data.userCounts)
}else{
$("#searchCardataShow").val(data.message)
alert(data.message);
}
}
});
}
//获取所有的使用用户
(function(){
var data = {};
var host = window.location.host;
$.ajax({
url:"http://" + host + "/protocolTools/M_carSimulater_process/getConnects",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
obj = data.result
$("#totalSessionNums").val(data.userCounts)
}else{
}
}
});
})()
// -------------------------------- 实时控制js代码-------------------------------------------
//设置隐藏或显示实时控制区域
function isShowRealTimeCtrArea(e){
var value = $(e).val()
if(value == "0"){
$("#realTimeCtl_area").css("display","none")
}else{
$("#realTimeCtl_area").css("display","block")
}
}
// -------------------------------- 事件控制js代码-------------------------------------------
//设置隐藏或显示事件控制区域
function isShowEventArea(e){
var value = $(e).val()
if(value == "0"){
$("#event_area").css("display","none")
}else{
$("#event_area").css("display","block")
}
}
//事件的选择与取消选择
function eventSelect(e){
if($(e).is(':checked')){
if($(e).attr("id") == "insertAlarm_check"){
$("#insertAlarm_button").css("display","inline")
}else if($(e).attr("id") == "lowVoltage_check"){
$("#lowVoltage_button").css("display","inline")
}else if($(e).attr("id") == "powerOff_check"){
$("#powerOff_button").css("display","inline")
}else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
$("#rapidlyAccelerateEvent_button").css("display","inline")
}else if($(e).attr("id") == "sharpSlowdownEvent_check"){
$("#sharpSlowdownEvent_button").css("display","inline")
}else if($(e).attr("id") == "sharpTurnEvent_check"){
$("#sharpTurnEvent_button").css("display","inline")
}else if($(e).attr("id") == "collisionAlarmEvent_check"){
$("#collisionAlarmEvent_button").css("display","inline")
}else if($(e).attr("id") == "setUpDefencesEvent_check"){
$("#setUpDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "lowGearHighSpeed_check"){
$("#lowGearHighSpeed_button").css("display","inline")
}else if($(e).attr("id") == "highGearLowSpeed_check"){
$("#highGearLowSpeed_button").css("display","inline")
}else if($(e).attr("id") == "surplusOil_check"){
$("#surplusOil_button").css("display","inline")
}
}else{
if($(e).attr("id") == "insertAlarm_check"){
$("#insertAlarm_button").css("display","none")
}else if($(e).attr("id") == "lowVoltage_check"){
$("#lowVoltage_button").css("display","none")
}else if($(e).attr("id") == "powerOff_check"){
$("#powerOff_button").css("display","none")
}else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
$("#rapidlyAccelerateEvent_button").css("display","none")
}else if($(e).attr("id") == "sharpSlowdownEvent_check"){
$("#sharpSlowdownEvent_button").css("display","none")
}else if($(e).attr("id") == "sharpTurnEvent_check"){
$("#sharpTurnEvent_button").css("display","none")
}else if($(e).attr("id") == "collisionAlarmEvent_check"){
$("#collisionAlarmEvent_button").css("display","none")
}else if($(e).attr("id") == "setUpDefencesEvent_check"){
$("#setUpDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "lowGearHighSpeed_check"){
$("#lowGearHighSpeed_button").css("display","none")
}else if($(e).attr("id") == "highGearLowSpeed_check"){
$("#highGearLowSpeed_button").css("display","none")
}else if($(e).attr("id") == "surplusOil_check"){
$("#surplusOil_button").css("display","none")
}
}
}
//发送终端插入报警
function sendInsertAlarmEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendInsertAlarmEvent";
sendjson(data,url);
}
//发送汽车电瓶低电压报警
function sendLowVoltageEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendLowVoltageEvent";
sendjson(data,url);
}
//发送汽车电瓶低电压报警
function sendPowerOffEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendPowerOffEvent";
sendjson(data,url);
}
//发送急加速事件消息
function sendRapidlyAccelerateEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendRapidlyAccelerateEvent";
sendjson(data,url);
}
//发送急减速事件消息
function sendSharpSlowdownEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSharpSlowdownEvent";
sendjson(data,url);
}
//发送急转弯事件消息
function sendSharpTurnEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSharpTurnEvent";
sendjson(data,url);
}
//发送碰撞告警事件
function sendCollisionAlarmEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendCollisionAlarmEvent";
sendjson(data,url);
}
//发送设防事件消息
function sendSetUpDefencesEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSetUpDefencesEvent";
sendjson(data,url);
}
//发送撤防事件消息
function sendSetDownDefencesEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSetDownDefencesEvent";
sendjson(data,url);
}
//发送低档高速报警事件消息
function sendLowGearHighSpeedEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendLowGearHighSpeedEvent";
sendjson(data,url);
}
//发送高档低速报警事件消息
function sendHighGearLowSpeedEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendHighGearLowSpeedEvent";
sendjson(data,url);
}
//发送剩余油量异常告警事件消息
function sendSurplusOilAlarmEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSurplusOilAlarmEvent";
sendjson(data,url);
}
// -------------------------------- 实时控制js代码-------------------------------------------
//改变车速
function changeSpeed(){
var data = {}
var carId = $("#carId").val()
var speed = $("#change_speed").val()
data["carId"] = carId
data["speed"] = speed
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/changeCarSpeed";
$("#carSpeed").val(speed)
sendjson(data,url);
}
//改变油耗
function changeOilExpend(){
var data = {}
var carId = $("#carId").val()
var oilExpend = $("#change_oilExpend").val()
data["carId"] = carId
data["oilExpend"] = oilExpend
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/changeOilExpend";
$("#oilExpend").val(oilExpend)
sendjson(data,url);
}
//改变发送间隔
function changeDurTime(){
var data = {}
var carId = $("#carId").val()
var durTime = $("#change_durTime").val()
data["carId"] = carId
data["durTime"] = durTime
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
$("#durTime").val(durTime)
url = "/protocolTools/M_carSimulater_process/changeDurTime";
sendjson(data,url);
}
//控制发送数据是否保存到本地
function storeMsg(){
var butTxt = $("#storeMsgBut").text()
if(butTxt == "存储上报消息"){
var data = {}
var carId = $("#carId").val()
data["carId"] = carId
data["sendType"] = 1
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/controlStoreMsg";
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
$("#storeMsgBut").text("取消存储上报消息")
$("#storeMsgLab").text("存储中...")
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}else{
var data = {}
var carId = $("#carId").val()
data["carId"] = carId
data["sendType"] = 0
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/controlStoreMsg";
var host = window.location.host;
$.ajax({
//url:"http://" + host + "/protocolTools/M_carSimulater_process/porcessSocketSetting",
url:"http://" + host + url,
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
$("#storeMsgBut").text("存储上报消息")
$("#storeMsgLab").text("未存储...")
//window.location.reload()
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
}else{
var curTime = getCurTime();
var txt = $("#showFeedback").val()
txt = txt + "[" + curTime + "] " + data.message + "\n"
$("#showFeedback").val(txt)
alert(data.message);
}
}
});
}
}
//控制GPS是否有效
function changeGPSValid(e){
var data = {}
var carId = $("#carId").val()
var GPSValid = $(e).val()
data["carId"] = carId
data["GPSValid"] = GPSValid
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/controlGPSValid";
sendjson(data,url);
}
//控制经纬度为0还是正常
function changeLngLatIsOk(e){
var data = {}
var carId = $("#carId").val()
var lngLatIsOk = $(e).val()
data["carId"] = carId
data["lngLatIsOk"] = lngLatIsOk
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/controlLngLatIsOk";
sendjson(data,url);
}
</script>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
......@@ -33,147 +33,147 @@
<li style="width:350px;"><label>状态掩码:</label><input style="width:250px;" id="statusMask" type="text" class="form-control" value="ffffffffffffffffffff"></li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>安全状态:</h4>
<div style="width:100%" id="safeStatus">
<sapn><label>ACC状态:</label><select style="width:65px;" id="accStatus" class="form-control">
<span><label>ACC状态:</label><select style="width:65px;" id="accStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">设防撤防状态:</label><select style="width:65px;" id="defenseStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">设防撤防状态:</label><select style="width:65px;" id="defenseStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>脚刹状态:</label><select style="width:65px;" id="brakeStatus" class="form-control">
<option value="2"></option></select></span>
<span><label>脚刹状态:</label><select style="width:65px;" id="brakeStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>是否踩油门:</label><select style="width:65px;" id="acceleratorStatus" class="form-control">
<option value="4"></option></select></span>
<span><label>是否踩油门:</label><select style="width:65px;" id="acceleratorStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>手刹状态:</label><select style="width:65px;" id="handBrakeStatus" class="form-control">
<option value="8"></option></select></span>
<span><label>手刹状态:</label><select style="width:65px;" id="handBrakeStatus" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">主驾驶安全带:</label><select style="width:65px;" id="mainSafetyBelt" class="form-control">
<option value="16"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">主驾驶安全带:</label><select style="width:65px;" id="mainSafetyBelt" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">副驾驶安全带:</label><select style="width:65px;" id="subSafetyBelt" class="form-control">
<option value="32"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">副驾驶安全带:</label><select style="width:65px;" id="subSafetyBelt" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<option value="64"></option></select></span>
</div>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>门状态:</h4>
<div style="width:100%" id="doorStatus">
<sapn><label>左前门:</label><select style="width:65px;" id="lfDoorStatus" class="form-control">
<span><label>左前门:</label><select style="width:65px;" id="lfDoorStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label>右前门:</label><select style="width:65px;" id="rfDoorStatus" class="form-control">
<option value="1"></option></select></span>
<span><label>右前门:</label><select style="width:65px;" id="rfDoorStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>左后门:</label><select style="width:65px;" id="lbDoorStatus" class="form-control">
<option value="2"></option></select></span>
<span><label>左后门:</label><select style="width:65px;" id="lbDoorStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>右后门:</label><select style="width:65px;" id="rbDoorStatus" class="form-control">
<option value="4"></option></select></span>
<span><label>右后门:</label><select style="width:65px;" id="rbDoorStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>后备箱:</label><select style="width:65px;" id="trunk" class="form-control">
<option value="8"></option></select></span>
<span><label>后备箱:</label><select style="width:65px;" id="trunk" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label>发动机盖:</label><select style="width:65px;" id="enginCover" class="form-control">
<option value="16"></option></select></span>
<span><label>发动机盖:</label><select style="width:65px;" id="enginCover" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<option value="32"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>锁状态:</h4>
<div style="width:100%" id="lockStatus">
<sapn><label style="word-break:break-all;font-size:10px;">左前门锁状态:</label><select style="width:65px;" id="lfDoorLockStatus" class="form-control">
<span><label style="word-break:break-all;font-size:10px;">左前门锁状态:</label><select style="width:65px;" id="lfDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">右前门锁状态:</label><select style="width:65px;" id="rfDoorLockStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">右前门锁状态:</label><select style="width:65px;" id="rfDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">左后门锁状态:</label><select style="width:65px;" id="lbDoorLockStatus" class="form-control">
<option value="2"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">左后门锁状态:</label><select style="width:65px;" id="lbDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">右后门锁状态:</label><select style="width:65px;" id="rbDoorLockStatus" class="form-control">
<option value="4"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">右后门锁状态:</label><select style="width:65px;" id="rbDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<option value="8"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>窗户状态:</h4>
<div style="width:100%" id="windowStatus">
<sapn><label style="width:80px;">左前窗:</label><select style="width:65px;" id="lfWindowStatus" class="form-control">
<span><label style="width:80px;">左前窗:</label><select style="width:65px;" id="lfWindowStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="width:80px;">右前窗:</label><select style="width:65px;" id="rfWindowStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="width:80px;">右前窗:</label><select style="width:65px;" id="rfWindowStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="width:80px;">左后窗:</label><select style="width:65px;" id="lbWindowStatus" class="form-control">
<option value="2"></option></select></span>
<span><label style="width:80px;">左后窗:</label><select style="width:65px;" id="lbWindowStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="width:80px;">右后窗:</label><select style="width:65px;" id="rbWindowStatus" class="form-control">
<option value="4"></option></select></span>
<span><label style="width:80px;">右后窗:</label><select style="width:65px;" id="rbWindowStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label style="width:80px;">天窗开关:</label><select style="width:65px;" id="topWindowStatus" class="form-control">
<option value="8"></option></select></span>
<span><label style="width:80px;">天窗开关:</label><select style="width:65px;" id="topWindowStatus" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="width:80px;">左转向灯:</label><select style="width:65px;" id="lTurnLight" class="form-control">
<option value="16"></option></select></span>
<span><label style="width:80px;">左转向灯:</label><select style="width:65px;" id="lTurnLight" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="width:80px;">右转向灯:</label><select style="width:65px;" id="rTurnLight" class="form-control">
<option value="32"></option></select></span>
<span><label style="width:80px;">右转向灯:</label><select style="width:65px;" id="rTurnLight" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<sapn><label style="width:80px;">阅读灯:</label><select style="width:65px;" id="readLight" class="form-control">
<option value="64"></option></select></span>
<span><label style="width:80px;">阅读灯:</label><select style="width:65px;" id="readLight" class="form-control">
<option value="0"></option>
<option value="128"></option></select></sapn>
<option value="128"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>灯状态:</h4>
<div style="width:100%" id="lightStatus">
<sapn><label style="width:80px;">近光灯:</label><select style="width:65px;" id="lowHeadlight" class="form-control">
<span><label style="width:80px;">近光灯:</label><select style="width:65px;" id="lowHeadlight" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="width:80px;">远光灯:</label><select style="width:65px;" id="highHeadlight" class="form-control">
<option value="1"></option></select></span>
<span><label style="width:80px;">远光灯:</label><select style="width:65px;" id="highHeadlight" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="width:80px;">前雾灯:</label><select style="width:65px;" id="ffogLight" class="form-control">
<option value="2"></option></select></span>
<span><label style="width:80px;">前雾灯:</label><select style="width:65px;" id="ffogLight" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="width:80px;">后雾灯:</label><select style="width:65px;" id="bfogLight" class="form-control">
<option value="4"></option></select></span>
<span><label style="width:80px;">后雾灯:</label><select style="width:65px;" id="bfogLight" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label style="width:80px;">危险灯:</label><select style="width:65px;" id="dangerLight" class="form-control">
<option value="8"></option></select></span>
<span><label style="width:80px;">危险灯:</label><select style="width:65px;" id="dangerLight" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="width:80px;">倒车灯:</label><select style="width:65px;" id="backCarLight" class="form-control">
<option value="16"></option></select></span>
<span><label style="width:80px;">倒车灯:</label><select style="width:65px;" id="backCarLight" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="width:80px;">auto灯:</label><select style="width:65px;" id="autoLight" class="form-control">
<option value="32"></option></select></span>
<span><label style="width:80px;">auto灯:</label><select style="width:65px;" id="autoLight" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<sapn><label style="width:80px;">示宽灯:</label><select style="width:65px;" id="widthLight" class="form-control">
<option value="64"></option></select></span>
<span><label style="width:80px;">示宽灯:</label><select style="width:65px;" id="widthLight" class="form-control">
<option value="0"></option>
<option value="128"></option></select></sapn>
<option value="128"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>开关状态A:</h4>
<div style="width:100%" id="swichStatusA">
<sapn><label>机油报警:</label><select style="width:65px;" id="machineOilWarning" class="form-control">
<span><label>机油报警:</label><select style="width:65px;" id="machineOilWarning" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label>燃油报警:</label><select style="width:65px;" id="oilWarning" class="form-control">
<option value="1"></option></select></span>
<span><label>燃油报警:</label><select style="width:65px;" id="oilWarning" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>雨刷报警:</label><select style="width:65px;" id="wiperWarning" class="form-control">
<option value="2"></option></select></span>
<span><label>雨刷报警:</label><select style="width:65px;" id="wiperWarning" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>喇叭报警:</label><select style="width:65px;" id="loudsspeakerWaring" class="form-control">
<option value="4"></option></select></span>
<span><label>喇叭报警:</label><select style="width:65px;" id="loudsspeakerWaring" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>空调:</label><select style="width:65px;" id="airConditionerWaring" class="form-control">
<option value="8"></option></select></span>
<span><label>空调:</label><select style="width:65px;" id="airConditionerWaring" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label>后视镜状态:</label><select style="width:65px;" id="backMirrorWaring" class="form-control">
<option value="16"></option></select></span>
<span><label>后视镜状态:</label><select style="width:65px;" id="backMirrorWaring" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<option value="32"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>开关状态B:</h4>
<div style="width:100%" id="swichStatusB">
<sapn><label>档位:</label><select style="width:100px;" id="gears" class="form-control">
<span><label>档位:</label><select style="width:100px;" id="gears" class="form-control">
<option value="0">P档</option>
<option value="16">R档</option>
<option value="32">N档</option>
......@@ -185,29 +185,29 @@
<option value="128">5档</option>
<option value="144">6档</option>
<option value="160">M档</option>
<option value="176">S档</option></select></sapn>
<option value="176">S档</option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>数据字节:</h4>
<div style="width:100%" id="dataBit">
<sapn><label>V1N1:</label><select style="width:90px;" id="V1N1" class="form-control">
<span><label>V1N1:</label><select style="width:90px;" id="V1N1" class="form-control">
<option value="1">存在</option>
<option value="0">不存在</option></select></sapn>
<sapn><label>总线总里程:</label><select style="width:90px;" id="busMileage" class="form-control">
<option value="0">不存在</option></select></span>
<span><label>总线总里程:</label><select style="width:90px;" id="busMileage" class="form-control">
<option value="8">存在</option>
<option value="0">不存在</option></select></sapn>
<sapn><label>仪表数据:</label><select style="width:90px;" id="dashboardData" class="form-control">
<option value="0">不存在</option></select></span>
<span><label>仪表数据:</label><select style="width:90px;" id="dashboardData" class="form-control">
<option value="16">存在</option>
<option value="0">不存在</option></select></sapn>
<sapn><label>发动机转速:</label><select style="width:90px;" id="engineSpeed_dataBit" class="form-control">
<option value="0">不存在</option></select></span>
<span><label>发动机转速:</label><select style="width:90px;" id="engineSpeed_dataBit" class="form-control">
<option value="32">存在</option>
<option value="0">不存在</option></select></sapn>
<sapn><label>车辆速度:</label><select style="width:90px;" id="carSpeed" class="form-control">
<option value="0">不存在</option></select></span>
<span><label>车辆速度:</label><select style="width:90px;" id="carSpeed" class="form-control">
<option value="64">存在</option>
<option value="0">不存在</option></select></sapn>
<sapn><label>剩余油量:</label><select style="width:90px;" id="surplueOil" class="form-control">
<option value="0">不存在</option></select></span>
<span><label>剩余油量:</label><select style="width:90px;" id="surplueOil" class="form-control">
<option value="128">存在</option>
<option value="0">不存在</option></select></sapn>
<option value="0">不存在</option></select></span>
</div>
</li>
......
......@@ -16,18 +16,18 @@
<H3 style="border-bottom: 1px solid #eee;">设置GPS消息内容:</H3>
<ul class="protocol_content" style="padding:0px;">
<li><label>日期:</label><input id="dateInfo" type="text" class="form-control" value=""></li>
<li style="width:495px;"><label>维度:</label><sapn>
<li style="width:495px;"><label>维度:</label><span>
<input id="latitude" type="text" class="form-control" value="40.22077">
<select style="width:80px;" id="latitudeType" class="form-control">
<option value="0">北纬</option>
<option value="1">南纬</option></select>
</sapn></li>
<li style="width:495px;"><label>经度:</label><sapn>
</span></li>
<li style="width:495px;"><label>经度:</label><span>
<input id="longitude" type="text" class="form-control" value="116.23128">
<select style="width:80px;" id="longitudeType" class="form-control">
<option value="0">东经</option>
<option value="1">西经</option></select>
</sapn></li>
</span></li>
<li><label>定位星数:</label><input id="positionStar" type="text" class="form-control" value="2"></li>
<li><label>速度:</label><input id="speed" type="text" class="form-control" value="66.0"></li>
<li><label>方向角:</label><input id="direction" type="text" class="form-control" value="55.3"></li>
......
......@@ -15,21 +15,24 @@
</div>
<H3 style="border-bottom: 1px solid #eee;">设置报警消息内容:</H3>
<div style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;">
<h4>GPS报警信息</h4>
<ul class="protocol_content" style="padding:0px;">
<h5>GPS报警信息<span style="margin-left:10px;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="gps_radio" type="radio" value="0" checked="checked" onclick="isShowGPS_area(this)"/>隐藏</label>
<label style="margin-left:10px;"><input name="gps_radio" type="radio" value="1" onclick="isShowGPS_area(this)"/>显示</label>
</span></h5>
<ul class="protocol_content" style="padding:0px;display:none;" id="GPS_area">
<li><label>日期:</label><input id="dateInfo" type="text" class="form-control" value=""></li>
<li style="width:495px;"><label>维度:</label><sapn>
<li style="width:495px;"><label>维度:</label><span>
<input id="latitude" type="text" class="form-control" value="40.22077">
<select style="width:80px;" id="latitudeType" class="form-control">
<option value="0">北纬</option>
<option value="1">南纬</option></select>
</sapn></li>
<li style="width:495px;"><label>经度:</label><sapn>
</span></li>
<li style="width:495px;"><label>经度:</label><span>
<input id="longitude" type="text" class="form-control" value="116.23128">
<select style="width:80px;" id="longitudeType" class="form-control">
<option value="0">东经</option>
<option value="1">西经</option></select>
</sapn></li>
</span></li>
<li><label>定位星数:</label><input id="positionStar" type="text" class="form-control" value="2"></li>
<li><label>速度:</label><input id="speed" type="text" class="form-control" value="66.0"></li>
<li><label>方向角:</label><input id="direction" type="text" class="form-control" value="55.3"></li>
......@@ -49,166 +52,169 @@
</ul>
</div>
<div style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;margin-top:5px;">
<h4>GSM主基站数据包</h4>
<h5>GSM主基站数据包</h5>
<ul class="protocol_content" style="padding:0px;">
<li><label>运营商类别:</label><sapn>
<li><label>运营商类别:</label><span>
<select style="width:120px;" id="operatorType" class="form-control">
<option value="1">移动</option>
<option value="2">联通</option>
<option value="3">电信</option>
</select>
</sapn></li>
</span></li>
<li><label>服务器LAC:</label><input id="LAC" type="text" class="form-control" value="1234"></li>
<li><label style="word-break:break-all;font-size:10px;">服务器CellID:</label><input id="CellID" type="text" class="form-control" value="5678"></li>
<li><label style="word-break:break-all;font-size:10px;">服务器CellID:</label><input id="CellId" type="text" class="form-control" value="5678"></li>
</ul>
</div>
<div style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;margin-top:5px;">
<h4>CAN状态数据包</h4>
<ul class="protocol_content" style="padding:0px;">
<h5>CAN状态数据包<span style="margin-left:10px;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="canObd" type="radio" value="0" checked="checked" onclick="isShowCAN_area(this)"/>隐藏</label>
<label style="margin-left:10px;"><input name="canObd" type="radio" value="1" onclick="isShowCAN_area(this)"/>显示</label>
</span></h5>
<ul class="protocol_content" style="padding:0px;display:none;" id="CAN_area">
<li style="width:350px;"><label>状态掩码:</label><input style="width:250px;" id="statusMask" type="text" class="form-control" value="ffffffffffffffffffff"></li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>安全状态:</h4>
<div style="width:100%" id="safeStatus">
<sapn><label>ACC状态:</label><select style="width:65px;" id="CAN_accStatus" class="form-control">
<span><label>ACC状态:</label><select style="width:65px;" id="CAN_accStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">设防撤防状态:</label><select style="width:65px;" id="defenseStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">设防撤防状态:</label><select style="width:65px;" id="defenseStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>脚刹状态:</label><select style="width:65px;" id="brakeStatus" class="form-control">
<option value="2"></option></select></span>
<span><label>脚刹状态:</label><select style="width:65px;" id="brakeStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>是否踩油门:</label><select style="width:65px;" id="acceleratorStatus" class="form-control">
<option value="4"></option></select></span>
<span><label>是否踩油门:</label><select style="width:65px;" id="acceleratorStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>手刹状态:</label><select style="width:65px;" id="handBrakeStatus" class="form-control">
<option value="8"></option></select></span>
<span><label>手刹状态:</label><select style="width:65px;" id="handBrakeStatus" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">主驾驶安全带:</label><select style="width:65px;" id="mainSafetyBelt" class="form-control">
<option value="16"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">主驾驶安全带:</label><select style="width:65px;" id="mainSafetyBelt" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">副驾驶安全带:</label><select style="width:65px;" id="subSafetyBelt" class="form-control">
<option value="32"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">副驾驶安全带:</label><select style="width:65px;" id="subSafetyBelt" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<option value="64"></option></select></span>
</div>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>门状态:</h4>
<div style="width:100%" id="doorStatus">
<sapn><label>左前门:</label><select style="width:65px;" id="lfDoorStatus" class="form-control">
<span><label>左前门:</label><select style="width:65px;" id="lfDoorStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label>右前门:</label><select style="width:65px;" id="rfDoorStatus" class="form-control">
<option value="1"></option></select></span>
<span><label>右前门:</label><select style="width:65px;" id="rfDoorStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>左后门:</label><select style="width:65px;" id="lbDoorStatus" class="form-control">
<option value="2"></option></select></span>
<span><label>左后门:</label><select style="width:65px;" id="lbDoorStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>右后门:</label><select style="width:65px;" id="rbDoorStatus" class="form-control">
<option value="4"></option></select></span>
<span><label>右后门:</label><select style="width:65px;" id="rbDoorStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>后备箱:</label><select style="width:65px;" id="trunk" class="form-control">
<option value="8"></option></select></span>
<span><label>后备箱:</label><select style="width:65px;" id="trunk" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label>发动机盖:</label><select style="width:65px;" id="enginCover" class="form-control">
<option value="16"></option></select></span>
<span><label>发动机盖:</label><select style="width:65px;" id="enginCover" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<option value="32"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>锁状态:</h4>
<div style="width:100%" id="lockStatus">
<sapn><label style="word-break:break-all;font-size:10px;">左前门锁状态:</label><select style="width:65px;" id="lfDoorLockStatus" class="form-control">
<span><label style="word-break:break-all;font-size:10px;">左前门锁状态:</label><select style="width:65px;" id="lfDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">右前门锁状态:</label><select style="width:65px;" id="rfDoorLockStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">右前门锁状态:</label><select style="width:65px;" id="rfDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">左后门锁状态:</label><select style="width:65px;" id="lbDoorLockStatus" class="form-control">
<option value="2"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">左后门锁状态:</label><select style="width:65px;" id="lbDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="word-break:break-all;font-size:10px;">右后门锁状态:</label><select style="width:65px;" id="rbDoorLockStatus" class="form-control">
<option value="4"></option></select></span>
<span><label style="word-break:break-all;font-size:10px;">右后门锁状态:</label><select style="width:65px;" id="rbDoorLockStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<option value="8"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>窗户状态:</h4>
<div style="width:100%" id="windowStatus">
<sapn><label style="width:80px;">左前窗:</label><select style="width:65px;" id="lfWindowStatus" class="form-control">
<span><label style="width:80px;">左前窗:</label><select style="width:65px;" id="lfWindowStatus" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="width:80px;">右前窗:</label><select style="width:65px;" id="rfWindowStatus" class="form-control">
<option value="1"></option></select></span>
<span><label style="width:80px;">右前窗:</label><select style="width:65px;" id="rfWindowStatus" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="width:80px;">左后窗:</label><select style="width:65px;" id="lbWindowStatus" class="form-control">
<option value="2"></option></select></span>
<span><label style="width:80px;">左后窗:</label><select style="width:65px;" id="lbWindowStatus" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="width:80px;">右后窗:</label><select style="width:65px;" id="rbWindowStatus" class="form-control">
<option value="4"></option></select></span>
<span><label style="width:80px;">右后窗:</label><select style="width:65px;" id="rbWindowStatus" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label style="width:80px;">天窗开关:</label><select style="width:65px;" id="topWindowStatus" class="form-control">
<option value="8"></option></select></span>
<span><label style="width:80px;">天窗开关:</label><select style="width:65px;" id="topWindowStatus" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="width:80px;">左转向灯:</label><select style="width:65px;" id="lTurnLight" class="form-control">
<option value="16"></option></select></span>
<span><label style="width:80px;">左转向灯:</label><select style="width:65px;" id="lTurnLight" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="width:80px;">右转向灯:</label><select style="width:65px;" id="rTurnLight" class="form-control">
<option value="32"></option></select></span>
<span><label style="width:80px;">右转向灯:</label><select style="width:65px;" id="rTurnLight" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<sapn><label style="width:80px;">阅读灯:</label><select style="width:65px;" id="readLight" class="form-control">
<option value="64"></option></select></span>
<span><label style="width:80px;">阅读灯:</label><select style="width:65px;" id="readLight" class="form-control">
<option value="0"></option>
<option value="128"></option></select></sapn>
<option value="128"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>灯状态:</h4>
<div style="width:100%" id="lightStatus">
<sapn><label style="width:80px;">近光灯:</label><select style="width:65px;" id="lowHeadlight" class="form-control">
<span><label style="width:80px;">近光灯:</label><select style="width:65px;" id="lowHeadlight" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label style="width:80px;">远光灯:</label><select style="width:65px;" id="highHeadlight" class="form-control">
<option value="1"></option></select></span>
<span><label style="width:80px;">远光灯:</label><select style="width:65px;" id="highHeadlight" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label style="width:80px;">前雾灯:</label><select style="width:65px;" id="ffogLight" class="form-control">
<option value="2"></option></select></span>
<span><label style="width:80px;">前雾灯:</label><select style="width:65px;" id="ffogLight" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label style="width:80px;">后雾灯:</label><select style="width:65px;" id="bfogLight" class="form-control">
<option value="4"></option></select></span>
<span><label style="width:80px;">后雾灯:</label><select style="width:65px;" id="bfogLight" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label style="width:80px;">危险灯:</label><select style="width:65px;" id="dangerLight" class="form-control">
<option value="8"></option></select></span>
<span><label style="width:80px;">危险灯:</label><select style="width:65px;" id="dangerLight" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label style="width:80px;">倒车灯:</label><select style="width:65px;" id="backCarLight" class="form-control">
<option value="16"></option></select></span>
<span><label style="width:80px;">倒车灯:</label><select style="width:65px;" id="backCarLight" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<sapn><label style="width:80px;">auto灯:</label><select style="width:65px;" id="autoLight" class="form-control">
<option value="32"></option></select></span>
<span><label style="width:80px;">auto灯:</label><select style="width:65px;" id="autoLight" class="form-control">
<option value="0"></option>
<option value="64"></option></select></sapn>
<sapn><label style="width:80px;">示宽灯:</label><select style="width:65px;" id="widthLight" class="form-control">
<option value="64"></option></select></span>
<span><label style="width:80px;">示宽灯:</label><select style="width:65px;" id="widthLight" class="form-control">
<option value="0"></option>
<option value="128"></option></select></sapn>
<option value="128"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>开关状态A:</h4>
<div style="width:100%" id="swichStatusA">
<sapn><label>机油报警:</label><select style="width:65px;" id="machineOilWarning" class="form-control">
<span><label>机油报警:</label><select style="width:65px;" id="machineOilWarning" class="form-control">
<option value="0"></option>
<option value="1"></option></select></sapn>
<sapn><label>燃油报警:</label><select style="width:65px;" id="oilWarning" class="form-control">
<option value="1"></option></select></span>
<span><label>燃油报警:</label><select style="width:65px;" id="oilWarning" class="form-control">
<option value="0"></option>
<option value="2"></option></select></sapn>
<sapn><label>雨刷报警:</label><select style="width:65px;" id="wiperWarning" class="form-control">
<option value="2"></option></select></span>
<span><label>雨刷报警:</label><select style="width:65px;" id="wiperWarning" class="form-control">
<option value="0"></option>
<option value="4"></option></select></sapn>
<sapn><label>喇叭报警:</label><select style="width:65px;" id="loudsspeakerWaring" class="form-control">
<option value="4"></option></select></span>
<span><label>喇叭报警:</label><select style="width:65px;" id="loudsspeakerWaring" class="form-control">
<option value="0"></option>
<option value="8"></option></select></sapn>
<sapn><label>空调:</label><select style="width:65px;" id="airConditionerWaring" class="form-control">
<option value="8"></option></select></span>
<span><label>空调:</label><select style="width:65px;" id="airConditionerWaring" class="form-control">
<option value="0"></option>
<option value="16"></option></select></sapn>
<sapn><label>后视镜状态:</label><select style="width:65px;" id="backMirrorWaring" class="form-control">
<option value="16"></option></select></span>
<span><label>后视镜状态:</label><select style="width:65px;" id="backMirrorWaring" class="form-control">
<option value="0"></option>
<option value="32"></option></select></sapn>
<option value="32"></option></select></span>
</div>
</li>
<li style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"><h4>开关状态B:</h4>
<div style="width:100%" id="swichStatusB">
<sapn><label>档位:</label><select style="width:100px;" id="gears" class="form-control">
<span><label>档位:</label><select style="width:100px;" id="gears" class="form-control">
<option value="0">P档</option>
<option value="16">R档</option>
<option value="32">N档</option>
......@@ -220,11 +226,15 @@
<option value="128">5档</option>
<option value="144">6档</option>
<option value="160">M档</option>
<option value="176">S档</option></select></sapn>
<option value="176">S档</option></select></span>
</div>
</li>
</ul>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;">
<h5><b>选择要上报的事件:</b></h5>
<label style="padding: 0px 10px;"><input type="checkbox" id="0001" onclick="alarmSelect(this)" class="alarm_select"/>点火 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0002" onclick="alarmSelect(this)" class="alarm_select"/>熄火 </label>
</div>
<H3 style="border-bottom: 1px solid #eee;">控制:</H3>
<div style="width:100%;padding:5px;margin-top:10px;">
......@@ -239,13 +249,61 @@
<script>
//发送GPS数据
//发送报警事件数据
$("#sendMsgBtn").click(function(){
var FUNID = $("#FUNID").val();
var waterCode = $("#waterCode").val();
var DEV_ID = $("#DEV_ID").val();
var encryptionType = $("#encryptionType").val();
if ($(".alarm_select:checked").length > 1){
alert("不能同时选择多个报警事件")
}else if($(".alarm_select:checked").length == 0){
alert("请至少选择一个报警事件")
}else{
var FUNID = $("#FUNID").val();
var waterCode = $("#waterCode").val();
var DEV_ID = $("#DEV_ID").val();
var encryptionType = $("#encryptionType").val();
var GPSData = getGpsData();
var OBDCANData = getOBDCANData();
var GSMData = getGSMData();
var alarm = alarmData()
var data = {};
data["FUNID"] = FUNID;
data["waterCode"] = waterCode;
data["DEV_ID"] = DEV_ID;
data["encryptionType"] = encryptionType;
data["GPSData"] = GPSData;
data["OBDCANData"] = OBDCANData;
data["GSMData"] = GSMData;
data["alarm"] = alarm;
//console.log(data)
//console.log(JSON.stringify(data))
var host = window.location.host;
$("#showFeedback").val("")
$.ajax({
url:"http://" + host + "/m300Tools/P_m300Protocol_process/porcessAlarmMsg",
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var theShow = "原始数据: " + data.msgSend + "\n";
theShow = theShow + "收到数据: " + data.result + "\n";
theShow = theShow + "收到数据16进制: " + data.rev + "\n";
theShow = theShow + "解析数据: " + JSON.stringify(data.orgRev) + "\n";
$("#showFeedback").val(theShow)
}else{
$("#showFeedback").val(data.message)
alert(data.message);
}
}
});
}
});
//获取GPS数据
function getGpsData(){
var dateInfo = $("#dateInfo").val();
var latitude = parseFloat($("#latitude").val());
var latitudeType = parseInt($("#latitudeType").val());
......@@ -268,13 +326,7 @@ $("#sendMsgBtn").click(function(){
var valid_2 = parseInt($("#valid_2").val());
var valid = valid_1 + valid_2
var tripMark = $("#tripMark").val();
var data = {};
data["FUNID"] = FUNID;
data["waterCode"] = waterCode;
data["DEV_ID"] = DEV_ID;
data["encryptionType"] = encryptionType;
data["dateInfo"] = dateInfo;
data["latitude"] = latitude;
data["longitude"] = longitude;
......@@ -287,34 +339,130 @@ $("#sendMsgBtn").click(function(){
data["OBDSpeed"] = OBDSpeed;
data["valid"] = valid;
data["tripMark"] = tripMark;
return data
}
//获取OBD CAN 数据
function getOBDCANData(){
var statusMask = $("#statusMask").val();
var accStatus = parseInt($("#CAN_accStatus").val());
var defenseStatus = parseInt($("#defenseStatus").val());
var brakeStatus = parseInt($("#brakeStatus").val());
var acceleratorStatus = parseInt($("#acceleratorStatus").val());
var handBrakeStatus = parseInt($("#handBrakeStatus").val());
var mainSafetyBelt = parseInt($("#mainSafetyBelt").val());
var subSafetyBelt = parseInt($("#subSafetyBelt").val());
var host = window.location.host;
$("#showFeedback").val("")
$.ajax({
url:"http://" + host + "/m300Tools/P_m300Protocol_process/porcessGPSMsg",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var theShow = "原始数据: " + data.msgSend + "\n";
theShow = theShow + "收到数据: " + data.result + "\n";
theShow = theShow + "收到数据16进制: " + data.rev + "\n";
theShow = theShow + "解析数据: " + JSON.stringify(data.orgRev) + "\n";
$("#showFeedback").val(theShow)
}else{
$("#showFeedback").val(data.message)
alert(data.message);
}
}
});
});
var safeStatus = accStatus + defenseStatus + brakeStatus + acceleratorStatus + handBrakeStatus + mainSafetyBelt + subSafetyBelt
var lfDoorStatus = parseInt($("#lfDoorStatus").val());
var rfDoorStatus = parseInt($("#rfDoorStatus").val());
var lbDoorStatus = parseInt($("#lbDoorStatus").val());
var rbDoorStatus = parseInt($("#rbDoorStatus").val());
var trunk = parseInt($("#trunk").val());
var enginCover = parseInt($("#enginCover").val());
var doorStatus = lfDoorStatus + rfDoorStatus + lbDoorStatus + rbDoorStatus + trunk + enginCover
var lfDoorLockStatus = parseInt($("#lfDoorLockStatus").val());
var rfDoorLockStatus = parseInt($("#rfDoorLockStatus").val());
var lbDoorLockStatus = parseInt($("#lbDoorLockStatus").val());
var rbDoorLockStatus = parseInt($("#rbDoorLockStatus").val());
var lockStatus = lfDoorLockStatus + rfDoorLockStatus + lbDoorLockStatus + rbDoorLockStatus
var lfWindowStatus = parseInt($("#lfWindowStatus").val());
var rfWindowStatus = parseInt($("#rfWindowStatus").val());
var lbWindowStatus = parseInt($("#lbWindowStatus").val());
var rbWindowStatus = parseInt($("#rbWindowStatus").val());
var topWindowStatus = parseInt($("#topWindowStatus").val());
var lTurnLight = parseInt($("#lTurnLight").val());
var rTurnLight = parseInt($("#rTurnLight").val());
var readLight = parseInt($("#readLight").val());
var windowStatus = lfWindowStatus + rfWindowStatus + lbWindowStatus + rbWindowStatus + topWindowStatus + lTurnLight + rTurnLight + readLight
var lowHeadlight = parseInt($("#lowHeadlight").val());
var highHeadlight = parseInt($("#highHeadlight").val());
var ffogLight = parseInt($("#ffogLight").val());
var bfogLight = parseInt($("#bfogLight").val());
var dangerLight = parseInt($("#dangerLight").val());
var backCarLight = parseInt($("#backCarLight").val());
var autoLight = parseInt($("#autoLight").val());
var widthLight = parseInt($("#widthLight").val());
var lightStatus = lowHeadlight + highHeadlight + ffogLight + bfogLight + dangerLight + backCarLight + autoLight + widthLight
var machineOilWarning = parseInt($("#machineOilWarning").val());
var oilWarning = parseInt($("#oilWarning").val());
var wiperWarning = parseInt($("#wiperWarning").val());
var loudsspeakerWaring = parseInt($("#loudsspeakerWaring").val());
var airConditionerWaring = parseInt($("#airConditionerWaring").val());
var backMirrorWaring = parseInt($("#backMirrorWaring").val());
var swichStatusA = machineOilWarning + oilWarning + wiperWarning + loudsspeakerWaring + airConditionerWaring + backMirrorWaring
var swichStatusB = parseInt($("#gears").val());
var data = {};
data["statusMask"] = statusMask;
data["safeStatus"] = safeStatus;
data["doorStatus"] = doorStatus;
data["lockStatus"] = lockStatus;
data["windowStatus"] = windowStatus;
data["lightStatus"] = lightStatus;
data["swichStatusA"] = swichStatusA;
data["swichStatusB"] = swichStatusB;
return data
}
//获取GSM主基站数据
function getGSMData(){
var operatorType = $("#operatorType").val();
var LAC = $("#LAC").val();
var CellId = $("#CellId").val();
var data = {};
data["operatorType"] = operatorType;
data["LAC"] = LAC;
data["CellId"] = CellId;
return data
}
//获取报警数据
function alarmData(){
var data = {}
if($("#0001").is(':checked')){
data["0001"] = get0001(); //获取点火事件数据
}
if($("#0002").is(':checked')){
data["0002"] = get0002(); //获取熄火事件数据
}
return data;
}
function get0001(){
return {};
}
function get0002(){
return {};
}
//事件的选择与取消选择
function alarmSelect(){
}
//设置当前时间到UTC时间输入框
(function(){
var curTime = getCurTime();
$("#dateInfo").val(curTime);
})();
function isShowCAN_area(e){
var val = $(e).val()
if(val == "0"){
$("#CAN_area").css("display","none")
}else{
$("#CAN_area").css("display","block")
}
}
function isShowGPS_area(e){
var val = $(e).val()
if(val == "0"){
$("#GPS_area").css("display","none")
}else{
$("#GPS_area").css("display","block")
}
}
</script>
{% endblock %}
\ No newline at end of file
......@@ -19,7 +19,7 @@
<li><label>软件日期:</label><input id="SWDate" type="text" class="form-control" value="2020-03-30"></li>
<li><label>硬件版本:</label><input id="HWVersion" type="text" class="form-control" value="M1.0"></li>
<li><label>GSM 型号:</label><input id="GSMType" type="text" class="form-control" value="GSM_type_123456"></li>
<li><label>车系车型ID:</label><input id="carType" type="text" class="form-control" value="150D"></li>
<li><label>车系车型ID:</label><input id="carType" type="text" class="form-control" value="150"></li>
<li><label style="word-break:break-all;font-size:10px;">发动机编码类别:</label><input id="engineCode" type="text" class="form-control" value="1"></li>
<li style="width:350px;"><label style="word-break:break-all;font-size:10px;">汽车VIN码或发动机ECU编码:</label><input style="width:250px;" id="VINCode" type="text" class="form-control" value="VIN_CODE_01234567890"></li>
</ul>
......
#coding:utf-8
from flask import Blueprint ,Response,request
from configparser import ConfigParser
import json
import traceback
M_m300Simulater_process = Blueprint('M_m300Simulater_process', __name__)
connects = {} #用来保存连接的信息s
websocket = None #保存创建的websocket
##########################################
# 【接口类型】设置socket信息
##########################################
@M_m300Simulater_process.route("/porcessSocketSetting",methods=['POST'])
def porcessSocketSetting():
host = request.form.get("host")
port = request.form.get("port")
data = {}
if (host == None or port == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
# d读取config文件
conf_R = ConfigParser()
conf_R.read("config/m300Tools/m300Simulater.conf")
conf_W = conf_R
conf_W["socket"]["host"] = host
conf_W["socket"]["port"] = port
with open("config/m300Tools/m300Simulater.conf", "w") as fi:
conf_W.write(fi)
data["status"] = "200"
data["message"] = "Sucess: "
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
#coding:utf-8
from configparser import ConfigParser
from flask import Blueprint, render_template ,request
import re
from lib.util import fileUtil
M_m300Simulater_view = Blueprint('M_m300Simulater_view', __name__)
##########################################
# 【视图类型】访问车机模拟器页面
##########################################
@M_m300Simulater_view.route('/M_m300Simulater_page')
def M_m300Simulater_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "m300Tools/report/M_m300Simulater_page.html"
arg["path"] = reqPath.split("/")
arg["gpsLines"] = fileUtil.getDirFilesListMap("data/protocolTools/GPSLines")
return render_template(path,arg=arg)
##########################################
# 【视图类型】访问模拟器设置页面
##########################################
@M_m300Simulater_view.route('/M_m300Setting_page')
def M_m300Setting_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "m300Tools/report/M_m300Setting_page.html"
arg["path"] = reqPath.split("/")
arg["socket"] = {}
# 读取config文件
conf_R = ConfigParser()
conf_R.read("config/m300Tools/m300Simulater.conf")
arg["socket"]["host"] = conf_R.get("socket", "host")
arg["socket"]["port"] = conf_R.getint("socket", "port")
return render_template(path,arg=arg)
\ No newline at end of file
......@@ -3,6 +3,7 @@
from flask import Blueprint ,Response,request
from configparser import ConfigParser
from lib.protocol.m300.Alarm_protocol_m300 import Alarm_protocol_m300
from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from lib.protocol.m300.Heartbeat_protocol_300 import Heartbeat_protocol_300
from lib.protocol.m300.Login_protocol_m300 import Login_protocol_m300
......@@ -16,6 +17,8 @@ import json
import traceback
import binascii
from lib.util.jsonUtil import hasJsonDataIsNone
P_m300Protocol_process = Blueprint('P_m300Protocol_process', __name__)
##########################################
......@@ -364,4 +367,42 @@ def porcessCANMsg():
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】处理发送的报警报文
##########################################
@P_m300Protocol_process.route("/porcessAlarmMsg",methods=['POST'])
def porcessAlarmMsg():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
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/m300Tools/m300Tools.conf")
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
protocolObj = Alarm_protocol_m300(waterCode=int(params["waterCode"]),DEV_ID=params["DEV_ID"],encryptionType=int(params["encryptionType"]), \
alarmType=list(params["alarm"].keys())[0],data=params)
msg = protocolObj.generateMsg()
cliSocket.send(msg)
socRecv = cliSocket.receive()
socRecvo = str(socRecv)
cliSocket.close()
data["status"] = "200"
data["message"] = "Sucess: "
data["msgSend"] = msg
data["result"] = socRecvo
data["rev"] = str(binascii.b2a_hex(socRecv))[2:][:-1]
data["orgRev"] = json.loads(M300Common_res(data["rev"]).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