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端连接的sectionLink LinkRefA *ref.LinkRef //道岔B端连接的sectionLink LinkRefB *ref.LinkRef //道岔C端连接的sectionLink LinkRefC *ref.LinkRef // 道岔相连的计轴信息 AxlePoints map[string]*AxlePointDeviceModel // A端连接的Link端点 ALinkPort *ref.DevicePort[*LinkModel] // B端连接的Link端点 BLinkPort *ref.DevicePort[*LinkModel] // C端连接的Link端点 CLinkPort *ref.DevicePort[*LinkModel] } // 获取道岔端口关联的轨道 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 }