rts-sim-testing-service/ats/verify/simulation/wayside/model/device/switch_device_model.go
2023-08-10 14:18:55 +08:00

87 lines
2.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package device
import (
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/ref"
)
// 道岔装置(规定A端为岔尖规定B端为定位端轨道C端为反位端)
type SwitchDeviceModel struct {
//道岔基本信息
face.DeviceModel
//端点的公里标,单位为mm
//list中元素类型为graphicData.KilometerSystem
KilometerSystems []*graphicData.KilometerSystem
//道岔A端连接的link
LinkRefA *ref.LinkRef
//道岔B端连接的link
LinkRefB *ref.LinkRef
//道岔C端连接的link
LinkRefC *ref.LinkRef
// 道岔相连的计轴信息
AxlePoints map[string]*AxlePointDeviceModel
}
// 获取道岔端口关联的轨道
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
}