2023-08-09 15:34:19 +08:00
|
|
|
package ref
|
|
|
|
|
2023-08-24 18:22:25 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/face"
|
|
|
|
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
|
|
|
|
)
|
2023-08-09 15:34:19 +08:00
|
|
|
|
2023-08-24 18:22:25 +08:00
|
|
|
type DevicePosition[T face.DeviceModeller] struct {
|
|
|
|
Device T
|
2023-08-09 15:34:19 +08:00
|
|
|
Offset int32
|
|
|
|
}
|
2023-08-24 18:22:25 +08:00
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|