From 5667b3fcd1993b6b0a5a10283b903487ae33b79b Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 10 Nov 2023 11:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E7=90=86=E5=8C=BA=E6=AE=B5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0LinkRange?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repository/link.go | 102 ++++++--------------------------- repository/physical_section.go | 10 +--- 2 files changed, 19 insertions(+), 93 deletions(-) diff --git a/repository/link.go b/repository/link.go index fddb41b..4720cc1 100644 --- a/repository/link.go +++ b/repository/link.go @@ -141,88 +141,20 @@ func (l *LinkPort) Device() PortedDevice { return l.link } -//// DeviceLinkPosition device在link上的位置 -//type DeviceLinkPosition struct { -// device Identity -// position LinkPosition -//} -// -//// SlopeLinkSegment Slope在Link上的区间 -//type SlopeLinkSegment struct { -// slope *Slope -// start *LinkPosition -// end *LinkPosition -//} -// -//func (s *SlopeLinkSegment) Slope() *Slope { -// return s.slope -//} -// -//func (s *SlopeLinkSegment) Start() *LinkPosition { -// return s.start -//} -// -//func (s *SlopeLinkSegment) End() *LinkPosition { -// return s.end -//} -// -//type SectionalCurvatureLinkSegment struct { -// sectionalCurvature *SectionalCurvature -// start *LinkPosition -// end *LinkPosition -//} -// -//// LinkNode link节点 -//type LinkNode struct { -// Identity -// turnout *Turnout -// aRelation LinkPort -// bRelation LinkPort -// cRelation LinkPort -//} -// -//func (ln LinkNode) ButtonCode() string { -// return ln.turnout.ButtonCode() -//} -// -//func (ln LinkNode) PortNum() int { -// return 3 -//} -// -//func (ln LinkNode) bindDevicePort(port proto.Port, devicePort DevicePort) error { -// linkPort, isLinkPort := devicePort.(*LinkPort) -// if !isLinkPort { -// return errors.New(fmt.Sprintf("Link节点不能与[%s]类型的设备关联", devicePort.Device().Type())) -// } -// switch port { -// case proto.Port_A: -// ln.aRelation = *linkPort -// case proto.Port_B: -// ln.bRelation = *linkPort -// case proto.Port_C: -// ln.cRelation = *linkPort -// default: -// return errors.New(fmt.Sprintf("Link节点没有端口[%s]", port)) -// } -// return nil -//} -// -//type LinkNodePort struct { -// node *LinkNode -// port proto.Port -//} -// -//func NewLinkNodePort(node *LinkNode, port proto.Port) *LinkNodePort { -// return &LinkNodePort{ -// node: node, -// port: port, -// } -//} -// -//func (lp *LinkNodePort) Port() proto.Port { -// return lp.port -//} -// -//func (lp *LinkNodePort) Device() PortedDevice { -// return lp.node -//} +type LinkRange struct { + link *Link + start int64 + end int64 +} + +func (l *LinkRange) Link() *Link { + return l.link +} + +func (l *LinkRange) Start() int64 { + return l.start +} + +func (l *LinkRange) End() int64 { + return l.end +} diff --git a/repository/physical_section.go b/repository/physical_section.go index dbf45d7..c678309 100644 --- a/repository/physical_section.go +++ b/repository/physical_section.go @@ -33,6 +33,8 @@ type PhysicalSection struct { //在Link上的区间(根据aKm和bKm计算出的,start的offset一定小于end的offset) startLinkPosition *LinkPosition endLinkPosition *LinkPosition + //在Link上的区间 + linkRanges []*LinkRange //物理区段所属集中站 centralizedStation string @@ -56,14 +58,6 @@ func (s *PhysicalSection) BLinkPosition() *LinkPosition { return s.bLinkPosition } -func (s *PhysicalSection) StartLinkPosition() *LinkPosition { - return s.startLinkPosition -} - -func (s *PhysicalSection) EndLinkPosition() *LinkPosition { - return s.endLinkPosition -} - func (s *PhysicalSection) ARelation() DevicePort { return s.aRelation }