2023-08-14 16:23:34 +08:00
|
|
|
|
package model
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
import (
|
|
|
|
|
"joylink.club/rtsssimulation/umi"
|
|
|
|
|
)
|
2023-08-21 15:12:57 +08:00
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
// 长轨道,道岔端点间的轨道
|
2023-08-14 16:23:34 +08:00
|
|
|
|
type LinkModel struct {
|
2023-08-14 18:06:26 +08:00
|
|
|
|
DeviceModel
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//轨道A端口连接的道岔
|
2023-08-23 09:54:41 +08:00
|
|
|
|
PortA umi.ISwitchRef
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//轨道B端口连接的道岔
|
2023-08-23 09:54:41 +08:00
|
|
|
|
PortB umi.ISwitchRef
|
|
|
|
|
//长度,单位mm
|
|
|
|
|
Length int64
|
2023-08-14 16:23:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-21 15:12:57 +08:00
|
|
|
|
func NewLinkModel(id string) *LinkModel {
|
2023-08-23 16:52:01 +08:00
|
|
|
|
return &LinkModel{DeviceModel: DeviceModel{Id: id, Type: umi.Link}}
|
2023-08-21 15:12:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
// 获取轨道长度,单位mm
|
|
|
|
|
func (me *LinkModel) Len() int64 {
|
|
|
|
|
return me.Length
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 轨道A端连接的道岔
|
|
|
|
|
func (me *LinkModel) PortASwitch() umi.ISwitchRef {
|
|
|
|
|
return me.PortA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 轨道B端连接的道岔
|
|
|
|
|
func (me *LinkModel) PortBSwitch() umi.ISwitchRef {
|
|
|
|
|
return me.PortB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 轨道端口引用
|
|
|
|
|
type LinkRef struct {
|
|
|
|
|
Link umi.ILinkModel
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//引用轨道的端口
|
2023-08-23 09:54:41 +08:00
|
|
|
|
Port umi.PortEnum
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewLinkRef(link *LinkModel, port umi.PortEnum) *LinkRef {
|
|
|
|
|
return &LinkRef{Link: link, Port: port}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 被引用的轨道模型
|
|
|
|
|
func (me *LinkRef) LinkModel() umi.ILinkModel {
|
|
|
|
|
return me.Link
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 被引用的轨道的端口
|
|
|
|
|
func (me *LinkRef) LinkPort() umi.PortEnum {
|
|
|
|
|
return me.Port
|
2023-08-14 16:23:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 轨道偏移位置引用,轨道A端为偏移起始位置
|
2023-08-14 16:23:34 +08:00
|
|
|
|
type LinkOffsetRef struct {
|
2023-08-23 09:54:41 +08:00
|
|
|
|
Link umi.ILinkModel
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//偏移位置,单位mm
|
|
|
|
|
Offset int64
|
|
|
|
|
}
|
2023-08-23 09:54:41 +08:00
|
|
|
|
|
|
|
|
|
func NewLinkOffsetRef(link *LinkModel, offset int64) *LinkOffsetRef {
|
|
|
|
|
return &LinkOffsetRef{Link: link, Offset: offset}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 被引用的轨道模型
|
|
|
|
|
func (me *LinkOffsetRef) LinkModel() umi.ILinkModel {
|
|
|
|
|
return me.Link
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 偏移量,单位mm
|
|
|
|
|
func (me *LinkOffsetRef) GetOffset() int64 {
|
|
|
|
|
return me.Offset
|
|
|
|
|
}
|