2023-08-14 16:23:34 +08:00
|
|
|
|
package model
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
import (
|
2023-08-23 15:13:06 +08:00
|
|
|
|
"joylink.club/rtsssimulation/components/cstate"
|
2023-08-23 09:54:41 +08:00
|
|
|
|
"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 SwitchModel 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.ILinkRef
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//道岔B端口连接的轨道
|
2023-08-23 09:54:41 +08:00
|
|
|
|
PortB umi.ILinkRef
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//道岔C端口连接的轨道
|
2023-08-23 09:54:41 +08:00
|
|
|
|
PortC umi.ILinkRef
|
2023-08-18 17:59:16 +08:00
|
|
|
|
//道岔转动需要的时间(从开度0-100的时间),单位ms
|
|
|
|
|
TurnTime int64
|
2023-08-14 16:23:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
func NewSwitchModel(id string) *SwitchModel {
|
|
|
|
|
return &SwitchModel{DeviceModel: DeviceModel{Id: id, Type: cstate.DeviceType_Switch}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔转动从0-100耗时,单位ms
|
2023-08-22 11:00:14 +08:00
|
|
|
|
func (me *SwitchModel) TurningTime() int64 {
|
|
|
|
|
return me.TurnTime
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
// 道岔A端口连接的轨道
|
|
|
|
|
func (me *SwitchModel) PortALink() umi.ILinkRef {
|
|
|
|
|
return me.PortA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔B端口连接的轨道
|
|
|
|
|
func (me *SwitchModel) PortBLink() umi.ILinkRef {
|
|
|
|
|
return me.PortB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 道岔C端口连接的轨道
|
|
|
|
|
func (me *SwitchModel) PortCLink() umi.ILinkRef {
|
|
|
|
|
return me.PortC
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// 道岔端口引用
|
|
|
|
|
type SwitchRef struct {
|
|
|
|
|
Switch umi.ISwitchModel
|
2023-08-14 16:23:34 +08:00
|
|
|
|
//引用道岔的端口
|
2023-08-23 09:54:41 +08:00
|
|
|
|
Port umi.PortEnum
|
2023-08-14 16:23:34 +08:00
|
|
|
|
}
|
2023-08-21 15:12:57 +08:00
|
|
|
|
|
2023-08-23 09:54:41 +08:00
|
|
|
|
func NewSwitchRef(switchModel *SwitchModel, port umi.PortEnum) *SwitchRef {
|
|
|
|
|
return &SwitchRef{Switch: switchModel, Port: port}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 被引用的道岔模型
|
|
|
|
|
func (me *SwitchRef) SwitchModel() umi.ISwitchModel {
|
|
|
|
|
return me.Switch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 被引用的道岔的端口
|
|
|
|
|
func (me *SwitchRef) SwitchPort() umi.PortEnum {
|
|
|
|
|
return me.Port
|
2023-08-21 15:12:57 +08:00
|
|
|
|
}
|