列车应答器添加可变报文,修改列车初始化制动力及列车行驶制动力
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 2m54s
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 2m54s
This commit is contained in:
parent
85d5781122
commit
272274a5c4
@ -1 +1 @@
|
||||
Subproject commit ae5ee2729ef4024e55b1656e82f917f71ab5183f
|
||||
Subproject commit 51702238da69fcf28d7c07ddccfc6e240222456e
|
45
third_party/can_btm/balise_detection.go
vendored
45
third_party/can_btm/balise_detection.go
vendored
@ -2,14 +2,12 @@ package can_btm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
uuid2 "github.com/google/uuid"
|
||||
"joylink.club/bj-rtsts-server/dto/state_proto"
|
||||
"joylink.club/bj-rtsts-server/third_party/btm_vobc"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"log/slog"
|
||||
"math"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -31,7 +29,7 @@ type BtmAntennaRunningInfo struct {
|
||||
|
||||
const (
|
||||
//BtmAntennaOffsetHead = int64(1000) //车载BTM天线距车头端点的距离,mm
|
||||
BtmAntennaOffsetHead = int64(1000) //车载BTM天线距车头端点的距离,mm
|
||||
BtmAntennaOffsetHead = int64(0) //车载BTM天线距车头端点的距离,mm
|
||||
)
|
||||
|
||||
// TrainHeadPositionInfo 列车车头运行位置信息
|
||||
@ -88,6 +86,7 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
|
||||
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
|
||||
var startBalises []*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)
|
||||
//endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset)
|
||||
/* if th.Up {
|
||||
@ -128,13 +127,13 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
|
||||
if len(balises) > 0 {
|
||||
balise := balises[0]
|
||||
baliseInfo := &BtmAntennaScanningBaliseInfo{BaliseId: balise.Id(), BaliseType: balise.BaliseType()}
|
||||
uuid := uuid2.NewString()
|
||||
/*uuid := uuid2.NewString()
|
||||
for _, transponder := range balises {
|
||||
slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, transponder.Id(), baliseInfo.Distance, curAntennaRi.Up))
|
||||
}*/
|
||||
|
||||
}
|
||||
telegram, utel := t.rcvTelegram(wd, balise.Id())
|
||||
if t.addExpectedBalise(baliseInfo) {
|
||||
telegram, utel := t.rcvTelegram2(wd, balise.Id())
|
||||
if utel != nil && t.addExpectedBalise(baliseInfo) {
|
||||
t.baliseCounterAdd1() //应答器计数器
|
||||
if len(telegram) > 0 {
|
||||
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天线接收应答器报文(线程不安全)
|
||||
func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) ([]byte, []byte) {
|
||||
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()
|
||||
})
|
||||
for _, r := range rs {
|
||||
|
||||
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))
|
||||
balises = append(balises, r)
|
||||
@ -394,13 +420,8 @@ func (t *BaliseDetector) searchBalisesFromBetweenLinkPosition(repo *repository.R
|
||||
sort.SliceStable(rs, func(i, j int) bool {
|
||||
return rs[j].LinkPosition().Offset() < rs[i].LinkPosition().Offset()
|
||||
})
|
||||
//cha := int64(math.Abs(float64(toOffset - fromOffset)))
|
||||
|
||||
for _, r := range rs {
|
||||
/*if r.LinkPosition().Offset() <= fromOffset && r.LinkPosition().Offset() >= toOffset {
|
||||
|
||||
balises = append(balises, r)
|
||||
}*/
|
||||
if r.LinkPosition().Offset() <= toOffset {
|
||||
cha := int64(math.Abs(float64(toOffset - fromOffset)))
|
||||
cha2 := int64(math.Abs(float64(toOffset - r.LinkPosition().Offset())))
|
||||
|
2
third_party/dynamics/dynamics.go
vendored
2
third_party/dynamics/dynamics.go
vendored
@ -141,7 +141,7 @@ func (d *dynamics) requestStartSimulation(base *message.LineBaseInfo) error {
|
||||
}
|
||||
url := d.buildUrl("/api/start/")
|
||||
data, _ := json.Marshal(base)
|
||||
fmt.Println(string(data))
|
||||
//fmt.Println(string(data))
|
||||
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return sys_error.New("动力学开始仿真请求发送错误", err)
|
||||
|
1
third_party/message/dynamics.go
vendored
1
third_party/message/dynamics.go
vendored
@ -86,6 +86,7 @@ type DynamicsTrainInfo struct {
|
||||
|
||||
// 解析动力学的列车信息
|
||||
func (t *DynamicsTrainInfo) Decode(buf []byte) error {
|
||||
|
||||
t.LifeSignal = binary.BigEndian.Uint16(buf[0:2])
|
||||
t.Number = buf[2]
|
||||
t.Len = binary.BigEndian.Uint32(buf[3:7])
|
||||
|
1
third_party/train_pc_sim/train_pc_sim.go
vendored
1
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -172,6 +172,7 @@ func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2,
|
||||
}
|
||||
if sd, err := d.findTrainConn(sta); err == nil {
|
||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||
//sd.speedPlace.PulseCount1 += float32(uint32(h1 * 10))
|
||||
sd.speedPlace.PulseCount2 = sd.speedPlace.PulseCount1
|
||||
}
|
||||
if sta.TrainRunUp {
|
||||
|
@ -99,7 +99,7 @@ func findTrainTccGraphicDataHandler(tccG *data_proto.TccGraphicStorage, id uint3
|
||||
}
|
||||
|
||||
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,
|
||||
ConfirmBtn: true, AtpPowerOnBtn: true,
|
||||
}
|
||||
|
@ -343,9 +343,8 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
||||
sta.OldLinkOffset = outLinkOffset
|
||||
sta.OldLink = outLinkId
|
||||
}
|
||||
//slog.Info(fmt.Sprintf("old:%v ,new :%v,--:%v", outLinkOffset, sta.OldLinkOffset, pointTo))
|
||||
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 {
|
||||
sta.OldLink = outLinkId
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ func trainControlHandle(vobc *state_proto.TrainVobcState, tcc *state_proto.Train
|
||||
notBreak = 1
|
||||
} else if request.Val < 0 {
|
||||
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
|
||||
jjzdBtn.Passed = false
|
||||
brakeState = 0
|
||||
@ -696,11 +696,9 @@ func (s *VerifySimulation) TrainPcSimMockInfo(train *state_proto.TrainState, dat
|
||||
train.VobcState.MockInfo = uint32(mockData)
|
||||
}
|
||||
|
||||
var sendData []uint32
|
||||
|
||||
// 4.4.4. 车载输出BTM查询同步帧报文内容(0x04)
|
||||
func (s *VerifySimulation) TrainBtmQuery(train *state_proto.TrainState, data []byte) {
|
||||
//time.Sleep(time.Millisecond * 50)
|
||||
|
||||
uuid := uuid2.NewString()
|
||||
ts := time.Now().UnixMilli()
|
||||
//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))
|
||||
return
|
||||
}
|
||||
|
||||
if train.BtmState == nil {
|
||||
slog.Warn(fmt.Sprintf("列车暂时未获取到应答器信息,无法进行btm查询列车id:%v", train.Id))
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user