Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtsts-server-go
This commit is contained in:
commit
a499ec1ba9
@ -78,9 +78,12 @@ func createByProjectId(c *gin.Context) {
|
||||
if len(mapInfos) == 0 {
|
||||
panic(sys_error.New("测试启动失败,项目未关联发布图"))
|
||||
}
|
||||
mapIds := make([]int32, len(mapInfos))
|
||||
for i, mapInfo := range mapInfos {
|
||||
mapIds[i] = mapInfo.ID
|
||||
var mapIds []int32
|
||||
for _, mapInfo := range mapInfos {
|
||||
if mapInfo.Type == graphicData.PictureType_value[graphicData.PictureType_TrainData.String()] {
|
||||
continue
|
||||
}
|
||||
mapIds = append(mapIds, mapInfo.ID)
|
||||
}
|
||||
// 运行环境配置
|
||||
runConfig := service.QueryRunConfig(req.ProjectRunConfigId)
|
||||
|
@ -4,12 +4,9 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -148,23 +145,6 @@ func (c *RsspConfig) CheckAddress(srcAddr uint16, dstAddr uint16) bool {
|
||||
|
||||
var Config AppConfig
|
||||
|
||||
var SimulationId_prefix = (func() string {
|
||||
ip := "127.0.0.1"
|
||||
addrList, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err.Error()})
|
||||
}
|
||||
for _, address := range addrList {
|
||||
if ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
|
||||
if ipNet.IP.To4() != nil {
|
||||
ip = ipNet.IP.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
ipArr := strings.Split(ip, ".")
|
||||
return ipArr[2] + "_" + ipArr[3]
|
||||
})()
|
||||
|
||||
// 获取配置文件名称,从运行flag参数config中获取,若未提供,使用默认'dev'
|
||||
func getConfigName() string {
|
||||
configName := ""
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: request.proto
|
||||
|
||||
|
@ -23,7 +23,7 @@ func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto {
|
||||
).
|
||||
LeftJoin(pv, p.DataID.EqCol(pv.ID)).
|
||||
LeftJoin(u, pv.UserID.EqCol(u.ID)).
|
||||
Order(pv.PublishAt.Desc())
|
||||
Order(p.Status.Desc(), pv.PublishAt.Desc())
|
||||
if req.Name != "" {
|
||||
where = where.Where(p.Code.Like(fmt.Sprintf("%%%s%%", req.Name)))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: ibpGraphics.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: picture.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: pslGraphics.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: relayCabinetLayoutGraphics.proto
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.23.1
|
||||
// source: device_state.proto
|
||||
|
||||
|
@ -83,39 +83,109 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
||||
SpksSwitchIds: make(map[string]*elementIdStructure, len(data.SpksSwitchs)),
|
||||
}
|
||||
city, lineId, _ := getUIdPrefix(data.UniqueIdPrefix)
|
||||
// 处理车站信息
|
||||
stationMap := make(map[string]*graphicData.Station)
|
||||
for _, s := range data.Stations {
|
||||
stationMap[s.Common.Id] = s
|
||||
gus.StationIds[s.Common.Id] = &elementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Code: s.StationName,
|
||||
Uid: GenerateElementUid(city, lineId, nil, s.StationName),
|
||||
}
|
||||
}
|
||||
// 初始化计轴信息
|
||||
for _, a := range data.AxleCountings {
|
||||
stationNames := make([]string, len(a.CentralizedStations))
|
||||
for i, id := range a.CentralizedStations {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if stationMap[id] == nil {
|
||||
stationNames[i] = id
|
||||
} else {
|
||||
stationNames[i] = stationMap[id].StationName
|
||||
}
|
||||
}
|
||||
gus.AxlePointIds[a.Common.Id] = &elementIdStructure{
|
||||
CommonId: a.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, a.CentralizedStations, a.Code),
|
||||
Code: a.Code,
|
||||
Uid: GenerateElementUid(city, lineId, stationNames, a.Code),
|
||||
}
|
||||
}
|
||||
// 初始化道岔信息
|
||||
for _, t := range data.Turnouts {
|
||||
stationNames := make([]string, len(t.CentralizedStations))
|
||||
for i, id := range t.CentralizedStations {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if stationMap[id] == nil {
|
||||
stationNames[i] = id
|
||||
} else {
|
||||
stationNames[i] = stationMap[id].StationName
|
||||
}
|
||||
}
|
||||
gus.TurnoutIds[t.Common.Id] = &elementIdStructure{
|
||||
CommonId: t.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, t.CentralizedStations, t.Code),
|
||||
Code: t.Code,
|
||||
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
|
||||
}
|
||||
}
|
||||
// 初始化物理区段信息
|
||||
for _, s := range data.Section {
|
||||
stationNames := make([]string, len(s.CentralizedStations))
|
||||
for i, id := range s.CentralizedStations {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if stationMap[id] == nil {
|
||||
stationNames[i] = id
|
||||
} else {
|
||||
stationNames[i] = stationMap[id].StationName
|
||||
}
|
||||
}
|
||||
gus.PhysicalSectionIds[s.Common.Id] = &elementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, s.CentralizedStations, s.Code),
|
||||
Code: s.Code,
|
||||
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
|
||||
}
|
||||
}
|
||||
// 初始化信号机信息
|
||||
for _, s := range data.Signals {
|
||||
stationNames := make([]string, len(s.CentralizedStations))
|
||||
for i, id := range s.CentralizedStations {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if stationMap[id] == nil {
|
||||
stationNames[i] = id
|
||||
} else {
|
||||
stationNames[i] = stationMap[id].StationName
|
||||
}
|
||||
}
|
||||
gus.SignalIds[s.Common.Id] = &elementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, s.CentralizedStations, s.Code),
|
||||
Code: s.Code,
|
||||
Uid: GenerateElementUid(city, lineId, stationNames, s.Code),
|
||||
}
|
||||
}
|
||||
// 初始化应答器
|
||||
for _, t := range data.Transponders {
|
||||
stationNames := make([]string, len(t.CentralizedStations))
|
||||
for i, id := range t.CentralizedStations {
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
if stationMap[id] == nil {
|
||||
stationNames[i] = id
|
||||
} else {
|
||||
stationNames[i] = stationMap[id].StationName
|
||||
}
|
||||
}
|
||||
gus.TransponderIds[t.Common.Id] = &elementIdStructure{
|
||||
CommonId: t.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, t.CentralizedStations, t.Code),
|
||||
Code: t.Code,
|
||||
Uid: GenerateElementUid(city, lineId, stationNames, t.Code),
|
||||
}
|
||||
}
|
||||
// 初始化坡度
|
||||
@ -155,15 +225,7 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *StationUidStructure {
|
||||
Uid: GenerateElementUid(city, lineId, nil, code),
|
||||
}
|
||||
}
|
||||
// 处理车站信息
|
||||
stationMap := make(map[string]*graphicData.Station)
|
||||
for _, s := range data.Stations {
|
||||
stationMap[s.Common.Id] = s
|
||||
gus.StationIds[s.Common.Id] = &elementIdStructure{
|
||||
CommonId: s.Common.Id,
|
||||
Uid: GenerateElementUid(city, lineId, nil, s.StationName),
|
||||
}
|
||||
}
|
||||
|
||||
// 站台
|
||||
platformMap := make(map[string]*graphicData.Platform)
|
||||
for _, platform := range data.Platforms {
|
||||
|
@ -974,8 +974,13 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
}
|
||||
centralizedStation := ""
|
||||
if len(data.CentralizedStations) > 0 {
|
||||
s := uidsMap.StationIds[data.CentralizedStations[0]]
|
||||
if s != nil {
|
||||
centralizedStation = s.Code
|
||||
} else {
|
||||
centralizedStation = data.CentralizedStations[0]
|
||||
}
|
||||
}
|
||||
physicalSection := &proto.PhysicalSection{
|
||||
Id: data.Common.Id,
|
||||
ADevicePort: convertDevicePort(data.PaRef),
|
||||
@ -1047,7 +1052,14 @@ func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphi
|
||||
Type: convertToProtoBaliseType(data.Type),
|
||||
}
|
||||
repo.Transponders = append(repo.Transponders, converTransponderUid(responder, uidsMap))
|
||||
for _, stationName := range data.CentralizedStations {
|
||||
for _, stationId := range data.CentralizedStations {
|
||||
var stationName string
|
||||
if uidsMap.StationIds[stationId] == nil {
|
||||
stationName = stationId
|
||||
} else {
|
||||
stationName = uidsMap.StationIds[stationId].Code
|
||||
}
|
||||
|
||||
if stm[stationName] == nil {
|
||||
stm[stationName] = []string{responder.Id}
|
||||
} else {
|
||||
|
@ -143,8 +143,6 @@ func stopThirdParty(s *memory.VerifySimulation) {
|
||||
}
|
||||
|
||||
func createSimulationId(projectId int32) string {
|
||||
// // 当前服务器IP + 端口 + 项目
|
||||
// return config.SimulationId_prefix + "_" + strconv.Itoa(config.Config.Server.Port) + "_" + strconv.Itoa(int(projectId))
|
||||
// MQTT客户端id+项目
|
||||
return mqtt.GetClientId() + "_" + strconv.Itoa(int(projectId))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user