Commit 705f5da0 authored by liyuanhong's avatar liyuanhong

新车机模拟器开发完成

parent d71af237
{"time": {"dateTime": "2020-04-24 11:28:51", "date": "2020-04-24", "time": "11:28:51"}, "curDayTravel": {"todayTotalMilleage": 1755, "todayTotalOil": 314, "todayTotalTime": 157, "theMilleage": 1738, "theOil": 158, "theTime": 79}, "travelData": {"totalMilleage": 1755, "totalOil": 314, "totalTime": 157}}
\ No newline at end of file
......@@ -187,9 +187,9 @@ class MessageSimulaterService():
self.OBDdata["baseInfo"]["longtitude"] = self.gpsLine[self.gpsLineIndex]["lng"]
self.OBDdata["extraInfo"]["EB"]["60C0"] = 0 #发动机转速
self.OBDdata["extraInfo"]["EB"]["60D0"] = 0 #车速
# self.OBDdata["extraInfo"]["EB"]["670a"] = self.carData["travelData"]["totalOil"] #总油耗
# self.OBDdata["extraInfo"]["EB"]["6709"] = self.carData["travelData"]["totalTime"] #总运行时间
# self.OBDdata["extraInfo"]["01"]["extra_01"] = self.carData["travelData"]["totalMilleage"] #总里程
self.OBDdata["extraInfo"]["EB"]["670a"] = self.carData["travelData"]["totalOil"] #总油耗
self.OBDdata["extraInfo"]["EB"]["6709"] = self.carData["travelData"]["totalTime"] #总运行时间
self.OBDdata["extraInfo"]["01"]["extra_01"] = self.carData["travelData"]["totalMilleage"] #总里程
obdMsg = msgObj.generateMsg_GUI(self.OBDdata)
self.sendMsg(obdMsg)
type = self.getMsgFunId(obdMsg)
......@@ -201,9 +201,11 @@ class MessageSimulaterService():
#车机行驶服务
########################################################
def serviceTrave(self):
plusMilleage = 0 #每次增加的里程数,上报的时候要除以100,因为原始文档总里程的单位是0.1km
plusMilleage2 = 0 #每次增加的里程数,用于写入文件 用,写入后置为0
while self.serviceStatus == 1:
gpsMsg = ""
obdMsg = ""
obdMsg = "" #对比比上一次上报,所增加的里程
if self.travelStatus == 0: #行驶服务未启动
gpsParams = {"msgID": "0200", "phoneNum": "13146201119", "msgWaterCode": "1", "encryptionType": "0",
"subPkg": "0","pkgCounts": "0", "baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.569133,
......@@ -254,7 +256,10 @@ class MessageSimulaterService():
self.OBDdata["extraInfo"]["EB"]["60D0"] = speed # 车速
self.OBDdata["extraInfo"]["EB"]["670a"] = self.OBDdata["extraInfo"]["EB"]["670a"] + int((self.sendDur * (speed * 1000 / 3600)) * (1000 / (oilExpend * 1000))) # 总油耗
self.OBDdata["extraInfo"]["EB"]["6709"] = self.OBDdata["extraInfo"]["EB"]["6709"] + self.sendDur # 总运行时间
self.OBDdata["extraInfo"]["01"]["extra_01"] = self.OBDdata["extraInfo"]["01"]["extra_01"] + int(self.sendDur * (speed * 1000 / 3600)) # 总里程
plusMilleage = plusMilleage + int(self.sendDur * (speed * 1000 / 3600))
plusMilleage2 = int(self.sendDur * (speed * 1000 / 3600))
self.OBDdata["extraInfo"]["01"]["extra_01"] = self.OBDdata["extraInfo"]["01"]["extra_01"] + int(plusMilleage / 100) # 总里程
plusMilleage = plusMilleage - int(plusMilleage / 100) * 100
obdObj = Location_msg()
obdMsg = obdObj.generateMsg_GUI(self.OBDdata)
if self.travelDirection == 0:
......@@ -278,7 +283,8 @@ class MessageSimulaterService():
"subPkg": "0", "pkgCounts": "0",
"baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.569133,
"longtitude": 106.586571, "elevation": "521", "speed": "0",
"directionAngle": "59", "infoTime": "2020-04-21 18:09:34"}}
"directionAngle": "59", "infoTime": "2020-04-21 18:09:34"},
"extraInfo": {}}
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
......@@ -301,12 +307,15 @@ class MessageSimulaterService():
self.OBDdata["extraInfo"]["EB"]["60D0"] = speed # 车速
self.OBDdata["extraInfo"]["EB"]["670a"] = self.OBDdata["extraInfo"]["EB"]["670a"] + int((self.sendDur * (speed * 1000 / 3600)) * (1000 / (oilExpend * 1000))) # 总油耗
self.OBDdata["extraInfo"]["EB"]["6709"] = self.OBDdata["extraInfo"]["EB"]["6709"] + self.sendDur # 总运行时间
self.OBDdata["extraInfo"]["01"]["extra_01"] = self.OBDdata["extraInfo"]["01"]["extra_01"] + int(self.sendDur * (speed * 1000 / 3600)) # 总里程
plusMilleage = plusMilleage + int(self.sendDur * (speed * 1000 / 3600))
plusMilleage2 = int(self.sendDur * (speed * 1000 / 3600))
self.OBDdata["extraInfo"]["01"]["extra_01"] = self.OBDdata["extraInfo"]["01"]["extra_01"] + int(plusMilleage / 100) # 总里程
plusMilleage = plusMilleage - int(plusMilleage / 100) * 100
obdObj = Location_msg()
obdMsg = obdObj.generateMsg_GUI(self.OBDdata)
self.carDataObj.setTodayTotalMilleage(self.carData["curDayTravel"]["todayTotalMilleage"] + self.OBDdata["extraInfo"]["01"]["extra_01"] - self.OBDdataOri["extraInfo"]["01"]["extra_01"])
self.carDataObj.setTheMilleage(self.carData["curDayTravel"]["theMilleage"] + self.OBDdata["extraInfo"]["01"]["extra_01"] - self.OBDdataOri["extraInfo"]["01"]["extra_01"])
self.carDataObj.setTotalMilleage(self.carData["travelData"]["totalMilleage"] + self.OBDdata["extraInfo"]["01"]["extra_01"] - self.OBDdataOri["extraInfo"]["01"]["extra_01"])
self.carDataObj.setTodayTotalMilleage(self.carData["curDayTravel"]["todayTotalMilleage"] + plusMilleage2)
self.carDataObj.setTheMilleage(self.carData["curDayTravel"]["theMilleage"] + plusMilleage2)
self.carDataObj.setTotalMilleage(self.carData["travelData"]["totalMilleage"] + plusMilleage2)
temp = self.OBDdata["extraInfo"]["01"]["extra_01"]
self.OBDdataOri["extraInfo"]["01"]["extra_01"] = temp
self.carDataObj.setTodayTodayTotalOil(self.carData["curDayTravel"]["todayTotalOil"] + self.OBDdata["extraInfo"]["EB"]["670a"] - self.OBDdataOri["extraInfo"]["EB"]["670a"])
......
......@@ -69,6 +69,7 @@ def porcessConnect():
service.setSocket(cliSocket)
service.setTimeout(int(params["timeout"]))
service.setCarId(params["phoneNum"])
service.setSendDur(int(params["durTime"]))
service.setData(params) #传入页面传过来的数据
service.startWebsocketService() #启动websocket服务
service.startReciveService() #接收消息的服务
......
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