28 lines
629 B
Go
28 lines
629 B
Go
package ref
|
|
|
|
import (
|
|
"fmt"
|
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
|
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
|
|
)
|
|
|
|
type DevicePosition[T face.DeviceModeller] struct {
|
|
Device T
|
|
Offset int32
|
|
}
|
|
|
|
func (dp *DevicePosition[T]) String() string {
|
|
return fmt.Sprintf("%s-%d", dp.Device.GetIndex(), dp.Offset)
|
|
}
|
|
|
|
func ConvertFromDevicePort(dp *DevicePort[*device.LinkModel]) *DevicePosition[*device.LinkModel] {
|
|
var offset int32 = 0
|
|
if dp.Port == face.B {
|
|
offset = dp.Device.Length
|
|
}
|
|
return &DevicePosition[*device.LinkModel]{
|
|
Device: dp.Device,
|
|
Offset: offset,
|
|
}
|
|
}
|