Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
wsmock
Commits
b213484f
Commit
b213484f
authored
Jan 23, 2026
by
p x
Browse files
avp模拟服务
parent
d3e221c7
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/kotlin/com/inzy/wsmock/bean/CarVeh
icle
.kt
→
src/main/kotlin/com/inzy/wsmock/bean/CarVeh
Bak
.kt
View file @
b213484f
...
...
@@ -21,7 +21,7 @@ package com.sd.cavphmi.bean
// val data: VehData
//)
class
CarVeh
icle
{
class
CarVeh
Bak
{
var
businessStatus
:
String
=
""
// val progress: Any = ""
...
...
@@ -30,4 +30,7 @@ class CarVehicle {
//vehiclePos 里面分别是 经度、纬度、航向角
var
vehiclePos
:
List
<
Double
>?
=
null
//车辆行驶当前位置,用于吃掉小地图路径
var
carPos
=
0
}
\ No newline at end of file
src/main/kotlin/com/inzy/wsmock/bean/CarVeh.kt
→
src/main/kotlin/com/inzy/wsmock/bean/
Route
CarVeh.kt
View file @
b213484f
package
com.inzy.wsmock.bean
/***车辆位姿*/
class
CarVeh
{
class
Route
CarVeh
{
/**业务状态 park call park_com call_com**/
var
status
=
"park"
/***车辆行驶的点位**/
...
...
src/main/kotlin/com/inzy/wsmock/push/AvpPushTask.kt
View file @
b213484f
...
...
@@ -4,18 +4,19 @@ import com.alibaba.fastjson2.JSON
import
com.alibaba.fastjson2.JSONObject
import
com.inzy.wsmock.ChannelManager
import
com.inzy.wsmock.RequestParamHandler
import
com.inzy.wsmock.bean.CarVeh
import
com.inzy.wsmock.bean.
Route
CarVeh
import
com.inzy.wsmock.bean.ParkPath
import
com.inzy.wsmock.bean.V2xStartBean
import
com.inzy.wsmock.bean.VObject
import
com.inzy.wsmock.utils.FileIoUtil
import
com.inzy.wsmock.utils.MyMapUtils
import
com.sd.cavphmi.bean.CarVeh
icle
import
com.sd.cavphmi.bean.CarVeh
Bak
import
io.netty.channel.Channel
import
io.netty.handler.codec.http.websocketx.TextWebSocketFrame
import
jakarta.annotation.PostConstruct
import
jakarta.annotation.PreDestroy
import
kotlinx.coroutines.*
import
kotlinx.coroutines.time.delay
import
org.slf4j.LoggerFactory
import
org.springframework.core.io.ResourceLoader
import
org.springframework.stereotype.Component
...
...
@@ -35,16 +36,19 @@ class AvpPushTask(
// 注入ChannelManager单例
private
val
channelManager
=
ChannelManager
.
instance
//车辆位姿
private
var
carBak
=
CarVehBak
()
//车辆位姿,泊车
// private var carDstPark = mutableListOf<String>()
private
var
carVehPark
:
CarVeh
?
=
null
private
var
carVehPark
:
Route
CarVeh
?
=
null
//车辆位姿,倒车入库
//倒车路径
private
var
parkPath
:
ParkPath
?
=
null
//车辆位姿,召车
// private var carDstCall = mutableListOf<String>()
private
var
carVehCall
:
CarVeh
?
=
null
private
var
carVehCall
:
RouteCarVeh
?
=
null
//车辆行驶的位置
private
var
carIndex
=
0
...
...
@@ -67,7 +71,7 @@ class AvpPushTask(
CoroutineScope
(
Dispatchers
.
IO
).
launch
{
//读取泊车数据
val
parkStr
=
FileIoUtil
.
getFileDate
(
classpathResource
.
inputStream
)
carVehPark
=
JSON
.
parseObject
(
parkStr
,
CarVeh
::
class
.
java
)
carVehPark
=
JSON
.
parseObject
(
parkStr
,
Route
CarVeh
::
class
.
java
)
//计算航向角
carVehPark
!!
.
rs
?.
forEachIndexed
{
i
,
doubles
->
if
(
i
>
0
)
{
...
...
@@ -90,7 +94,7 @@ class AvpPushTask(
//读取召车数据
classpathResource
=
resourceLoader
.
getResource
(
"classpath:avpm/Car_fangzhen_call.txt"
)
val
callStr
=
FileIoUtil
.
getFileDate
(
classpathResource
.
inputStream
)
carVehCall
=
JSON
.
parseObject
(
callStr
,
CarVeh
::
class
.
java
)
carVehCall
=
JSON
.
parseObject
(
callStr
,
Route
CarVeh
::
class
.
java
)
//计算航向角
carVehCall
!!
.
rs
?.
forEachIndexed
{
i
,
doubles
->
if
(
i
>
0
)
{
...
...
@@ -140,67 +144,73 @@ class AvpPushTask(
}
}
private
var
carVehicle
=
CarVehicle
()
/**
* 推送车辆位姿
*/
private
fun
pushCarPos
(
channel
:
Channel
)
{
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
delay
(
1
2
000
)
delay
(
1
8
000
)
if
(
carVehPark
?.
rs
?.
count
()
==
0
||
carVehCall
?.
rs
?.
count
()
==
0
)
return
@launch
status
=
"park"
//开始推送泊车
car
Vehicle
.
businessStatus
=
status
car
Bak
.
businessStatus
=
status
carVehPark
!!
.
status
=
status
carVehPark
!!
.
rs
?.
forEachIndexed
{
i
,
doubles
->
carIndex
++
carVehicle
.
vehiclePos
=
doubles
sendMsg
(
channel
,
JSON
.
toJSONString
(
carVehPark
))
carBak
.
vehiclePos
=
doubles
carBak
.
carPos
=
i
sendMsg
(
channel
,
JSON
.
toJSONString
(
carBak
))
delay
(
300
)
}
//开始倒车入库
status
=
"parking"
carVehicle
.
businessStatus
=
status
carBak
.
businessStatus
=
status
carBak
.
carPos
=
-
1
//开始后退
va
r
for
word
=
parkPath
!!
.
result
.
routes
.
find
{
it
.
gear
==
1
}
for
word
?.
polyline
?.
forEachIndexed
{
index
,
doubles
->
va
l
for
back
=
parkPath
!!
.
result
.
routes
.
find
{
it
.
gear
==
1
}
for
back
?.
polyline
?.
forEachIndexed
{
index
,
doubles
->
carIndex
++
car
Vehicle
.
vehiclePos
=
listOf
<
Double
>(
doubles
[
0
],
doubles
[
1
],
doubles
[
3
])
sendMsg
(
channel
,
JSON
.
toJSONString
(
car
Vehicle
))
car
Bak
.
vehiclePos
=
listOf
<
Double
>(
doubles
[
0
],
doubles
[
1
],
doubles
[
3
])
sendMsg
(
channel
,
JSON
.
toJSONString
(
car
Bak
))
delay
(
300
)
}
//泊车完成
status
=
"park_com"
car
Vehicle
.
businessStatus
=
status
car
Vehicle
.
vehiclePos
=
emptyList
()
car
Bak
.
businessStatus
=
status
car
Bak
.
vehiclePos
=
emptyList
()
//泊车完成消息
sendMsg
(
channel
,
JSON
.
toJSONString
(
car
VehPar
k
))
sendMsg
(
channel
,
JSON
.
toJSONString
(
car
Ba
k
))
delay
(
3000
)
//开始推送召车
status
=
"call"
/* //开始推送召车
carVehCall!!.status = status
carBak
.
businessStatus
=
status
carVehCall
!!
.
rs
?.
forEachIndexed
{
i
,
doubles
->
carIndex = i
carVehCall?.carPos = i
sendMsg(channel, JSON.toJSONString(carVehCall))
carIndex
++
carBak
.
vehiclePos
=
doubles
carBak
.
carPos
=
i
sendMsg
(
channel
,
JSON
.
toJSONString
(
carBak
))
delay
(
300
)
}
delay
(
1000
)
//召车完成
status
=
"call_com"
carVehCall?.apply {
status = this@AvpPushTask.status
carPos = 0
rs = listOf()
}
carBak
.
businessStatus
=
status
carBak
.
vehiclePos
=
emptyList
()
//发送召车完成消息
sendMsg(channel, JSON.toJSONString(car
VehCall
))
sendMsg
(
channel
,
JSON
.
toJSONString
(
car
Bak
))
//全部完成
carIndex
=
0
status
=
""
carVehCall?.apply {
carBak
.
businessStatus
=
status
carBak
.
carPos
=
0
carBak
.
vehiclePos
=
emptyList
()
sendMsg
(
channel
,
JSON
.
toJSONString
(
carBak
))
/* carVehCall?.apply {
this.status = this@AvpPushTask.status
carPos = 0
rs = listOf()
...
...
@@ -209,6 +219,11 @@ class AvpPushTask(
}
}
private
fun
pushPark
()
{
}
/**感知物**/
private
fun
pushPre
(
channel
:
Channel
)
{
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
...
...
@@ -228,11 +243,14 @@ class AvpPushTask(
CoroutineScope
(
Dispatchers
.
Default
).
launch
{
while
(
isActive
)
{
// carPos = 0
// println("-------------carIndex = ${carIndex}")
if
(
carIndex
==
0
||
status
.
equals
(
""
))
val
carPos
=
carBak
.
carPos
// println("----------carPos ${carPos} status ${status}")
if
(
carPos
==
0
||
status
.
equals
(
""
))
{
delay
(
100
)
continue
}
if
(
status
.
equals
(
"park"
))
{
when
(
car
Index
)
{
when
(
car
Pos
)
{
8
->
{
//紧急制动预警
// val v2x = V2xStartBean().apply {
// type = 6
...
...
@@ -262,7 +280,7 @@ class AvpPushTask(
}
}
else
if
(
status
.
equals
(
"call"
))
{
when
(
car
Index
)
{
when
(
car
Pos
)
{
70
->
{
//盲区预警
/* val v2x = V2xStartBean().apply {
type = 4
...
...
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