2023-12-28 16:49:28 +08:00
|
|
|
package modelrepo
|
2023-12-27 15:59:46 +08:00
|
|
|
|
2023-12-28 16:49:28 +08:00
|
|
|
import "joylink.club/rtsssimulation/modelrepo/model"
|
2023-12-27 15:59:46 +08:00
|
|
|
|
2023-12-28 16:49:28 +08:00
|
|
|
type Repo interface {
|
2023-12-27 15:59:46 +08:00
|
|
|
// 模型仓库id
|
|
|
|
Id() string
|
2023-12-28 14:35:11 +08:00
|
|
|
// 获取所有设备集中站
|
2023-12-28 16:49:28 +08:00
|
|
|
GetEcses() []model.EcStation
|
2023-12-27 15:59:46 +08:00
|
|
|
// 获取所有道岔
|
2024-01-02 18:22:28 +08:00
|
|
|
GetTurnouts() []model.Points
|
2023-12-28 16:49:28 +08:00
|
|
|
// 获取所有信号机
|
|
|
|
GetSignals() []model.Signal
|
|
|
|
// 获取所有站台屏蔽门
|
|
|
|
GetPsds() []model.Psd
|
2023-12-27 15:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type IdMap interface {
|
|
|
|
// 获取数据元素id
|
|
|
|
DeId() string
|
|
|
|
// 获取uid
|
|
|
|
Uid() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// type repo struct {
|
|
|
|
// id string
|
|
|
|
// idMapping *IdMapping // id映射
|
|
|
|
// modelMap map[string]model.Model // 模型map,key为uid
|
|
|
|
// linkMap map[string]*impl.Link // 链路map,key为uid
|
|
|
|
// physicalSectionMap map[string]*impl.PhysicalSection // 物理区段map,key为uid
|
|
|
|
// turnoutMap map[string]*impl.Turnout // 道岔map,key为uid
|
|
|
|
// }
|
|
|
|
|
2023-12-28 16:49:28 +08:00
|
|
|
// func BuildFrom(msgs *dto.modelrepo) (modelrepo, *ErrorRecord) {
|
2023-12-27 15:59:46 +08:00
|
|
|
// errRecord := NewErrorRecord()
|
|
|
|
// idMapping := BuildIdMapping(msgs, errRecord)
|
|
|
|
// if errRecord.HasError() {
|
|
|
|
// return nil, errRecord
|
|
|
|
// }
|
|
|
|
// repo := &repo{
|
|
|
|
// id: msgs.Id,
|
|
|
|
// idMapping: idMapping,
|
|
|
|
// modelMap: make(map[string]model.Model, 1024),
|
|
|
|
// linkMap: make(map[string]*impl.Link, 256),
|
|
|
|
// physicalSectionMap: make(map[string]*impl.PhysicalSection, 256),
|
|
|
|
// turnoutMap: make(map[string]*impl.Turnout, 128),
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return repo, errRecord
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // 模型仓库id
|
|
|
|
// func (r *repo) Id() string {
|
|
|
|
// return r.id
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // 通过uid查询模型对象
|
|
|
|
// func (r *repo) FindByUid(uid string) model.Model {
|
|
|
|
// return nil
|
|
|
|
// }
|