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
02b4babe
Commit
02b4babe
authored
Mar 11, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
位置上报界面完成
parent
dec8403f
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
521 additions
and
31 deletions
+521
-31
lib/multiThread/SendMultMsgThread_m500.py
lib/multiThread/SendMultMsgThread_m500.py
+20
-3
lib/protocol/message/DataUpstreamTransport_msg.py
lib/protocol/message/DataUpstreamTransport_msg.py
+5
-1
lib/protocol/message/Location_msg.py
lib/protocol/message/Location_msg.py
+4
-3
lib/protocol/message/data/AlarmEvent_data.py
lib/protocol/message/data/AlarmEvent_data.py
+9
-9
lib/protocol/message/data/CarSafeStatusInfo.py
lib/protocol/message/data/CarSafeStatusInfo.py
+2
-2
lib/socket/messageTest.py
lib/socket/messageTest.py
+2
-2
templates/messageTools/message/location_msg_page.html
templates/messageTools/message/location_msg_page.html
+479
-11
No files found.
lib/multiThread/SendMultMsgThread_m500.py
View file @
02b4babe
...
...
@@ -16,18 +16,19 @@ class SendMultMsgThread():
self
.
host
=
host
self
.
port
=
port
self
.
msg
=
msg
self
.
timeOut
=
6
0
#socket超时时间
self
.
timeOut
=
12
0
#socket超时时间
self
.
BUF_SIZE
=
1024
#接收消息缓存
self
.
threadCount
=
1000
#并发线程数
self
.
threadCount
=
1000
0
#并发线程数
self
.
totalTime
=
0
#所有线程的运行总和
self
.
threadArr
=
{}
#保存每个线程的信息
self
.
failThreadCount
=
0
#失败线程数
self
.
durThreads
=
[]
#持续发送线程数组,当数组为空,表示所有线程已经结束
self
.
durTime
=
6
0
#线程持续时间
self
.
durTime
=
12
0
#线程持续时间
self
.
connectTimeoutNum
=
0
#连接超时线程数
self
.
sendTimeoutNum
=
0
#发送超时线程数
self
.
reviceTimeoutNum
=
0
#接收超时线程数
self
.
sucessNum
=
0
#成功线程数
self
.
messageCon
=
[]
#用来统计每个线程所发的消息数
pass
############################################
...
...
@@ -96,6 +97,7 @@ class SendMultMsgThread():
client
.
settimeout
(
self
.
timeOut
)
startTime
=
int
(
time
.
time
())
endTime
=
int
(
time
.
time
())
msgCon
=
0
#统计线程发的消息数量
self
.
durThreads
.
append
(
threadName
)
try
:
client
.
connect
((
self
.
host
,
self
.
port
))
...
...
@@ -108,12 +110,15 @@ class SendMultMsgThread():
timeExpend
=
endTime
-
startTime
self
.
threadArr
[
threadName
][
"timeExp"
]
=
timeExpend
self
.
connectTimeoutNum
=
self
.
connectTimeoutNum
+
1
self
.
messageCon
.
append
(
msgCon
)
self
.
threadArr
[
threadName
][
"msgCon"
]
=
msgCon
print
(
threadName
+
":"
+
"连接超时,socket断开"
)
return
while
(
endTime
-
startTime
)
<
self
.
durTime
:
msg
=
self
.
getRandomMsg
(
carId
)
try
:
client
.
send
(
binascii
.
a2b_hex
(
msg
))
msgCon
=
msgCon
+
1
except
BaseException
as
e
:
client
.
close
()
self
.
durThreads
.
remove
(
threadName
)
...
...
@@ -123,6 +128,8 @@ class SendMultMsgThread():
timeExpend
=
endTime
-
startTime
self
.
threadArr
[
threadName
][
"timeExp"
]
=
timeExpend
self
.
sendTimeoutNum
=
self
.
sendTimeoutNum
+
1
self
.
messageCon
.
append
(
msgCon
)
self
.
threadArr
[
threadName
][
"msgCon"
]
=
msgCon
print
(
threadName
+
":"
+
"发送超时,socket断开"
)
return
try
:
...
...
@@ -133,6 +140,8 @@ class SendMultMsgThread():
self
.
threadArr
[
threadName
][
"status"
]
=
1
self
.
failThreadCount
=
self
.
failThreadCount
+
1
self
.
reviceTimeoutNum
=
self
.
connectTimeoutNum
+
1
self
.
messageCon
.
append
(
msgCon
)
self
.
threadArr
[
threadName
][
"msgCon"
]
=
msgCon
print
(
threadName
+
":"
+
'socket 接收消息超时!'
)
endTime
=
int
(
time
.
time
())
timeExpend
=
endTime
-
startTime
...
...
@@ -144,6 +153,8 @@ class SendMultMsgThread():
endTime
=
int
(
time
.
time
())
timeExpend
=
endTime
-
startTime
self
.
threadArr
[
threadName
][
"timeExp"
]
=
timeExpend
self
.
messageCon
.
append
(
msgCon
)
self
.
threadArr
[
threadName
][
"msgCon"
]
=
msgCon
client
.
close
()
self
.
sucessNum
=
self
.
sucessNum
+
1
self
.
durThreads
.
remove
(
threadName
)
...
...
@@ -189,14 +200,20 @@ class SendMultMsgThread():
timeEnd
=
int
(
time
.
time
()
*
1000
)
timeExpend
=
timeEnd
-
timeStart
print
(
"耗时:"
+
str
(
timeExpend
)
+
" 毫秒产生了"
+
str
(
self
.
threadCount
)
+
"线程"
)
time
.
sleep
(
0.5
)
#防止启动的时候溜掉某些启动比较慢的线程
while
len
(
self
.
durThreads
)
!=
0
:
print
(
"剩余线程数:"
+
str
(
len
(
self
.
durThreads
)))
time
.
sleep
(
5
)
time
.
sleep
(
2
)
#防止线程慢的时候,某些线程被漏统计的情况
print
(
"-------------------------- 统计信息 --------------------------"
)
totalMsg
=
0
for
i
in
self
.
messageCon
:
totalMsg
=
totalMsg
+
i
print
(
"耗时:"
+
str
(
timeExpend
)
+
" 毫秒产生了"
+
str
(
self
.
threadCount
)
+
"线程"
)
print
(
"设置socket超时时间:"
+
str
(
self
.
timeOut
))
print
(
"设置线程持续时间:"
+
str
(
self
.
durTime
))
print
(
"成功线程数:"
+
str
(
self
.
sucessNum
))
print
(
"消息总数:"
+
str
(
totalMsg
))
print
(
"连接失败:"
+
str
(
self
.
connectTimeoutNum
))
print
(
"发送失败:"
+
str
(
self
.
sendTimeoutNum
))
print
(
"接收失败:"
+
str
(
self
.
reviceTimeoutNum
))
...
...
lib/protocol/message/DataUpstreamTransport_msg.py
View file @
02b4babe
...
...
@@ -334,7 +334,11 @@ class DataUpstreamTransport_msg(MessageBase):
#故障码
troubleCode
=
""
for
i
in
range
(
0
,
troubleCodeNums
):
troubleCode
=
troubleCode
+
self
.
int2hexStringByBytes
(
i
,
4
)
tbc0
=
self
.
int2hexStringByBytes
(
i
)
tbc1
=
self
.
int2hexStringByBytes
(
1
)
tbc2
=
self
.
int2hexStringByBytes
(
2
)
tbc3
=
self
.
int2hexStringByBytes
(
3
)
troubleCode
=
troubleCode
+
tbc0
+
tbc1
+
tbc2
+
tbc3
data
=
infoTime
+
latitude
+
longitude
+
troubleCodeNumsHex
+
troubleCode
return
data
...
...
lib/protocol/message/Location_msg.py
View file @
02b4babe
...
...
@@ -174,7 +174,8 @@ class Location_msg(MessageBase):
extra_FA
=
"FA"
+
self
.
int2hexStringByBytes
(
int
(
len
(
AlarmEvent_data
()
.
generateAlarmEvent_data
())
/
2
))
+
AlarmEvent_data
()
.
generateAlarmEvent_data
()
# data = extra_01 + extra_02 + extra_11 + extra_31 + extra_EA + extra_EB + extra_FA
data
=
extra_11
+
extra_31
+
extra_EA
+
extra_EB
+
extra_FA
# data = extra_11 + extra_31 + extra_EA + extra_EB + extra_FA
data
=
extra_11
+
extra_31
+
extra_EA
+
extra_FA
# data = extra_01 + extra_02 + extra_11 + extra_12 + extra_13
# data = data + extra_2A + extra_30 + extra_31 + extra_EA + extra_EB
...
...
@@ -508,7 +509,7 @@ class Location_msg(MessageBase):
#######################################################
# 获取
精
度信息
# 获取
纬
度信息
#######################################################
def
getLatitude
(
self
,
data
=
29.40268
):
data
=
int
(
data
*
1000000
)
...
...
@@ -516,7 +517,7 @@ class Location_msg(MessageBase):
return
dataHex
#######################################################
# 获取
纬
度信息
# 获取
经
度信息
#######################################################
def
getLongtitude
(
self
,
data
=
106.54041
):
data
=
int
(
data
*
1000000
)
...
...
lib/protocol/message/data/AlarmEvent_data.py
View file @
02b4babe
...
...
@@ -49,14 +49,14 @@ class AlarmEvent_data(MessageBase):
crashAlarm
=
"0114"
+
self
.
int2hexStringByBytes
(
0
)
#碰撞报警
rapidChangeLines
=
"0115"
+
self
.
int2hexStringByBytes
(
0
)
#急变道报警
# data = buslineNotSleep
data
=
data
+
ignition
+
flameout
+
setUpDefences
+
withdrawGarrision
+
doorOpen
data
=
data
+
doorClose
+
systemStart
+
trailCarAlarm
+
locationTooLong
+
terminalPullOut
data
=
data
+
terminalInsert
+
lowVoltage
+
idlingSpeedOver
+
overspeedAlarm
+
fatigueDriving
data
=
data
+
waterTemperatureAlarm
+
highSpeedNeutralGear
+
oilExpendNotSurport
+
OBDNotSurport
+
lowWaterTemperatureHighSpeed
data
=
data
+
buslineNotSleep
+
illegalOpenDoor
+
illegalFire
+
rapidAccelerateAlarm
+
sharpSlowdownAlarm
data
=
data
+
sharpBendAlarm
+
crashAlarm
+
rapidChangeLines
data
=
ignition
#
data = data + ignition + flameout + setUpDefences + withdrawGarrision + doorOpen
#
data = data + doorClose + systemStart + trailCarAlarm + locationTooLong + terminalPullOut
#
data = data + terminalInsert + lowVoltage + idlingSpeedOver + overspeedAlarm + fatigueDriving
#
data = data + waterTemperatureAlarm + highSpeedNeutralGear + oilExpendNotSurport + OBDNotSurport + lowWaterTemperatureHighSpeed
#
data = data + buslineNotSleep + illegalOpenDoor + illegalFire + rapidAccelerateAlarm + sharpSlowdownAlarm
#
data = data + sharpBendAlarm + crashAlarm + rapidChangeLines
return
data
# 创建报警事件数据,数据随机产生
...
...
@@ -213,7 +213,7 @@ class AlarmEvent_data(MessageBase):
return
data
#####################################################
# 获取
疲劳驾驶
报警附带信息
# 获取
水温
报警附带信息
#####################################################
def
getWaterTemperatureAlarm
(
self
):
#报警属性 1 BYTE 1:报警触发(无下面的数据内容项) 0:报警解除(有下面的数据内容项)
...
...
lib/protocol/message/data/CarSafeStatusInfo.py
View file @
02b4babe
...
...
@@ -82,7 +82,7 @@ class CarSafeStatusInfo(MessageBase):
lbDoorStatus
=
0
#左后门,4:开 0:关
rbDoorStatus
=
0
#右后门,8:开 0:关
trunk
=
0
#后备箱,16:开 0:关
enginCover
=
32
#发送
机盖:32:开 0:关
enginCover
=
0
#发动
机盖:32:开 0:关
retain1
=
0
#预留字段
retain2
=
0
#预留字段
...
...
@@ -101,7 +101,7 @@ class CarSafeStatusInfo(MessageBase):
lfDoorLockStatus
=
0
#左前门锁状态,1:开 0:关
rfDoorLockStatus
=
0
#右前门锁状态,2:开 0:关
lbDoorLockStatus
=
0
#左后门锁状态,4:开 0:关
rbDoorLockStatus
=
0
#
有
后门锁状态,8:开 0:关
rbDoorLockStatus
=
0
#
右
后门锁状态,8:开 0:关
retain1
=
0
retain2
=
0
retain3
=
0
...
...
lib/socket/messageTest.py
View file @
02b4babe
...
...
@@ -29,8 +29,8 @@ port = 9001
# msg = TerminalVersionInfo_msg().generateMsg() #终端版本信息上报
# msg = QueryTerminalParam_res().generateMsg() #查询终端参数应答
# msg = QueryTerminalProperty_res().generateMsg() #查询终端属性应答消息
msg
=
Location_msg
()
.
generateMsg
()
#位置信息汇报
#
msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息
#
msg = Location_msg().generateMsg() #位置信息汇报
msg
=
DataUpstreamTransport_msg
()
.
generateMsg
()
#数据上行透传消息
# msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知
# msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传
# msg = TextInfoUpload_msg().generateMsg() #文本信息上传
...
...
templates/messageTools/message/location_msg_page.html
View file @
02b4babe
This diff is collapsed.
Click to expand it.
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