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