主要是为了提交go.work文件

This commit is contained in:
joylink_zhangsai 2023-09-20 18:21:00 +08:00
parent bccdb424a9
commit 79f82e9358
5 changed files with 96 additions and 171 deletions

1
.gitignore vendored
View File

@ -22,5 +22,4 @@ output/
# vendor/ # vendor/
# Go workspace file # Go workspace file
go.work
/pom.xml /pom.xml

View File

@ -186,55 +186,45 @@ func GetSimulationArr() []*memory.VerifySimulation {
} }
func convert(info *dynamics.TrainInfo, sta *state.TrainState, simulation *memory.VerifySimulation) *state.TrainState { func convert(info *dynamics.TrainInfo, sta *state.TrainState, simulation *memory.VerifySimulation) *state.TrainState {
//var vs *memory.VerifyStructure zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset)
//linkId := int32(info.Link) id, port, offset, runDirection, pointTo, kilometer := memory.QueryDeviceByCalcLink(simulation.Repo, strconv.Itoa(int(info.Link)), int64(info.LinkOffset), info.Up)
//for _, mapId := range simulation.MapIds { zap.S().Debugf("转换后的消息:[%d-车头:%s-偏移:%d-上行:%v-是否ab:%v]", info.Number, id, offset, runDirection, pointTo)
// vm := memory.QueryMapVerifyStructure(mapId) sta.HeadDeviceId = id
// if vm.LinkModelMap[linkId] == nil { sta.DevicePort = port
// continue sta.HeadOffset = offset
// } sta.PointTo = pointTo
// vs = vm sta.TrainKilometer = kilometer
// break sta.RunDirection = runDirection
//} //判定车头方向
//zap.S().Debugf("原始消息:[%d-%d-%d]", info.Number, info.Link, info.LinkOffset) sta.HeadDirection = runDirection
//id, port, offset, runDirection, pointTo, kilometer := memory.QueryDeviceByCalcLink(vs, linkId, int64(info.LinkOffset), info.Up, sta.RunDirection) if sta.VobcState != nil {
//zap.S().Debugf("转换后的消息:[%d-车头:%s-偏移:%d-上行:%v-是否ab:%v]", info.Number, id, offset, runDirection, pointTo) if sta.VobcState.DirectionForward {
//sta.HeadDeviceId = id sta.HeadDirection = runDirection
//sta.DevicePort = port } else if sta.VobcState.DirectionBackward {
//sta.HeadOffset = offset sta.HeadDirection = !runDirection
//sta.PointTo = pointTo }
//sta.TrainKilometer = kilometer }
//sta.RunDirection = runDirection if info.Speed < 0 {
////判定车头方向 sta.RunDirection = !sta.RunDirection
//sta.HeadDirection = runDirection }
//if sta.VobcState != nil { // 赋值动力学信息
// if sta.VobcState.DirectionForward { sta.DynamicState.Heartbeat = int32(info.LifeSignal)
// sta.HeadDirection = runDirection sta.DynamicState.HeadLinkId = strconv.Itoa(int(info.Link))
// } else if sta.VobcState.DirectionBackward { sta.DynamicState.HeadLinkOffset = int64(info.LinkOffset)
// sta.HeadDirection = !runDirection sta.DynamicState.Slope = int32(info.Slope)
// } sta.DynamicState.Upslope = info.UpSlope
//} sta.DynamicState.RunningUp = info.Up
//if info.Speed < 0 { sta.DynamicState.RunningResistanceSum = float32(info.TotalResistance) / 1000
// sta.RunDirection = !sta.RunDirection sta.DynamicState.AirResistance = float32(info.AirResistance) / 1000
//} sta.DynamicState.RampResistance = float32(info.SlopeResistance) / 1000
//// 赋值动力学信息 sta.DynamicState.CurveResistance = float32(info.CurveResistance) / 1000
//sta.DynamicState.Heartbeat = int32(info.LifeSignal) sta.DynamicState.Speed = speedParse(info.Speed)
//sta.DynamicState.HeadLinkId = strconv.Itoa(int(info.Link)) sta.DynamicState.HeadSensorSpeed1 = speedParse(info.HeadSpeed1)
//sta.DynamicState.HeadLinkOffset = int64(info.LinkOffset) sta.DynamicState.HeadSensorSpeed2 = speedParse(info.HeadSpeed2)
//sta.DynamicState.Slope = int32(info.Slope) sta.DynamicState.TailSensorSpeed1 = speedParse(info.TailSpeed1)
//sta.DynamicState.Upslope = info.UpSlope sta.DynamicState.TailSensorSpeed2 = speedParse(info.TailSpeed2)
//sta.DynamicState.RunningUp = info.Up sta.DynamicState.HeadRadarSpeed = speedParse(info.HeadRadarSpeed)
//sta.DynamicState.RunningResistanceSum = float32(info.TotalResistance) / 1000 sta.DynamicState.TailRadarSpeed = speedParse(info.TailRadarSpeed)
//sta.DynamicState.AirResistance = float32(info.AirResistance) / 1000
//sta.DynamicState.RampResistance = float32(info.SlopeResistance) / 1000
//sta.DynamicState.CurveResistance = float32(info.CurveResistance) / 1000
//sta.DynamicState.Speed = speedParse(info.Speed)
//sta.DynamicState.HeadSensorSpeed1 = speedParse(info.HeadSpeed1)
//sta.DynamicState.HeadSensorSpeed2 = speedParse(info.HeadSpeed2)
//sta.DynamicState.TailSensorSpeed1 = speedParse(info.TailSpeed1)
//sta.DynamicState.TailSensorSpeed2 = speedParse(info.TailSpeed2)
//sta.DynamicState.HeadRadarSpeed = speedParse(info.HeadRadarSpeed)
//sta.DynamicState.TailRadarSpeed = speedParse(info.TailRadarSpeed)
return sta return sta
} }

View File

@ -4,6 +4,7 @@ import (
"container/list" "container/list"
"fmt" "fmt"
"joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository"
proto2 "joylink.club/rtsssimulation/repository/model/proto"
"math" "math"
"sort" "sort"
"strconv" "strconv"
@ -293,126 +294,54 @@ Outter:
// 根据linkID和link相对偏移量返回区段道岔偏移量 // 根据linkID和link相对偏移量返回区段道岔偏移量
// 设备ID、端口、偏移量、上下行、AB走向 // 设备ID、端口、偏移量、上下行、AB走向
func QueryDeviceByCalcLink(repo *repository.Repository, id int32, offset int64, up, defaultRunDirection bool) (string, string, int64, bool, bool, int64) { func QueryDeviceByCalcLink(repo *repository.Repository, id string, offset int64, up bool) (
//link := repo.FindLink(strconv.Itoa(int(id))) deviceId, port string, deviceOffset int64, runDirection, pointTo bool, km int64) {
//if link == nil {
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到link【%d】", id)}) link := repo.FindLink(id)
//} if link == nil {
//if offset > link.Length() { panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到link【%s】", id)})
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("偏移超出link范围【%d】", id)}) }
//} if offset > link.Length() {
//for _, model := range link.Devices() { panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("偏移【%d】超出link范围【%d】", offset, link.Length())})
// physicalSection, ok := model.(*repository.PhysicalSection) }
// if ok { aTp := link.ARelation()
// if number.IsBetween(offset, physicalSection.StartLinkPosition().Offset(), physicalSection.EndLinkPosition().Offset()) { bTp := link.BRelation()
// aOffset := aTp.Turnout().FindLinkPositionByPort(aTp.Port()).Offset()
// } bOffset := bTp.Turnout().FindLinkPositionByPort(bTp.Port()).Offset()
// } if offset <= aOffset {
// deviceId = aTp.Turnout().Id()
//} deviceOffset = aOffset - (aOffset - offset)
// if up {
//calcPositionArr := convertPositionToCalcPosition(linkModel) // 转换位置对象 pointTo = false
//var devicePosition, calcPosition *calcLinkPositionStruct // 获取当前、下一个节点,偏移量在这个范围中 } else {
//for _, v := range calcPositionArr { pointTo = true
// if v.position.Offset > int32(offset) { }
// calcPosition = v switch aTp.Port() {
// break case proto2.Port_A:
// } else { port = "A"
// devicePosition = v case proto2.Port_B:
// } port = "B"
//} case proto2.Port_C:
//// 运行方向 port = "C"
//var runDirection bool }
//if calcPosition != nil { } else if offset >= bOffset {
// runDirection = (calcPosition.kilometer.Kilometer >= devicePosition.kilometer.Kilometer) == up deviceId = bTp.Turnout().Id()
//} else { deviceOffset = link.Length() - offset
// runDirection = defaultRunDirection if up {
//} pointTo = true
//isSwitch := (devicePosition.deviceType == 2) // 道岔 } else {
//// 获取另一个端点 pointTo = false
//if calcPosition != nil { }
// isSwitch = isSwitch || calcPosition.deviceType == 2 // 道岔 switch bTp.Port() {
//} case proto2.Port_A:
//if isSwitch { port = "A"
// var sid string case proto2.Port_B:
// var port string port = "B"
// var op int64 case proto2.Port_C:
// var trainOffset int64 port = "C"
// var trainKilometer int64 }
// var tendTo bool }
// if devicePosition.deviceType == 2 { return
// sid = devicePosition.index
// op = int64(devicePosition.position.Offset)
// trainKilometer = devicePosition.kilometer.Kilometer
// } else {
// sid = calcPosition.index
// op = int64(calcPosition.position.Offset)
// trainKilometer = calcPosition.kilometer.Kilometer
// }
// tm := vm.SwitchDeviceModelMap[sid]
// if tm == nil {
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", sid)})
// }
// if linkModel.ARelatedSwitchRef.SwitchDevice != nil && linkModel.ARelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 起始点
// port, trainOffset, tendTo = linkModel.ARelatedSwitchRef.Port.Name(), offset-op, !up
// } else if linkModel.BRelatedSwitchRef.SwitchDevice != nil && linkModel.BRelatedSwitchRef.SwitchDevice.GetIndex() == sid { // 结束点
// port, trainOffset, tendTo = linkModel.BRelatedSwitchRef.Port.Name(), op-offset, up
// } else {
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("不存在道岔【index:%s】", devicePosition.index)})
// }
// trainKilometer = concertTrainKilometer(trainKilometer, trainOffset, tendTo)
// // return sid, linkModel.ARelatedSwitchRef.Port.Name(), offset - op, runDirection, !up
// // return sid, linkModel.BRelatedSwitchRef.Port.Name(), op - offset, runDirection, up
// return sid, port, trainOffset, runDirection, tendTo, trainKilometer
//} else {
// sectionModel, ok := linkOffsetQuerySection(vm, devicePosition, calcPosition)
// if ok {
// isEnd := (calcPosition == nil) && (offset == int64(linkModel.Length)) // 是否已经走到尽头
// pointA := sectionModel.PortAxlePoints[face.A.Name()]
// var trainOffset int64
// var trainKilometer int64
// var tendTo bool
// var bk *graphicData.KilometerSystem
// if calcPosition != nil {
// bk = calcPosition.kilometer
// }
// if devicePosition.index == pointA.GetIndex() {
// trainOffset = offset - int64(devicePosition.position.Offset)
// trainKilometer = devicePosition.kilometer.Kilometer
// tendTo = convertPointTo(devicePosition.kilometer, bk, runDirection)
// } else if calcPosition != nil {
// trainOffset = int64(calcPosition.position.Offset) - offset
// trainKilometer = bk.Kilometer
// tendTo = convertPointTo(bk, devicePosition.kilometer, runDirection)
// } else {
// for _, v := range calcPositionArr {
// if v.deviceType == 1 && v.index == pointA.GetIndex() { // 计轴
// trainKilometer = v.kilometer.Kilometer
// if isEnd {
// trainOffset = offset - int64(v.position.Offset)
// tendTo = convertPointTo(v.kilometer, nil, runDirection)
// } else {
// trainOffset = int64(v.position.Offset) - offset
// tendTo = convertPointTo(v.kilometer, devicePosition.kilometer, runDirection)
// }
// break
// }
// }
// if trainKilometer == 0 {
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("区段【%s】A端计轴缺失", sectionModel.GraphicId)})
// }
// }
// trainKilometer = concertTrainKilometer(trainKilometer, trainOffset, tendTo)
// // return sectionModel.Index, "", offset - int64(devicePosition.position.Offset), runDirection, convertPointTo(devicePosition.kilometer, bk, runDirection)
// // return sectionModel.Index, "", int64(calcPosition.position.Offset) - offset, runDirection, convertPointTo(bk, devicePosition.kilometer, runDirection)
// // return sectionModel.Index, "", offset - int64(v.position.Offset), runDirection, convertPointTo(v.kilometer, nil, runDirection)
// // return sectionModel.Index, "", int64(v.position.Offset) - offset, runDirection, convertPointTo(v.kilometer, devicePosition.kilometer, runDirection)
// return sectionModel.Index, "", trainOffset, runDirection, tendTo, trainKilometer
// } else {
// panic(dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("未找到区段【index:%s-index:%s】", devicePosition.index, calcPosition.index)})
// }
//}
return "", "", 0, false, false, 0
} }
//// 根据linkID和link相对偏移量返回区段道岔偏移量 //// 根据linkID和link相对偏移量返回区段道岔偏移量

7
go.work Normal file
View File

@ -0,0 +1,7 @@
go 1.20
use (
.
./rtss_simulation
./rtss_simulation/jl-ecs-go
)

@ -1 +1 @@
Subproject commit 6edac119a197cbc717584f4f6ad5b7c8ec33acfe Subproject commit 49a30032e01e60c6b235c12e5ffd5f893b31f76b