rts-sim-module/examples/test1/tmodel/psd_model.go
2023-08-24 10:27:50 +08:00

57 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tmodel
import (
"joylink.club/rtsssimulation/umi"
)
// 站台一侧屏蔽门模型
type PsdModel struct {
DeviceModel
//屏蔽门所包含的单元
Cells []*PsdCellModel
//屏蔽门移动从0-100耗时单位ms
MoveTime int64
}
func NewPsdModel(id string) *PsdModel {
return &PsdModel{DeviceModel: DeviceModel{Id: id, Type: umi.Psd}, Cells: make([]*PsdCellModel, 0)}
}
func (me *PsdModel) addCell(cell *PsdCellModel) {
me.Cells = append(me.Cells, cell)
}
// 屏蔽门移动从0-100耗时单位ms
func (me *PsdModel) MovingTime() int64 {
return me.MoveTime
}
// 屏蔽门的所有单元门
func (me *PsdModel) AllDeviceCells() []umi.IDeviceModel {
rt := make([]umi.IDeviceModel, 0, len(me.Cells))
for _, cell := range me.Cells {
rt = append(rt, cell)
}
return rt
}
/////////////////////////////////////////////
// 站台一侧屏蔽门单元模型
type PsdCellModel struct {
DeviceModel
//该屏蔽门单元所属的屏蔽门
psd umi.IDeviceModel
}
func NewPsdCellModel(id string, psdModel *PsdModel) *PsdCellModel {
cell := &PsdCellModel{
DeviceModel: DeviceModel{Id: id, Type: umi.PsdCell},
psd: psdModel,
}
psdModel.addCell(cell)
return cell
}
func (me *PsdCellModel) Psd() *PsdModel {
return me.psd.(*PsdModel)
}