Commit cc9ab483 authored by liyuanhong's avatar liyuanhong

M300模拟器开发完成

parent 910ca259
{"time": {"dateTime": "2020-05-29 18:06:43", "date": "2020-05-29", "time": "18:06:43"}, "curDayTravel": {"todayTotalMilleage": 166, "todayTotalOil": 16, "todayTotalTime": 10, "theMilleage": 166, "theOil": 16, "theTime": 10}, "travelData": {"totalMilleage": 166, "totalOil": 16, "totalTime": 10}}
\ No newline at end of file
{"time": {"dateTime": "2020-05-28 10:09:51", "date": "2020-05-28", "time": "10:09:51"}, "curDayTravel": {"todayTotalMilleage": 5491, "todayTotalOil": 421, "todayTotalTime": 338, "theMilleage": 1497, "theOil": 102, "theTime": 93}, "travelData": {"totalMilleage": 341804, "totalOil": 32099, "totalTime": 20303}, "event": {"threeRapid": {"totalRapidlyAccelerate": 19, "totalSharpSlowdown": 18, "totalSharpTurn": 17}}} {"time": {"dateTime": "2020-05-29 14:34:14", "date": "2020-05-29", "time": "14:34:14"}, "curDayTravel": {"todayTotalMilleage": 1469, "todayTotalOil": 134, "todayTotalTime": 89, "theMilleage": 307, "theOil": 22, "theTime": 19}, "travelData": {"totalMilleage": 343273, "totalOil": 32233, "totalTime": 20392}, "event": {"threeRapid": {"totalRapidlyAccelerate": 19, "totalSharpSlowdown": 18, "totalSharpTurn": 17}}}
\ No newline at end of file \ No newline at end of file
...@@ -21,10 +21,12 @@ class Alarm_protocol_m300(M300Base): ...@@ -21,10 +21,12 @@ class Alarm_protocol_m300(M300Base):
self.GSMPkg = "0000000000" self.GSMPkg = "0000000000"
self.CANStatus = "ffffffffffffffffffff00000000000000000000" self.CANStatus = "ffffffffffffffffffff00000000000000000000"
else: else:
self.waterCode = data["waterCode"]
self.DEV_ID = data["DEV_ID"]
self.alarm = data["alarm"]
GPSData = data["GPSData"] GPSData = data["GPSData"]
GSMData = data["GSMData"] GSMData = data["GSMData"]
OBDData = data["OBDCANData"] OBDData = data["OBDCANData"]
self.alarm = data["alarm"]
self.GPSPkg = GPS_protocol_m300(dateInfo=GPSData["dateInfo"],latitude=float(GPSData["latitude"]),longitude=float(GPSData["longitude"]) \ 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"]), \ ,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"]), \ altitude=float(GPSData["altitude"]),ACCStatus=int(GPSData["ACCStatus"]),valtage=float(GPSData["valtage"]),OBDSpeed=float(GPSData["OBDSpeed"]), \
......
...@@ -66,9 +66,9 @@ class OBDCAN_protocol_m300(M300Base): ...@@ -66,9 +66,9 @@ class OBDCAN_protocol_m300(M300Base):
self.timeInfo = data self.timeInfo = data
def setAccstatus(self,data): def setAccstatus(self,data):
if data == 1: if data == 1:
return self.safeStatus | 1 self.safeStatus = self.safeStatus | 1
elif data == 0: elif data == 0:
return self.safeStatus & ~1 self.safeStatus = self.safeStatus & ~1
def setEngineSpeed(self,data): def setEngineSpeed(self,data):
self.engineSpeed = data self.engineSpeed = data
def setSpeed(self,data): def setSpeed(self,data):
......
...@@ -43,28 +43,6 @@ class M300SimulaterDataService(): ...@@ -43,28 +43,6 @@ class M300SimulaterDataService():
data["travelData"]["totalMilleage"] = 0 #行驶总里程 data["travelData"]["totalMilleage"] = 0 #行驶总里程
data["travelData"]["totalOil"] = 0 #行驶总油耗 data["travelData"]["totalOil"] = 0 #行驶总油耗
data["travelData"]["totalTime"] = 0 #行驶总时间 data["travelData"]["totalTime"] = 0 #行驶总时间
data["event"] = {}
data["event"]["threeRapid"] = {} #急加速,急减速,急转弯基本数据
data["event"]["threeRapid"]["totalRapidlyAccelerate"] = 0 #急加速总次数
data["event"]["threeRapid"]["totalSharpSlowdown"] = 0 #急减速总次数
data["event"]["threeRapid"]["totalSharpTurn"] = 0 #急转弯总次数
return data
####################################################
# 修复默认数据模板
# 用于在升级模拟器的时候,对增加的字段进行初始化
####################################################
def fixDataTemplate(self,data):
if not "event" in data:
data["event"] = {}
data["event"]["threeRapid"] = {}
data["event"]["threeRapid"]["totalRapidlyAccelerate"] = 0 # 急加速总次数
data["event"]["threeRapid"]["totalSharpSlowdown"] = 0 # 急减速总次数
data["event"]["threeRapid"]["totalSharpTurn"] = 0 # 急转弯总次数
if not "threeRapid" in data["event"]:
data["event"]["threeRapid"] = {}
data["event"]["threeRapid"]["totalRapidlyAccelerate"] = 0 #急加速总次数
data["event"]["threeRapid"]["totalSharpSlowdown"] = 0 #急减速总次数
data["event"]["threeRapid"]["totalSharpTurn"] = 0 #急转弯总次数
return data return data
#设今日行驶总里程,同时写入文件 #设今日行驶总里程,同时写入文件
...@@ -106,31 +84,6 @@ class M300SimulaterDataService(): ...@@ -106,31 +84,6 @@ class M300SimulaterDataService():
self.data["travelData"]["totalTime"] = data self.data["travelData"]["totalTime"] = data
self.writeToFile(self.path + self.fileName,self.data) self.writeToFile(self.path + self.fileName,self.data)
#设置急加速总次数,同时写入文件
def setTotalRapidlyAccelerateCount(self,data):
if not "event" in data:
data["event"] = {}
if not "threeRapid" in data["event"]:
data["event"]["threeRapid"] = {}
data["event"]["threeRapid"]["totalRapidlyAccelerate"] = data
self.writeToFile(self.path + self.fileName, self.data)
# 设置急减速总次数,同时写入文件
def setTotalSharpSlowdown(self,data):
if not "event" in data:
data["event"] = {}
if not "threeRapid" in data["event"]:
data["event"]["threeRapid"] = {}
data["event"]["threeRapid"]["totalSharpSlowdown"] = data
self.writeToFile(self.path + self.fileName, self.data)
# 设置急转弯总次数,同时写入文件
def setTotalSharpTurn(self,data):
if not "event" in data:
data["event"] = {}
if not "threeRapid" in data["event"]:
data["event"]["threeRapid"] = {}
data["event"]["threeRapid"]["totalSharpTurn"] = data
self.writeToFile(self.path + self.fileName, self.data)
#设今日日期时间 #设今日日期时间
def setDateTime2file(self,data): def setDateTime2file(self,data):
self.data["time"]["dateTime"] = data self.data["time"]["dateTime"] = data
......
This diff is collapsed.
...@@ -106,7 +106,7 @@ class MessageSimulaterService(): ...@@ -106,7 +106,7 @@ class MessageSimulaterService():
def revMsg(self): def revMsg(self):
self.socket.setTimeOut(self.timeout) self.socket.setTimeOut(self.timeout)
return self.socket.receive() return self.socket.receive()
#websocket向网页发送消息,可指定消息的描述类型 #websocket向网页发送消息
def serviceSendMsg(self,msg): def serviceSendMsg(self,msg):
self.sendMsg(msg) self.sendMsg(msg)
type = self.getMsgFunId(msg) type = self.getMsgFunId(msg)
......
...@@ -447,12 +447,12 @@ class ProtocolSimulaterService(): ...@@ -447,12 +447,12 @@ class ProtocolSimulaterService():
self.sn = self.sn + 1 self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + msg, self.websocketId) self.websocket.sendMsgToClient(type + ">>>>:" + msg, self.websocketId)
sleep(0.1) # sleep(0.1)
gpsMsg = self.genGPSMsg(self.gpsLine[gpsLineIndex]["lat"], self.gpsLine[gpsLineIndex]["lng"]) # gpsMsg = self.genGPSMsg(self.gpsLine[gpsLineIndex]["lat"], self.gpsLine[gpsLineIndex]["lng"])
type = self.getMsgFunId(gpsMsg) # type = self.getMsgFunId(gpsMsg)
self.sendMsg(gpsMsg) # self.sendMsg(gpsMsg)
self.sn = self.sn + 1 # self.sn = self.sn + 1
self.websocket.sendMsgToClient(type + ">>>>:" + gpsMsg,self.websocketId) # self.websocket.sendMsgToClient(type + ">>>>:" + gpsMsg,self.websocketId)
#根据特定参数,生成GPS消息 #根据特定参数,生成GPS消息
def genGPSMsg(self,latitude,longtitude,direct=0): def genGPSMsg(self,latitude,longtitude,direct=0):
......
This diff is collapsed.
...@@ -278,11 +278,11 @@ def fileUplad(): ...@@ -278,11 +278,11 @@ def fileUplad():
f = request.files.get('file') f = request.files.get('file')
file_content = f.read() file_content = f.read()
try: try:
file_content = file_content.decode("utf-8") file_content = file_content.decode("utf-8").replace("\n","")
except BaseException as e: except BaseException as e:
pass pass
try: try:
file_content = file_content.decode("gbk") file_content = file_content.decode("gbk").replace("\n","")
except BaseException as e: except BaseException as e:
pass pass
maxPrefix = int(fileUtil.getMaxPrefixFilePre("data/messageTools/GPSLines")) maxPrefix = int(fileUtil.getMaxPrefixFilePre("data/messageTools/GPSLines"))
......
...@@ -307,11 +307,11 @@ def fileUplad(): ...@@ -307,11 +307,11 @@ def fileUplad():
f = request.files.get('file') f = request.files.get('file')
file_content = f.read() file_content = f.read()
try: try:
file_content = file_content.decode("utf-8") file_content = file_content.decode("utf-8").replace("\n","")
except BaseException as e: except BaseException as e:
pass pass
try: try:
file_content = file_content.decode("gbk") file_content = file_content.decode("gbk").replace("\n","")
except BaseException as e: except BaseException as e:
pass pass
maxPrefix = int(fileUtil.getMaxPrefixFilePre("data/protocolTools/GPSLines")) maxPrefix = int(fileUtil.getMaxPrefixFilePre("data/protocolTools/GPSLines"))
......
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