列车应答器添加可变报文,修改列车初始化制动力及列车行驶制动力
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 2m54s

This commit is contained in:
tiger_zhou 2024-08-09 16:41:41 +08:00
parent 85d5781122
commit 272274a5c4
8 changed files with 41 additions and 22 deletions

@ -1 +1 @@
Subproject commit ae5ee2729ef4024e55b1656e82f917f71ab5183f Subproject commit 51702238da69fcf28d7c07ddccfc6e240222456e

View File

@ -2,14 +2,12 @@ package can_btm
import ( import (
"fmt" "fmt"
uuid2 "github.com/google/uuid"
"joylink.club/bj-rtsts-server/dto/state_proto" "joylink.club/bj-rtsts-server/dto/state_proto"
"joylink.club/bj-rtsts-server/third_party/btm_vobc" "joylink.club/bj-rtsts-server/third_party/btm_vobc"
"joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/fi" "joylink.club/rtsssimulation/fi"
"joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto" "joylink.club/rtsssimulation/repository/model/proto"
"log/slog"
"math" "math"
"sort" "sort"
"sync" "sync"
@ -31,7 +29,7 @@ type BtmAntennaRunningInfo struct {
const ( const (
//BtmAntennaOffsetHead = int64(1000) //车载BTM天线距车头端点的距离mm //BtmAntennaOffsetHead = int64(1000) //车载BTM天线距车头端点的距离mm
BtmAntennaOffsetHead = int64(1000) //车载BTM天线距车头端点的距离mm BtmAntennaOffsetHead = int64(0) //车载BTM天线距车头端点的距离mm
) )
// TrainHeadPositionInfo 列车车头运行位置信息 // TrainHeadPositionInfo 列车车头运行位置信息
@ -88,6 +86,7 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头 curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
var startBalises []*repository.Transponder var startBalises []*repository.Transponder
var endBalises []*repository.Transponder var endBalises []*repository.Transponder
//startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, th2.LinkOffset, th.LinkOffset)
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset) startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
//endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset) //endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset)
/* if th.Up { /* if th.Up {
@ -128,13 +127,13 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
if len(balises) > 0 { if len(balises) > 0 {
balise := balises[0] balise := balises[0]
baliseInfo := &BtmAntennaScanningBaliseInfo{BaliseId: balise.Id(), BaliseType: balise.BaliseType()} baliseInfo := &BtmAntennaScanningBaliseInfo{BaliseId: balise.Id(), BaliseType: balise.BaliseType()}
uuid := uuid2.NewString() /*uuid := uuid2.NewString()
for _, transponder := range balises { for _, transponder := range balises {
slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, transponder.Id(), baliseInfo.Distance, curAntennaRi.Up)) slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, transponder.Id(), baliseInfo.Distance, curAntennaRi.Up))
}*/
} telegram, utel := t.rcvTelegram2(wd, balise.Id())
telegram, utel := t.rcvTelegram(wd, balise.Id()) if utel != nil && t.addExpectedBalise(baliseInfo) {
if t.addExpectedBalise(baliseInfo) {
t.baliseCounterAdd1() //应答器计数器 t.baliseCounterAdd1() //应答器计数器
if len(telegram) > 0 { if len(telegram) > 0 {
baliseInfo.telegram = utel baliseInfo.telegram = utel
@ -222,6 +221,32 @@ func (t *BaliseDetector) baliseMessageCounterAdd1() {
} }
} }
// BTM天线接收应答器报文(线程不安全)
func (t *BaliseDetector) rcvTelegram2(wd *component.WorldData, baliseId string) ([]byte, []byte) {
if entry, ok := wd.EntityMap[baliseId]; ok {
workedState := component.BaliseWorkStateType.Get(entry)
if !workedState.Work {
return nil, nil
}
//hasVar := entry.HasComponent(component.BaliseVariableTelegramType)
//hexFix := entry.HasComponent(component.BaliseFixedTelegramType)
if entry.HasComponent(component.BaliseVariableTelegramType) {
baliseVar := component.BaliseVariableTelegramType.Get(entry)
//slog.Info(fmt.Sprintf("find_baliseId:%v ,work:%v,var:%v,fix:%v,tel:%v,usertel:%v", baliseId, workedState.Work, hasVar, hexFix, hex.EncodeToString(baliseVar.Telegram), hex.EncodeToString(baliseVar.UserTelegram)))
return baliseVar.Telegram, baliseVar.UserTelegram
} else if entry.HasComponent(component.BaliseFixedTelegramType) {
fixBalise := component.BaliseFixedTelegramType.Get(entry)
//slog.Info(fmt.Sprintf("find_baliseId:%v ,work:%v,var:%v,fix:%v,tel:%v,usertel:%v", baliseId, workedState.Work, hasVar, hexFix, hex.EncodeToString(tel), hex.EncodeToString(utel)))
return fixBalise.Telegram, fixBalise.UserTelegram
}
}
return nil, nil
}
// BTM天线接收应答器报文(线程不安全) // BTM天线接收应答器报文(线程不安全)
func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) ([]byte, []byte) { func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) ([]byte, []byte) {
entry, ok := wd.EntityMap[baliseId] entry, ok := wd.EntityMap[baliseId]
@ -385,6 +410,7 @@ func (t *BaliseDetector) searchBalisesFromBetweenLinkPosition(repo *repository.R
return rs[i].LinkPosition().Offset() < rs[j].LinkPosition().Offset() return rs[i].LinkPosition().Offset() < rs[j].LinkPosition().Offset()
}) })
for _, r := range rs { for _, r := range rs {
if r.LinkPosition().Offset() >= fromOffset && r.LinkPosition().Offset() <= toOffset { if r.LinkPosition().Offset() >= fromOffset && r.LinkPosition().Offset() <= toOffset {
//slog.Info(fmt.Sprintf("up id:%v,offset:%v,from:%v,to:%v", r.Id(), r.LinkPosition().Offset(), fromOffset, toOffset)) //slog.Info(fmt.Sprintf("up id:%v,offset:%v,from:%v,to:%v", r.Id(), r.LinkPosition().Offset(), fromOffset, toOffset))
balises = append(balises, r) balises = append(balises, r)
@ -394,13 +420,8 @@ func (t *BaliseDetector) searchBalisesFromBetweenLinkPosition(repo *repository.R
sort.SliceStable(rs, func(i, j int) bool { sort.SliceStable(rs, func(i, j int) bool {
return rs[j].LinkPosition().Offset() < rs[i].LinkPosition().Offset() return rs[j].LinkPosition().Offset() < rs[i].LinkPosition().Offset()
}) })
//cha := int64(math.Abs(float64(toOffset - fromOffset)))
for _, r := range rs { for _, r := range rs {
/*if r.LinkPosition().Offset() <= fromOffset && r.LinkPosition().Offset() >= toOffset {
balises = append(balises, r)
}*/
if r.LinkPosition().Offset() <= toOffset { if r.LinkPosition().Offset() <= toOffset {
cha := int64(math.Abs(float64(toOffset - fromOffset))) cha := int64(math.Abs(float64(toOffset - fromOffset)))
cha2 := int64(math.Abs(float64(toOffset - r.LinkPosition().Offset()))) cha2 := int64(math.Abs(float64(toOffset - r.LinkPosition().Offset())))

View File

@ -141,7 +141,7 @@ func (d *dynamics) requestStartSimulation(base *message.LineBaseInfo) error {
} }
url := d.buildUrl("/api/start/") url := d.buildUrl("/api/start/")
data, _ := json.Marshal(base) data, _ := json.Marshal(base)
fmt.Println(string(data)) //fmt.Println(string(data))
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data)) resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
if err != nil { if err != nil {
return sys_error.New("动力学开始仿真请求发送错误", err) return sys_error.New("动力学开始仿真请求发送错误", err)

View File

@ -86,6 +86,7 @@ type DynamicsTrainInfo struct {
// 解析动力学的列车信息 // 解析动力学的列车信息
func (t *DynamicsTrainInfo) Decode(buf []byte) error { func (t *DynamicsTrainInfo) Decode(buf []byte) error {
t.LifeSignal = binary.BigEndian.Uint16(buf[0:2]) t.LifeSignal = binary.BigEndian.Uint16(buf[0:2])
t.Number = buf[2] t.Number = buf[2]
t.Len = binary.BigEndian.Uint32(buf[3:7]) t.Len = binary.BigEndian.Uint32(buf[3:7])

View File

@ -172,6 +172,7 @@ func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2,
} }
if sd, err := d.findTrainConn(sta); err == nil { if sd, err := d.findTrainConn(sta); err == nil {
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
//sd.speedPlace.PulseCount1 += float32(uint32(h1 * 10))
sd.speedPlace.PulseCount2 = sd.speedPlace.PulseCount1 sd.speedPlace.PulseCount2 = sd.speedPlace.PulseCount1
} }
if sta.TrainRunUp { if sta.TrainRunUp {

View File

@ -99,7 +99,7 @@ func findTrainTccGraphicDataHandler(tccG *data_proto.TccGraphicStorage, id uint3
} }
func initTrainVobc(trainLoad int64, trainIsUp bool) (*state_proto.TrainVobcState, uint32) { func initTrainVobc(trainLoad int64, trainIsUp bool) (*state_proto.TrainVobcState, uint32) {
vobc := &state_proto.TrainVobcState{TrainLoad: int64(trainLoad), BrakingStatus: true, BrakeForce: 100, DirectionForward: true, vobc := &state_proto.TrainVobcState{TrainLoad: int64(trainLoad), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE * 100, DirectionForward: true,
AllDoorClose: true, ObstacleCheckBtn: true, RightDoorCloseCommand: true, LeftDoorCloseCommand: true, BrakeHeavyFault: true, AtpCutSwitch: true, AllDoorClose: true, ObstacleCheckBtn: true, RightDoorCloseCommand: true, LeftDoorCloseCommand: true, BrakeHeavyFault: true, AtpCutSwitch: true,
ConfirmBtn: true, AtpPowerOnBtn: true, ConfirmBtn: true, AtpPowerOnBtn: true,
} }

View File

@ -343,9 +343,8 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
sta.OldLinkOffset = outLinkOffset sta.OldLinkOffset = outLinkOffset
sta.OldLink = outLinkId sta.OldLink = outLinkId
} }
//slog.Info(fmt.Sprintf("old:%v ,new :%v,--:%v", outLinkOffset, sta.OldLinkOffset, pointTo))
updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset) updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset)
//slog.Info(fmt.Sprintf("动力学,当前速度(米/秒):%v,加速度:%v", info.Speed, info.Acceleration)) //slog.Info(fmt.Sprintf("动力学,当前速度(米/秒):%v,加速度:%v,位移距离:%v", info.Speed, info.Acceleration, info.Displacement))
if sta.OldLink != outLinkId { if sta.OldLink != outLinkId {
sta.OldLink = outLinkId sta.OldLink = outLinkId
} }

View File

@ -428,7 +428,7 @@ func trainControlHandle(vobc *state_proto.TrainVobcState, tcc *state_proto.Train
notBreak = 1 notBreak = 1
} else if request.Val < 0 { } else if request.Val < 0 {
vobc.BrakingStatus = true vobc.BrakingStatus = true
vobc.BrakeForce = -int64(math.Abs(float64(request.Val))/100*DEFAULT_BRAKE_FORCE) * 100 vobc.BrakeForce = int64(math.Abs(float64(request.Val))/100*DEFAULT_BRAKE_FORCE) * 100
vobc.EmergencyBrakingStatus = false vobc.EmergencyBrakingStatus = false
jjzdBtn.Passed = false jjzdBtn.Passed = false
brakeState = 0 brakeState = 0
@ -696,11 +696,9 @@ func (s *VerifySimulation) TrainPcSimMockInfo(train *state_proto.TrainState, dat
train.VobcState.MockInfo = uint32(mockData) train.VobcState.MockInfo = uint32(mockData)
} }
var sendData []uint32
// 4.4.4. 车载输出BTM查询同步帧报文内容0x04 // 4.4.4. 车载输出BTM查询同步帧报文内容0x04
func (s *VerifySimulation) TrainBtmQuery(train *state_proto.TrainState, data []byte) { func (s *VerifySimulation) TrainBtmQuery(train *state_proto.TrainState, data []byte) {
//time.Sleep(time.Millisecond * 50)
uuid := uuid2.NewString() uuid := uuid2.NewString()
ts := time.Now().UnixMilli() ts := time.Now().UnixMilli()
//slog.Info(fmt.Sprintf("收到车载输出BTM查询同步帧uuid:%v,时间:%v, 报文内容:%v", uuid, ts, hex.EncodeToString(data))) //slog.Info(fmt.Sprintf("收到车载输出BTM查询同步帧uuid:%v,时间:%v, 报文内容:%v", uuid, ts, hex.EncodeToString(data)))
@ -708,7 +706,6 @@ func (s *VerifySimulation) TrainBtmQuery(train *state_proto.TrainState, data []b
slog.Error("列车btm查询报文长度错误:", len(data)) slog.Error("列车btm查询报文长度错误:", len(data))
return return
} }
if train.BtmState == nil { if train.BtmState == nil {
slog.Warn(fmt.Sprintf("列车暂时未获取到应答器信息,无法进行btm查询列车id:%v", train.Id)) slog.Warn(fmt.Sprintf("列车暂时未获取到应答器信息,无法进行btm查询列车id:%v", train.Id))
return return