Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
new-socketemulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
new-socketemulator
Commits
2a514be0
Commit
2a514be0
authored
May 12, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了OBD 报文多出几个数据的问题,以及增加了模拟器信号不好的场景控制
parent
5903a330
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
2 deletions
+107
-2
lib/protocol/report/OBDReport_CAN_protocol.py
lib/protocol/report/OBDReport_CAN_protocol.py
+1
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+1
-1
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+78
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+27
-0
No files found.
lib/protocol/report/OBDReport_CAN_protocol.py
View file @
2a514be0
...
@@ -123,7 +123,7 @@ class OBDReport_CAN_protocol(ProtocolBase):
...
@@ -123,7 +123,7 @@ class OBDReport_CAN_protocol(ProtocolBase):
#####################################################
#####################################################
def
generateBD_CAN_Pkg
(
self
,
data
):
def
generateBD_CAN_Pkg
(
self
,
data
):
pkgLen
=
len
(
data
)
pkgLen
=
len
(
data
)
pkgNum
=
(
pkgLen
/
2
)
/
100
pkgNum
=
(
pkgLen
/
2
)
/
83
# print("------------------------" + str(pkgNum))
# print("------------------------" + str(pkgNum))
pkgNumHex
=
self
.
int2hexString
(
int
(
pkgNum
))
pkgNumHex
=
self
.
int2hexString
(
int
(
pkgNum
))
pkg
=
pkgNumHex
+
data
pkg
=
pkgNumHex
+
data
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
2a514be0
...
@@ -43,7 +43,7 @@ class ProtocolSimulaterService():
...
@@ -43,7 +43,7 @@ class ProtocolSimulaterService():
为0表示正常发送,type为1表示数据写入本地
为0表示正常发送,type为1表示数据写入本地
# 用来控制发送消息的方式(是正常发送,还是将发送的数据保存到本地,不发送)
# 用来控制发送消息的方式(是正常发送,还是将发送的数据保存到本地,不发送)
'''
'''
self
.
sendType
=
1
self
.
sendType
=
0
# 定义要发送的obd数据
# 定义要发送的obd数据
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
2a514be0
...
@@ -161,6 +161,7 @@
...
@@ -161,6 +161,7 @@
<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/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>
油耗(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"
><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>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -795,6 +796,83 @@ function changeDurTime(){
...
@@ -795,6 +796,83 @@ function changeDurTime(){
url
=
"
/protocolTools/M_carSimulater_process/changeDurTime
"
;
url
=
"
/protocolTools/M_carSimulater_process/changeDurTime
"
;
sendjson
(
data
,
url
);
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
);
}
}
});
}
}
</script>
</script>
{% endblock %}
{% endblock %}
</div>
</div>
...
...
views/protocolTools/M_carSimulater_process.py
View file @
2a514be0
...
@@ -962,4 +962,31 @@ def changeDurTime():
...
@@ -962,4 +962,31 @@ def changeDurTime():
traceback
.
print_exc
()
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 改变发送间隔失败!"
data
[
"message"
]
=
"Error: 改变发送间隔失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】控制是否存储消息到本地
##########################################
@
M_carSimulater_process
.
route
(
"/controlStoreMsg"
,
methods
=
[
'POST'
])
def
controlStoreMsg
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
sessionId
=
params
[
"session"
][
"sessionId"
]
data
=
{}
if
not
sessionId
in
connects
.
keys
():
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 未启动服务,不可存储消息!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
service
=
connects
[
sessionId
][
"service"
]
try
:
sendType
=
int
(
params
[
"sendType"
])
service
.
setSendType
(
sendType
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"控制是否存储消息到本地成功!"
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 控制是否存储消息到本地失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment