rts-sim-testing-service/ats/verify/simulation/wayside/model/device/switch_device_model.go

93 lines
2.6 KiB
Go
Raw Normal View History

2023-07-28 18:12:50 +08:00
package device
import (
2023-08-02 15:50:46 +08:00
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
2023-07-31 11:30:34 +08:00
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
2023-07-31 15:59:23 +08:00
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/ref"
2023-07-28 18:12:50 +08:00
)
// 道岔装置(规定A端为岔尖规定B端为定位端轨道C端为反位端)
type SwitchDeviceModel struct {
//道岔基本信息
2023-07-31 11:30:34 +08:00
face.DeviceModel
2023-07-28 18:12:50 +08:00
//端点的公里标,单位为mm
//list中元素类型为graphicData.KilometerSystem
2023-08-02 15:50:46 +08:00
KilometerSystems []*graphicData.KilometerSystem
//道岔A端连接的sectionLink
2023-07-31 15:59:23 +08:00
LinkRefA *ref.LinkRef
//道岔B端连接的sectionLink
2023-07-31 15:59:23 +08:00
LinkRefB *ref.LinkRef
//道岔C端连接的sectionLink
2023-07-31 15:59:23 +08:00
LinkRefC *ref.LinkRef
2023-08-10 14:18:55 +08:00
// 道岔相连的计轴信息
AxlePoints map[string]*AxlePointDeviceModel
// A端连接的Link端点
ALinkPort *ref.DevicePort[*LinkModel]
// B端连接的Link端点
BLinkPort *ref.DevicePort[*LinkModel]
// C端连接的Link端点
CLinkPort *ref.DevicePort[*LinkModel]
2023-07-31 15:59:23 +08:00
}
// 获取道岔端口关联的轨道
func (dm *SwitchDeviceModel) FindLinkRefByPort(portEnum face.PortEnum) *ref.LinkRef {
switch portEnum {
case face.A:
{
return dm.LinkRefA
}
case face.B:
{
return dm.LinkRefB
}
case face.C:
{
return dm.LinkRefC
}
}
return nil
}
// 统计与该道岔关联的轨道数量值为3
func (dm *SwitchDeviceModel) RelationCount() int {
var count int = 0
if dm.LinkRefA != nil {
count++
}
if dm.LinkRefB != nil {
count++
}
if dm.LinkRefC != nil {
count++
}
return count
}
// 道岔A、B端连接的轨道的索引集合
// 返回值中map key、value均为索引值
func (dm *SwitchDeviceModel) AbPortsLinkIndexes() map[string]string {
var rt map[string]string = make(map[string]string)
rt[dm.LinkRefA.LinkSection.GetIndex()] = dm.LinkRefA.LinkSection.GetIndex()
rt[dm.LinkRefB.LinkSection.GetIndex()] = dm.LinkRefB.LinkSection.GetIndex()
return rt
}
// 道岔A、C端连接的轨道的索引集合
// 返回值中map key、value均为索引值
func (dm *SwitchDeviceModel) AcPortsLinkIndexes() map[string]string {
var rt map[string]string = make(map[string]string)
rt[dm.LinkRefA.LinkSection.GetIndex()] = dm.LinkRefA.LinkSection.GetIndex()
rt[dm.LinkRefC.LinkSection.GetIndex()] = dm.LinkRefC.LinkSection.GetIndex()
return rt
}
// 道岔B、C端连接的轨道的索引集合
// 返回值中map key、value均为索引值
func (dm *SwitchDeviceModel) BcPortsLinkIndexes() map[string]string {
var rt map[string]string = make(map[string]string)
rt[dm.LinkRefB.LinkSection.GetIndex()] = dm.LinkRefB.LinkSection.GetIndex()
rt[dm.LinkRefC.LinkSection.GetIndex()] = dm.LinkRefC.LinkSection.GetIndex()
return rt
2023-07-28 18:12:50 +08:00
}