70 lines
982 B
Go
70 lines
982 B
Go
package model
|
|
|
|
import "joylink.club/rtsssimulation/repository/model/proto"
|
|
|
|
type Link struct {
|
|
Model
|
|
|
|
aRelation LinkNodePort
|
|
bRelation LinkNodePort
|
|
}
|
|
|
|
func NewLink(id string) Link {
|
|
return Link{Model: modelInfo{id: id}}
|
|
}
|
|
|
|
// link位置
|
|
type LinkPosition struct {
|
|
link *Link
|
|
offset int
|
|
}
|
|
|
|
// link节点
|
|
type LinkNode struct {
|
|
turnout *Turnout
|
|
aRelation LinkPort
|
|
bRelation LinkPort
|
|
cRelation LinkPort
|
|
}
|
|
|
|
func (ln LinkNode) Id() string {
|
|
return ln.turnout.Id()
|
|
}
|
|
|
|
// link端口
|
|
type LinkPort struct {
|
|
DevicePort
|
|
|
|
link *Link
|
|
port proto.Port
|
|
}
|
|
|
|
func NewLinkPort(link *Link, port proto.Port) LinkPort {
|
|
return LinkPort{
|
|
link: link,
|
|
port: port,
|
|
}
|
|
}
|
|
|
|
func (lp LinkPort) Device() Model {
|
|
return lp.link
|
|
}
|
|
|
|
type LinkNodePort struct {
|
|
DevicePort
|
|
|
|
node *LinkNode
|
|
port proto.Port
|
|
}
|
|
|
|
func NewLinkNodePort(node *LinkNode, port proto.Port) LinkNodePort {
|
|
return LinkNodePort{
|
|
node: node,
|
|
port: port,
|
|
}
|
|
}
|
|
|
|
func (lp LinkNodePort) Device() Model {
|
|
return lp.node
|
|
}
|