This commit is contained in:
xzb 2023-12-27 13:35:50 +08:00
commit f0b6cd1b71
6 changed files with 821 additions and 1029 deletions

View File

@ -4,17 +4,13 @@ package message;
option go_package = "./repo/dto";
message Repo {
//
message CgRepo {
string id = 1;
oneof data {
CGData cgData = 2;
GTData gtData = 3;
}
}
//
message GTData {
// 线
repeated Line lines = 2;
// (IBP/PSL/MKX等),线
repeated JKP jkps = 3;
}
// (Train Running Direction)
@ -25,14 +21,6 @@ enum TRD {
Downward = 1;
}
//
message CGData {
// 线
repeated Line lines = 1;
// (IBP/PSL/MKX等),线
repeated JKP jkps = 2;
}
// 线
message Line {
//
@ -179,11 +167,12 @@ message DevidingPoint {
// id
repeated uint32 ecsIds = 6;
}
//
message Device {
//
//
message Model {
//
enum Type {
//
//
Unknown = 0;
//
Section = 1;
@ -192,39 +181,32 @@ message Device {
//
Signal = 3;
}
// ()
enum Port {
A = 0;
B = 1;
C = 2;
}
// id
// id
uint32 id = 1;
//
//
Type type = 2;
}
//
message SectionPort {
//
enum SectionType {
//
Section = 0;
//
Turnout = 1;
}
//
enum PortType {
enum Type {
A = 0;
B = 1;
C = 2;
}
//
// enum ElementType {
// //
// Section = 0;
// //
// Turnout = 1;
// }
//
SectionType type = 1;
Model.Type type = 1;
// / id
uint32 id = 2;
//
PortType port = 3;
Type port = 3;
}
//
message Signal {
@ -272,6 +254,8 @@ message Signal {
Model model = 3;
// id
uint32 ecsId = 4;
// ()
TRD trd = 5;
}
//
message Turnout {
@ -318,6 +302,8 @@ message Section {
SectionPort bsp = 5;
// id
uint32 ecsId = 6;
// ()
TRD trd = 7;
}
//
message Psd {
@ -478,7 +464,7 @@ message Lamp {
//
message DeviceEcc {
//
Device.Type deviceType = 1;
Model.Type deviceType = 1;
//
string deviceCode = 2;
//

View File

@ -2,7 +2,7 @@ package repo
import "joylink.club/rtsssimulation/repo/model"
type Repo interface {
type CgRepo interface {
// 模型仓库id
Id() string
// 通过uid查询模型对象

File diff suppressed because it is too large Load Diff

View File

@ -122,20 +122,9 @@ func (m *IdMapping) checkUidAndAdd(idmap *idMap) (existed *idMap, uidExisted boo
return
}
// 构建id映射
func BuildIdMapping(msgs *dto.Repo, errRecord *ErrorRecord) *IdMapping {
if cg := msgs.GetCgData(); cg != nil {
return BuildCgIdMapping(cg, errRecord)
} else if gt := msgs.GetGtData(); gt != nil {
return BuildGtIdMapping(gt)
}
errRecord.AddError("构建id映射表错误: 没有数据")
return nil
}
// 构建城轨id映射
func BuildCgIdMapping(cg *dto.CGData, errRecord *ErrorRecord) *IdMapping {
if cg == nil {
func BuildIdMapping(msgs *dto.CgRepo, errRecord *ErrorRecord) *IdMapping {
if msgs == nil {
errRecord.AddError("构建城轨id映射表错误: 未关联任何数据")
return nil
}
@ -144,14 +133,14 @@ func BuildCgIdMapping(cg *dto.CGData, errRecord *ErrorRecord) *IdMapping {
uidMap: make(map[string]*idMap),
}
lineSet := make(map[string]struct{})
for _, l := range cg.Lines {
for _, l := range msgs.Lines {
if _, ok := lineSet[l.City+l.LineId]; ok {
errRecord.AddError(fmt.Sprintf("构建城轨id映射表错误: 线路重复:%s_%s", l.City, l.LineId))
return nil
}
lineSet[l.City+l.LineId] = struct{}{}
}
for _, line := range cg.Lines {
for _, line := range msgs.Lines {
buildXhbz(idMapping, line, errRecord)
if errRecord.HasError() {
return nil
@ -221,7 +210,7 @@ func buildXhbz(idMapping *IdMapping, line *dto.Line, errRecord *ErrorRecord) {
}
}
// 物理区段
for _, ps := range xhbz.PhysicalSections {
for _, ps := range xhbz.Sections {
eid := ps.Id
if checkFieldEmpty(did, eid, ps.Code, errPrefix, "物理区段编号", errRecord) {
continue
@ -478,7 +467,3 @@ func checkRepeatOrAddIdMap(idm *idMap, idMapping *IdMapping, prefix string, errR
}
return
}
func BuildGtIdMapping(gt *dto.GTData) *IdMapping {
panic("未实现")
}

View File

@ -7,16 +7,16 @@ import (
)
type repoManager struct {
repoMap map[string]Repo
repoMap map[string]CgRepo
lock sync.Mutex
}
var defaultManager = &repoManager{
repoMap: make(map[string]Repo),
repoMap: make(map[string]CgRepo),
}
// 获取或构建模型仓库
func GetOrBuildRepo(id string, dc func(errRecord *ErrorRecord) *dto.Repo) (Repo, *ErrorRecord) {
func GetOrBuildRepo(id string, dc func(errRecord *ErrorRecord) *dto.CgRepo) (CgRepo, *ErrorRecord) {
manager := defaultManager
manager.lock.Lock()
defer manager.lock.Unlock()

View File

@ -15,7 +15,7 @@ type repo struct {
turnoutMap map[string]*impl.Turnout // 道岔map,key为uid
}
func BuildFrom(msgs *dto.Repo) (Repo, *ErrorRecord) {
func BuildFrom(msgs *dto.CgRepo) (CgRepo, *ErrorRecord) {
errRecord := NewErrorRecord()
idMapping := BuildIdMapping(msgs, errRecord)
if errRecord.HasError() {